]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: Remove duplicated AsyncOpTracker in librbd/Utils.h
authorlixiaoy1 <xiaoyan.li@intel.com>
Wed, 14 Aug 2019 14:32:44 +0000 (10:32 -0400)
committerlixiaoy1 <xiaoyan.li@intel.com>
Wed, 14 Aug 2019 14:38:31 +0000 (10:38 -0400)
Signed-off-by: Xiaoyan Li <xiaoyan.li@intel.com>
src/librbd/Journal.cc
src/librbd/Journal.h
src/librbd/Utils.h

index b73a240e2316a9beba80209152e36d96687d41c0..1e4eee18172c04c219d1a4032de697b3579fcc17 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "librbd/Journal.h"
 #include "include/rados/librados.hpp"
+#include "common/AsyncOpTracker.h"
 #include "common/errno.h"
 #include "common/Timer.h"
 #include "common/WorkQueue.h"
@@ -1127,7 +1128,8 @@ void Journal<I>::destroy_journaler(int r) {
       std::lock_guard locker{m_lock};
       m_journaler->shut_down(ctx);
     });
-  m_async_journal_op_tracker.wait(m_image_ctx, ctx);
+  ctx = create_async_context_callback(m_image_ctx, ctx);
+  m_async_journal_op_tracker.wait_for_ops(ctx);
 }
 
 template <typename I>
@@ -1640,7 +1642,7 @@ int Journal<I>::check_resync_requested(bool *do_resync) {
 }
 
 struct C_RefreshTags : public Context {
-  util::AsyncOpTracker &async_op_tracker;
+  AsyncOpTracker &async_op_tracker;
   Context *on_finish = nullptr;
 
   ceph::mutex lock =
@@ -1648,7 +1650,7 @@ struct C_RefreshTags : public Context {
   uint64_t tag_tid = 0;
   journal::TagData tag_data;
 
-  explicit C_RefreshTags(util::AsyncOpTracker &async_op_tracker)
+  explicit C_RefreshTags(AsyncOpTracker &async_op_tracker)
     : async_op_tracker(async_op_tracker) {
     async_op_tracker.start_op();
   }
index 13be62aa1635dc925505bacf2144495029d11694..7213120d62fbcf20d6161c8c7137279dda92e016 100644 (file)
@@ -8,6 +8,7 @@
 #include "include/Context.h"
 #include "include/interval_set.h"
 #include "include/rados/librados_fwd.hpp"
+#include "common/AsyncOpTracker.h"
 #include "common/Cond.h"
 #include "common/WorkQueue.h"
 #include "journal/Future.h"
@@ -301,7 +302,7 @@ private:
 
   journal::Replay<ImageCtxT> *m_journal_replay;
 
-  util::AsyncOpTracker m_async_journal_op_tracker;
+  AsyncOpTracker m_async_journal_op_tracker;
 
   struct MetadataListener : public ::journal::JournalMetadataListener {
     Journal<ImageCtxT> *journal;
index 0f9ebe3a82db672c3c763cdf83a56fe15aaa0308..9aa01edb2dff30a1e617140108bb239edbc208d6 100644 (file)
@@ -171,39 +171,6 @@ inline ImageCtx *get_image_ctx(ImageCtx *image_ctx) {
   return image_ctx;
 }
 
-/// helper for tracking in-flight async ops when coordinating
-/// a shut down of the invoking class instance
-class AsyncOpTracker {
-public:
-  void start_op() {
-    m_refs++;
-  }
-
-  void finish_op() {
-    if (--m_refs == 0 && m_on_finish != nullptr) {
-      Context *on_finish = nullptr;
-      std::swap(on_finish, m_on_finish);
-      on_finish->complete(0);
-    }
-  }
-
-  template <typename I>
-  void wait(I &image_ctx, Context *on_finish) {
-    ceph_assert(m_on_finish == nullptr);
-
-    on_finish = create_async_context_callback(image_ctx, on_finish);
-    if (m_refs == 0) {
-      on_finish->complete(0);
-      return;
-    }
-    m_on_finish = on_finish;
-  }
-
-private:
-  std::atomic<uint64_t> m_refs = { 0 };
-  Context *m_on_finish = nullptr;
-};
-
 uint64_t get_rbd_default_features(CephContext* cct);
 
 bool calc_sparse_extent(const bufferptr &bp,