From: Kotresh HR Date: Tue, 16 Jun 2026 16:38:15 +0000 (+0530) Subject: tools/cephfs_mirror: Add per-peer tick thread with configurable interval X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=be881563f64656b0db4747bc77f906ac30b7e5cc;p=ceph.git tools/cephfs_mirror: Add per-peer tick thread with configurable interval Introduce a per-peer tick thread controlled by cephfs_mirror_tick_interval (default 5 seconds). The interval is re-read each iteration so configuration changes take effect without restarting the daemon. The thread provides a generic hook for future periodic mirroring work. Fixes: https://tracker.ceph.com/issues/76686 Signed-off-by: Kotresh HR (cherry picked from commit b8310f33c377b4c3e3f43026184f5fdd741f6a8e) --- diff --git a/src/common/options/cephfs-mirror.yaml.in b/src/common/options/cephfs-mirror.yaml.in index b009c0a8d6fa..399076cda0bc 100644 --- a/src/common/options/cephfs-mirror.yaml.in +++ b/src/common/options/cephfs-mirror.yaml.in @@ -104,6 +104,17 @@ options: services: - cephfs-mirror min: 1 +- name: cephfs_mirror_tick_interval + type: secs + level: advanced + desc: interval for the per-peer mirroring tick thread + long_desc: interval in seconds for the per-peer tick thread that runs periodic + mirroring work. The value is re-read each iteration so configuration changes + take effect without restarting the daemon. + default: 5 + services: + - cephfs-mirror + min: 1 - name: cephfs_mirror_max_consecutive_failures_per_directory type: uint level: advanced diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 93bc04ddaf81..4bd4681f0e06 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -310,6 +310,12 @@ int PeerReplayer::init() { data_replayer->create(name.c_str()); m_data_replayers.push_back(std::move(data_replayer)); } + + m_tick_thread.reset(new TickThread(this)); + m_tick_thread->create("tick"); + + set_changed_mirroring_configurations(); + return 0; } @@ -349,6 +355,11 @@ void PeerReplayer::shutdown() { } m_replayers.clear(); + if (m_tick_thread) { + m_tick_thread->join(); + m_tick_thread.reset(); + } + ceph_unmount(m_remote_mount); ceph_release(m_remote_mount); m_remote_mount = nullptr; @@ -2336,6 +2347,21 @@ int PeerReplayer::sync_snaps(const std::string &dir_root, return r; } +void PeerReplayer::run_tick() { + dout(10) << ": started" << dendl; + + std::unique_lock locker(m_lock); + while (true) { + auto interval = g_ceph_context->_conf.get_val( + "cephfs_mirror_tick_interval"); + m_cond.wait_for(locker, interval, [this]{return is_stopping();}); + if (is_stopping()) { + dout(5) << ": shutting down exiting" << dendl; + break; + } + } +} + void PeerReplayer::run(SnapshotReplayerThread *replayer) { dout(10) << ": snapshot replayer=" << replayer << dendl; diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index abe95c6dfe89..e91c5b495b29 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -129,6 +129,21 @@ private: PeerReplayer *m_peer_replayer; }; + class TickThread : public Thread { + public: + explicit TickThread(PeerReplayer *peer_replayer) + : m_peer_replayer(peer_replayer) { + } + + void *entry() override { + m_peer_replayer->run_tick(); + return 0; + } + + private: + PeerReplayer *m_peer_replayer; + }; + struct DirRegistry { int fd; bool canceled = false; @@ -636,6 +651,7 @@ private: SnapshotReplayers m_replayers; SnapshotDataReplayers m_data_replayers; + std::unique_ptr m_tick_thread; std::atomic m_active_datasync_threads{0}; ceph::mutex smq_lock; @@ -652,6 +668,7 @@ private: void run(SnapshotReplayerThread *replayer); void run_datasync(SnapshotDataSyncThread *data_replayer); + void run_tick(); void remove_syncm(const std::shared_ptr& syncm_obj); bool is_syncm_active(const std::shared_ptr& syncm_obj); std::shared_ptr pick_next_syncm_and_mark();