From 67fe2e5b149cba637eb266562a28aea8f52be254 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 10 Mar 2020 13:31:34 -0400 Subject: [PATCH] librbd: race condition in image watcher notification callback If a refresh is in-progress when a header update notification is received, the notification was previously incorrectly dropped. This prevented rbd-mirror's snapshot-based mirroring replayer from detecting updates in some cases. Signed-off-by: Jason Dillaman --- src/librbd/ImageState.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/librbd/ImageState.cc b/src/librbd/ImageState.cc index 24cb10d3eff..fda3148f319 100644 --- a/src/librbd/ImageState.cc +++ b/src/librbd/ImageState.cc @@ -302,9 +302,18 @@ void ImageState::handle_update_notification() { ldout(cct, 20) << __func__ << ": refresh_seq = " << m_refresh_seq << ", " << "last_refresh = " << m_last_refresh << dendl; - if (m_state == STATE_OPEN) { - m_update_watchers->notify(); + switch (m_state) { + case STATE_UNINITIALIZED: + case STATE_CLOSED: + case STATE_OPENING: + case STATE_CLOSING: + ldout(cct, 5) << "dropping update notification to watchers" << dendl; + return; + default: + break; } + + m_update_watchers->notify(); } template -- 2.39.5