]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: switch to common C_TrackedOp context class
authorJason Dillaman <dillaman@redhat.com>
Fri, 17 Apr 2020 14:20:44 +0000 (10:20 -0400)
committerNathan Cutler <ncutler@suse.com>
Tue, 28 Apr 2020 20:29:16 +0000 (22:29 +0200)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 64f8d9c30c53077f48107e83ba836897aa99e609)

src/tools/rbd_mirror/image_replayer/journal/Replayer.cc
src/tools/rbd_mirror/image_replayer/journal/Replayer.h
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.h

index cd7a04926109e4a2b212185d760eaf01e12e649d..f1552ac68ca591743fdb2ec9d406875e6428a9ef 100644 (file)
@@ -75,22 +75,6 @@ struct Replayer<I>::C_ReplayCommitted : public Context {
   }
 };
 
-template <typename I>
-struct Replayer<I>::C_TrackedOp : public Context {
-  Replayer *replayer;
-  Context* ctx;
-
-  C_TrackedOp(Replayer* replayer, Context* ctx)
-    : replayer(replayer), ctx(ctx) {
-    replayer->m_in_flight_op_tracker.start_op();
-  }
-
-  void finish(int r) override {
-    ctx->complete(r);
-    replayer->m_in_flight_op_tracker.finish_op();
-  }
-};
-
 template <typename I>
 struct Replayer<I>::RemoteJournalerListener
   : public ::journal::JournalMetadataListener {
@@ -99,9 +83,11 @@ struct Replayer<I>::RemoteJournalerListener
   RemoteJournalerListener(Replayer* replayer) : replayer(replayer) {}
 
   void handle_update(::journal::JournalMetadata*) override {
-    auto ctx = new C_TrackedOp(replayer, new LambdaContext([this](int r) {
-      replayer->handle_remote_journal_metadata_updated();
-    }));
+    auto ctx = new C_TrackedOp(
+      replayer->m_in_flight_op_tracker,
+      new LambdaContext([this](int r) {
+        replayer->handle_remote_journal_metadata_updated();
+      }));
     replayer->m_threads->work_queue->queue(ctx, 0);
   }
 };
@@ -247,7 +233,7 @@ template <typename I>
 void Replayer<I>::flush(Context* on_finish) {
   dout(10) << dendl;
 
-  flush_local_replay(new C_TrackedOp(this, on_finish));
+  flush_local_replay(new C_TrackedOp(m_in_flight_op_tracker, on_finish));
 }
 
 template <typename I>
@@ -264,7 +250,7 @@ bool Replayer<I>::get_replay_status(std::string* description,
     return false;
   }
 
-  on_finish = new C_TrackedOp(this, on_finish);
+  on_finish = new C_TrackedOp(m_in_flight_op_tracker, on_finish);
   return m_replay_status_formatter->get_or_send_update(description,
                                                        on_finish);
 }
@@ -1136,7 +1122,7 @@ void Replayer<I>::notify_status_updated() {
 
   dout(10) << dendl;
 
-  auto ctx = new C_TrackedOp(this, new LambdaContext(
+  auto ctx = new C_TrackedOp(m_in_flight_op_tracker, new LambdaContext(
     [this](int) {
       m_replayer_listener->handle_notification();
     }));
index 90ef61022331ed54206a26d3874e911fc19eab05..f5d59a07f8a4733d1f9e864dab4be2e815aea1fe 100644 (file)
@@ -174,7 +174,6 @@ private:
   };
 
   struct C_ReplayCommitted;
-  struct C_TrackedOp;
   struct RemoteJournalerListener;
   struct RemoteReplayHandler;
   struct LocalJournalListener;
index 091a40d5b2c6dedfc727f12b2089b63cecac0ae1..18a56b3a8d4b3e21f35918398072e9142042aafe 100644 (file)
@@ -87,22 +87,6 @@ struct Replayer<I>::C_UpdateWatchCtx : public librbd::UpdateWatchCtx {
   }
 };
 
-template <typename I>
-struct Replayer<I>::C_TrackedOp : public Context {
-  Replayer *replayer;
-  Context* ctx;
-
-  C_TrackedOp(Replayer* replayer, Context* ctx)
-    : replayer(replayer), ctx(ctx) {
-    replayer->m_in_flight_op_tracker.start_op();
-  }
-
-  void finish(int r) override {
-    ctx->complete(r);
-    replayer->m_in_flight_op_tracker.finish_op();
-  }
-};
-
 template <typename I>
 struct Replayer<I>::DeepCopyHandler : public librbd::deep_copy::Handler {
   Replayer *replayer;
@@ -1101,7 +1085,8 @@ void Replayer<I>::update_non_primary_snapshot(bool complete) {
     &op, m_local_snap_id_end, m_local_mirror_snap_ns.complete,
     m_local_mirror_snap_ns.last_copied_object_number);
 
-  auto ctx = new C_TrackedOp(this, new LambdaContext([this, complete](int r) {
+  auto ctx = new C_TrackedOp(
+    m_in_flight_op_tracker, new LambdaContext([this, complete](int r) {
       handle_update_non_primary_snapshot(complete, r);
     }));
   auto aio_comp = create_rados_callback(ctx);
@@ -1419,7 +1404,7 @@ void Replayer<I>::notify_status_updated() {
   ceph_assert(ceph_mutex_is_locked_by_me(m_lock));
 
   dout(10) << dendl;
-  auto ctx = new C_TrackedOp(this, new LambdaContext(
+  auto ctx = new C_TrackedOp(m_in_flight_op_tracker, new LambdaContext(
     [this](int) {
       m_replayer_listener->handle_notification();
     }));
index dda101b0c2a4e246e5e98b6c340d35cc4961909d..3eab052a20d30b602b2097a83aa894b84168c28d 100644 (file)
@@ -189,7 +189,6 @@ private:
   };
 
   struct C_UpdateWatchCtx;
-  struct C_TrackedOp;
   struct DeepCopyHandler;
 
   Threads<ImageCtxT>* m_threads;