]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/cephfs_mirror: Make PeerReplayer::m_stopping atomic
authorKotresh HR <khiremat@redhat.com>
Sun, 15 Feb 2026 03:09:54 +0000 (08:39 +0530)
committerKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 20:12:39 +0000 (01:42 +0530)
Make PeerReplayer::m_stopping as std::<atomic> and make it
independant of m_lock. This helps 'm_stopping' to be used
as predicate in any conditional wait which doesn't use
m_lock.

Fixes: https://tracker.ceph.com/issues/73452
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index ca9933c31b840e765c8fbc24033e17f533713720..f1bc47b47708e66a314ad76bb84d4db54cb66e53 100644 (file)
@@ -315,11 +315,14 @@ int PeerReplayer::init() {
 void PeerReplayer::shutdown() {
   dout(20) << dendl;
 
+  bool expected = false;
+  if (!m_stopping.compare_exchange_strong(expected, true)) {
+    dout(1) << ": shutdown is already in progress - return"<< dendl;
+    return;
+  }
   {
-    std::scoped_lock locker(m_lock);
-    ceph_assert(!m_stopping);
-    m_stopping = true;
-    m_cond.notify_all();
+    std::scoped_lock lock(m_lock);
+    m_cond.notify_all(); //wake up shutdown wait
   }
 
   for (auto &replayer : m_replayers) {
index d6f185fa25b14e8415fc16d020942296d6694db4..b60de132bd5a214a6924704ea5b85979b0c4458e 100644 (file)
@@ -76,7 +76,7 @@ private:
   };
 
   bool is_stopping() {
-    return m_stopping;
+    return m_stopping.load(std::memory_order_acquire);
   }
 
   struct Replayer;
@@ -471,7 +471,7 @@ private:
   ceph::condition_variable m_cond;
   RadosRef m_remote_cluster;
   MountRef m_remote_mount;
-  bool m_stopping = false;
+  std::atomic<bool> m_stopping{false};
   SnapshotReplayers m_replayers;
 
   SnapshotDataReplayers m_data_replayers;