From b7151a5152680e26f79d68ce6ee3831a21542d53 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 19 Feb 2019 16:06:48 -0500 Subject: [PATCH] librbd: add missing shutdown states to managed lock helper The PRE_SHUTTING_DOWN and SHUTTING_DOWN states were missed in the 'is_state_shutdown' helper method. This resulted in rbd-mirror potentially entering an infinite loop during shutdown. http://tracker.ceph.com/issues/38387 Signed-off-by: Jason Dillaman (cherry picked from commit 82af5710ad49dd6e24c2736a9865e1a41add89a2) --- src/librbd/ManagedLock.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librbd/ManagedLock.cc b/src/librbd/ManagedLock.cc index c3cda70204e73..4b15af7f1bac5 100644 --- a/src/librbd/ManagedLock.cc +++ b/src/librbd/ManagedLock.cc @@ -453,9 +453,17 @@ template bool ManagedLock::is_state_shutdown() const { assert(m_lock.is_locked()); - return ((m_state == STATE_SHUTDOWN) || - (!m_actions_contexts.empty() && - m_actions_contexts.back().first == ACTION_SHUT_DOWN)); + switch (m_state) { + case STATE_PRE_SHUTTING_DOWN: + case STATE_SHUTTING_DOWN: + case STATE_SHUTDOWN: + return true; + default: + break; + } + + return (!m_actions_contexts.empty() && + m_actions_contexts.back().first == ACTION_SHUT_DOWN); } template -- 2.39.5