]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: race condition in image watcher notification callback
authorJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2020 17:31:34 +0000 (13:31 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2020 23:23:02 +0000 (19:23 -0400)
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 <dillaman@redhat.com>
src/librbd/ImageState.cc

index 24cb10d3eff59577f611e3ced7bdc804336c3841..fda3148f3199d298c18b707e50b3ec283322bf6a 100644 (file)
@@ -302,9 +302,18 @@ void ImageState<I>::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 <typename I>