]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: exclusive lock might be disabled while waiting to acquire lock
authorJason Dillaman <dillaman@redhat.com>
Sat, 9 Apr 2016 18:29:14 +0000 (14:29 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sat, 9 Apr 2016 18:44:41 +0000 (14:44 -0400)
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 <dillaman@redhat.com>
src/librbd/ExclusiveLock.cc
src/librbd/ImageWatcher.cc

index 82d00425e0bd89699a7ab0047496d6330f309439..4c0ebfef4fab1379409889fb487cc9ad5370b67a 100644 (file)
@@ -104,9 +104,14 @@ template <typename I>
 void ExclusiveLock<I>::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 <typename I>
index 9579723b2271091a4ccc10e2cc42c5a3ac22881a..df8f366520d45aa67108fb804760adec8dd35c94 100644 (file)
@@ -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"