From c5c6016c29b2dc43f6221decc2115204633454b3 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 8 Dec 2020 09:58:07 -0500 Subject: [PATCH] librbd/io: flush IO before shutting down image IO dispatchers Otherwise, if the dispatchers are shut down, there is a potential race where the flush can be assigned to a stuck IO and never completed. Signed-off-by: Jason Dillaman --- src/librbd/io/ImageDispatcher.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librbd/io/ImageDispatcher.cc b/src/librbd/io/ImageDispatcher.cc index a9c1c985522de..fa0cc77703d65 100644 --- a/src/librbd/io/ImageDispatcher.cc +++ b/src/librbd/io/ImageDispatcher.cc @@ -217,11 +217,11 @@ void ImageDispatcher::shut_down(Context* on_finish) { delete async_op; on_finish->complete(0); }); - on_finish = new LambdaContext([this, async_op, on_finish](int r) { - async_op->start_op(*this->m_image_ctx); - async_op->flush(on_finish); + on_finish = new LambdaContext([this, on_finish](int r) { + Dispatcher::shut_down(on_finish); }); - Dispatcher::shut_down(on_finish); + async_op->start_op(*this->m_image_ctx); + async_op->flush(on_finish); } template -- 2.39.5