]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: avoid holding owner_lock waiting for exclusive lock
authorJason Dillaman <dillaman@redhat.com>
Mon, 13 Jun 2016 01:42:59 +0000 (21:42 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 13 Jun 2016 01:42:59 +0000 (21:42 -0400)
Fixes: http://tracker.ceph.com/issues/16235
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/internal.cc

index 46c515af90122e5c23d1a8a858778a035bb71fb7..a8e4dbff463066f655b0c438149ac44bd604939a 100644 (file)
@@ -1706,11 +1706,17 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
 
       C_SaferCond lock_ctx;
       ictx->exclusive_lock->request_lock(&lock_ctx);
+
+      // don't block holding lock since refresh might be required
+      ictx->owner_lock.put_read();
       r = lock_ctx.wait();
+      ictx->owner_lock.get_read();
+
       if (r < 0) {
         lderr(cct) << "failed to lock image: " << cpp_strerror(r) << dendl;
         return r;
-      } else if (!ictx->exclusive_lock->is_lock_owner()) {
+      } else if (ictx->exclusive_lock == nullptr ||
+                 !ictx->exclusive_lock->is_lock_owner()) {
         lderr(cct) << "failed to acquire exclusive lock" << dendl;
         return -EROFS;
       }
@@ -2936,11 +2942,17 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
 
     C_SaferCond lock_ctx;
     ictx->exclusive_lock->request_lock(&lock_ctx);
+
+    // don't block holding lock since refresh might be required
+    ictx->owner_lock.put_read();
     r = lock_ctx.wait();
+    ictx->owner_lock.get_read();
+
     if (r < 0) {
       lderr(cct) << "failed to lock image: " << cpp_strerror(r) << dendl;
       return r;
-    } else if (!ictx->exclusive_lock->is_lock_owner()) {
+    } else if (ictx->exclusive_lock == nullptr ||
+               !ictx->exclusive_lock->is_lock_owner()) {
       lderr(cct) << "failed to acquire exclusive lock" << dendl;
       return -EROFS;
     }