]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMap: fix pgmap stat adjustment during map_pg_creates() 4914/head
authorSage Weil <sage@redhat.com>
Thu, 11 Jun 2015 00:41:27 +0000 (17:41 -0700)
committerSage Weil <sage@redhat.com>
Thu, 11 Jun 2015 00:41:57 +0000 (17:41 -0700)
PGMonitor::map_pg_creates() is the only caller that passes sumonly=true,
which is necessary to avoid modifying creating_pgs while it is iterating
over it. However, everything else we *do* want to update--especially the
osd counts.

Rename the arg and skip only the creating bit.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/PGMap.cc
src/mon/PGMap.h

index 0aa837af59d7290c9eb99a4b619e2da0ed53fa87..ada4db92fd03025d8a03e20a52f591b6799f540f 100644 (file)
@@ -459,22 +459,21 @@ void PGMap::remove_osd(int osd)
   }
 }
 
-void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly,
+void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
                        bool sameosds)
 {
   pg_pool_sum[pgid.pool()].add(s);
   pg_sum.add(s);
 
-  if (sumonly)
-    return;
-
   num_pg++;
   num_pg_by_state[s.state]++;
 
-  if (s.state & PG_STATE_CREATING) {
-    creating_pgs.insert(pgid);
-    if (s.acting_primary >= 0)
-      creating_pgs_by_osd[s.acting_primary].insert(pgid);
+  if (!nocreating) {
+    if (s.state & PG_STATE_CREATING) {
+      creating_pgs.insert(pgid);
+      if (s.acting_primary >= 0)
+       creating_pgs_by_osd[s.acting_primary].insert(pgid);
+    }
   }
 
   if (sameosds)
@@ -492,7 +491,7 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly,
     pg_by_osd[*p].insert(pgid);
 }
 
-void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly,
+void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating,
                        bool sameosds)
 {
   pool_stat_t& ps = pg_pool_sum[pgid.pool()];
@@ -501,19 +500,18 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly,
     pg_pool_sum.erase(pgid.pool());
   pg_sum.sub(s);
 
-  if (sumonly)
-    return;
-
   num_pg--;
   if (--num_pg_by_state[s.state] == 0)
     num_pg_by_state.erase(s.state);
 
-  if (s.state & PG_STATE_CREATING) {
-    creating_pgs.erase(pgid);
-    if (s.acting_primary >= 0) {
-      creating_pgs_by_osd[s.acting_primary].erase(pgid);
-      if (creating_pgs_by_osd[s.acting_primary].size() == 0)
-       creating_pgs_by_osd.erase(s.acting_primary);
+  if (!nocreating) {
+    if (s.state & PG_STATE_CREATING) {
+      creating_pgs.erase(pgid);
+      if (s.acting_primary >= 0) {
+       creating_pgs_by_osd[s.acting_primary].erase(pgid);
+       if (creating_pgs_by_osd[s.acting_primary].size() == 0)
+         creating_pgs_by_osd.erase(s.acting_primary);
+      }
     }
   }
 
index 3df2c49e7e591f86962d552fffc2165f5263e0d1..733b2f0ebcbdf4b26b6f42d0ae515c6c43e94985 100644 (file)
@@ -258,9 +258,9 @@ public:
   void redo_full_sets();
   void register_nearfull_status(int osd, const osd_stat_t& s);
   void calc_stats();
-  void stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly=false,
+  void stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating=false,
                   bool sameosds=false);
-  void stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly=false,
+  void stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating=false,
                   bool sameosds=false);
   void stat_pg_update(const pg_t pgid, pg_stat_t &prev, bufferlist::iterator& blp);
   void stat_osd_add(const osd_stat_t &s);