]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: don't hold owner_lock for write during flush
authorJason Dillaman <dillaman@redhat.com>
Thu, 7 May 2015 16:35:36 +0000 (12:35 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 5 Jun 2015 16:29:32 +0000 (12:29 -0400)
The various IO callback codepaths will attempt to take
the lock, which will result in deadlock since the flush
cannot complete.

Backport: hammer
Fixes: #11537
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Conflicts:
src/librbd/ImageWatcher.cc

src/librbd/ImageWatcher.cc

index a8a7c2114d8812f5e9d3565dcfd3258e61bf1b99..82e45db1693781dab3b37e9b9aab7dc91d8a876b 100644 (file)
@@ -376,21 +376,21 @@ bool ImageWatcher::release_lock()
     return false;
   }
   prepare_unlock();
-
   m_image_ctx.owner_lock.put_write();
   m_image_ctx.cancel_async_requests();
   m_image_ctx.flush_async_operations();
-  m_image_ctx.owner_lock.get_write();
-
-  if (!is_lock_owner()) {
-    return false;
-  }
 
   {
-    RWLock::WLocker l2(m_image_ctx.md_lock);
+    RWLock::RLocker owner_locker(m_image_ctx.owner_lock);
+    RWLock::WLocker md_locker(m_image_ctx.md_lock);
     librbd::_flush(&m_image_ctx);
   }
 
+  m_image_ctx.owner_lock.get_write();
+  if (!is_lock_owner()) {
+    return false;
+  }
+
   unlock();
   return true;
 }