]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/: move should_restart_peering to PeeringState
authorsjust@redhat.com <sjust@redhat.com>
Wed, 27 Mar 2019 18:31:11 +0000 (11:31 -0700)
committersjust@redhat.com <sjust@redhat.com>
Wed, 1 May 2019 18:22:13 +0000 (11:22 -0700)
Signed-off-by: sjust@redhat.com <sjust@redhat.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/PeeringState.cc
src/osd/PeeringState.h
src/test/osd/types.cc

index 4c30caead3a1b64b5ad266447c352019e1ba7c25..5af3b642b74c3ab8b236b52a96863f84f754db7f 100644 (file)
@@ -5735,37 +5735,6 @@ void PG::fulfill_query(const MQuery& query, PeeringCtx *rctx)
   }
 }
 
-bool PG::should_restart_peering(
-  int newupprimary,
-  int newactingprimary,
-  const vector<int>& newup,
-  const vector<int>& newacting,
-  OSDMapRef lastmap,
-  OSDMapRef osdmap)
-{
-  if (PastIntervals::is_new_interval(
-       primary.osd,
-       newactingprimary,
-       acting,
-       newacting,
-       up_primary.osd,
-       newupprimary,
-       up,
-       newup,
-       osdmap.get(),
-       lastmap.get(),
-       info.pgid.pgid)) {
-    dout(20) << "new interval newup " << newup
-            << " newacting " << newacting << dendl;
-    return true;
-  }
-  if (!lastmap->is_up(osd->whoami) && osdmap->is_up(osd->whoami)) {
-    dout(10) << __func__ << " osd transitioned from down -> up" << dendl;
-    return true;
-  }
-  return false;
-}
-
 bool PG::old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch)
 {
   if (last_peering_reset > reply_epoch ||
index a47d3db8ecd57f1a4a8156ca49cf4df7845d051e..167471c98e8b9dc6de47652ce4f139ff7c5c0352 100644 (file)
@@ -1679,14 +1679,6 @@ protected:
   void fulfill_log(pg_shard_t from, const pg_query_t &query, epoch_t query_epoch);
   void fulfill_query(const MQuery& q, PeeringCtx *rctx);
 
-  bool should_restart_peering(
-    int newupprimary,
-    int newactingprimary,
-    const vector<int>& newup,
-    const vector<int>& newacting,
-    OSDMapRef lastmap,
-    OSDMapRef osdmap);
-
   // OpRequest queueing
   bool can_discard_op(OpRequestRef& op);
   bool can_discard_scan(OpRequestRef op);
index 9ee0924e90c3faa761820f9f26b2569a612bb49e..eab00391a48c08efd9c8c299de3f9df51f96e46b 100644 (file)
@@ -421,6 +421,36 @@ void PeeringState::check_full_transition(OSDMapRef lastmap, OSDMapRef osdmap)
   }
 }
 
+bool PG::should_restart_peering(
+  int newupprimary,
+  int newactingprimary,
+  const vector<int>& newup,
+  const vector<int>& newacting,
+  OSDMapRef lastmap,
+  OSDMapRef osdmap)
+{
+  if (PastIntervals::is_new_interval(
+       primary.osd,
+       newactingprimary,
+       acting,
+       newacting,
+       up_primary.osd,
+       newupprimary,
+       up,
+       newup,
+       osdmap.get(),
+       lastmap.get(),
+       info.pgid.pgid)) {
+    dout(20) << "new interval newup " << newup
+            << " newacting " << newacting << dendl;
+    return true;
+  }
+  if (!lastmap->is_up(osd->whoami) && osdmap->is_up(osd->whoami)) {
+    dout(10) << __func__ << " osd transitioned from down -> up" << dendl;
+    return true;
+  }
+  return false;
+}
 
 /*------------ Peering State Machine----------------*/
 #undef dout_prefix
@@ -502,7 +532,7 @@ boost::statechart::result PeeringState::Started::react(const AdvMap& advmap)
   PG *pg = context< PeeringMachine >().pg;
   psdout(10) << "Started advmap" << dendl;
   ps->check_full_transition(advmap.lastmap, advmap.osdmap);
-  if (pg->should_restart_peering(
+  if (ps->should_restart_peering(
        advmap.up_primary,
        advmap.acting_primary,
        advmap.newup,
@@ -563,7 +593,7 @@ boost::statechart::result PeeringState::Reset::react(const AdvMap& advmap)
 
   ps->check_full_transition(advmap.lastmap, advmap.osdmap);
 
-  if (pg->should_restart_peering(
+  if (ps->should_restart_peering(
        advmap.up_primary,
        advmap.acting_primary,
        advmap.newup,
@@ -1785,7 +1815,7 @@ PeeringState::Active::Active(my_context ctx)
 boost::statechart::result PeeringState::Active::react(const AdvMap& advmap)
 {
   PG *pg = context< PeeringMachine >().pg;
-  if (pg->should_restart_peering(
+  if (ps->should_restart_peering(
        advmap.up_primary,
        advmap.acting_primary,
        advmap.newup,
index 9d8473057de6c83932df2bd810fafeaa4d3f5318..8d39db3a9a7f6f0d8bbde3a538a3e869a35cfc7f 100644 (file)
@@ -1161,6 +1161,14 @@ public:
   void check_recovery_sources(const OSDMapRef& map);
   void set_last_peering_reset();
   void check_full_transition(OSDMapRef lastmap, OSDMapRef osdmap);
+  bool should_restart_peering(
+    int newupprimary,
+    int newactingprimary,
+    const vector<int>& newup,
+    const vector<int>& newacting,
+    OSDMapRef lastmap,
+    OSDMapRef osdmap);
+
 
 public:
   PeeringState(
index 6aba395c56a8e405b12a94c06f78a8c0d9102048..550d97c3b74600ba8d57c895ee02fa444b0a7c09 100644 (file)
@@ -190,7 +190,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                   osdmap,
                                                   lastmap,
                                                   pgid,
-                                                   recoverable.get(),
+                                                   *recoverable,
                                                   &past_intervals));
     ASSERT_TRUE(past_intervals.empty());
   }
@@ -219,7 +219,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
     old_primary = new_primary;
   }
@@ -248,7 +248,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -275,7 +275,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -309,7 +309,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -343,7 +343,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pg_t(pg_num - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -378,7 +378,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  lastmap,  // reverse order!
                                                  osdmap,
                                                  pg_t(pg_num - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -411,7 +411,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pg_t(pg_num - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -444,7 +444,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pg_t(pg_num / 2 - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -477,7 +477,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  lastmap,  // reverse order!
                                                  osdmap,
                                                  pg_t(pg_num / 2 - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -510,7 +510,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pg_t(pg_num / 2 - 1, pool_id),
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -544,7 +544,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals));
   }
 
@@ -573,7 +573,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals,
                                                  &out));
     ASSERT_NE(string::npos, out.str().find("acting set is too small"));
@@ -623,7 +623,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals,
                                                  &out));
     ASSERT_NE(string::npos, out.str().find("acting set is too small"));
@@ -656,7 +656,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals,
                                                  &out));
     ASSERT_NE(string::npos, out.str().find("includes interval"));
@@ -699,7 +699,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals,
                                                  &out));
     ASSERT_NE(string::npos, out.str().find("presumed to have been rw"));
@@ -746,7 +746,7 @@ for (unsigned i = 0; i < 4; ++i) {
                                                  osdmap,
                                                  lastmap,
                                                  pgid,
-                                                  recoverable.get(),
+                                                  *recoverable,
                                                  &past_intervals,
                                                  &out));
     ASSERT_NE(string::npos, out.str().find("does not include interval"));