]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/cephfs_mirror: Add synced files metric
authorKotresh HR <khiremat@redhat.com>
Wed, 21 Jan 2026 13:18:47 +0000 (18:48 +0530)
committerKotresh HR <khiremat@redhat.com>
Wed, 4 Feb 2026 08:53:14 +0000 (14:23 +0530)
Fixes: https://tracker.ceph.com/issues/73453
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index 68ee414d12847807fcacf5eba6efc4139fd5f03f..8fe82379bb68fcb1456a2f1076e450429cb01be3 100644 (file)
@@ -898,6 +898,7 @@ int PeerReplayer::remote_file_op(std::shared_ptr<SyncMechanism>& syncm, const st
     }
   }
 
+  inc_sync_files(dir_root);
   return 0;
 }
 
@@ -1324,7 +1325,7 @@ PeerReplayer::SyncMechanism::~SyncMechanism() {
 void PeerReplayer::SyncMechanism::push_dataq_entry(SyncEntry e) {
   dout(10) << ": snapshot data replayer dataq pushed" << " syncm=" << this
           << " epath=" << e.epath << dendl;
-  m_peer_replayer.inc_total_bytes(std::string(m_dir_root), e.stx.stx_size);
+  m_peer_replayer.inc_total_bytes_files(std::string(m_dir_root), e.stx.stx_size);
   std::unique_lock lock(sdq_lock);
   m_sync_dataq.push(std::move(e));
   sdq_cv.notify_all();
@@ -2416,8 +2417,17 @@ void PeerReplayer::peer_status(Formatter *f) {
         os << std::fixed << std::setprecision(2) << sync_pct << "%";
         f->dump_string("sync_percent", os.str());
       }
-
       f->close_section(); //bytes
+      f->open_object_section("files");
+      f->dump_unsigned("sync_files", sync_stat.sync_files);
+      f->dump_unsigned("total_files", sync_stat.total_files);
+      if (sync_stat.total_files > 0) {
+        double sync_file_pct = (static_cast<double>(sync_stat.sync_files) * 100.0) / sync_stat.total_files;
+        std::ostringstream os;
+        os << std::fixed << std::setprecision(2) << sync_file_pct << "%";
+        f->dump_string("sync_percent", os.str());
+      }
+      f->close_section(); //files
       f->close_section(); //current_syncing_snap
     }
     if (sync_stat.last_synced_snap) {
@@ -2431,6 +2441,9 @@ void PeerReplayer::peer_status(Formatter *f) {
       if (sync_stat.last_sync_bytes) {
        f->dump_unsigned("sync_bytes", *sync_stat.last_sync_bytes);
       }
+      if (sync_stat.last_sync_files) {
+       f->dump_unsigned("sync_files", *sync_stat.last_sync_files);
+      }
       f->close_section();
     }
     f->dump_unsigned("snaps_synced", sync_stat.synced_snap_count);
index 930d727cd30302d50107a1869d2103d5b397d416..ad56a2a724ffce992a214e8e80f484670459b27e 100644 (file)
@@ -351,8 +351,11 @@ private:
     monotime last_synced = clock::zero();
     boost::optional<double> last_sync_duration;
     boost::optional<uint64_t> last_sync_bytes; //last sync bytes for display in status
+    boost::optional<uint64_t> last_sync_files; //last num of sync files for display in status
     uint64_t sync_bytes = 0; //sync bytes counter, independently for each directory sync.
     uint64_t total_bytes = 0; //total bytes counter, independently for each directory sync.
+    uint64_t sync_files = 0; //sync files counter, independently for each directory sync.
+    uint64_t total_files = 0; //total files counter, independently for each directory sync.
   };
 
   void _inc_failed_count(const std::string &dir_root) {
@@ -395,6 +398,8 @@ private:
     auto &sync_stat = m_snap_sync_stats.at(dir_root);
     sync_stat.sync_bytes = 0;
     sync_stat.total_bytes = 0;
+    sync_stat.sync_files = 0;
+    sync_stat.total_files = 0;
   }
   void set_current_syncing_snap(const std::string &dir_root, uint64_t snap_id,
                                 const std::string &snap_name) {
@@ -425,6 +430,7 @@ private:
     sync_stat.last_synced = clock::now();
     sync_stat.last_sync_duration = duration;
     sync_stat.last_sync_bytes = sync_stat.sync_bytes;
+    sync_stat.last_sync_files = sync_stat.sync_files;
     ++sync_stat.synced_snap_count;
   }
   void inc_sync_bytes(const std::string &dir_root, const uint64_t& b) {
@@ -432,10 +438,16 @@ private:
     auto &sync_stat = m_snap_sync_stats.at(dir_root);
     sync_stat.sync_bytes += b;
   }
-  void inc_total_bytes(const std::string &dir_root, const uint64_t& b) {
+  void inc_sync_files(const std::string &dir_root) {
+    std::scoped_lock locker(m_lock);
+    auto &sync_stat = m_snap_sync_stats.at(dir_root);
+    sync_stat.sync_files++;
+  }
+  void inc_total_bytes_files(const std::string &dir_root, const uint64_t& b) {
     std::scoped_lock locker(m_lock);
     auto &sync_stat = m_snap_sync_stats.at(dir_root);
     sync_stat.total_bytes += b;
+    sync_stat.total_files++;
   }
   bool should_backoff(const std::string &dir_root, int *retval) {
     if (m_fs_mirror->is_blocklisted()) {