From fd2436156b8613c14d21d7831455458e58832d8d Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Sat, 9 Apr 2016 14:28:14 -0400 Subject: [PATCH] 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 --- src/librbd/internal.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 2abc1a2559b78..cb86f18c70169 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) { -- 2.39.5