From: Ilya Dryomov Date: Mon, 15 Jul 2024 09:28:12 +0000 (+0200) Subject: librbd: fold complete_event_socket() into notify_callbacks_complete() X-Git-Tag: v20.0.0~1475^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed082dbd127152ddd7b41c1972c21b87a4a2818c;p=ceph.git librbd: fold complete_event_socket() into notify_callbacks_complete() Since commit 50694f790245 ("librbd: fix race condition with AIO completion callbacks"), the former is always called before the latter. Move event socket notification code into notify_callbacks_complete() and rename it to mark_complete_and_notify(). Signed-off-by: Ilya Dryomov --- diff --git a/src/librbd/io/AioCompletion.cc b/src/librbd/io/AioCompletion.cc index c04b80770f99..7164d98c2594 100644 --- a/src/librbd/io/AioCompletion.cc +++ b/src/librbd/io/AioCompletion.cc @@ -103,12 +103,10 @@ void AioCompletion::complete() { complete_external_callback(); } else { complete_cb(rbd_comp, complete_arg); - complete_event_socket(); - notify_callbacks_complete(); + mark_complete_and_notify(); } } else { - complete_event_socket(); - notify_callbacks_complete(); + mark_complete_and_notify(); } tracepoint(librbd, aio_complete_exit); @@ -259,20 +257,17 @@ void AioCompletion::complete_external_callback() { // from multiple librbd-internal threads. boost::asio::dispatch(ictx->asio_engine->get_api_strand(), [this]() { complete_cb(rbd_comp, complete_arg); - complete_event_socket(); - notify_callbacks_complete(); + mark_complete_and_notify(); put(); }); } -void AioCompletion::complete_event_socket() { +void AioCompletion::mark_complete_and_notify() { if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) { ictx->event_socket_completions.push(this); ictx->event_socket.notify(); } -} -void AioCompletion::notify_callbacks_complete() { state = AIO_STATE_COMPLETE; { diff --git a/src/librbd/io/AioCompletion.h b/src/librbd/io/AioCompletion.h index 4ae93fe36d20..9afced7e2be9 100644 --- a/src/librbd/io/AioCompletion.h +++ b/src/librbd/io/AioCompletion.h @@ -180,8 +180,7 @@ struct AioCompletion { private: void queue_complete(); void complete_external_callback(); - void complete_event_socket(); - void notify_callbacks_complete(); + void mark_complete_and_notify(); }; class C_AioRequest : public Context {