]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: exclusive lock image dispatch should not wait on IO when setting lock
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 May 2020 23:14:14 +0000 (19:14 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 3 Jun 2020 13:45:23 +0000 (09:45 -0400)
IO from later dispatch layers might have caused the need to acquire the lock
(i.e. like an image refresh). In that case, the IO will be blocked waiting for
the exclusive lock to be acquired -- but will deadlock waiting for the IO
to flush.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/exclusive_lock/ImageDispatch.cc

index 253ae149ce67573f3226f4949b9786e5dd88d801..dccb340a954466d4b05db76f54ed00a20e2f28e6 100644 (file)
@@ -63,27 +63,21 @@ void ImageDispatch<I>::shut_down(Context* on_finish) {
 template <typename I>
 void ImageDispatch<I>::set_require_lock(io::Direction direction,
                                         Context* on_finish) {
-  auto cct = m_image_ctx->cct;
-
   // pause any matching IO from proceeding past this layer
   set_require_lock(direction, true);
 
-  auto ctx = new C_Gather(cct, on_finish);
-
-  // passive wait for in-flight IO to complete
-  m_flush_tracker->flush(ctx->new_sub());
-
-  if (direction != io::DIRECTION_READ) {
-    // push through an flush for any in-flight writes at lower levels
-    auto aio_comp = io::AioCompletion::create_and_start(
-      ctx->new_sub(), util::get_image_ctx(m_image_ctx), io::AIO_TYPE_FLUSH);
-    auto req = io::ImageDispatchSpec<I>::create_flush(
-      *m_image_ctx, io::IMAGE_DISPATCH_LAYER_EXCLUSIVE_LOCK, aio_comp,
-      io::FLUSH_SOURCE_INTERNAL, {});
-    req->send();
+  if (direction == io::DIRECTION_READ) {
+    on_finish->complete(0);
+    return;
   }
 
-  ctx->activate();
+  // push through a flush for any in-flight writes at lower levels
+  auto aio_comp = io::AioCompletion::create_and_start(
+    on_finish, util::get_image_ctx(m_image_ctx), io::AIO_TYPE_FLUSH);
+  auto req = io::ImageDispatchSpec<I>::create_flush(
+    *m_image_ctx, io::IMAGE_DISPATCH_LAYER_EXCLUSIVE_LOCK, aio_comp,
+    io::FLUSH_SOURCE_INTERNAL, {});
+  req->send();
 }
 
 template <typename I>