From: Mykola Golub Date: Mon, 22 Feb 2021 16:22:54 +0000 (+0000) Subject: rbd-mirror: reset update_status_task pointer in timer thread X-Git-Tag: v17.1.0~2866^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39625%2Fhead;p=ceph.git 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 --- diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 9289510e11d9..f5cd65fe821e 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(); });