From: Sage Weil Date: Fri, 19 May 2017 21:01:22 +0000 (-0400) Subject: mon/PGMap: new check_osd_map that takes a OSDMap& const X-Git-Tag: ses5-milestone6~8^2~19^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=90d45c1dea544537f20664eaa1e0e4a26db28f28;p=ceph.git mon/PGMap: new check_osd_map that takes a OSDMap& const The previous version takes an Incremental and requires that we see every single consecutive map in the history. This version is mgr-friendly and just takes the latest OSDMap. It's a bit simpler too because it ignores the full/nearfull (legacy preluminous) and last_osd_report. Signed-off-by: Sage Weil --- diff --git a/src/common/histogram.h b/src/common/histogram.h index 2b0ae5342c93..5be69663714c 100644 --- a/src/common/histogram.h +++ b/src/common/histogram.h @@ -51,6 +51,9 @@ public: void clear() { h.clear(); } + bool empty() const { + return h.empty(); + } void set_bin(int bin, int32_t count) { _expand_to(bin + 1); h[bin] = count; diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 427c669db59a..64522d89c0c1 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -3273,6 +3273,49 @@ void PGMapUpdater::check_osd_map(const OSDMap::Incremental &osd_inc, } } +void PGMapUpdater::check_osd_map( + CephContext *cct, + const OSDMap& osdmap, + const PGMap& pgmap, + PGMap::Incremental *pending_inc) +{ + for (auto& p : pgmap.osd_stat) { + if (!osdmap.exists(p.first)) { + // remove osd_stat + pending_inc->rm_stat(p.first); + } else if (osdmap.is_out(p.first)) { + // zero osd_stat + if (p.second.kb != 0) { + pending_inc->stat_osd_out(p.first); + } + } else if (!osdmap.is_up(p.first)) { + // zero the op_queue_age_hist + if (!p.second.op_queue_age_hist.empty()) { + pending_inc->stat_osd_down_up(p.first, pgmap); + } + } + } + for (auto& p : pgmap.pg_pool_sum) { + if (!osdmap.have_pg_pool(p.first)) { + ldout(cct, 10) << __func__ << " pool " << p.first << " gone, removing pgs" + << dendl; + for (auto& q : pgmap.pg_stat) { + if (q.first.pool() == (uint64_t)p.first) { + pending_inc->pg_remove.insert(q.first); + } + } + auto q = pending_inc->pg_stat_updates.begin(); + while (q != pending_inc->pg_stat_updates.end()) { + if (q->first.pool() == (uint64_t)p.first) { + q = pending_inc->pg_stat_updates.erase(q); + } else { + ++q; + } + } + } + } +} + void PGMapUpdater::register_pg( const OSDMap &osd_map, pg_t pgid, epoch_t epoch, diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index aa920347ef3c..dc9c72674b6f 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -245,7 +245,7 @@ public: // 0 the stats for the osd osd_stat_updates[osd] = osd_stat_t(); } - void stat_osd_down_up(int32_t osd, PGMap& pg_map) { + void stat_osd_down_up(int32_t osd, const PGMap& pg_map) { // 0 the op_queue_age_hist for this osd auto p = osd_stat_updates.find(osd); if (p != osd_stat_updates.end()) { @@ -485,6 +485,11 @@ public: PGMap *pg_map, PGMap::Incremental *pending_inc); + static void check_osd_map( + CephContext *cct, + const OSDMap &osdmap, + const PGMap& pg_map, + PGMap::Incremental *pending_inc); /** * check latest osdmap for new pgs to register */