From: Jason Dillaman Date: Mon, 13 Jun 2016 01:42:59 +0000 (-0400) Subject: librbd: avoid holding owner_lock waiting for exclusive lock X-Git-Tag: v10.2.2~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=edef63d56bc329638f79ce8017e72810dcd768f1;p=ceph.git librbd: avoid holding owner_lock waiting for exclusive lock Fixes: http://tracker.ceph.com/issues/16235 Signed-off-by: Jason Dillaman (cherry picked from commit b96ab805eed49d4bdb494c8919d2e1ee7ad0a7e6) --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 46c515af9012..a8e4dbff4630 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1706,11 +1706,17 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, C_SaferCond lock_ctx; ictx->exclusive_lock->request_lock(&lock_ctx); + + // don't block holding lock since refresh might be required + ictx->owner_lock.put_read(); r = lock_ctx.wait(); + ictx->owner_lock.get_read(); + if (r < 0) { lderr(cct) << "failed to lock image: " << cpp_strerror(r) << dendl; return r; - } else if (!ictx->exclusive_lock->is_lock_owner()) { + } else if (ictx->exclusive_lock == nullptr || + !ictx->exclusive_lock->is_lock_owner()) { lderr(cct) << "failed to acquire exclusive lock" << dendl; return -EROFS; } @@ -2936,11 +2942,17 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force, C_SaferCond lock_ctx; ictx->exclusive_lock->request_lock(&lock_ctx); + + // don't block holding lock since refresh might be required + ictx->owner_lock.put_read(); r = lock_ctx.wait(); + ictx->owner_lock.get_read(); + if (r < 0) { lderr(cct) << "failed to lock image: " << cpp_strerror(r) << dendl; return r; - } else if (!ictx->exclusive_lock->is_lock_owner()) { + } else if (ictx->exclusive_lock == nullptr || + !ictx->exclusive_lock->is_lock_owner()) { lderr(cct) << "failed to acquire exclusive lock" << dendl; return -EROFS; }