]> 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)
committerNathan Cutler <ncutler@suse.com>
Tue, 23 Jun 2015 15:21:36 +0000 (17:21 +0200)
Signed-off-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 2ee355113ed4374c664909a8cd7dc5dfdc4c9ed7)

src/osd/osd_types.cc
src/osd/osd_types.h

index d08e9b7d9db22cfcbb1cb48fd80f657e1f44c7bf..087236124f3f5db9b80ae3c285fb0c8ad8a712fe 100644 (file)
@@ -2196,6 +2196,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,
@@ -2218,15 +2242,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 a296df046939e90841b3e6c8f076f8d062569166..6e60cc8714e6a61f05bc2575542195c54fe44f0b 100644 (file)
@@ -1752,13 +1752,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