From 88436dc7685033c2cc078b89a9c1aff2ca5721e0 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 14 Jan 2026 13:57:34 +0530 Subject: [PATCH] tools/cephfs_mirror: Use the existing m_lock and m_cond 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 --- src/tools/cephfs_mirror/PeerReplayer.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 9c3f9013a35..db10bb91ed6 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -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(); } } -- 2.47.3