From: Jason Dillaman Date: Mon, 16 Mar 2020 17:17:17 +0000 (-0400) Subject: librbd: defer event socket completion until after callback issued X-Git-Tag: v15.2.0~30^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33994%2Fhead;p=ceph.git librbd: defer event socket completion until after callback issued A change post-Nautilus fixed an issue where multiple threads could concurrently invoke callbacks to librbd clients. However, it also introduced the potential that a callback hasn't yet fired by the time the event socket is completed. This resulted in a crash of fio under high-throughput testing since it expected both a callback and the event socket completion, in that order. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/io/AioCompletion.cc b/src/librbd/io/AioCompletion.cc index 603c1f18fb1a..afd4a30d7688 100644 --- a/src/librbd/io/AioCompletion.cc +++ b/src/librbd/io/AioCompletion.cc @@ -104,12 +104,10 @@ void AioCompletion::complete() { complete_external_callback(); } else { complete_cb(rbd_comp, complete_arg); + complete_event_socket(); } - } - - if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) { - ictx->event_socket_completions.push(this); - ictx->event_socket.notify(); + } else { + complete_event_socket(); } state = AIO_STATE_COMPLETE; @@ -261,6 +259,7 @@ void AioCompletion::complete_external_callback() { AioCompletion* aio_comp; while (ictx->external_callback_completions.pop(aio_comp)) { aio_comp->complete_cb(aio_comp->rbd_comp, aio_comp->complete_arg); + aio_comp->complete_event_socket(); } ictx->external_callback_in_progress.store(false); @@ -272,5 +271,12 @@ void AioCompletion::complete_external_callback() { } } +void AioCompletion::complete_event_socket() { + if (ictx != nullptr && event_notify && ictx->event_socket.is_valid()) { + ictx->event_socket_completions.push(this); + ictx->event_socket.notify(); + } +} + } // namespace io } // namespace librbd diff --git a/src/librbd/io/AioCompletion.h b/src/librbd/io/AioCompletion.h index cdaaa6a32b50..9df547cd2413 100644 --- a/src/librbd/io/AioCompletion.h +++ b/src/librbd/io/AioCompletion.h @@ -178,6 +178,7 @@ struct AioCompletion { private: void queue_complete(); void complete_external_callback(); + void complete_event_socket(); };