From: Jason Dillaman Date: Sat, 9 Apr 2016 18:29:14 +0000 (-0400) Subject: librbd: exclusive lock might be disabled while waiting to acquire lock X-Git-Tag: ses3-milestone4~16^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad489f7b5c239900aca3610667fbdd7698a0b184;p=ceph.git librbd: exclusive lock might be disabled while waiting to acquire lock Disabling exclusive lock will now acquire the exclusive lock before proceeding. If this resulted in another client releasing the lock and re-requesting it, support for exclusive locking might be disabled while a request is pending. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index 82d00425e0bd..4c0ebfef4fab 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -104,9 +104,14 @@ template void ExclusiveLock::shut_down(Context *on_shut_down) { ldout(m_image_ctx.cct, 10) << this << " " << __func__ << dendl; - Mutex::Locker locker(m_lock); - assert(!is_shutdown()); - execute_action(ACTION_SHUT_DOWN, on_shut_down); + { + Mutex::Locker locker(m_lock); + assert(!is_shutdown()); + execute_action(ACTION_SHUT_DOWN, on_shut_down); + } + + // if stalled in request state machine -- abort + handle_lock_released(); } template diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 9579723b2271..df8f366520d4 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -417,8 +417,11 @@ void ImageWatcher::handle_request_lock(int r) { RWLock::RLocker owner_locker(m_image_ctx.owner_lock); RWLock::RLocker snap_locker(m_image_ctx.snap_lock); - // ExclusiveLock state machine cannot transition - assert(!m_image_ctx.exclusive_lock->is_lock_owner()); + // ExclusiveLock state machine cannot transition -- but can be + // dynamically disabled + if (m_image_ctx.exclusive_lock == nullptr) { + return; + } if (r == -ETIMEDOUT) { ldout(m_image_ctx.cct, 5) << this << " timed out requesting lock: retrying"