From: Jason Dillaman Date: Mon, 31 Aug 2020 22:07:14 +0000 (-0400) Subject: librbd: drop ImageDispatchInterface::handle_finished virtual method X-Git-Tag: v17.0.0~1064^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a40718283db35250cb64531b91566209e799b303;p=ceph-ci.git librbd: drop ImageDispatchInterface::handle_finished virtual method Any dispatch layer can now directly place themselves in the finish callback handler chain without the use of the generic callback. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/exclusive_lock/ImageDispatch.h b/src/librbd/exclusive_lock/ImageDispatch.h index 5a3e9259c8e..7f0353b39e1 100644 --- a/src/librbd/exclusive_lock/ImageDispatch.h +++ b/src/librbd/exclusive_lock/ImageDispatch.h @@ -89,9 +89,6 @@ public: io::DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override { - } - private: typedef std::list Contexts; typedef std::unordered_set Tids; diff --git a/src/librbd/io/ImageDispatch.h b/src/librbd/io/ImageDispatch.h index c1f15404f9c..5ace3ec79e5 100644 --- a/src/librbd/io/ImageDispatch.h +++ b/src/librbd/io/ImageDispatch.h @@ -73,8 +73,6 @@ public: DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override {} - private: ImageCtxT* m_image_ctx; diff --git a/src/librbd/io/ImageDispatchInterface.h b/src/librbd/io/ImageDispatchInterface.h index 6b0770dc8df..bf44ee8ad63 100644 --- a/src/librbd/io/ImageDispatchInterface.h +++ b/src/librbd/io/ImageDispatchInterface.h @@ -70,8 +70,6 @@ struct ImageDispatchInterface { DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) = 0; - virtual void handle_finished(int r, uint64_t tid) = 0; - }; } // namespace io diff --git a/src/librbd/io/ImageDispatcher.cc b/src/librbd/io/ImageDispatcher.cc index 5226e9ec95d..03b30a04bf2 100644 --- a/src/librbd/io/ImageDispatcher.cc +++ b/src/librbd/io/ImageDispatcher.cc @@ -182,38 +182,6 @@ void ImageDispatcher::wait_on_writes_unblocked(Context *on_unblocked) { m_write_block_dispatch->wait_on_writes_unblocked(on_unblocked); } -template -void ImageDispatcher::finish(int r, ImageDispatchLayer image_dispatch_layer, - uint64_t tid) { - auto cct = this->m_image_ctx->cct; - ldout(cct, 20) << "r=" << r << ", tid=" << tid << dendl; - - // loop in reverse order from last invoked dispatch layer calling its - // handle_finished method - while (image_dispatch_layer != IMAGE_DISPATCH_LAYER_NONE) { - std::shared_lock locker{this->m_lock}; - auto it = this->m_dispatches.find(image_dispatch_layer); - image_dispatch_layer = static_cast( - image_dispatch_layer - 1); - - if (it == this->m_dispatches.end()) { - continue; - } - - // track callback while lock is dropped so that the layer cannot be shutdown - auto& dispatch_meta = it->second; - auto dispatch = dispatch_meta.dispatch; - auto async_op_tracker = dispatch_meta.async_op_tracker; - async_op_tracker->start_op(); - locker.unlock(); - - dispatch->handle_finished(r, tid); - - // safe since dispatch_meta cannot be deleted until ops finished - async_op_tracker->finish_op(); - } -} - template bool ImageDispatcher::send_dispatch( ImageDispatchInterface* image_dispatch, diff --git a/src/librbd/io/ImageDispatcher.h b/src/librbd/io/ImageDispatcher.h index bfbea68c921..176b2a229fe 100644 --- a/src/librbd/io/ImageDispatcher.h +++ b/src/librbd/io/ImageDispatcher.h @@ -43,9 +43,6 @@ public: void unblock_writes() override; void wait_on_writes_unblocked(Context *on_unblocked) override; - void finish(int r, ImageDispatchLayer image_dispatch_layer, - uint64_t tid) override; - protected: bool send_dispatch( ImageDispatchInterface* image_dispatch, diff --git a/src/librbd/io/ImageDispatcherInterface.h b/src/librbd/io/ImageDispatcherInterface.h index 9259479b53e..78f90977d78 100644 --- a/src/librbd/io/ImageDispatcherInterface.h +++ b/src/librbd/io/ImageDispatcherInterface.h @@ -27,9 +27,6 @@ public: virtual void unblock_writes() = 0; virtual void wait_on_writes_unblocked(Context *on_unblocked) = 0; - - virtual void finish(int r, ImageDispatchLayer image_dispatch_layer, - uint64_t tid) = 0; }; } // namespace io diff --git a/src/librbd/io/QosImageDispatch.h b/src/librbd/io/QosImageDispatch.h index 4ddd21b99cd..386cf0b4eef 100644 --- a/src/librbd/io/QosImageDispatch.h +++ b/src/librbd/io/QosImageDispatch.h @@ -90,8 +90,6 @@ public: DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override; - private: ImageCtxT* m_image_ctx; @@ -100,6 +98,8 @@ private: FlushTracker* m_flush_tracker; + void handle_finished(int r, uint64_t tid); + bool set_throttle_flag(std::atomic* image_dispatch_flags, uint32_t flag); bool needs_throttle(bool read_op, const Extents& image_extents, uint64_t tid, diff --git a/src/librbd/io/QueueImageDispatch.h b/src/librbd/io/QueueImageDispatch.h index cbadad95ec1..c1d0ac4c615 100644 --- a/src/librbd/io/QueueImageDispatch.h +++ b/src/librbd/io/QueueImageDispatch.h @@ -77,13 +77,13 @@ public: DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override; - private: ImageCtxT* m_image_ctx; FlushTracker* m_flush_tracker; + void handle_finished(int r, uint64_t tid); + bool enqueue(bool read_op, uint64_t tid, DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched); diff --git a/src/librbd/io/RefreshImageDispatch.h b/src/librbd/io/RefreshImageDispatch.h index 3510b350f4c..e9c53772fcd 100644 --- a/src/librbd/io/RefreshImageDispatch.h +++ b/src/librbd/io/RefreshImageDispatch.h @@ -73,8 +73,6 @@ public: DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override {} - private: ImageCtxT* m_image_ctx; diff --git a/src/librbd/io/WriteBlockImageDispatch.h b/src/librbd/io/WriteBlockImageDispatch.h index adbb357c1cd..00e2c89c003 100644 --- a/src/librbd/io/WriteBlockImageDispatch.h +++ b/src/librbd/io/WriteBlockImageDispatch.h @@ -89,8 +89,6 @@ public: DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) override; - void handle_finished(int r, uint64_t tid) override; - private: struct C_BlockedWrites; @@ -107,6 +105,8 @@ private: Contexts m_write_blocker_contexts; Contexts m_unblocked_write_waiter_contexts; + void handle_finished(int r, uint64_t tid); + bool process_io(uint64_t tid, DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched); void flush_io(Context* on_finish); diff --git a/src/test/librbd/mock/io/MockImageDispatch.h b/src/test/librbd/mock/io/MockImageDispatch.h index 683c8003ec0..d4c145e8cc3 100644 --- a/src/test/librbd/mock/io/MockImageDispatch.h +++ b/src/test/librbd/mock/io/MockImageDispatch.h @@ -77,8 +77,6 @@ public: return false; } - void handle_finished(int r, uint64_t tid) override {}; - }; } // namespace io