]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix possible recursive lock of ImageReplayer::m_lock 62043/head
authorN Balachandran <nithya.balachandran@ibm.com>
Sat, 15 Feb 2025 13:26:31 +0000 (18:56 +0530)
committerN Balachandran <nithya.balachandran@ibm.com>
Fri, 28 Feb 2025 03:23:49 +0000 (08:53 +0530)
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 <idryomov@gmail.com>
Signed-off-by: N Balachandran <nithya.balachandran@ibm.com>
(cherry picked from commit c60514087bc29540d3babd7855c5a4e28f2bf1b0)

src/tools/rbd_mirror/ImageReplayer.cc

index 1e88c3262f16f0d72acb905829d2b906faca4eb7..abf7b2bcdc77f2d2eee319331c759009d4efca24 100644 (file)
@@ -716,10 +716,12 @@ void ImageReplayer<I>::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();
     });