From b96ab805eed49d4bdb494c8919d2e1ee7ad0a7e6 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Sun, 12 Jun 2016 21:42:59 -0400 Subject: [PATCH] librbd: avoid holding owner_lock waiting for exclusive lock Fixes: http://tracker.ceph.com/issues/16235 Signed-off-by: Jason Dillaman --- src/librbd/internal.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 46c515af901..a8e4dbff463 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; } -- 2.39.5