]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: acquire exclusive lock before disabling features
authorJason Dillaman <dillaman@redhat.com>
Sat, 9 Apr 2016 18:28:14 +0000 (14:28 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sat, 9 Apr 2016 18:28:14 +0000 (14:28 -0400)
If object map or journaling is dynamically disabled, we want to
ensure that no in-flight IO could be updating the objects while
we attempt to delete them.

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

index 2abc1a2559b7815e84761ce3d8bd58a245ed186b..cb86f18c701693a335820e9dce711eefb5884162 100644 (file)
@@ -1607,6 +1607,21 @@ remove_mirroring_image:
         return -EINVAL;
       }
 
+      // 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) {
+        C_SaferCond lock_ctx;
+        ictx->exclusive_lock->request_lock(&lock_ctx);
+        r = lock_ctx.wait();
+        if (r < 0) {
+          lderr(cct) << "failed to lock image: " << cpp_strerror(r) << dendl;
+          return r;
+        } else if (!ictx->exclusive_lock->is_lock_owner()) {
+          lderr(cct) << "failed to acquire exclusive lock" << dendl;
+          return -EROFS;
+        }
+      }
+
       RWLock::WLocker snap_locker(ictx->snap_lock);
       uint64_t new_features;
       if (enabled) {