]> git.apps.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>
Wed, 29 Jul 2015 17:29:50 +0000 (13: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>
(cherry picked from commit 2b6d0633d5c89de3a557cdd72621dfc19f0540de)

src/librbd/ImageWatcher.cc

index eb6cd2da605321a2e6f8357445dd09f21945e06b..798b4320343eadd7c837cf12bfe8402eadef8226 100644 (file)
@@ -377,21 +377,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;
 }