]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
PeeringState: begin abstracting out PG, add dpp for logging
authorSamuel Just <sjust@redhat.com>
Fri, 22 Mar 2019 01:21:36 +0000 (18:21 -0700)
committersjust@redhat.com <sjust@redhat.com>
Wed, 1 May 2019 18:22:12 +0000 (11:22 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/PeeringState.cc
src/osd/PeeringState.h

index d18cc7c2b887fda4759a43ed077dc5e734590a68..e15809b3154a86400bfd555d9270bb9eae364c78 100644 (file)
@@ -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),
index d40bce881014aa342bb60b9ef94a2cc484c46bbe..2a1d7f4df3dbe0962e19bd627d937ac7bd1e95aa 100644 (file)
@@ -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:
index 932d089563d1f6b0b1c1fd3c8327683970533eea..aeaa89720607ad83bde9afaf4009b920d70919dc 100644 (file)
 #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)
 
index 38f78bf9acb5efe907277bb8af0810730f701043..91666963b932d806876c35e757b1f940dc98c7ae 100644 (file)
@@ -10,6 +10,7 @@
 #include <boost/statechart/state_machine.hpp>
 #include <boost/statechart/transition.hpp>
 #include <boost/statechart/event_base.hpp>
+#include <string>
 
 #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<int, map<spg_t, pg_query_t> > 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<PeeringCtx> 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) {