Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon,mgr: fix "ceph osd df", add some tools to find untested commands #15675

Merged
merged 8 commits into from Jun 15, 2017

mon: move most PGMapStatService into PGMap; rename PGMon's to PGMonSt…

…atService

Most of this is independent of the PGMonitor, so move it into
PGMap and strip out those few bits. It'll come in handy shortly
when I move "ceph osd df" into the mgr.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
  • Loading branch information...
gregsfortytwo committed Jun 9, 2017
commit b0e5225eddef47a27a25289437543f610c9633cf
@@ -26,6 +26,7 @@
#include "osd/osd_types.h"
#include "include/mempool.h"
#include <sstream>
#include "mon/PGStatService.h"

// FIXME: don't like including this here to get OSDMap::Incremental, maybe
// PGMapUpdater needs its own header.
@@ -579,4 +580,90 @@ namespace reweight {
Formatter *f);
}


class PGMapStatService : public PGStatService {
const PGMap& pgmap;
public:
PGMapStatService(const PGMap& o)
: pgmap(o) {}

bool is_readable() const override { return true; }

const pool_stat_t* get_pool_stat(int poolid) const override {
auto i = pgmap.pg_pool_sum.find(poolid);
if (i != pgmap.pg_pool_sum.end()) {
return &i->second;
}
return nullptr;
}

const osd_stat_t& get_osd_sum() const override { return pgmap.osd_sum; }

const osd_stat_t *get_osd_stat(int osd) const override {
auto i = pgmap.osd_stat.find(osd);
if (i == pgmap.osd_stat.end()) {
return nullptr;
}
return &i->second;
}
const mempool::pgmap::unordered_map<int32_t,osd_stat_t>& get_osd_stat() const override {
return pgmap.osd_stat;
}
float get_full_ratio() const override { return pgmap.full_ratio; }
float get_nearfull_ratio() const override { return pgmap.nearfull_ratio; }

bool have_creating_pgs() const override {
return !pgmap.creating_pgs.empty();
}
bool is_creating_pg(pg_t pgid) const override {
return pgmap.creating_pgs.count(pgid);
}

epoch_t get_min_last_epoch_clean() const override {
return pgmap.get_min_last_epoch_clean();
}

bool have_full_osds() const override { return !pgmap.full_osds.empty(); }
bool have_nearfull_osds() const override {
return !pgmap.nearfull_osds.empty();
}

size_t get_num_pg_by_osd(int osd) const override {
return pgmap.get_num_pg_by_osd(osd);
}
ceph_statfs get_statfs() const override {
ceph_statfs statfs;
statfs.kb = pgmap.osd_sum.kb;
statfs.kb_used = pgmap.osd_sum.kb_used;
statfs.kb_avail = pgmap.osd_sum.kb_avail;
statfs.num_objects = pgmap.pg_sum.stats.sum.num_objects;
return statfs;
}
void print_summary(Formatter *f, ostream *out) const override {
pgmap.print_summary(f, out);
}
virtual void dump_info(Formatter *f) const override {
f->dump_object("pgmap", pgmap);
}
void dump_fs_stats(stringstream *ss,
Formatter *f,
bool verbose) const override {
pgmap.dump_fs_stats(ss, f, verbose);
}
void dump_pool_stats(const OSDMap& osdm, stringstream *ss, Formatter *f,
bool verbose) const override {
pgmap.dump_pool_stats_full(osdm, ss, f, verbose);
}

int process_pg_command(const string& prefix,
const map<string,cmd_vartype>& cmdmap,
const OSDMap& osdmap,
Formatter *f,
stringstream *ss,
bufferlist *odata) const override {
return process_pg_map_command(prefix, cmdmap, pgmap, osdmap, f, ss, odata);
}
};


#endif
@@ -1172,11 +1172,11 @@ bool PGMonitor::check_sub(Subscription *sub)
return true;
}

class PGMapStatService : public MonPGStatService {
class PGMonStatService : public MonPGStatService {
const PGMap& pgmap;
PGMonitor *pgmon;
public:
PGMapStatService(const PGMap& o, PGMonitor *pgm)
PGMonStatService(const PGMap& o, PGMonitor *pgm)
: pgmap(o),
pgmon(pgm) {}

@@ -1314,7 +1314,7 @@ class PGMapStatService : public MonPGStatService {
MonPGStatService *PGMonitor::get_pg_stat_service()
{
if (!pgservice) {
pgservice.reset(new PGMapStatService(pg_map, this));
pgservice.reset(new PGMonStatService(pg_map, this));
}
return pgservice.get();
}
@@ -34,10 +34,11 @@ using namespace std;

class MPGStats;
class MonPGStatService;
class PGMonStatService;

class PGMonitor : public PaxosService {
PGMap pg_map;
std::unique_ptr<MonPGStatService> pgservice;
std::unique_ptr<PGMonStatService> pgservice;

bool do_delete = false; ///< propose deleting pgmap data
bool did_delete = false; ///< we already deleted pgmap data
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.