From: Sage Weil Date: Fri, 11 Mar 2011 17:23:06 +0000 (-0800) Subject: osd: fix osdmap scanning on pg creation X-Git-Tag: v0.25.1~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8ec6fff97c618219d75e3201ebc2a3daf972f545;p=ceph.git osd: fix osdmap scanning on pg creation 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 Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 767201fc268f..433697bb1e09 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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. diff --git a/src/osd/PG.cc b/src/osd/PG.cc index cbfcbbcbead2..98c55cda1b6f 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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;