From 6e28b271fefb57c26b199f8b826a988a6c7ee230 Mon Sep 17 00:00:00 2001 From: "sjust@redhat.com" Date: Wed, 27 Mar 2019 14:40:11 -0700 Subject: [PATCH] osd/: move check_past_interval_bounds into PeeringState Signed-off-by: sjust@redhat.com --- src/osd/PG.cc | 54 +++------------------------------ src/osd/PG.h | 15 +-------- src/osd/PeeringState.cc | 67 +++++++++++++++++++++++++++++++++++++++-- src/osd/PeeringState.h | 3 ++ 4 files changed, 73 insertions(+), 66 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 45b63bc7935..79a870c9cd7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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(op->get_req()); diff --git a/src/osd/PG.h b/src/osd/PG.h index f16f180f223..fcd27758b1f 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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 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); diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 367ee623961..3977b612681 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -735,6 +735,67 @@ void PeeringState::clear_primary_state() pl->clear_primary_state(); } +/// return [start,end) bounds for required past_intervals +static pair 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()); diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 0dc182ac1d8..b5f887c5457 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -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( -- 2.39.5