]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/PeeringState: make PeeringCtx inherit from BufferedRecoveryMessages
authorSamuel Just <rexludorum@gmail.com>
Wed, 22 May 2019 09:57:03 +0000 (02:57 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 11 Jun 2019 00:37:28 +0000 (17:37 -0700)
This'll be convenient in crimson for compound messages, don't want
to share an actual PeeringCtx, but want to combine the messages
to send.  Using inheritance here simply prevents another round of
changing all of the PeeringCtx member users.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/PeeringState.cc
src/osd/PeeringState.h

index a707e48426f62e25979f88d850cf2aa37b8212b8..0acaf1f7b7fa3ac915b3eb8f4896dee230a9dc7a 100644 (file)
 #define dout_context cct
 #define dout_subsys ceph_subsys_osd
 
+BufferedRecoveryMessages::BufferedRecoveryMessages(PeeringCtx &ctx)
+  : query_map(std::move(ctx.query_map)),
+    info_map(std::move(ctx.info_map)),
+    notify_list(std::move(ctx.notify_list))
+{
+  ctx.query_map.clear();
+  ctx.info_map.clear();
+  ctx.notify_list.clear();
+}
+
 void PGPool::update(CephContext *cct, OSDMapRef map)
 {
   const pg_pool_t *pi = map->get_pg_pool(id);
index d24661876076a693f5a6d34663097c54b540c423..1e20b81d553ae88e07a728615b1e9b1e1a3e2232 100644 (file)
@@ -54,25 +54,16 @@ struct PGPool {
   void update(CephContext *cct, OSDMapRef map);
 };
 
+class PeeringCtx;
+
 // [primary only] content recovery state
 struct BufferedRecoveryMessages {
   map<int, map<spg_t, pg_query_t> > query_map;
   map<int, vector<pair<pg_notify_t, PastIntervals> > > info_map;
   map<int, vector<pair<pg_notify_t, PastIntervals> > > notify_list;
-};
-
-struct PeeringCtx {
-  map<int, map<spg_t, pg_query_t> > query_map;
-  map<int, vector<pair<pg_notify_t, PastIntervals> > > info_map;
-  map<int, vector<pair<pg_notify_t, PastIntervals> > > notify_list;
-  ObjectStore::Transaction transaction;
-  HBHandle* handle = nullptr;
-
-  PeeringCtx() = default;
 
-  void reset_transaction() {
-    transaction = ObjectStore::Transaction();
-  }
+  BufferedRecoveryMessages() = default;
+  BufferedRecoveryMessages(PeeringCtx &);
 
   void accept_buffered_messages(BufferedRecoveryMessages &m) {
     for (auto &[target, qmap] : m.query_map) {
@@ -94,6 +85,22 @@ struct PeeringCtx {
   }
 };
 
+struct PeeringCtx : BufferedRecoveryMessages {
+  ObjectStore::Transaction transaction;
+  HBHandle* handle = nullptr;
+
+  PeeringCtx() = default;
+
+  PeeringCtx(const PeeringCtx &) = delete;
+  PeeringCtx &operator=(const PeeringCtx &) = delete;
+
+  PeeringCtx(PeeringCtx &&) = default;
+  PeeringCtx &operator=(PeeringCtx &&) = default;
+
+  void reset_transaction() {
+    transaction = ObjectStore::Transaction();
+  }
+};
 
   /* Encapsulates PG recovery process */
 class PeeringState : public MissingLoc::MappingInfo {