]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix osdmap scanning on pg creation
authorSage Weil <sage@newdream.net>
Fri, 11 Mar 2011 17:23:06 +0000 (09:23 -0800)
committerSage Weil <sage@newdream.net>
Fri, 11 Mar 2011 17:23:06 +0000 (09:23 -0800)
On PG creation we were scanning the complete history of all osdmaps ever.
Fix initialization of PG::Info::History epoch_created and same_*_since
fields in the base (creation) case to make this work the way it was
supposed to.

Reported-by: Yehuda Sadeh <yehuda.sadeh@dreamhost.com>
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/PG.cc

index 767201fc268f844a6d360b94fd876418377472b8..433697bb1e09d37260f461f9f3d08952c9d10345 100644 (file)
@@ -1144,7 +1144,8 @@ void OSD::project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
            << ", start " << h
            << dendl;
 
-  for (epoch_t e = osdmap->get_epoch();
+  epoch_t e;
+  for (e = osdmap->get_epoch();
        e > from;
        e--) {
     // verify during intermediate epoch (e-1)
@@ -1177,6 +1178,17 @@ void OSD::project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
       break;
   }
 
+  // base case: these floors should be the creation epoch if we didn't
+  // find any changes.
+  if (e == h.epoch_created) {
+    if (!h.same_acting_since)
+      h.same_acting_since = e;
+    if (!h.same_up_since)
+      h.same_up_since = e;
+    if (!h.same_primary_since)
+      h.same_primary_since = e;
+  }
+
   dout(15) << "project_pg_history end " << h << dendl;
 }
 
@@ -3890,6 +3902,8 @@ void OSD::handle_pg_create(MOSDPGCreate *m)
 
     // figure history
     PG::Info::History history;
+    history.epoch_created = created;
+    history.last_epoch_clean = created;
     project_pg_history(pgid, history, created, up, acting);
     
     // register.
index cbfcbbcbead2b7cdf872b0c19bc8137560eedeff..98c55cda1b6f9dd8e6e0f8e03397089b4dfc3bc5 100644 (file)
@@ -845,7 +845,7 @@ void PG::generate_past_intervals()
   }
 
   epoch_t first_epoch = 0;
-  epoch_t stop = MAX(1, info.history.last_epoch_clean);
+  epoch_t stop = MAX(info.history.epoch_created, info.history.last_epoch_clean);
   epoch_t last_epoch = info.history.same_acting_since - 1;
   dout(10) << __func__ << " over epochs " << stop << "-" << last_epoch << dendl;