From b73e4374147210628a64267cfeaf3970c55a45eb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 12 May 2017 23:51:45 -0500 Subject: [PATCH] mgr: send PGMapDigest instead of PGMap to mon Signed-off-by: Sage Weil --- src/messages/MMonMgrReport.h | 5 ----- src/mgr/ClusterState.cc | 4 +++- src/mon/MgrMonitor.cc | 35 ++++++++++++++++------------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/messages/MMonMgrReport.h b/src/messages/MMonMgrReport.h index 20ac9aa35eae2..8ddc81de10797 100644 --- a/src/messages/MMonMgrReport.h +++ b/src/messages/MMonMgrReport.h @@ -35,7 +35,6 @@ private: public: bool needs_send = false; - PGMap pg_map; const char *get_type_name() const override { return "monmgrreport"; } void print(ostream& out) const override { @@ -44,14 +43,10 @@ public: void encode_payload(uint64_t features) override { paxos_encode(); - bufferlist pmb; - pg_map.encode(pmb); - payload.append(pmb); } void decode_payload() override { bufferlist::iterator p = payload.begin(); paxos_decode(p); - ::decode(pg_map, p); } }; diff --git a/src/mgr/ClusterState.cc b/src/mgr/ClusterState.cc index b23628473c74a..9a498e9584754 100644 --- a/src/mgr/ClusterState.cc +++ b/src/mgr/ClusterState.cc @@ -117,6 +117,8 @@ void ClusterState::notify_osdmap(const OSDMap &osd_map) void ClusterState::tick(MMonMgrReport *m) { dout(0) << __func__ << dendl; - m->pg_map = pg_map; + // FIXME: no easy way to get mon features here. this will do for + // now, though, as long as we don't make a backward-incompat change. + pg_map.encode_digest(m->get_data(), CEPH_FEATURES_ALL); m->needs_send = true; } diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index a0c84b56b15e8..761d2378874cd 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -36,51 +36,48 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, class MgrPGStatService : public PGMap, public PGStatService { - PGMap& parent; + PGMapDigest digest; public: - MgrPGStatService() : PGMap(), PGStatService(), - parent(*static_cast(this)) {} - MgrPGStatService(const PGMap& o) : PGMap(o), PGStatService(), - parent(*static_cast(this)) {} - void reset(const PGMap& o) { - parent = o; + void decode_digest(bufferlist& bl) { + auto p = bl.begin(); + ::decode(digest, p); } const pool_stat_t* get_pool_stat(int poolid) const { - auto i = parent.pg_pool_sum.find(poolid); - if (i != parent.pg_pool_sum.end()) { + auto i = digest.pg_pool_sum.find(poolid); + if (i != digest.pg_pool_sum.end()) { return &i->second; } return NULL; } - const pool_stat_t& get_pg_sum() const { return parent.pg_sum; } - const osd_stat_t& get_osd_sum() const { return parent.osd_sum; } + const pool_stat_t& get_pg_sum() const { return digest.pg_sum; } + const osd_stat_t& get_osd_sum() const { return digest.osd_sum; } const osd_stat_t *get_osd_stat(int osd) const { - auto i = parent.osd_stat.find(osd); - if (i == parent.osd_stat.end()) { + auto i = digest.osd_stat.find(osd); + if (i == digest.osd_stat.end()) { return NULL; } return &i->second; } const ceph::unordered_map *get_osd_stat() const { - return &parent.osd_stat; + return &digest.osd_stat; } size_t get_num_pg_by_osd(int osd) const { - return parent.get_num_pg_by_osd(osd); + return digest.get_num_pg_by_osd(osd); } void print_summary(Formatter *f, ostream *out) const { - parent.print_summary(f, out); + digest.print_summary(f, out); } void dump_fs_stats(stringstream *ss, Formatter *f, bool verbose) const { - parent.dump_fs_stats(ss, f, verbose); + digest.dump_fs_stats(ss, f, verbose); } void dump_pool_stats(const OSDMap& osdm, stringstream *ss, Formatter *f, bool verbose) const { - parent.dump_pool_stats_full(osdm, ss, f, verbose); + digest.dump_pool_stats_full(osdm, ss, f, verbose); } }; @@ -301,7 +298,7 @@ bool MgrMonitor::preprocess_report(MonOpRequestRef op) { return false; } bool MgrMonitor::prepare_report(MonOpRequestRef op) { MMonMgrReport *m = static_cast(op->get_req()); - pgservice->reset(m->pg_map); + pgservice->decode_digest(m->get_data()); return true; } -- 2.39.5