]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: pgstats: move some creating_pgs maintenance into the PGStatService
authorGreg Farnum <gfarnum@redhat.com>
Tue, 9 May 2017 19:01:22 +0000 (12:01 -0700)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 16:59:43 +0000 (12:59 -0400)
And remove get_pg_map() now that there are no users!

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/mon/OSDMonitor.cc
src/mon/PGStatService.h

index 4de827ad977d9413733b4a00e4fb0895350c48d4..b67a4858feadc7365dc24a51df83a9f6cd5f217a 100644 (file)
@@ -931,20 +931,11 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc)
   if (pending_creatings.last_scan_epoch > inc.epoch) {
     return pending_creatings;
   }
-  const auto& pgm = mon->pgservice->get_pg_map();
-  if (pgm.last_pg_scan >= creating_pgs.last_scan_epoch) {
-    // TODO: please stop updating pgmap with pgstats once the upgrade is completed
-    const unsigned total = pending_creatings.pgs.size();
-    for (auto& pgid : pgm.creating_pgs) {
-      auto st = pgm.pg_stat.find(pgid);
-      assert(st != pgm.pg_stat.end());
-      auto created = make_pair(st->second.created, st->second.last_scrub_stamp);
-      // no need to add the pg, if it already exists in creating_pgs
-      pending_creatings.pgs.emplace(pgid, created);
-    }
-    dout(7) << __func__ << total - pending_creatings.pgs.size()
-           << " pgs added from pgmap" << dendl;
-  }
+  const unsigned total = pending_creatings.pgs.size();
+  mon->pgservice->maybe_add_creating_pgs(creating_pgs.last_scan_epoch,
+                                        &pending_creatings);
+  dout(7) << __func__ << total - pending_creatings.pgs.size()
+         << " pgs added from pgmap" << dendl;
   unsigned added = 0;
   added += scan_for_creating_pgs(osdmap.get_pools(),
                                 inc.old_pools,
index b0e7ac8d4692a2129f2c47e0eece1239850f21ac..a2914ae6a97d5a68486a68d65d0fb0f754bf7a7a 100644 (file)
@@ -27,6 +27,7 @@
 #define CEPH_PGSTATSERVICE_H
 
 #include "mon/PGMap.h"
+struct creating_pgs_t;
 
 class PGStatService {
 public:
@@ -45,10 +46,14 @@ public:
   virtual float get_nearfull_ratio() const = 0;
   virtual bool have_creating_pgs() const = 0;
   virtual bool is_creating_pg(pg_t pgid) const = 0;
+  /**
+   * For upgrades. If the PGMap has newer data than the monitor's new
+   * creating_pgs (scan_epoch), insert them into the passed pending_creates.
+   */
+  virtual void maybe_add_creating_pgs(epoch_t scan_epoch,
+                                     creating_pgs_t *pending_creates) const = 0;
   virtual epoch_t get_min_last_epoch_clean() const = 0;
 
-  virtual PGMap& get_pg_map() = 0;
-
   virtual bool have_full_osds() const = 0;
   virtual bool have_nearfull_osds() const = 0;
 
@@ -102,8 +107,6 @@ public:
     return NULL;
   }
 
-  PGMap& get_pg_map() { return parent; }
-
   const pool_stat_t& get_pg_sum() const { return parent.pg_sum; }
   const osd_stat_t& get_osd_sum() const { return parent.osd_sum; }
 
@@ -125,6 +128,18 @@ public:
 
   bool have_creating_pgs() const { return !parent.creating_pgs.empty(); }
   bool is_creating_pg(pg_t pgid) const { return parent.creating_pgs.count(pgid); }
+  virtual void maybe_add_creating_pgs(epoch_t scan_epoch,
+                                     creating_pgs_t *pending_creates) const {
+    if (parent.last_pg_scan >= scan_epoch) {
+      for (auto& pgid : parent.creating_pgs) {
+       auto st = parent.pg_stat.find(pgid);
+       assert(st != parent.pg_stat.end());
+       auto created = make_pair(st->second.created, st->second.last_scrub_stamp);
+       // no need to add the pg, if it already exists in creating_pgs
+       pending_creatings->pgs.emplace(pgid, created);
+      }
+    }
+  }
   epoch_t get_min_last_epoch_clean() const { return parent.get_min_last_epoch_clean(); }
 
   bool have_full_osds() const { return !parent.full_osds.empty(); }