Skip to content

Commit cc721a5

Browse files
committed
cephfs_mirror: show 'sync_bytes' in peer status
Fixes: https://tracker.ceph.com/issues/65629 Signed-off-by: Jos Collin <[email protected]>
1 parent 808ecbb commit cc721a5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/tools/cephfs_mirror/PeerReplayer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ int PeerReplayer::remote_file_op(const std::string &dir_root, const std::string
753753
if (m_perf_counters) {
754754
m_perf_counters->inc(l_cephfs_mirror_peer_replayer_sync_bytes, stx.stx_size);
755755
}
756+
inc_sync_bytes(dir_root, stx.stx_size);
756757
} else if (S_ISLNK(stx.stx_mode)) {
757758
// free the remote link before relinking
758759
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) {
18011802
f->dump_float("sync_duration", *sync_stat.last_sync_duration);
18021803
f->dump_stream("sync_time_stamp") << sync_stat.last_synced;
18031804
}
1805+
if (sync_stat.last_sync_bytes) {
1806+
f->dump_unsigned("sync_bytes", *sync_stat.last_sync_bytes);
1807+
}
18041808
f->close_section();
18051809
}
18061810
f->dump_unsigned("snaps_synced", sync_stat.synced_snap_count);

src/tools/cephfs_mirror/PeerReplayer.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ class PeerReplayer {
149149
uint64_t renamed_snap_count = 0;
150150
monotime last_synced = clock::zero();
151151
boost::optional<double> last_sync_duration;
152+
boost::optional<uint64_t> last_sync_bytes; //last sync bytes for display in status
153+
uint64_t sync_bytes = 0; //sync bytes counter, independently for each directory sync.
152154
};
153155

154156
void _inc_failed_count(const std::string &dir_root) {
@@ -187,6 +189,8 @@ class PeerReplayer {
187189
const std::string &snap_name) {
188190
std::scoped_lock locker(m_lock);
189191
_set_last_synced_snap(dir_root, snap_id, snap_name);
192+
auto &sync_stat = m_snap_sync_stats.at(dir_root);
193+
sync_stat.sync_bytes = 0;
190194
}
191195
void set_current_syncing_snap(const std::string &dir_root, uint64_t snap_id,
192196
const std::string &snap_name) {
@@ -216,9 +220,14 @@ class PeerReplayer {
216220
auto &sync_stat = m_snap_sync_stats.at(dir_root);
217221
sync_stat.last_synced = clock::now();
218222
sync_stat.last_sync_duration = duration;
223+
sync_stat.last_sync_bytes = sync_stat.sync_bytes;
219224
++sync_stat.synced_snap_count;
220225
}
221-
226+
void inc_sync_bytes(const std::string &dir_root, const uint64_t& b) {
227+
std::scoped_lock locker(m_lock);
228+
auto &sync_stat = m_snap_sync_stats.at(dir_root);
229+
sync_stat.sync_bytes += b;
230+
}
222231
bool should_backoff(const std::string &dir_root, int *retval) {
223232
if (m_fs_mirror->is_blocklisted()) {
224233
*retval = -EBLOCKLISTED;

0 commit comments

Comments
 (0)