From: lixiaoy1 Date: Wed, 14 Aug 2019 14:32:44 +0000 (-0400) Subject: librbd: Remove duplicated AsyncOpTracker in librbd/Utils.h X-Git-Tag: v15.1.0~1829^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fd35dc5d88d3ac3ad7382aec0cd4e794acfab7c2;p=ceph-ci.git librbd: Remove duplicated AsyncOpTracker in librbd/Utils.h Signed-off-by: Xiaoyan Li --- diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index b73a240e231..1e4eee18172 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -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::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 @@ -1640,7 +1642,7 @@ int Journal::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(); } diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h index 13be62aa163..7213120d62f 100644 --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@ -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 *m_journal_replay; - util::AsyncOpTracker m_async_journal_op_tracker; + AsyncOpTracker m_async_journal_op_tracker; struct MetadataListener : public ::journal::JournalMetadataListener { Journal *journal; diff --git a/src/librbd/Utils.h b/src/librbd/Utils.h index 0f9ebe3a82d..9aa01edb2df 100644 --- a/src/librbd/Utils.h +++ b/src/librbd/Utils.h @@ -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 - 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 m_refs = { 0 }; - Context *m_on_finish = nullptr; -}; - uint64_t get_rbd_default_features(CephContext* cct); bool calc_sparse_extent(const bufferptr &bp,