]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: defer event socket completion until after callback issued 33994/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 16 Mar 2020 17:17:17 +0000 (13:17 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 16 Mar 2020 17:23:17 +0000 (13:23 -0400)
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 <dillaman@redhat.com>
src/librbd/io/AioCompletion.cc
src/librbd/io/AioCompletion.h

index 603c1f18fb1a8da477e4f48696ed4c8b3455f23b..afd4a30d76883180e1269d231b70ee0dbdbd60ce 100644 (file)
@@ -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
index cdaaa6a32b503c6ff311aa7c8cd8959974fb9136..9df547cd2413c8ef5fe9e71c40ecdcf17ee79fd1 100644 (file)
@@ -178,6 +178,7 @@ struct AioCompletion {
 private:
   void queue_complete();
   void complete_external_callback();
+  void complete_event_socket();
 
 };