]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/cephfs_mirror: Use the existing m_lock and m_cond
authorKotresh HR <khiremat@redhat.com>
Wed, 14 Jan 2026 08:27:34 +0000 (13:57 +0530)
committerKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 20:12:39 +0000 (01:42 +0530)
The entire snapshot is synced outside the lock.
The m_lock and m_cond pair is used for data sync
threads along with crawler threads to work well
with all terminal conditions like shutdown and
existing data structures.

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

index 9c3f9013a35762c647a9ff429ccc92e675be7bcb..db10bb91ed68b12d3eeaeac0501deddda7210951 100644 (file)
@@ -2121,16 +2121,32 @@ void PeerReplayer::run(SnapshotReplayerThread *replayer) {
 void PeerReplayer::run_datasync(SnapshotDataSyncThread *data_replayer) {
   dout(10) << ": snapshot datasync replayer=" << data_replayer << dendl;
 
-  // TODO Do we need separate m_lock/m_cond for synchornization or can you use the same?
-
+  /* The entire snapshot is synced outside the lock. The m_lock and m_cond pair
+   * is used for these threads along with crawler threads to work well with all
+   * terminal conditions like shutdown.
+   */
+  std::unique_lock locker(m_lock);
   while (true) {
-    // TODO is_stopping and is_blocklisted
+    m_cond.wait_for(locker, 1s, [this]{return is_stopping();});
+    if (is_stopping()) {
+      dout(5) << ": exiting snapshot data replayer=" << data_replayer << dendl;
+      break;
+    }
+    // do not check if client is blocklisted under lock
+    locker.unlock();
+    if (m_fs_mirror->is_blocklisted()) {
+      dout(5) << ": exiting snapshot data replayer=" << data_replayer << " as client is blocklisted" << dendl;
+      break;
+    }
 
     // TODO Wait and fetch syncm from SyncMechanism Queue
 
     // TODO pre_sync and open handles
 
     // TODO Wait and fetch files from syncm data queue and sync
+
+    //lock again to satify m_cond
+    locker.lock();
   }
 }