]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs_mirror: show 'sync_bytes' in peer status
authorJos Collin <jcollin@redhat.com>
Tue, 23 Apr 2024 13:32:43 +0000 (19:02 +0530)
committerJos Collin <jcollin@redhat.com>
Tue, 30 Jul 2024 05:31:06 +0000 (11:01 +0530)
Fixes: https://tracker.ceph.com/issues/65629
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index 1f8ff76837311faccf232f82964f855d80dbbe27..42d8fdb51e69eb92fda613ff8db7d7b02394ecaf 100644 (file)
@@ -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);
index 35918fc6e49ea18f19bf9b222d7820f96ce4481d..6d04cf0cd838c100012e875e68f96f98e7662c57 100644 (file)
@@ -149,6 +149,8 @@ private:
     uint64_t renamed_snap_count = 0;
     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
+    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;