From a1e1f0f72cd3ee3aa0ddaaaaef79ddb34592e665 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 31 Aug 2020 18:27:32 -0400 Subject: [PATCH] librbd: use an overridable finish handler for the image dispatcher This mimics the design from the object dispatcher and will allow for simplified in-flight IO tracking. Signed-off-by: Jason Dillaman --- src/librbd/exclusive_lock/ImageDispatch.cc | 18 ++++-- src/librbd/exclusive_lock/ImageDispatch.h | 18 ++++-- src/librbd/io/ImageDispatch.cc | 18 ++++-- src/librbd/io/ImageDispatch.h | 18 ++++-- src/librbd/io/ImageDispatchInterface.h | 18 ++++-- src/librbd/io/ImageDispatchSpec.cc | 7 +-- src/librbd/io/ImageDispatchSpec.h | 2 - src/librbd/io/ImageDispatcher.cc | 6 ++ src/librbd/io/QosImageDispatch.cc | 35 ++++++++---- src/librbd/io/QosImageDispatch.h | 21 ++++--- src/librbd/io/QueueImageDispatch.cc | 34 ++++++++---- src/librbd/io/QueueImageDispatch.h | 20 ++++--- src/librbd/io/RefreshImageDispatch.cc | 18 ++++-- src/librbd/io/RefreshImageDispatch.h | 18 ++++-- src/librbd/io/WriteBlockImageDispatch.cc | 61 +++++++++------------ src/librbd/io/WriteBlockImageDispatch.h | 24 +++++--- src/test/librbd/mock/io/MockImageDispatch.h | 18 ++++-- 17 files changed, 217 insertions(+), 137 deletions(-) diff --git a/src/librbd/exclusive_lock/ImageDispatch.cc b/src/librbd/exclusive_lock/ImageDispatch.cc index dc276f1e410f8..d6eb958e286df 100644 --- a/src/librbd/exclusive_lock/ImageDispatch.cc +++ b/src/librbd/exclusive_lock/ImageDispatch.cc @@ -108,7 +108,8 @@ bool ImageDispatch::read( io::ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -124,7 +125,8 @@ bool ImageDispatch::write( io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -141,7 +143,8 @@ bool ImageDispatch::discard( io::AioCompletion* aio_comp, io::Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -158,7 +161,8 @@ bool ImageDispatch::write_same( io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -176,7 +180,8 @@ bool ImageDispatch::compare_and_write( bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -193,7 +198,8 @@ bool ImageDispatch::flush( io::AioCompletion* aio_comp, io::FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) { + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; diff --git a/src/librbd/exclusive_lock/ImageDispatch.h b/src/librbd/exclusive_lock/ImageDispatch.h index 965499c45d433..5a3e9259c8ed4 100644 --- a/src/librbd/exclusive_lock/ImageDispatch.h +++ b/src/librbd/exclusive_lock/ImageDispatch.h @@ -54,34 +54,40 @@ public: io::ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write( io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( io::AioCompletion* aio_comp, io::Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( io::AioCompletion* aio_comp, io::FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - io::DispatchResult* dispatch_result, Context* on_dispatched) override; + io::DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override { } diff --git a/src/librbd/io/ImageDispatch.cc b/src/librbd/io/ImageDispatch.cc index 21262e591ff8a..7c7d85849d9c2 100644 --- a/src/librbd/io/ImageDispatch.cc +++ b/src/librbd/io/ImageDispatch.cc @@ -36,7 +36,8 @@ bool ImageDispatch::read( AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -54,7 +55,8 @@ bool ImageDispatch::write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -72,7 +74,8 @@ bool ImageDispatch::discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -90,7 +93,8 @@ bool ImageDispatch::write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -109,7 +113,8 @@ bool ImageDispatch::compare_and_write( bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "image_extents=" << image_extents << dendl; @@ -127,7 +132,8 @@ bool ImageDispatch::flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << dendl; diff --git a/src/librbd/io/ImageDispatch.h b/src/librbd/io/ImageDispatch.h index cc56264cddc7a..c1f15404f9c7c 100644 --- a/src/librbd/io/ImageDispatch.h +++ b/src/librbd/io/ImageDispatch.h @@ -38,34 +38,40 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override {} diff --git a/src/librbd/io/ImageDispatchInterface.h b/src/librbd/io/ImageDispatchInterface.h index ffe53d0f9c4f2..6b0770dc8df0b 100644 --- a/src/librbd/io/ImageDispatchInterface.h +++ b/src/librbd/io/ImageDispatchInterface.h @@ -35,34 +35,40 @@ struct ImageDispatchInterface { ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) = 0; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) = 0; virtual void handle_finished(int r, uint64_t tid) = 0; diff --git a/src/librbd/io/ImageDispatchSpec.cc b/src/librbd/io/ImageDispatchSpec.cc index 9b36386119197..95d8224ae904a 100644 --- a/src/librbd/io/ImageDispatchSpec.cc +++ b/src/librbd/io/ImageDispatchSpec.cc @@ -38,18 +38,13 @@ void ImageDispatchSpec::C_Dispatcher::complete(int r) { } void ImageDispatchSpec::C_Dispatcher::finish(int r) { - image_dispatch_spec->finish(r); + delete image_dispatch_spec; } void ImageDispatchSpec::send() { image_dispatcher->send(this); } -void ImageDispatchSpec::finish(int r) { - image_dispatcher->finish(r, dispatch_layer, tid); - delete this; -} - void ImageDispatchSpec::fail(int r) { dispatch_result = DISPATCH_RESULT_COMPLETE; aio_comp->fail(r); diff --git a/src/librbd/io/ImageDispatchSpec.h b/src/librbd/io/ImageDispatchSpec.h index 7dccf94bc2975..8b17b2591b2d6 100644 --- a/src/librbd/io/ImageDispatchSpec.h +++ b/src/librbd/io/ImageDispatchSpec.h @@ -204,8 +204,6 @@ private: aio_comp->image_dispatcher_ctx = &dispatcher_ctx; aio_comp->get(); } - - void finish(int r); }; } // namespace io diff --git a/src/librbd/io/ImageDispatcher.cc b/src/librbd/io/ImageDispatcher.cc index 9a37029e615da..5226e9ec95da6 100644 --- a/src/librbd/io/ImageDispatcher.cc +++ b/src/librbd/io/ImageDispatcher.cc @@ -44,6 +44,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } @@ -55,6 +56,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } @@ -65,6 +67,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->op_flags, image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } @@ -75,6 +78,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->op_flags, image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } @@ -88,6 +92,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } @@ -97,6 +102,7 @@ struct ImageDispatcher::SendVisitor : public boost::static_visitor { image_dispatch_spec->parent_trace, image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags, &image_dispatch_spec->dispatch_result, + &image_dispatch_spec->aio_comp->image_dispatcher_ctx, &image_dispatch_spec->dispatcher_ctx); } }; diff --git a/src/librbd/io/QosImageDispatch.cc b/src/librbd/io/QosImageDispatch.cc index 8badb58b1a4ac..66da8d440e45b 100644 --- a/src/librbd/io/QosImageDispatch.cc +++ b/src/librbd/io/QosImageDispatch.cc @@ -118,13 +118,14 @@ bool QosImageDispatch::read( AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; if (needs_throttle(true, image_extents, tid, image_dispatch_flags, - dispatch_result, on_dispatched)) { + dispatch_result, on_finish, on_dispatched)) { return true; } @@ -136,13 +137,14 @@ bool QosImageDispatch::write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; if (needs_throttle(false, image_extents, tid, image_dispatch_flags, - dispatch_result, on_dispatched)) { + dispatch_result, on_finish, on_dispatched)) { return true; } @@ -154,13 +156,14 @@ bool QosImageDispatch::discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; if (needs_throttle(false, image_extents, tid, image_dispatch_flags, - dispatch_result, on_dispatched)) { + dispatch_result, on_finish, on_dispatched)) { return true; } @@ -172,13 +175,14 @@ bool QosImageDispatch::write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; if (needs_throttle(false, image_extents, tid, image_dispatch_flags, - dispatch_result, on_dispatched)) { + dispatch_result, on_finish, on_dispatched)) { return true; } @@ -191,13 +195,14 @@ bool QosImageDispatch::compare_and_write( bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; if (needs_throttle(false, image_extents, tid, image_dispatch_flags, - dispatch_result, on_dispatched)) { + dispatch_result, on_finish, on_dispatched)) { return true; } @@ -209,7 +214,8 @@ bool QosImageDispatch::flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; @@ -243,13 +249,18 @@ template bool QosImageDispatch::needs_throttle( bool read_op, const Extents& image_extents, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; auto extent_length = get_extent_length(image_extents); bool all_qos_flags_set = false; if (!read_op) { m_flush_tracker->start_io(tid); + *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) { + handle_finished(r, tid); + on_finish->complete(r); + }); } *dispatch_result = DISPATCH_RESULT_CONTINUE; diff --git a/src/librbd/io/QosImageDispatch.h b/src/librbd/io/QosImageDispatch.h index 04ed33c001038..4ddd21b99cdd4 100644 --- a/src/librbd/io/QosImageDispatch.h +++ b/src/librbd/io/QosImageDispatch.h @@ -55,34 +55,40 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override; @@ -98,7 +104,8 @@ private: uint32_t flag); bool needs_throttle(bool read_op, const Extents& image_extents, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched); + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched); void handle_throttle_ready(Tag&& tag, uint64_t flag); }; diff --git a/src/librbd/io/QueueImageDispatch.cc b/src/librbd/io/QueueImageDispatch.cc index a07557aa278e9..f59d484d5c46f 100644 --- a/src/librbd/io/QueueImageDispatch.cc +++ b/src/librbd/io/QueueImageDispatch.cc @@ -42,11 +42,12 @@ bool QueueImageDispatch::read( AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return enqueue(true, tid, dispatch_result, on_dispatched); + return enqueue(true, tid, dispatch_result, on_finish, on_dispatched); } template @@ -54,11 +55,12 @@ bool QueueImageDispatch::write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return enqueue(false, tid, dispatch_result, on_dispatched); + return enqueue(false, tid, dispatch_result, on_finish, on_dispatched); } template @@ -66,11 +68,12 @@ bool QueueImageDispatch::discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return enqueue(false, tid, dispatch_result, on_dispatched); + return enqueue(false, tid, dispatch_result, on_finish, on_dispatched); } template @@ -78,11 +81,12 @@ bool QueueImageDispatch::write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return enqueue(false, tid, dispatch_result, on_dispatched); + return enqueue(false, tid, dispatch_result, on_finish, on_dispatched); } template @@ -91,11 +95,12 @@ bool QueueImageDispatch::compare_and_write( bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return enqueue(false, tid, dispatch_result, on_dispatched); + return enqueue(false, tid, dispatch_result, on_finish, on_dispatched); } template @@ -103,7 +108,8 @@ bool QueueImageDispatch::flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; @@ -123,13 +129,17 @@ void QueueImageDispatch::handle_finished(int r, uint64_t tid) { template bool QueueImageDispatch::enqueue( bool read_op, uint64_t tid, DispatchResult* dispatch_result, - Context* on_dispatched) { + Context** on_finish, Context* on_dispatched) { if (!m_image_ctx->non_blocking_aio) { return false; } if (!read_op) { m_flush_tracker->start_io(tid); + *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) { + handle_finished(r, tid); + on_finish->complete(r); + }); } *dispatch_result = DISPATCH_RESULT_CONTINUE; diff --git a/src/librbd/io/QueueImageDispatch.h b/src/librbd/io/QueueImageDispatch.h index 5592d1d5bd754..cbadad95ec1d3 100644 --- a/src/librbd/io/QueueImageDispatch.h +++ b/src/librbd/io/QueueImageDispatch.h @@ -42,34 +42,40 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override; @@ -79,7 +85,7 @@ private: FlushTracker* m_flush_tracker; bool enqueue(bool read_op, uint64_t tid, DispatchResult* dispatch_result, - Context* on_dispatched); + Context** on_finish, Context* on_dispatched); }; diff --git a/src/librbd/io/RefreshImageDispatch.cc b/src/librbd/io/RefreshImageDispatch.cc index 24a2038ca7ece..9ba3bda03ba19 100644 --- a/src/librbd/io/RefreshImageDispatch.cc +++ b/src/librbd/io/RefreshImageDispatch.cc @@ -32,7 +32,8 @@ bool RefreshImageDispatch::read( AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -49,7 +50,8 @@ bool RefreshImageDispatch::write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -66,7 +68,8 @@ bool RefreshImageDispatch::discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -83,7 +86,8 @@ bool RefreshImageDispatch::write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -101,7 +105,8 @@ bool RefreshImageDispatch::compare_and_write( bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents << dendl; @@ -118,7 +123,8 @@ bool RefreshImageDispatch::flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; diff --git a/src/librbd/io/RefreshImageDispatch.h b/src/librbd/io/RefreshImageDispatch.h index 154ff64b07521..3510b350f4cc8 100644 --- a/src/librbd/io/RefreshImageDispatch.h +++ b/src/librbd/io/RefreshImageDispatch.h @@ -38,34 +38,40 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override {} diff --git a/src/librbd/io/WriteBlockImageDispatch.cc b/src/librbd/io/WriteBlockImageDispatch.cc index 729ecc5e60041..d7895f1658cb9 100644 --- a/src/librbd/io/WriteBlockImageDispatch.cc +++ b/src/librbd/io/WriteBlockImageDispatch.cc @@ -124,28 +124,17 @@ void WriteBlockImageDispatch::wait_on_writes_unblocked( on_unblocked->complete(0); } -template -bool WriteBlockImageDispatch::read( - AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result, - int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, - std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { - auto cct = m_image_ctx->cct; - ldout(cct, 20) << "tid=" << tid << dendl; - - return process_io(true, tid, dispatch_result, on_dispatched); -} - template bool WriteBlockImageDispatch::write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return process_io(false, tid, dispatch_result, on_dispatched); + return process_io(tid, dispatch_result, on_finish, on_dispatched); } template @@ -153,11 +142,12 @@ bool WriteBlockImageDispatch::discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return process_io(false, tid, dispatch_result, on_dispatched); + return process_io(tid, dispatch_result, on_finish, on_dispatched); } template @@ -165,11 +155,12 @@ bool WriteBlockImageDispatch::write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return process_io(false, tid, dispatch_result, on_dispatched); + return process_io(tid, dispatch_result, on_finish, on_dispatched); } template @@ -178,11 +169,12 @@ bool WriteBlockImageDispatch::compare_and_write( bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; - return process_io(false, tid, dispatch_result, on_dispatched); + return process_io(tid, dispatch_result, on_finish, on_dispatched); } template @@ -190,7 +182,8 @@ bool WriteBlockImageDispatch::flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) { auto cct = m_image_ctx->cct; ldout(cct, 20) << "tid=" << tid << dendl; @@ -198,7 +191,7 @@ bool WriteBlockImageDispatch::flush( return false; } - return process_io(false, tid, dispatch_result, on_dispatched); + return process_io(tid, dispatch_result, on_finish, on_dispatched); } template @@ -208,10 +201,7 @@ void WriteBlockImageDispatch::handle_finished(int r, uint64_t tid) { std::unique_lock locker{m_lock}; auto it = m_in_flight_write_tids.find(tid); - if (it == m_in_flight_write_tids.end()) { - // assumed to be a read op - return; - } + ceph_assert(it != m_in_flight_write_tids.end()); m_in_flight_write_tids.erase(it); bool writes_blocked = false; @@ -228,19 +218,20 @@ void WriteBlockImageDispatch::handle_finished(int r, uint64_t tid) { template bool WriteBlockImageDispatch::process_io( - bool read_op, uint64_t tid, DispatchResult* dispatch_result, + uint64_t tid, DispatchResult* dispatch_result, Context** on_finish, Context* on_dispatched) { std::unique_lock locker{m_lock}; - if (!read_op) { - if (m_write_blockers > 0 || !m_on_dispatches.empty()) { - *dispatch_result = DISPATCH_RESULT_RESTART; - m_on_dispatches.push_back(on_dispatched); - return true; - } - - m_in_flight_write_tids.insert(tid); + if (m_write_blockers > 0 || !m_on_dispatches.empty()) { + *dispatch_result = DISPATCH_RESULT_RESTART; + m_on_dispatches.push_back(on_dispatched); + return true; } + *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) { + handle_finished(r, tid); + on_finish->complete(r); + }); + m_in_flight_write_tids.insert(tid); return false; } diff --git a/src/librbd/io/WriteBlockImageDispatch.h b/src/librbd/io/WriteBlockImageDispatch.h index 42e7fed828220..adbb357c1cd26 100644 --- a/src/librbd/io/WriteBlockImageDispatch.h +++ b/src/librbd/io/WriteBlockImageDispatch.h @@ -52,34 +52,42 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { + return false; + } bool write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool discard( AioCompletion* aio_comp, Extents &&image_extents, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool write_same( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool compare_and_write( AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; bool flush( AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override; + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override; void handle_finished(int r, uint64_t tid) override; @@ -99,8 +107,8 @@ private: Contexts m_write_blocker_contexts; Contexts m_unblocked_write_waiter_contexts; - bool process_io(bool read_op, uint64_t tid, DispatchResult* dispatch_result, - Context* on_dispatched); + bool process_io(uint64_t tid, DispatchResult* dispatch_result, + Context** on_finish, Context* on_dispatched); void flush_io(Context* on_finish); void handle_blocked_writes(int r); diff --git a/src/test/librbd/mock/io/MockImageDispatch.h b/src/test/librbd/mock/io/MockImageDispatch.h index 80afcec563320..683c8003ec060 100644 --- a/src/test/librbd/mock/io/MockImageDispatch.h +++ b/src/test/librbd/mock/io/MockImageDispatch.h @@ -25,7 +25,8 @@ public: ReadResult &&read_result, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } @@ -33,7 +34,8 @@ public: AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } @@ -42,7 +44,8 @@ public: uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } @@ -50,7 +53,8 @@ public: AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } @@ -59,7 +63,8 @@ public: bufferlist &&bl, uint64_t *mismatch_offset, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } @@ -67,7 +72,8 @@ public: AioCompletion* aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace, uint64_t tid, std::atomic* image_dispatch_flags, - DispatchResult* dispatch_result, Context* on_dispatched) override { + DispatchResult* dispatch_result, Context** on_finish, + Context* on_dispatched) override { return false; } -- 2.39.5