From b0b95771fa6485a096fd45ccb89fb551789a37fa Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 6 May 2020 10:52:58 -0400 Subject: [PATCH] librbd: complete ImageDispatchSpec upon AioCompletion finalization This will allow ImageDispatchSpec to invoke any necessary finalizers for the different dispatch layers and allows in-flight IO to be tracked since the image dispatch layer finalizers won't be invoked until after the AioCompletion fires. Signed-off-by: Jason Dillaman --- src/librbd/io/AioCompletion.cc | 4 ++++ src/librbd/io/AioCompletion.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librbd/io/AioCompletion.cc b/src/librbd/io/AioCompletion.cc index afd4a30d76883..9ebb334a2b153 100644 --- a/src/librbd/io/AioCompletion.cc +++ b/src/librbd/io/AioCompletion.cc @@ -116,6 +116,10 @@ void AioCompletion::complete() { cond.notify_all(); } + if (image_dispatcher_ctx != nullptr) { + image_dispatcher_ctx->complete(rval); + } + // note: possible for image to be closed after op marked finished if (async_op.started()) { async_op.finish_op(); diff --git a/src/librbd/io/AioCompletion.h b/src/librbd/io/AioCompletion.h index 9df547cd2413c..43ef324659778 100644 --- a/src/librbd/io/AioCompletion.h +++ b/src/librbd/io/AioCompletion.h @@ -19,11 +19,11 @@ #include #include +struct Context; namespace librbd { namespace io { - /** * AioCompletion is the overall completion for a single * rbd I/O request. It may be composed of many AioObjectRequests, @@ -72,6 +72,8 @@ struct AioCompletion { bool was_armed = false; bool external_callback = false; + Context* image_dispatcher_ctx = nullptr; + template static void callback_adapter(completion_t cb, void *arg) { AioCompletion *comp = reinterpret_cast(cb); -- 2.39.5