From b626b56b2d48dc94856332839f972ec65bd3d3f3 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Mon, 22 Feb 2021 16:22:54 +0000 Subject: [PATCH] rbd-mirror: reset update_status_task pointer in timer thread 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 (cherry picked from commit 3a289d43f6ab010bcadb80888fb73763f4f55ed0) --- src/tools/rbd_mirror/ImageReplayer.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 2d57a98d2f9c6..2d51efe8bb4f1 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -690,18 +690,18 @@ template void ImageReplayer::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(); }); -- 2.39.5