From: Jason Dillaman Date: Sat, 9 Apr 2016 18:28:14 +0000 (-0400) Subject: librbd: acquire exclusive lock before disabling features X-Git-Tag: ses3-milestone4~16^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd2436156b8613c14d21d7831455458e58832d8d;p=ceph.git librbd: acquire exclusive lock before disabling features 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 --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2abc1a2559b7..cb86f18c7016 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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) {