From: Sage Weil Date: Thu, 18 May 2017 19:32:57 +0000 (-0400) Subject: mon/MgrStatMonitor: fix digest vs pending digest X-Git-Tag: ses5-milestone6~8^2~19^2~74 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=960a8d6f6d18c464cb89cf3c5e05893a09a1f591;p=ceph.git mon/MgrStatMonitor: fix digest vs pending digest Signed-off-by: Sage Weil --- diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 9e9dafc01bf7..ff040366aa7e 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -6,15 +6,9 @@ #include "messages/MMonMgrReport.h" class MgrPGStatService : public PGStatService { - PGMapDigest digest; + PGMapDigest& digest; public: - void decode_digest(bufferlist& bl) { - auto p = bl.begin(); - ::decode(digest, p); - } - void encode_digest(bufferlist& bl, uint64_t features) { - ::encode(digest, bl, features); - } + MgrPGStatService(PGMapDigest& d) : digest(d) {} const pool_stat_t* get_pool_stat(int poolid) const override { auto i = digest.pg_pool_sum.find(poolid); @@ -71,7 +65,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon) { MgrStatMonitor::MgrStatMonitor(Monitor *mn, Paxos *p, const string& service_name) : PaxosService(mn, p, service_name), - pgservice(new MgrPGStatService()) + pgservice(new MgrPGStatService(digest)) { } @@ -82,6 +76,11 @@ PGStatService *MgrStatMonitor::get_pg_stat_service() return pgservice.get(); } +void MgrStatMonitor::create_initial() +{ + version = 0; +} + void MgrStatMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_last_committed(); @@ -89,25 +88,28 @@ void MgrStatMonitor::update_from_paxos(bool *need_bootstrap) get_version(version, bl); if (version) { assert(bl.length()); - bufferlist digestbl; auto p = bl.begin(); - ::decode(digestbl, p); + ::decode(digest, p); ::decode(health_summary, p); ::decode(health_detail, p); - pgservice->decode_digest(digestbl); } } +void MgrStatMonitor::create_pending() +{ + pending_digest = digest; + pending_health_summary = health_summary; + pending_health_detail = health_detail; +} + void MgrStatMonitor::encode_pending(MonitorDBStore::TransactionRef t) { ++version; dout(10) << __func__ << " " << version << dendl; - bufferlist digestbl; - pgservice->encode_digest(digestbl, mon->get_quorum_con_features()); bufferlist bl; - ::encode(digestbl, bl); - ::encode(health_summary, bl); - ::encode(health_detail, bl); + ::encode(pending_digest, bl, mon->get_quorum_con_features()); + ::encode(pending_health_summary, bl); + ::encode(pending_health_detail, bl); put_version(t, version, bl); put_last_committed(t, version); } @@ -169,8 +171,10 @@ bool MgrStatMonitor::preprocess_report(MonOpRequestRef op) bool MgrStatMonitor::prepare_report(MonOpRequestRef op) { auto m = static_cast(op->get_req()); - pgservice->decode_digest(m->get_data()); - health_summary.swap(m->health_summary); - health_detail.swap(m->health_detail); + bufferlist bl = m->get_data(); + auto p = bl.begin(); + ::decode(pending_digest, p); + pending_health_summary.swap(m->health_summary); + pending_health_detail.swap(m->health_detail); return true; } diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 660c18fde271..654bff0b0b6e 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -5,14 +5,24 @@ #include "include/Context.h" #include "PaxosService.h" +#include "mon/PGMap.h" class PGStatService; class MgrPGStatService; class MgrStatMonitor : public PaxosService { + // live version version_t version = 0; + PGMapDigest digest; + list> health_summary; + list> health_detail; + + // pending commit + PGMapDigest pending_digest; + list> pending_health_summary; + list> pending_health_detail; + std::unique_ptr pgservice; - list> health_summary, health_detail; public: MgrStatMonitor(Monitor *mn, Paxos *p, const string& service_name); @@ -21,9 +31,9 @@ public: void init() override {} void on_shutdown() override {} - void create_initial() override {} + void create_initial() override; void update_from_paxos(bool *need_bootstrap) override; - void create_pending() override {} + void create_pending() override; void encode_pending(MonitorDBStore::TransactionRef t) override; bool preprocess_query(MonOpRequestRef op) override;