]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd_types: factor out is_new_interval from check_new_interval
authorSamuel Just <sam.just@inktank.com>
Wed, 7 May 2014 18:02:16 +0000 (11:02 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 14 May 2014 20:17:08 +0000 (13:17 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/osd_types.cc
src/osd/osd_types.h

index 15dd661d1761a693641ebbcd280dd7f778319893..6bdbd6119326878d1a236511eebd070c2cbdd83d 100644 (file)
@@ -2186,6 +2186,30 @@ void pg_interval_t::generate_test_instances(list<pg_interval_t*>& o)
   o.back()->maybe_went_rw = true;
 }
 
+bool pg_interval_t::is_new_interval(
+  int old_acting_primary,
+  int new_acting_primary,
+  const vector<int> &old_acting,
+  const vector<int> &new_acting,
+  int old_up_primary,
+  int new_up_primary,
+  const vector<int> &old_up,
+  const vector<int> &new_up,
+  OSDMapRef osdmap,
+  OSDMapRef lastmap,
+  int64_t pool_id,
+  pg_t pgid) {
+  return old_acting_primary != new_acting_primary ||
+    new_acting != old_acting ||
+    old_up_primary != new_up_primary ||
+    new_up != old_up ||
+    (!(lastmap->get_pools().count(pool_id))) ||
+    (lastmap->get_pools().find(pool_id)->second.min_size !=
+     osdmap->get_pools().find(pool_id)->second.min_size)  ||
+    pgid.is_split(lastmap->get_pg_num(pgid.pool()),
+                 osdmap->get_pg_num(pgid.pool()), 0);
+}
+
 bool pg_interval_t::check_new_interval(
   int old_acting_primary,
   int new_acting_primary,
@@ -2208,15 +2232,19 @@ bool pg_interval_t::check_new_interval(
   //  NOTE: a change in the up set primary triggers an interval
   //  change, even though the interval members in the pg_interval_t
   //  do not change.
-  if (old_acting_primary != new_acting_primary ||
-      new_acting != old_acting ||
-      old_up_primary != new_up_primary ||
-      new_up != old_up ||
-      (!(lastmap->get_pools().count(pool_id))) ||
-      (lastmap->get_pools().find(pool_id)->second.min_size !=
-       osdmap->get_pools().find(pool_id)->second.min_size)  ||
-      pgid.is_split(lastmap->get_pg_num(pgid.pool()),
-        osdmap->get_pg_num(pgid.pool()), 0)) {
+  if (is_new_interval(
+       old_acting_primary,
+       new_acting_primary,
+       old_acting,
+       new_acting,
+       old_up_primary,
+       new_up_primary,
+       old_up,
+       new_up,
+       osdmap,
+       lastmap,
+       pool_id,
+       pgid)) {
     pg_interval_t& i = (*past_intervals)[same_interval_since];
     i.first = same_interval_since;
     i.last = osdmap->get_epoch() - 1;
index 0c68a531aafea6c1b855705842f2ea3f83d2ba05..67ece00c38df6265efdc0b0e821f5023024b93d8 100644 (file)
@@ -1703,13 +1703,31 @@ struct pg_interval_t {
   void dump(Formatter *f) const;
   static void generate_test_instances(list<pg_interval_t*>& o);
 
+  /**
+   * Determines whether there is an interval change
+   */
+  static bool is_new_interval(
+    int old_acting_primary,                     ///< [in] primary as of lastmap
+    int new_acting_primary,                     ///< [in] primary as of lastmap
+    const vector<int> &old_acting,              ///< [in] acting as of lastmap
+    const vector<int> &new_acting,              ///< [in] acting as of osdmap
+    int old_up_primary,                         ///< [in] up primary of lastmap
+    int new_up_primary,                         ///< [in] up primary of osdmap
+    const vector<int> &old_up,                  ///< [in] up as of lastmap
+    const vector<int> &new_up,                  ///< [in] up as of osdmap
+    ceph::shared_ptr<const OSDMap> osdmap,  ///< [in] current map
+    ceph::shared_ptr<const OSDMap> lastmap, ///< [in] last map
+    int64_t poolid,                             ///< [in] pool for pg
+    pg_t pgid                                   ///< [in] pgid for pg
+    );
+
   /**
    * Integrates a new map into *past_intervals, returns true
    * if an interval was closed out.
    */
   static bool check_new_interval(
     int old_acting_primary,                     ///< [in] primary as of lastmap
-    int new_acting_primary,                     ///< [in] primary as of lastmap
+    int new_acting_primary,                     ///< [in] primary as of osdmap
     const vector<int> &old_acting,              ///< [in] acting as of lastmap
     const vector<int> &new_acting,              ///< [in] acting as of osdmap
     int old_up_primary,                         ///< [in] up primary of lastmap