From 5829db1c3018adb74e0f460ba2a573a5a504d2e9 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 28 Apr 2020 23:38:18 -0400 Subject: [PATCH] librbd: move generic IO dispatcher logic to base class This will allow re-use between the existing ObjectDispatcher and the ImageDispatcher that will be added in a future commit. Signed-off-by: Jason Dillaman --- src/librbd/ImageCtx.cc | 2 +- src/librbd/ImageCtx.h | 4 +- src/librbd/Journal.cc | 6 +- .../cache/ObjectCacherObjectDispatch.cc | 4 +- src/librbd/cache/ObjectCacherObjectDispatch.h | 2 +- src/librbd/cache/ObjectCacherWriteback.cc | 2 +- src/librbd/cache/ParentCacheObjectDispatch.cc | 4 +- src/librbd/cache/ParentCacheObjectDispatch.h | 2 +- src/librbd/cache/WriteAroundObjectDispatch.cc | 4 +- src/librbd/cache/WriteAroundObjectDispatch.h | 2 +- .../exclusive_lock/PreReleaseRequest.cc | 2 +- src/librbd/image/CloseRequest.cc | 2 +- src/librbd/image/RefreshParentRequest.cc | 2 +- src/librbd/internal.cc | 2 +- src/librbd/io/Dispatcher.h | 184 ++++++++++++++++++ src/librbd/io/DispatcherInterface.h | 36 ++++ src/librbd/io/ImageRequest.cc | 2 +- src/librbd/io/ObjectDispatch.h | 2 +- src/librbd/io/ObjectDispatchInterface.h | 8 +- src/librbd/io/ObjectDispatchSpec.cc | 2 +- src/librbd/io/ObjectDispatchSpec.h | 4 +- src/librbd/io/ObjectDispatcher.cc | 164 +++------------- src/librbd/io/ObjectDispatcher.h | 61 ++---- src/librbd/io/ObjectDispatcherInterface.h | 30 +++ .../io/SimpleSchedulerObjectDispatch.cc | 2 +- src/librbd/io/SimpleSchedulerObjectDispatch.h | 2 +- src/librbd/io/Types.h | 2 + src/librbd/journal/ObjectDispatch.cc | 2 +- src/librbd/journal/ObjectDispatch.h | 2 +- src/librbd/operation/ResizeRequest.cc | 2 +- .../operation/SnapshotRollbackRequest.cc | 2 +- src/librbd/operation/TrimRequest.cc | 2 +- .../cache/test_mock_ParentImageCache.cc | 10 +- src/test/librbd/mock/io/MockObjectDispatch.h | 2 +- .../librbd/mock/io/MockObjectDispatcher.h | 7 +- src/test/librbd/test_mock_Journal.cc | 44 ++--- 36 files changed, 357 insertions(+), 255 deletions(-) create mode 100644 src/librbd/io/Dispatcher.h create mode 100644 src/librbd/io/DispatcherInterface.h create mode 100644 src/librbd/io/ObjectDispatcherInterface.h diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 4026fb93459..1a583aeeb51 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -141,7 +141,7 @@ public: this, "librbd::io_work_queue", cct->_conf.get_val("rbd_op_thread_timeout"), thread_pool); - io_object_dispatcher = new io::ObjectDispatcher<>(this); + io_object_dispatcher = new io::ObjectDispatcher(this); if (cct->_conf.get_val("rbd_auto_exclusive_lock_until_manual_request")) { exclusive_lock_policy = new exclusive_lock::AutomaticPolicy(this); diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 11f33b1d40c..74feaafd34a 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -59,7 +59,7 @@ namespace librbd { class AsyncOperation; template class CopyupRequest; template class ImageRequestWQ; - template class ObjectDispatcher; + struct ObjectDispatcherInterface; } namespace journal { struct Policy; } @@ -181,7 +181,7 @@ namespace librbd { xlist*> resize_reqs; io::ImageRequestWQ *io_work_queue; - io::ObjectDispatcher *io_object_dispatcher = nullptr; + io::ObjectDispatcherInterface *io_object_dispatcher = nullptr; ContextWQ *op_work_queue; diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index 66849c461fa..df459af73e1 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -16,7 +16,7 @@ #include "librbd/ImageCtx.h" #include "librbd/io/ImageRequestWQ.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/journal/CreateRequest.h" #include "librbd/journal/DemoteRequest.h" #include "librbd/journal/ObjectDispatch.h" @@ -572,7 +572,7 @@ void Journal::open(Context *on_finish) { on_finish = create_async_context_callback(m_image_ctx, on_finish); // inject our handler into the object dispatcher chain - m_image_ctx.io_object_dispatcher->register_object_dispatch( + m_image_ctx.io_object_dispatcher->register_dispatch( journal::ObjectDispatch::create(&m_image_ctx, this)); std::lock_guard locker{m_lock}; @@ -593,7 +593,7 @@ void Journal::close(Context *on_finish) { auto ctx = new LambdaContext([on_finish, r](int _) { on_finish->complete(r); }); - m_image_ctx.io_object_dispatcher->shut_down_object_dispatch( + m_image_ctx.io_object_dispatcher->shut_down_dispatch( io::OBJECT_DISPATCH_LAYER_JOURNAL, ctx); }); on_finish = create_async_context_callback(m_image_ctx, on_finish); diff --git a/src/librbd/cache/ObjectCacherObjectDispatch.cc b/src/librbd/cache/ObjectCacherObjectDispatch.cc index 26a75856cb6..9d304c54a05 100644 --- a/src/librbd/cache/ObjectCacherObjectDispatch.cc +++ b/src/librbd/cache/ObjectCacherObjectDispatch.cc @@ -9,7 +9,7 @@ #include "librbd/Utils.h" #include "librbd/cache/ObjectCacherWriteback.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/Types.h" #include "librbd/io/Utils.h" #include "osd/osd_types.h" @@ -151,7 +151,7 @@ void ObjectCacherObjectDispatch::init() { if (m_max_dirty > 0) { m_image_ctx->disable_zero_copy = true; } - m_image_ctx->io_object_dispatcher->register_object_dispatch(this); + m_image_ctx->io_object_dispatcher->register_dispatch(this); } template diff --git a/src/librbd/cache/ObjectCacherObjectDispatch.h b/src/librbd/cache/ObjectCacherObjectDispatch.h index 2c62e31f07c..c6d7af0cd7a 100644 --- a/src/librbd/cache/ObjectCacherObjectDispatch.h +++ b/src/librbd/cache/ObjectCacherObjectDispatch.h @@ -34,7 +34,7 @@ public: bool writethrough_until_flush); ~ObjectCacherObjectDispatch() override; - io::ObjectDispatchLayer get_object_dispatch_layer() const override { + io::ObjectDispatchLayer get_dispatch_layer() const override { return io::OBJECT_DISPATCH_LAYER_CACHE; } diff --git a/src/librbd/cache/ObjectCacherWriteback.cc b/src/librbd/cache/ObjectCacherWriteback.cc index c6e26506a3a..169b99a4ce0 100644 --- a/src/librbd/cache/ObjectCacherWriteback.cc +++ b/src/librbd/cache/ObjectCacherWriteback.cc @@ -21,7 +21,7 @@ #include "librbd/Utils.h" #include "librbd/io/AioCompletion.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/ReadResult.h" #include "include/ceph_assert.h" diff --git a/src/librbd/cache/ParentCacheObjectDispatch.cc b/src/librbd/cache/ParentCacheObjectDispatch.cc index b405989dc11..bb8a1aa056c 100644 --- a/src/librbd/cache/ParentCacheObjectDispatch.cc +++ b/src/librbd/cache/ParentCacheObjectDispatch.cc @@ -6,7 +6,7 @@ #include "librbd/Journal.h" #include "librbd/Utils.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/Utils.h" #include "librbd/cache/ParentCacheObjectDispatch.h" #include "osd/osd_types.h" @@ -60,7 +60,7 @@ void ParentCacheObjectDispatch::init(Context* on_finish) { m_connecting.store(true); create_cache_session(create_session_ctx, false); - m_image_ctx->io_object_dispatcher->register_object_dispatch(this); + m_image_ctx->io_object_dispatcher->register_dispatch(this); m_initialized = true; } diff --git a/src/librbd/cache/ParentCacheObjectDispatch.h b/src/librbd/cache/ParentCacheObjectDispatch.h index 475a5ad15fe..42222dd9d2b 100644 --- a/src/librbd/cache/ParentCacheObjectDispatch.h +++ b/src/librbd/cache/ParentCacheObjectDispatch.h @@ -29,7 +29,7 @@ public: ParentCacheObjectDispatch(ImageCtxT* image_ctx); ~ParentCacheObjectDispatch() override; - io::ObjectDispatchLayer get_object_dispatch_layer() const override { + io::ObjectDispatchLayer get_dispatch_layer() const override { return io::OBJECT_DISPATCH_LAYER_PARENT_CACHE; } diff --git a/src/librbd/cache/WriteAroundObjectDispatch.cc b/src/librbd/cache/WriteAroundObjectDispatch.cc index 3a6d315813d..cdd8ea27160 100644 --- a/src/librbd/cache/WriteAroundObjectDispatch.cc +++ b/src/librbd/cache/WriteAroundObjectDispatch.cc @@ -8,7 +8,7 @@ #include "librbd/ImageCtx.h" #include "librbd/Utils.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -44,7 +44,7 @@ void WriteAroundObjectDispatch::init() { if (m_init_max_dirty > 0) { m_image_ctx->disable_zero_copy = true; } - m_image_ctx->io_object_dispatcher->register_object_dispatch(this); + m_image_ctx->io_object_dispatcher->register_dispatch(this); } template diff --git a/src/librbd/cache/WriteAroundObjectDispatch.h b/src/librbd/cache/WriteAroundObjectDispatch.h index ce217d2cf45..f32e3b4d0f2 100644 --- a/src/librbd/cache/WriteAroundObjectDispatch.h +++ b/src/librbd/cache/WriteAroundObjectDispatch.h @@ -34,7 +34,7 @@ public: bool writethrough_until_flush); ~WriteAroundObjectDispatch() override; - io::ObjectDispatchLayer get_object_dispatch_layer() const override { + io::ObjectDispatchLayer get_dispatch_layer() const override { return io::OBJECT_DISPATCH_LAYER_CACHE; } diff --git a/src/librbd/exclusive_lock/PreReleaseRequest.cc b/src/librbd/exclusive_lock/PreReleaseRequest.cc index fc833a1c80b..571af209493 100644 --- a/src/librbd/exclusive_lock/PreReleaseRequest.cc +++ b/src/librbd/exclusive_lock/PreReleaseRequest.cc @@ -12,7 +12,7 @@ #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/io/ImageRequestWQ.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix diff --git a/src/librbd/image/CloseRequest.cc b/src/librbd/image/CloseRequest.cc index feae4160e52..b9cdbba6a25 100644 --- a/src/librbd/image/CloseRequest.cc +++ b/src/librbd/image/CloseRequest.cc @@ -13,7 +13,7 @@ #include "librbd/io/AioCompletion.h" #include "librbd/io/ImageDispatchSpec.h" #include "librbd/io/ImageRequestWQ.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix diff --git a/src/librbd/image/RefreshParentRequest.cc b/src/librbd/image/RefreshParentRequest.cc index 88084d13b77..2423c4c885b 100644 --- a/src/librbd/image/RefreshParentRequest.cc +++ b/src/librbd/image/RefreshParentRequest.cc @@ -10,7 +10,7 @@ #include "librbd/Utils.h" #include "librbd/image/CloseRequest.h" #include "librbd/image/OpenRequest.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index f4350c8ad27..50559bc445c 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -44,7 +44,7 @@ #include "librbd/io/AioCompletion.h" #include "librbd/io/ImageRequest.h" #include "librbd/io/ImageRequestWQ.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/ObjectRequest.h" #include "librbd/io/ReadResult.h" #include "librbd/journal/Types.h" diff --git a/src/librbd/io/Dispatcher.h b/src/librbd/io/Dispatcher.h new file mode 100644 index 00000000000..4b9d8b4df68 --- /dev/null +++ b/src/librbd/io/Dispatcher.h @@ -0,0 +1,184 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IO_DISPATCHER_H +#define CEPH_LIBRBD_IO_DISPATCHER_H + +#include "include/int_types.h" +#include "include/Context.h" +#include "common/ceph_mutex.h" +#include "common/dout.h" +#include "common/AsyncOpTracker.h" +#include "librbd/Utils.h" +#include "librbd/io/Types.h" +#include + +#define dout_subsys ceph_subsys_rbd +#undef dout_prefix +#define dout_prefix *_dout << "librbd::io::Dispatcher: " << this \ + << " " << __func__ << ": " + +namespace librbd { +namespace io { + +template +class Dispatcher : public DispatchInterfaceT { +public: + typedef typename DispatchInterfaceT::Dispatch Dispatch; + typedef typename DispatchInterfaceT::DispatchLayer DispatchLayer; + typedef typename DispatchInterfaceT::DispatchSpec DispatchSpec; + + Dispatcher(ImageCtxT* image_ctx) + : m_image_ctx(image_ctx), + m_lock(ceph::make_shared_mutex( + librbd::util::unique_lock_name("librbd::io::Dispatcher::lock", + this))) { + } + + virtual ~Dispatcher() { + ceph_assert(m_dispatches.empty()); + } + + void shut_down(Context* on_finish) override { + auto cct = m_image_ctx->cct; + ldout(cct, 5) << dendl; + + std::map dispatches; + { + std::unique_lock locker{m_lock}; + std::swap(dispatches, m_dispatches); + } + + for (auto it : dispatches) { + shut_down_dispatch(it.second, &on_finish); + } + on_finish->complete(0); + } + + void register_dispatch(Dispatch* dispatch) override { + auto cct = m_image_ctx->cct; + auto type = dispatch->get_dispatch_layer(); + ldout(cct, 5) << "dispatch_layer=" << type << dendl; + + std::unique_lock locker{m_lock}; + + auto result = m_dispatches.insert( + {type, {dispatch, new AsyncOpTracker()}}); + ceph_assert(result.second); + } + + void shut_down_dispatch(DispatchLayer dispatch_layer, + Context* on_finish) override { + auto cct = m_image_ctx->cct; + ldout(cct, 5) << "dispatch_layer=" << dispatch_layer << dendl; + + DispatchMeta dispatch_meta; + { + std::unique_lock locker{m_lock}; + auto it = m_dispatches.find(dispatch_layer); + ceph_assert(it != m_dispatches.end()); + + dispatch_meta = it->second; + m_dispatches.erase(it); + } + + shut_down_dispatch(dispatch_meta, &on_finish); + on_finish->complete(0); + } + + void send(DispatchSpec* dispatch_spec) { + auto cct = m_image_ctx->cct; + ldout(cct, 20) << "dispatch_spec=" << dispatch_spec << dendl; + + auto dispatch_layer = dispatch_spec->dispatch_layer; + + // apply the IO request to all layers -- this method will be re-invoked + // by the dispatch layer if continuing / restarting the IO + while (true) { + m_lock.lock_shared(); + dispatch_layer = dispatch_spec->dispatch_layer; + auto it = m_dispatches.upper_bound(dispatch_layer); + if (it == m_dispatches.end()) { + // the request is complete if handled by all layers + dispatch_spec->dispatch_result = DISPATCH_RESULT_COMPLETE; + m_lock.unlock_shared(); + break; + } + + auto& dispatch_meta = it->second; + auto dispatch = dispatch_meta.dispatch; + auto async_op_tracker = dispatch_meta.async_op_tracker; + dispatch_spec->dispatch_result = DISPATCH_RESULT_INVALID; + + // prevent recursive locking back into the dispatcher while handling IO + async_op_tracker->start_op(); + m_lock.unlock_shared(); + + // advance to next layer in case we skip or continue + dispatch_spec->dispatch_layer = dispatch->get_dispatch_layer(); + + bool handled = send_dispatch(dispatch, dispatch_spec); + async_op_tracker->finish_op(); + + // handled ops will resume when the dispatch ctx is invoked + if (handled) { + return; + } + } + + // skipped through to the last layer + dispatch_spec->dispatcher_ctx.complete(0); + } + +protected: + struct DispatchMeta { + Dispatch* dispatch = nullptr; + AsyncOpTracker* async_op_tracker = nullptr; + + DispatchMeta() { + } + DispatchMeta(Dispatch* dispatch, AsyncOpTracker* async_op_tracker) + : dispatch(dispatch), async_op_tracker(async_op_tracker) { + } + }; + + ImageCtxT* m_image_ctx; + + ceph::shared_mutex m_lock; + std::map m_dispatches; + + virtual bool send_dispatch(Dispatch* dispatch, + DispatchSpec* dispatch_spec) = 0; + +private: + void shut_down_dispatch(DispatchMeta& dispatch_meta, + Context** on_finish) { + auto dispatch = dispatch_meta.dispatch; + auto async_op_tracker = dispatch_meta.async_op_tracker; + + auto ctx = *on_finish; + ctx = new LambdaContext( + [dispatch, async_op_tracker, ctx](int r) { + delete dispatch; + delete async_op_tracker; + + ctx->complete(r); + }); + ctx = new LambdaContext([dispatch, ctx](int r) { + dispatch->shut_down(ctx); + }); + *on_finish = new LambdaContext([async_op_tracker, ctx](int r) { + async_op_tracker->wait_for_ops(ctx); + }); + } + +}; + +} // namespace io +} // namespace librbd + +#undef dout_subsys +#undef dout_prefix +#define dout_prefix *_dout + +#endif // CEPH_LIBRBD_IO_DISPATCHER_H diff --git a/src/librbd/io/DispatcherInterface.h b/src/librbd/io/DispatcherInterface.h new file mode 100644 index 00000000000..57a56602dfd --- /dev/null +++ b/src/librbd/io/DispatcherInterface.h @@ -0,0 +1,36 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IO_DISPATCHER_INTERFACE_H +#define CEPH_LIBRBD_IO_DISPATCHER_INTERFACE_H + +#include "include/int_types.h" + +struct Context; + +namespace librbd { +namespace io { + +template +struct DispatcherInterface { +public: + typedef DispatchT Dispatch; + typedef typename DispatchT::DispatchLayer DispatchLayer; + typedef typename DispatchT::DispatchSpec DispatchSpec; + + virtual ~DispatcherInterface() { + } + + virtual void shut_down(Context* on_finish) = 0; + + virtual void register_dispatch(Dispatch* dispatch) = 0; + virtual void shut_down_dispatch(DispatchLayer dispatch_layer, + Context* on_finish) = 0; + + virtual void send(DispatchSpec* dispatch_spec) = 0; +}; + +} // namespace io +} // namespace librbd + +#endif // CEPH_LIBRBD_IO_DISPATCHER_INTERFACE_H diff --git a/src/librbd/io/ImageRequest.cc b/src/librbd/io/ImageRequest.cc index 7b7e7e4f159..141f8f12740 100644 --- a/src/librbd/io/ImageRequest.cc +++ b/src/librbd/io/ImageRequest.cc @@ -12,7 +12,7 @@ #include "librbd/io/AsyncOperation.h" #include "librbd/io/ObjectDispatchInterface.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/Utils.h" #include "librbd/journal/Types.h" #include "include/rados/librados.hpp" diff --git a/src/librbd/io/ObjectDispatch.h b/src/librbd/io/ObjectDispatch.h index 8f04143e4fa..cbfe8b5ad0e 100644 --- a/src/librbd/io/ObjectDispatch.h +++ b/src/librbd/io/ObjectDispatch.h @@ -27,7 +27,7 @@ class ObjectDispatch : public ObjectDispatchInterface { public: ObjectDispatch(ImageCtxT* image_ctx); - ObjectDispatchLayer get_object_dispatch_layer() const override { + ObjectDispatchLayer get_dispatch_layer() const override { return OBJECT_DISPATCH_LAYER_CORE; } diff --git a/src/librbd/io/ObjectDispatchInterface.h b/src/librbd/io/ObjectDispatchInterface.h index 168d8006d14..31ed39994eb 100644 --- a/src/librbd/io/ObjectDispatchInterface.h +++ b/src/librbd/io/ObjectDispatchInterface.h @@ -18,12 +18,18 @@ namespace librbd { namespace io { struct AioCompletion; +struct ObjectDispatchInterface; +struct ObjectDispatchSpec; struct ObjectDispatchInterface { + typedef ObjectDispatchInterface Dispatch; + typedef ObjectDispatchLayer DispatchLayer; + typedef ObjectDispatchSpec DispatchSpec; + virtual ~ObjectDispatchInterface() { } - virtual ObjectDispatchLayer get_object_dispatch_layer() const = 0; + virtual ObjectDispatchLayer get_dispatch_layer() const = 0; virtual void shut_down(Context* on_finish) = 0; diff --git a/src/librbd/io/ObjectDispatchSpec.cc b/src/librbd/io/ObjectDispatchSpec.cc index 2b6dccc5cfc..0a4a3474eee 100644 --- a/src/librbd/io/ObjectDispatchSpec.cc +++ b/src/librbd/io/ObjectDispatchSpec.cc @@ -3,7 +3,7 @@ #include "librbd/io/ObjectDispatchSpec.h" #include "include/Context.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include namespace librbd { diff --git a/src/librbd/io/ObjectDispatchSpec.h b/src/librbd/io/ObjectDispatchSpec.h index 654ed3dd31c..91a76d7eea0 100644 --- a/src/librbd/io/ObjectDispatchSpec.h +++ b/src/librbd/io/ObjectDispatchSpec.h @@ -142,7 +142,7 @@ public: C_Dispatcher dispatcher_ctx; ObjectDispatcherInterface* object_dispatcher; - ObjectDispatchLayer object_dispatch_layer; + ObjectDispatchLayer dispatch_layer; int object_dispatch_flags = 0; DispatchResult dispatch_result = DISPATCH_RESULT_INVALID; @@ -250,7 +250,7 @@ private: Request&& request, int op_flags, const ZTracer::Trace& parent_trace, Context* on_finish) : dispatcher_ctx(this, on_finish), object_dispatcher(object_dispatcher), - object_dispatch_layer(object_dispatch_layer), request(std::move(request)), + dispatch_layer(object_dispatch_layer), request(std::move(request)), op_flags(op_flags), parent_trace(parent_trace) { } diff --git a/src/librbd/io/ObjectDispatcher.cc b/src/librbd/io/ObjectDispatcher.cc index 9a74a81340d..25ed4989c3e 100644 --- a/src/librbd/io/ObjectDispatcher.cc +++ b/src/librbd/io/ObjectDispatcher.cc @@ -35,23 +35,23 @@ struct ObjectDispatcher::C_LayerIterator : public Context { void complete(int r) override { while (true) { object_dispatcher->m_lock.lock_shared(); - auto it = object_dispatcher->m_object_dispatches.upper_bound( + auto it = object_dispatcher->m_dispatches.upper_bound( object_dispatch_layer); - if (it == object_dispatcher->m_object_dispatches.end()) { + if (it == object_dispatcher->m_dispatches.end()) { object_dispatcher->m_lock.unlock_shared(); Context::complete(r); return; } auto& object_dispatch_meta = it->second; - auto object_dispatch = object_dispatch_meta.object_dispatch; + auto object_dispatch = object_dispatch_meta.dispatch; // prevent recursive locking back into the dispatcher while handling IO object_dispatch_meta.async_op_tracker->start_op(); object_dispatcher->m_lock.unlock_shared(); // next loop should start after current layer - object_dispatch_layer = object_dispatch->get_object_dispatch_layer(); + object_dispatch_layer = object_dispatch->get_dispatch_layer(); auto handled = execute(object_dispatch, this); object_dispatch_meta.async_op_tracker->finish_op(); @@ -174,112 +174,30 @@ struct ObjectDispatcher::SendVisitor : public boost::static_visitor { template ObjectDispatcher::ObjectDispatcher(I* image_ctx) - : m_image_ctx(image_ctx), - m_lock(ceph::make_shared_mutex( - librbd::util::unique_lock_name("librbd::io::ObjectDispatcher::lock", - this))) { + : Dispatcher(image_ctx) { // configure the core object dispatch handler on startup auto object_dispatch = new ObjectDispatch(image_ctx); - m_object_dispatches[object_dispatch->get_object_dispatch_layer()] = - {object_dispatch, new AsyncOpTracker()}; -} - -template -ObjectDispatcher::~ObjectDispatcher() { - ceph_assert(m_object_dispatches.empty()); -} - -template -void ObjectDispatcher::shut_down(Context* on_finish) { - auto cct = m_image_ctx->cct; - ldout(cct, 5) << dendl; - - std::map object_dispatches; - { - std::unique_lock locker{m_lock}; - std::swap(object_dispatches, m_object_dispatches); - } - - for (auto it : object_dispatches) { - shut_down_object_dispatch(it.second, &on_finish); - } - on_finish->complete(0); -} - -template -void ObjectDispatcher::register_object_dispatch( - ObjectDispatchInterface* object_dispatch) { - auto cct = m_image_ctx->cct; - auto type = object_dispatch->get_object_dispatch_layer(); - ldout(cct, 5) << "object_dispatch_layer=" << type << dendl; - - std::unique_lock locker{m_lock}; - ceph_assert(type < OBJECT_DISPATCH_LAYER_LAST); - - auto result = m_object_dispatches.insert( - {type, {object_dispatch, new AsyncOpTracker()}}); - ceph_assert(result.second); -} - -template -void ObjectDispatcher::shut_down_object_dispatch( - ObjectDispatchLayer object_dispatch_layer, Context* on_finish) { - auto cct = m_image_ctx->cct; - ldout(cct, 5) << "object_dispatch_layer=" << object_dispatch_layer << dendl; - ceph_assert(object_dispatch_layer + 1 < OBJECT_DISPATCH_LAYER_LAST); - - ObjectDispatchMeta object_dispatch_meta; - { - std::unique_lock locker{m_lock}; - auto it = m_object_dispatches.find(object_dispatch_layer); - ceph_assert(it != m_object_dispatches.end()); - - object_dispatch_meta = it->second; - m_object_dispatches.erase(it); - } - - shut_down_object_dispatch(object_dispatch_meta, &on_finish); - on_finish->complete(0); -} - -template -void ObjectDispatcher::shut_down_object_dispatch( - ObjectDispatchMeta& object_dispatch_meta, Context** on_finish) { - auto object_dispatch = object_dispatch_meta.object_dispatch; - auto async_op_tracker = object_dispatch_meta.async_op_tracker; - - Context* ctx = *on_finish; - ctx = new LambdaContext( - [object_dispatch, async_op_tracker, ctx](int r) { - delete object_dispatch; - delete async_op_tracker; - - ctx->complete(r); - }); - ctx = new LambdaContext([object_dispatch, ctx](int r) { - object_dispatch->shut_down(ctx); - }); - *on_finish = new LambdaContext([async_op_tracker, ctx](int r) { - async_op_tracker->wait_for_ops(ctx); - }); + this->register_dispatch(object_dispatch); } template void ObjectDispatcher::invalidate_cache(Context* on_finish) { - auto cct = m_image_ctx->cct; + auto image_ctx = this->m_image_ctx; + auto cct = image_ctx->cct; ldout(cct, 5) << dendl; - on_finish = util::create_async_context_callback(*m_image_ctx, on_finish); + on_finish = util::create_async_context_callback(*image_ctx, on_finish); auto ctx = new C_InvalidateCache(this, on_finish); ctx->complete(0); } template void ObjectDispatcher::reset_existence_cache(Context* on_finish) { - auto cct = m_image_ctx->cct; + auto image_ctx = this->m_image_ctx; + auto cct = image_ctx->cct; ldout(cct, 5) << dendl; - on_finish = util::create_async_context_callback(*m_image_ctx, on_finish); + on_finish = util::create_async_context_callback(*image_ctx, on_finish); auto ctx = new C_ResetExistenceCache(this, on_finish); ctx->complete(0); } @@ -288,64 +206,26 @@ template void ObjectDispatcher::extent_overwritten( uint64_t object_no, uint64_t object_off, uint64_t object_len, uint64_t journal_tid, uint64_t new_journal_tid) { - auto cct = m_image_ctx->cct; + auto cct = this->m_image_ctx->cct; ldout(cct, 20) << object_no << " " << object_off << "~" << object_len << dendl; - for (auto it : m_object_dispatches) { + std::shared_lock locker{this->m_lock}; + for (auto it : this->m_dispatches) { auto& object_dispatch_meta = it.second; - auto object_dispatch = object_dispatch_meta.object_dispatch; + auto object_dispatch = object_dispatch_meta.dispatch; object_dispatch->extent_overwritten(object_no, object_off, object_len, journal_tid, new_journal_tid); } } template -void ObjectDispatcher::send(ObjectDispatchSpec* object_dispatch_spec) { - auto cct = m_image_ctx->cct; - ldout(cct, 20) << "object_dispatch_spec=" << object_dispatch_spec << dendl; - - auto object_dispatch_layer = object_dispatch_spec->object_dispatch_layer; - ceph_assert(object_dispatch_layer + 1 < OBJECT_DISPATCH_LAYER_LAST); - - // apply the IO request to all layers -- this method will be re-invoked - // by the dispatch layer if continuing / restarting the IO - while (true) { - m_lock.lock_shared(); - object_dispatch_layer = object_dispatch_spec->object_dispatch_layer; - auto it = m_object_dispatches.upper_bound(object_dispatch_layer); - if (it == m_object_dispatches.end()) { - // the request is complete if handled by all layers - object_dispatch_spec->dispatch_result = DISPATCH_RESULT_COMPLETE; - m_lock.unlock_shared(); - break; - } - - auto& object_dispatch_meta = it->second; - auto object_dispatch = object_dispatch_meta.object_dispatch; - object_dispatch_spec->dispatch_result = DISPATCH_RESULT_INVALID; - - // prevent recursive locking back into the dispatcher while handling IO - object_dispatch_meta.async_op_tracker->start_op(); - m_lock.unlock_shared(); - - // advance to next layer in case we skip or continue - object_dispatch_spec->object_dispatch_layer = - object_dispatch->get_object_dispatch_layer(); - - bool handled = boost::apply_visitor( - SendVisitor{object_dispatch, object_dispatch_spec}, - object_dispatch_spec->request); - object_dispatch_meta.async_op_tracker->finish_op(); - - // handled ops will resume when the dispatch ctx is invoked - if (handled) { - return; - } - } - - // skipped through to the last layer - object_dispatch_spec->dispatcher_ctx.complete(0); +bool ObjectDispatcher::send_dispatch( + ObjectDispatchInterface* object_dispatch, + ObjectDispatchSpec* object_dispatch_spec) { + return boost::apply_visitor( + SendVisitor{object_dispatch, object_dispatch_spec}, + object_dispatch_spec->request); } } // namespace io diff --git a/src/librbd/io/ObjectDispatcher.h b/src/librbd/io/ObjectDispatcher.h index c949a97573f..0f8317fb437 100644 --- a/src/librbd/io/ObjectDispatcher.h +++ b/src/librbd/io/ObjectDispatcher.h @@ -6,10 +6,13 @@ #include "include/int_types.h" #include "common/ceph_mutex.h" +#include "librbd/io/Dispatcher.h" +#include "librbd/io/ObjectDispatchInterface.h" +#include "librbd/io/ObjectDispatchSpec.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/io/Types.h" #include -struct AsyncOpTracker; struct Context; namespace librbd { @@ -18,67 +21,29 @@ struct ImageCtx; namespace io { -struct ObjectDispatchInterface; -struct ObjectDispatchSpec; - -struct ObjectDispatcherInterface { -public: - virtual ~ObjectDispatcherInterface() { - } - -private: - friend class ObjectDispatchSpec; - - virtual void send(ObjectDispatchSpec* object_dispatch_spec) = 0; -}; - template -class ObjectDispatcher : public ObjectDispatcherInterface { +class ObjectDispatcher + : public Dispatcher { public: ObjectDispatcher(ImageCtxT* image_ctx); - ~ObjectDispatcher(); - - void shut_down(Context* on_finish); - void register_object_dispatch(ObjectDispatchInterface* object_dispatch); - void shut_down_object_dispatch(ObjectDispatchLayer object_dispatch_layer, - Context* on_finish); - - void invalidate_cache(Context* on_finish); - void reset_existence_cache(Context* on_finish); + void invalidate_cache(Context* on_finish) override; + void reset_existence_cache(Context* on_finish) override; void extent_overwritten( uint64_t object_no, uint64_t object_off, uint64_t object_len, - uint64_t journal_tid, uint64_t new_journal_tid); - -private: - struct ObjectDispatchMeta { - ObjectDispatchInterface* object_dispatch = nullptr; - AsyncOpTracker* async_op_tracker = nullptr; + uint64_t journal_tid, uint64_t new_journal_tid) override; - ObjectDispatchMeta() { - } - ObjectDispatchMeta(ObjectDispatchInterface* object_dispatch, - AsyncOpTracker* async_op_tracker) - : object_dispatch(object_dispatch), async_op_tracker(async_op_tracker) { - } - }; +protected: + bool send_dispatch(ObjectDispatchInterface* object_dispatch, + ObjectDispatchSpec* object_dispatch_spec) override; +private: struct C_LayerIterator; struct C_InvalidateCache; struct C_ResetExistenceCache; struct SendVisitor; - ImageCtxT* m_image_ctx; - - ceph::shared_mutex m_lock; - std::map m_object_dispatches; - - void send(ObjectDispatchSpec* object_dispatch_spec); - - void shut_down_object_dispatch(ObjectDispatchMeta& object_dispatch_meta, - Context** on_finish); - }; } // namespace io diff --git a/src/librbd/io/ObjectDispatcherInterface.h b/src/librbd/io/ObjectDispatcherInterface.h new file mode 100644 index 00000000000..0b2befd3dd6 --- /dev/null +++ b/src/librbd/io/ObjectDispatcherInterface.h @@ -0,0 +1,30 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IO_OBJECT_DISPATCHER_INTERFACE_H +#define CEPH_LIBRBD_IO_OBJECT_DISPATCHER_INTERFACE_H + +#include "include/int_types.h" +#include "librbd/io/DispatcherInterface.h" +#include "librbd/io/ObjectDispatchInterface.h" + +struct Context; + +namespace librbd { +namespace io { + +struct ObjectDispatcherInterface + : public DispatcherInterface { +public: + virtual void invalidate_cache(Context* on_finish) = 0; + virtual void reset_existence_cache(Context* on_finish) = 0; + + virtual void extent_overwritten( + uint64_t object_no, uint64_t object_off, uint64_t object_len, + uint64_t journal_tid, uint64_t new_journal_tid) = 0; +}; + +} // namespace io +} // namespace librbd + +#endif // CEPH_LIBRBD_IO_OBJECT_DISPATCHER_INTERFACE_H diff --git a/src/librbd/io/SimpleSchedulerObjectDispatch.cc b/src/librbd/io/SimpleSchedulerObjectDispatch.cc index 6b6a60c9862..bae5f204425 100644 --- a/src/librbd/io/SimpleSchedulerObjectDispatch.cc +++ b/src/librbd/io/SimpleSchedulerObjectDispatch.cc @@ -198,7 +198,7 @@ void SimpleSchedulerObjectDispatch::init() { ldout(cct, 5) << dendl; // add ourself to the IO object dispatcher chain - m_image_ctx->io_object_dispatcher->register_object_dispatch(this); + m_image_ctx->io_object_dispatcher->register_dispatch(this); } template diff --git a/src/librbd/io/SimpleSchedulerObjectDispatch.h b/src/librbd/io/SimpleSchedulerObjectDispatch.h index e5a88371d7f..cca6b12b4c3 100644 --- a/src/librbd/io/SimpleSchedulerObjectDispatch.h +++ b/src/librbd/io/SimpleSchedulerObjectDispatch.h @@ -41,7 +41,7 @@ public: SimpleSchedulerObjectDispatch(ImageCtxT* image_ctx); ~SimpleSchedulerObjectDispatch() override; - ObjectDispatchLayer get_object_dispatch_layer() const override { + ObjectDispatchLayer get_dispatch_layer() const override { return OBJECT_DISPATCH_LAYER_SCHEDULER; } diff --git a/src/librbd/io/Types.h b/src/librbd/io/Types.h index daa663c4cbb..e9edced2020 100644 --- a/src/librbd/io/Types.h +++ b/src/librbd/io/Types.h @@ -9,6 +9,8 @@ #include #include +struct Context; + namespace librbd { namespace io { diff --git a/src/librbd/journal/ObjectDispatch.cc b/src/librbd/journal/ObjectDispatch.cc index e4bdca007ca..b3db1008007 100644 --- a/src/librbd/journal/ObjectDispatch.cc +++ b/src/librbd/journal/ObjectDispatch.cc @@ -9,7 +9,7 @@ #include "librbd/Journal.h" #include "librbd/Utils.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix diff --git a/src/librbd/journal/ObjectDispatch.h b/src/librbd/journal/ObjectDispatch.h index 47b19524a93..e63f05535f8 100644 --- a/src/librbd/journal/ObjectDispatch.h +++ b/src/librbd/journal/ObjectDispatch.h @@ -31,7 +31,7 @@ public: ObjectDispatch(ImageCtxT* image_ctx, Journal* journal); - io::ObjectDispatchLayer get_object_dispatch_layer() const override { + io::ObjectDispatchLayer get_dispatch_layer() const override { return io::OBJECT_DISPATCH_LAYER_JOURNAL; } diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc index 8db5afb3393..a14b6de24f4 100644 --- a/src/librbd/operation/ResizeRequest.cc +++ b/src/librbd/operation/ResizeRequest.cc @@ -10,7 +10,7 @@ #include "librbd/io/AioCompletion.h" #include "librbd/io/ImageDispatchSpec.h" #include "librbd/io/ImageRequestWQ.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/operation/TrimRequest.h" #include "common/dout.h" #include "common/errno.h" diff --git a/src/librbd/operation/SnapshotRollbackRequest.cc b/src/librbd/operation/SnapshotRollbackRequest.cc index 5dd3f2573eb..a18f79509f3 100644 --- a/src/librbd/operation/SnapshotRollbackRequest.cc +++ b/src/librbd/operation/SnapshotRollbackRequest.cc @@ -10,7 +10,7 @@ #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/io/ImageRequestWQ.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "librbd/operation/ResizeRequest.h" #include "osdc/Striper.h" #include diff --git a/src/librbd/operation/TrimRequest.cc b/src/librbd/operation/TrimRequest.cc index 3c2f58f64af..0fcb7af034b 100644 --- a/src/librbd/operation/TrimRequest.cc +++ b/src/librbd/operation/TrimRequest.cc @@ -9,7 +9,7 @@ #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/io/ObjectDispatchSpec.h" -#include "librbd/io/ObjectDispatcher.h" +#include "librbd/io/ObjectDispatcherInterface.h" #include "common/ContextCompletion.h" #include "common/dout.h" #include "common/errno.h" diff --git a/src/test/librbd/cache/test_mock_ParentImageCache.cc b/src/test/librbd/cache/test_mock_ParentImageCache.cc index d48b5ec1993..8ee85acd762 100644 --- a/src/test/librbd/cache/test_mock_ParentImageCache.cc +++ b/src/test/librbd/cache/test_mock_ParentImageCache.cc @@ -133,7 +133,7 @@ class TestMockParentImageCache : public TestMockFixture { void expect_io_object_dispatcher_register_state(MockParentImageCache& mparent_image_cache, int ret_val) { auto& expect = EXPECT_CALL((*(mparent_image_cache.get_image_ctx()->io_object_dispatcher)), - register_object_dispatch(_)); + register_dispatch(_)); expect.WillOnce(WithArg<0>(Invoke([ret_val, &mparent_image_cache] (io::ObjectDispatchInterface* object_dispatch) { @@ -168,7 +168,7 @@ TEST_F(TestMockParentImageCache, test_initialization_success) { mock_parent_image_cache->init(); cond.wait(); - ASSERT_EQ(mock_parent_image_cache->get_object_dispatch_layer(), + ASSERT_EQ(mock_parent_image_cache->get_dispatch_layer(), io::OBJECT_DISPATCH_LAYER_PARENT_CACHE); ASSERT_EQ(mock_parent_image_cache->get_state(), true); expect_cache_session_state(*mock_parent_image_cache, true); @@ -202,7 +202,7 @@ TEST_F(TestMockParentImageCache, test_initialization_fail_at_connect) { mock_parent_image_cache->init(); // initialization fails. - ASSERT_EQ(mock_parent_image_cache->get_object_dispatch_layer(), + ASSERT_EQ(mock_parent_image_cache->get_dispatch_layer(), io::OBJECT_DISPATCH_LAYER_PARENT_CACHE); ASSERT_EQ(mock_parent_image_cache->get_state(), true); ASSERT_EQ(mock_parent_image_cache->get_cache_client()->is_session_work(), false); @@ -240,7 +240,7 @@ TEST_F(TestMockParentImageCache, test_initialization_fail_at_register) { mock_parent_image_cache->init(); cond.wait(); - ASSERT_EQ(mock_parent_image_cache->get_object_dispatch_layer(), + ASSERT_EQ(mock_parent_image_cache->get_dispatch_layer(), io::OBJECT_DISPATCH_LAYER_PARENT_CACHE); ASSERT_EQ(mock_parent_image_cache->get_state(), true); expect_cache_session_state(*mock_parent_image_cache, true); @@ -317,7 +317,7 @@ TEST_F(TestMockParentImageCache, test_read) { mock_parent_image_cache->init(); conn_cond.wait(); - ASSERT_EQ(mock_parent_image_cache->get_object_dispatch_layer(), + ASSERT_EQ(mock_parent_image_cache->get_dispatch_layer(), io::OBJECT_DISPATCH_LAYER_PARENT_CACHE); ASSERT_EQ(mock_parent_image_cache->get_state(), true); expect_cache_session_state(*mock_parent_image_cache, true); diff --git a/src/test/librbd/mock/io/MockObjectDispatch.h b/src/test/librbd/mock/io/MockObjectDispatch.h index bd3d28693e9..16cf4b0d2b1 100644 --- a/src/test/librbd/mock/io/MockObjectDispatch.h +++ b/src/test/librbd/mock/io/MockObjectDispatch.h @@ -20,7 +20,7 @@ public: MockObjectDispatch() : lock("MockObjectDispatch::lock", true, false) { } - MOCK_CONST_METHOD0(get_object_dispatch_layer, ObjectDispatchLayer()); + MOCK_CONST_METHOD0(get_dispatch_layer, ObjectDispatchLayer()); MOCK_METHOD1(shut_down, void(Context*)); diff --git a/src/test/librbd/mock/io/MockObjectDispatcher.h b/src/test/librbd/mock/io/MockObjectDispatcher.h index 271c30102a3..908e2186816 100644 --- a/src/test/librbd/mock/io/MockObjectDispatcher.h +++ b/src/test/librbd/mock/io/MockObjectDispatcher.h @@ -21,19 +21,18 @@ struct MockObjectDispatcher : public ObjectDispatcherInterface { public: MOCK_METHOD1(shut_down, void(Context*)); - MOCK_METHOD1(register_object_dispatch, void(ObjectDispatchInterface*)); - MOCK_METHOD2(shut_down_object_dispatch, void(ObjectDispatchLayer, Context*)); + MOCK_METHOD1(register_dispatch, void(ObjectDispatchInterface*)); + MOCK_METHOD2(shut_down_dispatch, void(ObjectDispatchLayer, Context*)); MOCK_METHOD2(flush, void(FlushSource, Context*)); MOCK_METHOD1(invalidate_cache, void(Context*)); - MOCK_METHOD1(reset_existance_cache, void(Context*)); + MOCK_METHOD1(reset_existence_cache, void(Context*)); MOCK_METHOD5(extent_overwritten, void(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t)); MOCK_METHOD1(send, void(ObjectDispatchSpec*)); - }; } // namespace io diff --git a/src/test/librbd/test_mock_Journal.cc b/src/test/librbd/test_mock_Journal.cc index 78a7ae73ccc..bab068be063 100644 --- a/src/test/librbd/test_mock_Journal.cc +++ b/src/test/librbd/test_mock_Journal.cc @@ -300,15 +300,15 @@ public: .WillOnce(CompleteContext(0, static_cast(NULL))); } - void expect_register_object_dispatch(MockImageCtx& mock_image_ctx, - MockObjectDispatch& mock_object_dispatch) { + void expect_register_dispatch(MockImageCtx& mock_image_ctx, + MockObjectDispatch& mock_object_dispatch) { EXPECT_CALL(*mock_image_ctx.io_object_dispatcher, - register_object_dispatch(&mock_object_dispatch)); + register_dispatch(&mock_object_dispatch)); } - void expect_shut_down_object_dispatch(MockImageCtx& mock_image_ctx) { + void expect_shut_down_dispatch(MockImageCtx& mock_image_ctx) { EXPECT_CALL(*mock_image_ctx.io_object_dispatcher, - shut_down_object_dispatch(io::OBJECT_DISPATCH_LAYER_JOURNAL, _)) + shut_down_dispatch(io::OBJECT_DISPATCH_LAYER_JOURNAL, _)) .WillOnce(WithArg<1>(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue))); } @@ -510,7 +510,7 @@ public: expect_op_work_queue(mock_image_ctx); InSequence seq; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); expect_construct_journaler(mock_journaler); expect_open_journaler(mock_image_ctx, mock_journaler, mock_open_request, primary, 0); @@ -533,7 +533,7 @@ public: MockJournal *mock_journal, ::journal::MockJournaler &mock_journaler) { expect_stop_append(mock_journaler, 0); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } @@ -566,7 +566,7 @@ TEST_F(TestMockJournal, StateTransitions) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -603,7 +603,7 @@ TEST_F(TestMockJournal, StateTransitions) { expect_stop_append(mock_journaler, 0); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } @@ -624,7 +624,7 @@ TEST_F(TestMockJournal, InitError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -652,7 +652,7 @@ TEST_F(TestMockJournal, ReplayCompleteError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -688,7 +688,7 @@ TEST_F(TestMockJournal, ReplayCompleteError) { expect_stop_append(mock_journaler, 0); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } @@ -709,7 +709,7 @@ TEST_F(TestMockJournal, FlushReplayError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -750,7 +750,7 @@ TEST_F(TestMockJournal, FlushReplayError) { expect_stop_append(mock_journaler, 0); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } @@ -771,7 +771,7 @@ TEST_F(TestMockJournal, CorruptEntry) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -809,7 +809,7 @@ TEST_F(TestMockJournal, CorruptEntry) { expect_stop_append(mock_journaler, -EINVAL); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(-EINVAL, when_close(mock_journal)); } @@ -830,7 +830,7 @@ TEST_F(TestMockJournal, StopError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -852,7 +852,7 @@ TEST_F(TestMockJournal, StopError) { expect_stop_append(mock_journaler, -EINVAL); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(-EINVAL, when_close(mock_journal)); } @@ -872,7 +872,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPreFlushError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -941,7 +941,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPreFlushError) { expect_stop_append(mock_journaler, 0); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } @@ -962,7 +962,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPostFlushError) { InSequence seq; MockObjectDispatch mock_object_dispatch; - expect_register_object_dispatch(mock_image_ctx, mock_object_dispatch); + expect_register_dispatch(mock_image_ctx, mock_object_dispatch); ::journal::MockJournaler mock_journaler; MockJournalOpenRequest mock_open_request; @@ -1027,7 +1027,7 @@ TEST_F(TestMockJournal, ReplayOnDiskPostFlushError) { expect_stop_append(mock_journaler, 0); expect_shut_down_journaler(mock_journaler); - expect_shut_down_object_dispatch(mock_image_ctx); + expect_shut_down_dispatch(mock_image_ctx); ASSERT_EQ(0, when_close(mock_journal)); } -- 2.39.5