From: Kotresh HR Date: Wed, 21 Jan 2026 13:18:47 +0000 (+0530) Subject: tools/cephfs_mirror: Add synced files metric X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd4f3eda7694f88d71eb4423f240218942e471e1;p=ceph-ci.git tools/cephfs_mirror: Add synced files metric Fixes: https://tracker.ceph.com/issues/73453 Signed-off-by: Kotresh HR --- diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 68ee414d128..8fe82379bb6 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -898,6 +898,7 @@ int PeerReplayer::remote_file_op(std::shared_ptr& 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(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); diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index 930d727cd30..ad56a2a724f 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -351,8 +351,11 @@ private: monotime last_synced = clock::zero(); boost::optional last_sync_duration; boost::optional last_sync_bytes; //last sync bytes for display in status + boost::optional 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()) {