]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move calculation of past_interval range into helper
authorSage Weil <sage@inktank.com>
Wed, 25 Jul 2012 17:58:07 +0000 (10:58 -0700)
committerSage Weil <sage@inktank.com>
Wed, 25 Jul 2012 17:58:31 +0000 (10:58 -0700)
PG::generate_past_intervals() first calculates the range over which it
needs to generate past intervals.  Do this in a helper function.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
src/osd/PG.cc
src/osd/PG.h

index 18a882ddaf8678ac5155f341714cc182f13f3916..e3e214436d99234354504c62bd5234b6b822beb7 100644 (file)
@@ -710,30 +710,43 @@ bool PG::needs_recovery() const
   return ret;
 }
 
-void PG::generate_past_intervals()
+bool PG::_calc_past_interval_range(epoch_t *start, epoch_t *end)
 {
-  epoch_t end_epoch = info.history.same_interval_since;
+  *end = info.history.same_interval_since;
+
   // Do we already have the intervals we want?
   map<epoch_t,pg_interval_t>::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;
+      return false;
     }
-    end_epoch = past_intervals.begin()->first;
+    *end = past_intervals.begin()->first;
   }
 
-  epoch_t cur_epoch = MAX(MAX(info.history.epoch_created,
-                             info.history.last_epoch_clean),
-                         osd->superblock.oldest_map);
-  OSDMapRef last_map, cur_map;
-  if (cur_epoch >= end_epoch) {
-    dout(10) << __func__ << " start epoch " << cur_epoch
-            << " >= end epoch " << end_epoch
+  *start = MAX(MAX(info.history.epoch_created,
+                  info.history.last_epoch_clean),
+              osd->superblock.oldest_map);
+  if (*start >= *end) {
+    dout(10) << __func__ << " start epoch " << *start
+            << " >= end epoch " << *end
             << ", nothing to do" << dendl;
+    return false;
+  }
+
+  return true;
+}
+
+
+void PG::generate_past_intervals()
+{
+  epoch_t cur_epoch, end_epoch;
+  if (!_calc_past_interval_range(&cur_epoch, &end_epoch)) {
     return;
   }
+
+  OSDMapRef last_map, cur_map;
   vector<int> acting, up, old_acting, old_up;
 
   cur_map = osd->get_map(cur_epoch);
index b915121183df1d30b5ae7f399a4f98d75271e5bd..e785ebf046e011ab703a5b1621300bd246dfbe5c 100644 (file)
@@ -640,6 +640,8 @@ public:
   bool needs_recovery() const;
 
   void mark_clean();  ///< mark an active pg clean
+
+  bool _calc_past_interval_range(epoch_t *start, epoch_t *end);
   void generate_past_intervals();
   void trim_past_intervals();
   void build_prior(std::auto_ptr<PriorSet> &prior_set);