]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: note mapping_epoch for creating pgs
authorSage Weil <sage@redhat.com>
Tue, 6 Oct 2015 22:52:22 +0000 (18:52 -0400)
committerSage Weil <sage@redhat.com>
Mon, 23 Nov 2015 13:38:49 +0000 (08:38 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/PGMap.h
src/mon/PGMonitor.cc

index e1cdf2dea3c9de8293993eab621022503306b831..5f5f9f124d5b8926e1546db9a35cf6403abde341 100644 (file)
@@ -181,7 +181,7 @@ public:
 
  public:
 
-  set<pg_t> creating_pgs;   // lru: front = new additions, back = recently pinged
+  set<pg_t> creating_pgs;
   map<int,set<pg_t> > creating_pgs_by_osd;
 
   // Bits that use to be enum StuckPG
index 53df948af93dffca2a693cfeeccd61949594670c..70b2241f3df1dd5eb2f809ab1645f6fcd6c11170 100644 (file)
@@ -994,6 +994,7 @@ void PGMonitor::register_pg(pg_pool_t& pool, pg_t pgid, epoch_t epoch, bool new_
   stats.created = epoch;
   stats.parent = parent;
   stats.parent_split_bits = split_bits;
+  stats.mapping_epoch = epoch;
 
   if (parent_found) {
     stats.last_scrub_stamp = pg_map.pg_stat[parent].last_scrub_stamp;
@@ -1101,11 +1102,13 @@ void PGMonitor::map_pg_creates()
 {
   OSDMap *osdmap = &mon->osdmon()->osdmap;
   if (osdmap->get_epoch() == last_map_pg_create_osd_epoch) {
-    dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size() << " pgs -- no change" << dendl;
+    dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size()
+            << " pgs -- no change" << dendl;
     return;
   }
 
-  dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size() << " pgs osdmap epoch " << osdmap->get_epoch() << dendl;
+  dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size()
+          << " pgs osdmap epoch " << osdmap->get_epoch() << dendl;
   last_map_pg_create_osd_epoch = osdmap->get_epoch();
 
   for (set<pg_t>::iterator p = pg_map.creating_pgs.begin();
@@ -1134,15 +1137,23 @@ void PGMonitor::map_pg_creates()
       &acting,
       &acting_primary);
 
-    if (s->acting_primary != -1) {
-      pg_map.creating_pgs_by_osd[s->acting_primary].erase(pgid);
-      if (pg_map.creating_pgs_by_osd[s->acting_primary].size() == 0)
-        pg_map.creating_pgs_by_osd.erase(s->acting_primary);
+    bool changed = false;
+    if (up != s->up ||
+       up_primary != s->up_primary ||
+       acting !=  s->acting ||
+       acting_primary != s->acting_primary) {
+      changed = true;
+      if (s->acting_primary != -1) {
+       pg_map.creating_pgs_by_osd[s->acting_primary].erase(pgid);
+       if (pg_map.creating_pgs_by_osd[s->acting_primary].size() == 0)
+         pg_map.creating_pgs_by_osd.erase(s->acting_primary);
+      }
+      s->up = up;
+      s->up_primary = up_primary;
+      s->acting = acting;
+      s->acting_primary = acting_primary;
+      s->mapping_epoch = pg_map.last_pg_scan;
     }
-    s->up = up;
-    s->up_primary = up_primary;
-    s->acting = acting;
-    s->acting_primary = acting_primary;
     pg_map.stat_pg_add(pgid, *s, true);
 
     // don't send creates for localized pgs
@@ -1154,7 +1165,8 @@ void PGMonitor::map_pg_creates()
       continue;
 
     if (acting_primary != -1) {
-      pg_map.creating_pgs_by_osd[acting_primary].insert(pgid);
+      if (changed)
+       pg_map.creating_pgs_by_osd[acting_primary].insert(pgid);
     } else {
       dout(20) << "map_pg_creates  " << pgid << " -> no osds in epoch "
               << mon->osdmon()->osdmap.get_epoch() << ", skipping" << dendl;