]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: move check_past_interval_bounds into PeeringState
authorsjust@redhat.com <sjust@redhat.com>
Wed, 27 Mar 2019 21:40:11 +0000 (14:40 -0700)
committersjust@redhat.com <sjust@redhat.com>
Wed, 1 May 2019 18:22:14 +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

index 45b63bc7935a1882f6e91cfc3a753ce2d9052636..79a870c9cd72d073cde02338de423fcca8326f3d 100644 (file)
@@ -576,54 +576,6 @@ bool PG::needs_backfill() const
   return false;
 }
 
-
-void PG::check_past_interval_bounds() const
-{
-  auto rpib = get_required_past_interval_bounds(
-    info,
-    osd->get_superblock().oldest_map);
-  if (rpib.first >= rpib.second) {
-    if (!past_intervals.empty()) {
-      osd->clog->error() << info.pgid << " required past_interval bounds are"
-                        << " empty [" << rpib << ") but past_intervals is not: "
-                        << past_intervals;
-      derr << info.pgid << " required past_interval bounds are"
-          << " empty [" << rpib << ") but past_intervals is not: "
-          << past_intervals << dendl;
-    }
-  } else {
-    if (past_intervals.empty()) {
-      osd->clog->error() << info.pgid << " required past_interval bounds are"
-                        << " not empty [" << rpib << ") but past_intervals "
-                        << past_intervals << " is empty";
-      derr << info.pgid << " required past_interval bounds are"
-          << " not empty [" << rpib << ") but past_intervals "
-          << past_intervals << " is empty" << dendl;
-      ceph_assert(!past_intervals.empty());
-    }
-
-    auto apib = past_intervals.get_bounds();
-    if (apib.first > rpib.first) {
-      osd->clog->error() << info.pgid << " past_intervals [" << apib
-                        << ") start interval does not contain the required"
-                        << " bound [" << rpib << ") start";
-      derr << info.pgid << " past_intervals [" << apib
-          << ") start interval does not contain the required"
-          << " bound [" << rpib << ") start" << dendl;
-      ceph_abort_msg("past_interval start interval mismatch");
-    }
-    if (apib.second != rpib.second) {
-      osd->clog->error() << info.pgid << " past_interal bound [" << apib
-                        << ") end does not match required [" << rpib
-                        << ") end";
-      derr << info.pgid << " past_interal bound [" << apib
-          << ") end does not match required [" << rpib
-          << ") end" << dendl;
-      ceph_abort_msg("past_interval end mismatch");
-    }
-  }
-}
-
 bool PG::adjust_need_up_thru(const OSDMapRef osdmap)
 {
   epoch_t up_thru = osdmap->get_up_thru(osd->whoami);
@@ -1469,7 +1421,7 @@ void PG::build_might_have_unfound()
 
   dout(10) << __func__ << dendl;
 
-  check_past_interval_bounds();
+  recovery_state.check_past_interval_bounds();
 
   might_have_unfound = past_intervals.get_might_have_unfound(
     pg_whoami,
@@ -4114,6 +4066,10 @@ epoch_t PG::oldest_stored_osdmap() {
   return osd->get_superblock().oldest_map;
 }
 
+LogChannel &PG::get_clog() {
+  return *(osd->clog);
+}
+
 void PG::do_replica_scrub_map(OpRequestRef op)
 {
   const MOSDRepScrubMap *m = static_cast<const MOSDRepScrubMap*>(op->get_req());
index f16f180f2230a056a1be97dde49d9ed0e98e1cf4..fcd27758b1f2f5e47e2e4a2a2acf0fec7a9ab79a 100644 (file)
@@ -421,6 +421,7 @@ public:
   void clear_primary_state() override;
 
   epoch_t oldest_stored_osdmap() override;
+  LogChannel &get_clog() override;
 
   bool is_forced_recovery_or_backfill() const {
     return get_state() & (PG_STATE_FORCED_RECOVERY | PG_STATE_FORCED_BACKFILL);
@@ -947,20 +948,6 @@ protected:
 
   void try_mark_clean();  ///< mark an active pg clean
 
-  /// return [start,end) bounds for required past_intervals
-  static pair<epoch_t, epoch_t> get_required_past_interval_bounds(
-    const pg_info_t &info,
-    epoch_t oldest_map) {
-    epoch_t start = std::max(
-      info.history.last_epoch_clean ? info.history.last_epoch_clean :
-       info.history.epoch_pool_created,
-      oldest_map);
-    epoch_t end = std::max(
-      info.history.same_interval_since,
-      info.history.epoch_pool_created);
-    return make_pair(start, end);
-  }
-  void check_past_interval_bounds() const;
   PastIntervals::PriorSet build_prior();
 
   bool adjust_need_up_thru(const OSDMapRef osdmap);
index 367ee623961d37f9e154c3b27801a582cb9a453f..3977b61268113f6ded96ad532c6f6563e7b6b169 100644 (file)
@@ -735,6 +735,67 @@ void PeeringState::clear_primary_state()
   pl->clear_primary_state();
 }
 
+/// return [start,end) bounds for required past_intervals
+static pair<epoch_t, epoch_t> get_required_past_interval_bounds(
+  const pg_info_t &info,
+  epoch_t oldest_map) {
+  epoch_t start = std::max(
+    info.history.last_epoch_clean ? info.history.last_epoch_clean :
+    info.history.epoch_pool_created,
+    oldest_map);
+  epoch_t end = std::max(
+    info.history.same_interval_since,
+    info.history.epoch_pool_created);
+  return make_pair(start, end);
+}
+
+
+void PeeringState::check_past_interval_bounds() const
+{
+  auto rpib = get_required_past_interval_bounds(
+    info,
+    pl->oldest_stored_osdmap());
+  if (rpib.first >= rpib.second) {
+    if (!past_intervals.empty()) {
+      pl->get_clog().error() << info.pgid << " required past_interval bounds are"
+                            << " empty [" << rpib << ") but past_intervals is not: "
+                            << past_intervals;
+      derr << info.pgid << " required past_interval bounds are"
+          << " empty [" << rpib << ") but past_intervals is not: "
+          << past_intervals << dendl;
+    }
+  } else {
+    if (past_intervals.empty()) {
+      pl->get_clog().error() << info.pgid << " required past_interval bounds are"
+                            << " not empty [" << rpib << ") but past_intervals "
+                            << past_intervals << " is empty";
+      derr << info.pgid << " required past_interval bounds are"
+          << " not empty [" << rpib << ") but past_intervals "
+          << past_intervals << " is empty" << dendl;
+      ceph_assert(!past_intervals.empty());
+    }
+
+    auto apib = past_intervals.get_bounds();
+    if (apib.first > rpib.first) {
+      pl->get_clog().error() << info.pgid << " past_intervals [" << apib
+                            << ") start interval does not contain the required"
+                            << " bound [" << rpib << ") start";
+      derr << info.pgid << " past_intervals [" << apib
+          << ") start interval does not contain the required"
+          << " bound [" << rpib << ") start" << dendl;
+      ceph_abort_msg("past_interval start interval mismatch");
+    }
+    if (apib.second != rpib.second) {
+      pl->get_clog().error() << info.pgid << " past_interal bound [" << apib
+                            << ") end does not match required [" << rpib
+                            << ") end";
+      derr << info.pgid << " past_interal bound [" << apib
+          << ") end does not match required [" << rpib
+          << ") end" << dendl;
+      ceph_abort_msg("past_interval end mismatch");
+    }
+  }
+}
 
 /*------------ Peering State Machine----------------*/
 #undef dout_prefix
@@ -871,7 +932,6 @@ PeeringState::Reset::react(const IntervalFlush&)
 boost::statechart::result PeeringState::Reset::react(const AdvMap& advmap)
 {
   PeeringState *ps = context< PeeringMachine >().state;
-  PG *pg = context< PeeringMachine >().pg;
   psdout(10) << "Reset advmap" << dendl;
 
   ps->check_full_transition(advmap.lastmap, advmap.osdmap);
@@ -892,7 +952,7 @@ boost::statechart::result PeeringState::Reset::react(const AdvMap& advmap)
       context< PeeringMachine >().get_cur_transaction());
   }
   ps->remove_down_peer_info(advmap.osdmap);
-  pg->check_past_interval_bounds();
+  ps->check_past_interval_bounds();
   return discard_event();
 }
 
@@ -2796,8 +2856,9 @@ PeeringState::GetInfo::GetInfo(my_context ctx)
 {
   context< PeeringMachine >().log_enter(state_name);
 
+  PeeringState *ps = context< PeeringMachine >().state;
   PG *pg = context< PeeringMachine >().pg;
-  pg->check_past_interval_bounds();
+  ps->check_past_interval_bounds();
   PastIntervals::PriorSet &prior_set = context< Peering >().prior_set;
 
   ceph_assert(pg->blocked_by.empty());
index 0dc182ac1d8fd8585666107fefec149d7457dddd..b5f887c5457fbea18864321b044a8ae7e49fb00c 100644 (file)
@@ -20,6 +20,7 @@
 #include "os/ObjectStore.h"
 #include "OSDMap.h"
 #include "MissingLoc.h"
+#include "common/LogClient.h"
 
 class PG;
 
@@ -97,6 +98,7 @@ public:
     virtual void on_new_interval() = 0;
 
     virtual epoch_t oldest_stored_osdmap() = 0;
+    virtual LogChannel &get_clog() = 0;
 
     virtual ~PeeringListener() {}
   };
@@ -1193,6 +1195,7 @@ public:
     int new_up_primary,
     int new_acting_primary);
   void clear_primary_state();
+  void check_past_interval_bounds() const;
 
 public:
   PeeringState(