]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: reset update_status_task pointer in timer thread 39867/head
authorMykola Golub <mgolub@suse.com>
Mon, 22 Feb 2021 16:22:54 +0000 (16:22 +0000)
committerMykola Golub <mgolub@suse.com>
Fri, 5 Mar 2021 17:08:37 +0000 (19:08 +0200)
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 2d57a98d2f9c615334c21292850c7b5bc161c765..2d51efe8bb4f13729f48a1bb44a6b3bb40c810b0 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();
     });