From: Jason Dillaman Date: Mon, 2 May 2016 14:26:29 +0000 (-0400) Subject: librbd: update_features should release lock if acquired X-Git-Tag: v10.2.1~27^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e058fc852090ecb1b3a8daa3e0ee9df9d5eba3c;p=ceph.git librbd: update_features should release lock if acquired 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 (cherry picked from commit 608e09851396a9eeb7cf6dc1c7f687ef7a033601) --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 6a6c2139b75..3ec1f35e11a 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -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; }