]> 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, 1 Oct 2024 05:02:20 +0000 (10:32 +0530)
Fixes: https://tracker.ceph.com/issues/65629
Signed-off-by: Jos Collin <jcollin@redhat.com>
(cherry picked from commit cc721a55bd3886c3918ea18193078d513e96d933)

src/tools/cephfs_mirror/PeerReplayer.cc
src/tools/cephfs_mirror/PeerReplayer.h

index 47a4fd0219f9703fa431df0a3f406f85fe8f4476..b278731b023745bd0c9ad23ece203567a1e43e17 100644 (file)
@@ -746,6 +746,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);
@@ -1628,6 +1629,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 4d86dc43632dc9e353cb9f3d42324aa9125dc2cd..67b693719903a230abd91d8cc4050e0175a8997e 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;