]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pg: handle MNotifyRec event in down state 20959/head
authorMingxin Liu <mingxin@xsky.com>
Mon, 19 Mar 2018 10:15:38 +0000 (18:15 +0800)
committerMingxin Liu <mingxin@xsky.com>
Mon, 19 Mar 2018 10:26:26 +0000 (18:26 +0800)
if we receive notify with info contains newer les, try getinfo again

Signed-off-by: Mingxin Liu <mingxin@xsky.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.cc

index e416e336bb6964701b486c702c4bfd38c56f8d10..bcfd2ecdd99ccd95ff4bc73ee02e02de0db779f8 100644 (file)
@@ -8379,7 +8379,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MInfoRec& infoev
     pg->info.stats = infoevt.info.stats;
     pg->info.hit_set = infoevt.info.hit_set;
   }
-  
+
   assert(infoevt.info.last_update == pg->info.last_update);
   assert(pg->pg_log.get_head() == pg->info.last_update);
 
@@ -8902,6 +8902,28 @@ boost::statechart::result PG::RecoveryState::Down::react(const QueryState& q)
   return forward_event();
 }
 
+boost::statechart::result PG::RecoveryState::Down::react(const MNotifyRec& infoevt)
+{
+  PG *pg = context< RecoveryMachine >().pg;
+
+  assert(pg->is_primary());
+  epoch_t old_start = pg->info.history.last_epoch_started;
+  if (!pg->peer_info.count(infoevt.from) &&
+      pg->get_osdmap()->has_been_up_since(infoevt.from.osd, infoevt.notify.epoch_sent)) {
+    pg->update_history(infoevt.notify.info.history);
+  }
+  // if we got something new to make pg escape down state
+  if (pg->info.history.last_epoch_started > old_start) {
+      ldout(pg->cct, 10) << " last_epoch_started moved forward, re-enter getinfo" << dendl;
+    pg->state_clear(PG_STATE_DOWN);
+    pg->state_set(PG_STATE_PEERING);
+    return transit< GetInfo >();
+  }
+
+  return discard_event();
+}
+
+
 /*------Incomplete--------*/
 PG::RecoveryState::Incomplete::Incomplete(my_context ctx)
   : my_base(ctx),
index 0575cd8cc9eef94e1b0c0024af6821d796c6a2f0..f77a61e122b0da66d6465d47c09d6454c87c06db 100644 (file)
@@ -2703,9 +2703,11 @@ protected:
     struct Down : boost::statechart::state< Down, Peering>, NamedState {
       explicit Down(my_context ctx);
       typedef boost::mpl::list <
-       boost::statechart::custom_reaction< QueryState >
+       boost::statechart::custom_reaction< QueryState >,
+       boost::statechart::custom_reaction< MNotifyRec >
        > reactions;
-      boost::statechart::result react(const QueryState& infoevt);
+      boost::statechart::result react(const QueryState& q);
+      boost::statechart::result react(const MNotifyRec& infoevt);
       void exit();
     };
 
@@ -2718,7 +2720,7 @@ protected:
       explicit Incomplete(my_context ctx);
       boost::statechart::result react(const AdvMap &advmap);
       boost::statechart::result react(const MNotifyRec& infoevt);
-      boost::statechart::result react(const QueryState& infoevt);
+      boost::statechart::result react(const QueryState& q);
       void exit();
     };
 
index ca5ddc0bea3ccd339efe75b97cfb9762c4a62b9e..26395415fcce9bec36c29b5299861ead7ccd7087 100644 (file)
@@ -3492,20 +3492,18 @@ bool PastIntervals::check_new_interval(
         (*could_have_gone_active)(old_acting_shards)) {
       if (out)
        *out << __func__ << " " << i
-            << ": not rw,"
             << " up_thru " << lastmap->get_up_thru(i.primary)
             << " up_from " << lastmap->get_up_from(i.primary)
-            << " last_epoch_clean " << last_epoch_clean
-            << std::endl;
+            << " last_epoch_clean " << last_epoch_clean;
       if (lastmap->get_up_thru(i.primary) >= i.first &&
          lastmap->get_up_from(i.primary) <= i.first) {
        i.maybe_went_rw = true;
        if (out)
-         *out << __func__ << " " << i
+         *out << " " << i
               << " : primary up " << lastmap->get_up_from(i.primary)
               << "-" << lastmap->get_up_thru(i.primary)
               << " includes interval"
-              << std::endl;
+               << std::endl;
       } else if (last_epoch_clean >= i.first &&
                 last_epoch_clean <= i.last) {
        // If the last_epoch_clean is included in this interval, then
@@ -3517,18 +3515,18 @@ bool PastIntervals::check_new_interval(
        // last_epoch_clean timing.
        i.maybe_went_rw = true;
        if (out)
-         *out << __func__ << " " << i
+         *out << " " << i
               << " : includes last_epoch_clean " << last_epoch_clean
               << " and presumed to have been rw"
               << std::endl;
       } else {
        i.maybe_went_rw = false;
        if (out)
-         *out << __func__ << " " << i
+         *out << " " << i
               << " : primary up " << lastmap->get_up_from(i.primary)
               << "-" << lastmap->get_up_thru(i.primary)
               << " does not include interval"
-              << std::endl;
+               << std::endl;
       }
     } else {
       i.maybe_went_rw = false;