]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: reset update_status_task pointer in timer thread
authorMykola Golub <mgolub@suse.com>
Mon, 22 Feb 2021 16:22:54 +0000 (16:22 +0000)
committerJason Dillaman <dillaman@redhat.com>
Wed, 24 Feb 2021 14:05:35 +0000 (09:05 -0500)
To avoid a time window when m_update_status_task is invalid. If
during this time the cancel_update_mirror_image_replay_status is
called, it may cancel some other's ImageReplayer task, if it
happened to add the task with the same address.

Fixes: https://tracker.ceph.com/issues/49418
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 3a289d43f6ab010bcadb80888fb73763f4f55ed0)

src/tools/rbd_mirror/ImageReplayer.cc

index 9289510e11d9e7df1042b312079437c36c0ea92a..f5cd65fe821ecde22b3988f714ec504b1159af9d 100644 (file)
@@ -690,18 +690,18 @@ template <typename I>
 void ImageReplayer<I>::handle_update_mirror_image_replay_status(int r) {
   dout(10) << dendl;
 
+  ceph_assert(ceph_mutex_is_locked_by_me(m_threads->timer_lock));
+
+  ceph_assert(m_update_status_task != nullptr);
+  m_update_status_task = nullptr;
+
   auto ctx = new LambdaContext([this](int) {
       update_mirror_image_status(false, boost::none);
 
-      {
-        std::unique_lock locker{m_lock};
-        std::unique_lock timer_locker{m_threads->timer_lock};
-        ceph_assert(m_update_status_task != nullptr);
-        m_update_status_task = nullptr;
-
-        schedule_update_mirror_image_replay_status();
-      }
+      std::unique_lock locker{m_lock};
+      std::unique_lock timer_locker{m_threads->timer_lock};
 
+      schedule_update_mirror_image_replay_status();
       m_in_flight_op_tracker.finish_op();
     });