]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs_mirror: Add per-peer tick thread with configurable interval
authorKotresh HR <khiremat@redhat.com>
Tue, 16 Jun 2026 16:38:15 +0000 (22:08 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 16 Jun 2026 16:47:23 +0000 (22:17 +0530)
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 <khiremat@redhat.com>
src/common/options/cephfs-mirror.yaml.in
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index b009c0a8d6fa6c9b8f007b342db0153c583b488c..399076cda0bcf1e5744ee82aaf77cc28c9064dcc 100644 (file)
@@ -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
index 93bc04ddaf81b8f2b020329b1e1e48ae846f4939..4bd4681f0e06e098ba4d5004db0b22d9b0343c3a 100644 (file)
@@ -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<std::chrono::seconds>(
+      "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;
 
index abe95c6dfe8967c4736ecc00f0392a0de84b35ed..e91c5b495b291ce1b41b73f12ce2a9f49af18968 100644 (file)
@@ -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<TickThread> m_tick_thread;
   std::atomic<int> 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<SyncMechanism>& syncm_obj);
   bool is_syncm_active(const std::shared_ptr<SyncMechanism>& syncm_obj);
   std::shared_ptr<SyncMechanism> pick_next_syncm_and_mark();