]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/PGMap: new check_osd_map that takes a OSDMap& const
authorSage Weil <sage@redhat.com>
Fri, 19 May 2017 21:01:22 +0000 (17:01 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:50 +0000 (13:02 -0400)
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 <sage@redhat.com>
src/common/histogram.h
src/mon/PGMap.cc
src/mon/PGMap.h

index 2b0ae5342c93e8dd1fafccedb748310ae38f92f7..5be69663714c27cc621110ff9b8240baf1ad3ac7 100644 (file)
@@ -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;
index 427c669db59a63a9170b1550b61273ec374a5f1c..64522d89c0c132e7cbdaff03a70d1356ec87b4d8 100644 (file)
@@ -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,
index aa920347ef3c83271ecea1c3f802647cc3c2296a..dc9c72674b6fde132680bcce130d136332bc1b66 100644 (file)
@@ -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
    */