]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
generate_past_intervals:generate back to lastclean
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 22 Nov 2010 18:32:18 +0000 (10:32 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 22 Nov 2010 18:47:53 +0000 (10:47 -0800)
PG::generate_past_intervals needs to generate all the intervals back to
history.last_epoch_clean, rather than just to
history.last_epoch_started. This is required by
PG::build_might_have_unfound, which needs to examine these intervals
when building the might_have_unfound set.

Move the check for whether past_intervals is up-to-date into
generate_past_intervals itself. Fix the check.

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/osd/PG.cc

index bdf91ebdb8eb6971847f00ddf10385cdfd2b1e1c..7159f1c984b5d681957bdb0b85d0e68345505e69 100644 (file)
@@ -807,11 +807,21 @@ bool PG::is_all_uptodate() const
 
 void PG::generate_past_intervals()
 {
+  // Do we already have the intervals we want?
+  map<epoch_t,Interval>::const_iterator pif = past_intervals.begin();
+  if (pif != past_intervals.end()) {
+    if (pif->first <= info.history.last_epoch_clean) {
+      dout(10) << __func__ << ": already have past intervals back to "
+              << info.history.last_epoch_clean << dendl;
+      return;
+    }
+    past_intervals.clear();
+  }
+
   epoch_t first_epoch = 0;
-  epoch_t stop = MAX(1, info.history.last_epoch_started);
+  epoch_t stop = MAX(1, info.history.last_epoch_clean);
   epoch_t last_epoch = info.history.same_acting_since - 1;
-
-  dout(10) << "generate_past_intervals over epochs " << stop << "-" << last_epoch << dendl;
+  dout(10) << __func__ << " over epochs " << stop << "-" << last_epoch << dendl;
 
   OSDMap *nextmap = osd->get_map(last_epoch);
   for (;
@@ -850,12 +860,20 @@ void PG::generate_past_intervals()
   }
 }
 
+/*
+ * Trim past_intervals.
+ *
+ * This gets rid of all the past_intervals that happened before last_epoch_clean.
+ */
 void PG::trim_past_intervals()
 {
-  while (past_intervals.size() &&
-        past_intervals.begin()->second.last < info.history.last_epoch_started) {
-    dout(10) << "trim_past_intervals trimming " << past_intervals.begin()->second << dendl;
-    past_intervals.erase(past_intervals.begin());
+  std::map<epoch_t,Interval>::iterator pif = past_intervals.begin();
+  std::map<epoch_t,Interval>::iterator end = past_intervals.end();
+  while (pif != end) {
+    if (pif->second.last >= info.history.last_epoch_clean)
+      return;
+    dout(10) << __func__ << ": trimming " << pif->second << dendl;
+    past_intervals.erase(pif++);
   }
 }
 
@@ -1002,10 +1020,7 @@ void PG::build_prior()
   bool some_down = false;
 
   // generate past intervals, if we don't have them.
-  if (info.history.same_acting_since > info.history.last_epoch_started &&
-      (past_intervals.empty() ||
-       past_intervals.begin()->first > info.history.last_epoch_started))
-    generate_past_intervals();
+  generate_past_intervals();
   
   // see if i have ever started since joining the pg.  this is important only
   // if we want to exclude lost osds.