]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
tools/cephfs_mirror: Monitor num of active datasync threads
authorKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 14:06:39 +0000 (19:36 +0530)
committerKotresh HR <khiremat@redhat.com>
Sat, 21 Feb 2026 14:06:39 +0000 (19:36 +0530)
commit48fe59ab59d44bcd3b7bbaf95895d4b6c9b4bb16
tree6b31b17bd6b25ff25c3c7735da54bf3b60745b53
parentfc8ea20aed1f7c411303816d0fbf13134548a2ab
tools/cephfs_mirror: Monitor num of active datasync threads

Introduce an atomic counter in PeerReplayer to track the number of
active SnapshotDataSyncThread instances.

The counter is incremented when a datasync thread enters its entry()
function and decremented automatically on exit via a small RAII guard
(DataSyncThreadGuard). This ensures accurate accounting even in the
presence of early returns or future refactoring.

This change helps in handling of shutdown and blocklist scenarios.
At the time of shutdown or blocklisting, datasync threads may still
be processing multiple jobs across different SyncMechanism instances.
It is therefore essential that only the final exiting datasync thread
performs the notifications for all relevant waiters, including the
syncm data queue, syncm queue, and m_cond.

This approach ensures orderly teardown by keeping crawler threads
active until all datasync threads have completed execution.
Terminating crawler threads prematurely—before datasync threads have
exited—can lead to inconsistencies, as crawler threads deregister the
mirroring directory while datasync threads may still be accessing it.

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