From 365fe8638bd3bb0ba57407265a1ad0d924eea7a1 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 21 Mar 2019 18:21:36 -0700 Subject: [PATCH] PeeringState: begin abstracting out PG, add dpp for logging Signed-off-by: Samuel Just --- src/osd/PG.cc | 2 +- src/osd/PG.h | 2 +- src/osd/PeeringState.cc | 13 +++++++++---- src/osd/PeeringState.h | 22 ++++++++++++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index d18cc7c2b88..e15809b3154 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -304,7 +304,7 @@ PG::PG(OSDService *o, OSDMapRef curmap, backoff_lock("PG::backoff_lock"), scrub_after_recovery(false), active_pushes(0), - recovery_state(cct, info.pgid, this), + recovery_state(cct, info.pgid, this, this, this), peer_features(CEPH_FEATURES_SUPPORTED_DEFAULT), acting_features(CEPH_FEATURES_SUPPORTED_DEFAULT), upacting_features(CEPH_FEATURES_SUPPORTED_DEFAULT), diff --git a/src/osd/PG.h b/src/osd/PG.h index d40bce88101..2a1d7f4df3d 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -196,7 +196,7 @@ struct PGPool { * */ -class PG : public DoutPrefixProvider, public EpochSource { +class PG : public DoutPrefixProvider, public PeeringState::PeeringListener { friend class NamedState; friend class PeeringState; public: diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 932d089563d..aeaa8972060 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -11,10 +11,15 @@ #include "messages/MRecoveryReserve.h" #include "messages/MOSDScrubReserve.h" -PeeringState::PeeringState(CephContext *cct, spg_t spgid, PG *pg) +PeeringState::PeeringState( + CephContext *cct, + spg_t spgid, + DoutPrefixProvider *dpp, + PeeringListener *pl, + PG *pg) : state_history(pg), - machine(this, cct, spgid, pg, &state_history), cct(cct), - spgid(spgid), pg(pg), orig_ctx(0) { + machine(this, cct, spgid, dpp, pl, pg, &state_history), cct(cct), + spgid(spgid), dpp(dpp), pl(pl), pg(pg), orig_ctx(0) { machine.initiate(); } @@ -32,7 +37,7 @@ void PeeringState::PeeringMachine::send_query( #define dout_context cct #define dout_subsys ceph_subsys_osd #undef dout_prefix -#define dout_prefix (context< PeeringMachine >().pg->gen_prefix(*_dout) \ +#define dout_prefix (context< PeeringMachine >().dpp->gen_prefix(*_dout) \ << "state<" << get_state_name() << ">: ") #define psdout(x) ldout(context< PeeringMachine >().cct, x) diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 38f78bf9acb..91666963b93 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "PGStateUtils.h" #include "PGPeeringEvent.h" @@ -21,6 +22,10 @@ class PG; /* Encapsulates PG recovery process */ class PeeringState { public: + struct PeeringListener : public EpochSource { + virtual ~PeeringListener() {} + }; + // [primary only] content recovery state struct BufferedRecoveryMessages { map > query_map; @@ -214,6 +219,8 @@ public: PGStateHistory *state_history; CephContext *cct; spg_t spgid; + DoutPrefixProvider *dpp; + PeeringListener *pl; PG *pg; utime_t event_time; @@ -229,11 +236,15 @@ public: PeeringMachine( PeeringState *state, CephContext *cct, - spg_t spgid, PG *pg, + spg_t spgid, + DoutPrefixProvider *dpp, + PeeringListener *pl, + PG *pg, PGStateHistory *state_history) : state(state), state_history(state_history), cct(cct), spgid(spgid), + dpp(dpp), pl(pl), pg(pg), event_count(0) {} /* Accessor functions for state methods */ @@ -959,6 +970,8 @@ public: PeeringMachine machine; CephContext* cct; spg_t spgid; + DoutPrefixProvider *dpp; + PeeringListener *pl; PG *pg; /// context passed in by state machine caller @@ -975,7 +988,12 @@ public: boost::optional rctx; public: - PeeringState(CephContext *cct, spg_t spgid, PG *pg); + PeeringState( + CephContext *cct, + spg_t spgid, + DoutPrefixProvider *dpp, + PeeringListener *pl, + PG *pg); void handle_event(const boost::statechart::event_base &evt, PeeringCtx *rctx) { -- 2.39.5