]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PG: do some new interval work on init() too
authorSage Weil <sage@redhat.com>
Mon, 27 Jul 2015 16:17:45 +0000 (12:17 -0400)
committerSage Weil <sage@redhat.com>
Fri, 7 Aug 2015 14:16:06 +0000 (10:16 -0400)
Some work we need to do on any new interval, *including* when the PG is
first created and there is no "interval change".  Factor out the (mostly
new) bits of start_peering_interval() that also need to happen on the
initial interval after the PG is first instantiated into on_new_interval().

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/PG.cc
src/osd/PG.h

index 35f19d3bf4a786093d3880cf172fe4e55ad03e9e..62571083b9b858ce604fc19692add3ebb69634f7 100644 (file)
@@ -2612,7 +2612,7 @@ void PG::init(
     pg_log.mark_log_for_rewrite();
   }
 
-  reg_next_scrub();
+  on_new_interval();
 
   dirty_info = true;
   dirty_big_info = true;
@@ -4673,8 +4673,6 @@ void PG::start_peering_interval(
   else
     set_role(-1);
 
-  reg_next_scrub();
-
   // did acting, up, primary|acker change?
   if (!lastmap) {
     dout(10) << " no lastmap" << dendl;
@@ -4720,30 +4718,7 @@ void PG::start_peering_interval(
     info.history.same_primary_since = osdmap->get_epoch();
   }
 
-  // initialize features
-  acting_features = CEPH_FEATURES_SUPPORTED_DEFAULT;
-  upacting_features = CEPH_FEATURES_SUPPORTED_DEFAULT;
-  for (vector<int>::iterator p = acting.begin(); p != acting.end(); ++p) {
-    if (*p == CRUSH_ITEM_NONE)
-      continue;
-    uint64_t f = osdmap->get_xinfo(*p).features;
-    acting_features &= f;
-    upacting_features &= f;
-  }
-  for (vector<int>::iterator p = up.begin(); p != up.end(); ++p) {
-    if (*p == CRUSH_ITEM_NONE)
-      continue;
-    upacting_features &= osdmap->get_xinfo(*p).features;
-  }
-
-  if (g_conf->osd_debug_randomize_hobject_sort_order) {
-    // randomly use a nibblewise sort (when we otherwise might have
-    // done bitwise) based on some *deterministic* function such that
-    // all peers/osds will agree.
-    randomly_sort_nibblewise = (info.history.same_interval_since + info.pgid.ps()) & 1;
-  } else {
-    randomly_sort_nibblewise = false;
-  }
+  on_new_interval();
 
   dout(10) << " up " << oldup << " -> " << up 
           << ", acting " << oldacting << " -> " << acting 
@@ -4831,6 +4806,38 @@ void PG::start_peering_interval(
   }
 }
 
+void PG::on_new_interval()
+{
+  const OSDMapRef osdmap = get_osdmap();
+
+  reg_next_scrub();
+
+  // initialize features
+  acting_features = CEPH_FEATURES_SUPPORTED_DEFAULT;
+  upacting_features = CEPH_FEATURES_SUPPORTED_DEFAULT;
+  for (vector<int>::iterator p = acting.begin(); p != acting.end(); ++p) {
+    if (*p == CRUSH_ITEM_NONE)
+      continue;
+    uint64_t f = osdmap->get_xinfo(*p).features;
+    acting_features &= f;
+    upacting_features &= f;
+  }
+  for (vector<int>::iterator p = up.begin(); p != up.end(); ++p) {
+    if (*p == CRUSH_ITEM_NONE)
+      continue;
+    upacting_features &= osdmap->get_xinfo(*p).features;
+  }
+
+  if (g_conf->osd_debug_randomize_hobject_sort_order) {
+    // randomly use a nibblewise sort (when we otherwise might have
+    // done bitwise) based on some *deterministic* function such that
+    // all peers/osds will agree.
+    randomly_sort_nibblewise = (info.history.same_interval_since + info.pgid.ps()) & 1;
+  } else {
+    randomly_sort_nibblewise = false;
+  }
+}
+
 void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo)
 {
   assert(!is_primary());
index 2a1cbd97c157d5029b219958356b7511493574e2..733df0e3c593dd7139dd26c62db8db51d7b75f12 100644 (file)
@@ -2204,6 +2204,7 @@ public:
     const vector<int>& newup, int up_primary,
     const vector<int>& newacting, int acting_primary,
     ObjectStore::Transaction *t);
+  void on_new_interval();
   void start_flush(ObjectStore::Transaction *t,
                   list<Context *> *on_applied,
                   list<Context *> *on_safe);