From cc721a55bd3886c3918ea18193078d513e96d933 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Tue, 23 Apr 2024 19:02:43 +0530 Subject: [PATCH] cephfs_mirror: show 'sync_bytes' in peer status Fixes: https://tracker.ceph.com/issues/65629 Signed-off-by: Jos Collin --- src/tools/cephfs_mirror/PeerReplayer.cc | 4 ++++ src/tools/cephfs_mirror/PeerReplayer.h | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 1f8ff768373..42d8fdb51e6 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -753,6 +753,7 @@ int PeerReplayer::remote_file_op(const std::string &dir_root, const std::string if (m_perf_counters) { m_perf_counters->inc(l_cephfs_mirror_peer_replayer_sync_bytes, stx.stx_size); } + inc_sync_bytes(dir_root, stx.stx_size); } else if (S_ISLNK(stx.stx_mode)) { // free the remote link before relinking r = ceph_unlinkat(m_remote_mount, fh.r_fd_dir_root, epath.c_str(), 0); @@ -1801,6 +1802,9 @@ void PeerReplayer::peer_status(Formatter *f) { f->dump_float("sync_duration", *sync_stat.last_sync_duration); f->dump_stream("sync_time_stamp") << sync_stat.last_synced; } + if (sync_stat.last_sync_bytes) { + f->dump_unsigned("sync_bytes", *sync_stat.last_sync_bytes); + } 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 35918fc6e49..6d04cf0cd83 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -149,6 +149,8 @@ private: uint64_t renamed_snap_count = 0; monotime last_synced = clock::zero(); boost::optional last_sync_duration; + boost::optional last_sync_bytes; //last sync bytes for display in status + uint64_t sync_bytes = 0; //sync bytes counter, independently for each directory sync. }; void _inc_failed_count(const std::string &dir_root) { @@ -187,6 +189,8 @@ private: const std::string &snap_name) { std::scoped_lock locker(m_lock); _set_last_synced_snap(dir_root, snap_id, snap_name); + auto &sync_stat = m_snap_sync_stats.at(dir_root); + sync_stat.sync_bytes = 0; } void set_current_syncing_snap(const std::string &dir_root, uint64_t snap_id, const std::string &snap_name) { @@ -216,9 +220,14 @@ private: auto &sync_stat = m_snap_sync_stats.at(dir_root); sync_stat.last_synced = clock::now(); sync_stat.last_sync_duration = duration; + sync_stat.last_sync_bytes = sync_stat.sync_bytes; ++sync_stat.synced_snap_count; } - + void inc_sync_bytes(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.sync_bytes += b; + } bool should_backoff(const std::string &dir_root, int *retval) { if (m_fs_mirror->is_blocklisted()) { *retval = -EBLOCKLISTED; -- 2.39.5