]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: update_features should release lock if acquired
authorJason Dillaman <dillaman@redhat.com>
Mon, 2 May 2016 14:26:29 +0000 (10:26 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 10 May 2016 16:49:17 +0000 (12:49 -0400)
There is a small window where requests are unblocked and before
the image is shut down where new requests can be accepted.  These
are correctly canceled during the shut down, but it can lead to
warning messages.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 608e09851396a9eeb7cf6dc1c7f687ef7a033601)

src/librbd/internal.cc

index 6a6c2139b759632bf1e811d84572c2a851a869f0..3ec1f35e11ad0787a732a7df4ef0ce462ad74bea 100644 (file)
@@ -1623,7 +1623,11 @@ remove_mirroring_image:
 
     // if disabling features w/ exclusive lock supported, we need to
     // acquire the lock to temporarily block IO against the image
-    if (ictx->exclusive_lock != nullptr && !enabled) {
+    bool acquired_lock = false;
+    if (ictx->exclusive_lock != nullptr &&
+        !ictx->exclusive_lock->is_lock_owner() && !enabled) {
+      acquired_lock = true;
+
       C_SaferCond lock_ctx;
       ictx->exclusive_lock->request_lock(&lock_ctx);
       r = lock_ctx.wait();
@@ -1815,6 +1819,16 @@ remove_mirroring_image:
       }
     }
 
+    if (ictx->exclusive_lock != nullptr && acquired_lock) {
+      C_SaferCond lock_ctx;
+      ictx->exclusive_lock->release_lock(&lock_ctx);
+      r = lock_ctx.wait();
+      if (r < 0) {
+        lderr(cct) << "failed to unlock image: " << cpp_strerror(r) << dendl;
+        return r;
+      }
+    }
+
     ictx->notify_update();
     return 0;
   }