]> 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>
Tue, 17 Feb 2026 20:10:51 +0000 (01:40 +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 1284cc011454fb99a070559fcd27f7d85024f757..69c3f1f9e6c038ae71c865f7076386c02408a2ef 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 98c94a4838e7ba941259bed11fdef6f0b05c3e6f..e294e5bd0763d83805818089a97d120c24cd38f0 100644 (file)
@@ -76,7 +76,7 @@ private:
   };
 
   bool is_stopping() {
-    return m_stopping;
+    return m_stopping.load(std::memory_order_acquire);
   }
 
   struct Replayer;
@@ -472,7 +472,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;