From: Jason Dillaman Date: Tue, 10 Mar 2020 17:31:34 +0000 (-0400) Subject: librbd: race condition in image watcher notification callback X-Git-Tag: v15.1.1~31^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=67fe2e5b149cba637eb266562a28aea8f52be254;p=ceph.git 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 --- diff --git a/src/librbd/ImageState.cc b/src/librbd/ImageState.cc index 24cb10d3eff5..fda3148f3199 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