From: N Balachandran Date: Sat, 15 Feb 2025 13:26:31 +0000 (+0530) Subject: rbd-mirror: fix possible recursive lock of ImageReplayer::m_lock X-Git-Tag: v18.2.5~39^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=50c7d04812794427335f9ecd94044b3558396652;p=ceph.git rbd-mirror: fix possible recursive lock of ImageReplayer::m_lock If periodic status update (LambdaContext which is queued from handle_update_mirror_image_replay_status()) races with shutdown and ends up being the last in-flight operation that shutdown was pending on, we attempt to recursively acquire m_lock in shut_down() because m_in_flight_op_tracker.finish_op() is called with m_lock (and also m_threads->timer_lock) held. These locks are needed only for the call to schedule_update_mirror_image_replay_status() and should be unlocked immediately. Fixes: https://tracker.ceph.com/issues/69978 Co-authored-by: Ilya Dryomov Signed-off-by: N Balachandran (cherry picked from commit c60514087bc29540d3babd7855c5a4e28f2bf1b0) --- diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 1e88c3262f16f..abf7b2bcdc77f 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -716,10 +716,12 @@ void ImageReplayer::handle_update_mirror_image_replay_status(int r) { 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}; + { + std::unique_lock locker{m_lock}; + std::unique_lock timer_locker{m_threads->timer_lock}; - schedule_update_mirror_image_replay_status(); + schedule_update_mirror_image_replay_status(); + } m_in_flight_op_tracker.finish_op(); });