]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: add information about the last snapshot sync to image status 50266/head
authorDivyansh Kamboj <dkamboj@redhat.com>
Wed, 7 Dec 2022 10:25:38 +0000 (15:55 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 26 Feb 2023 16:57:57 +0000 (17:57 +0100)
this commit adds fields for time taken to sync and bytes in the last
snapshot to the mirror image status command.

Fixes: https://tracker.ceph.com/issues/58755
Signed-off-by: Divyansh Kamboj <dkamboj@redhat.com>
(cherry picked from commit 9b9f18a65d2430ddcf32cbf85566b0223be91758)

src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.h

index 4a44a57bc223534ce51ffacb4f9c2c06b041bee0..e9bbabeb1ff2b599b715c435277fd9f423500b28 100644 (file)
@@ -290,6 +290,9 @@ bool Replayer<I>::get_replay_status(std::string* description,
     m_bytes_per_snapshot);
   root_obj["bytes_per_snapshot"] = round_to_two_places(bytes_per_snapshot);
 
+  root_obj["last_snapshot_sync_seconds"] = m_last_snapshot_sync_seconds;
+  root_obj["last_snapshot_bytes"] = m_last_snapshot_bytes;
+
   auto pending_bytes = bytes_per_snapshot * m_pending_snapshots;
   if (bytes_per_second > 0 && m_pending_snapshots > 0) {
     std::uint64_t seconds_until_synced = round_to_two_places(
@@ -1102,21 +1105,23 @@ void Replayer<I>::handle_copy_image(int r) {
 
   {
     std::unique_lock locker{m_lock};
+    m_last_snapshot_bytes = m_snapshot_bytes;
     m_bytes_per_snapshot(m_snapshot_bytes);
-    auto time = ceph_clock_now() - m_snapshot_replay_start;
+    utime_t duration = ceph_clock_now() - m_snapshot_replay_start;
+    m_last_snapshot_sync_seconds = duration.sec();
+
     if (g_snapshot_perf_counters) {
       g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_replay_bytes,
                                     m_snapshot_bytes);
       g_snapshot_perf_counters->inc(l_rbd_mirror_snapshot_replay_snapshots);
       g_snapshot_perf_counters->tinc(
-        l_rbd_mirror_snapshot_replay_snapshots_time, time);
+        l_rbd_mirror_snapshot_replay_snapshots_time, duration);
     }
     if (m_perf_counters) {
       m_perf_counters->inc(l_rbd_mirror_snapshot_replay_bytes, m_snapshot_bytes);
       m_perf_counters->inc(l_rbd_mirror_snapshot_replay_snapshots);
-      m_perf_counters->tinc(l_rbd_mirror_snapshot_replay_snapshots_time, time);
+      m_perf_counters->tinc(l_rbd_mirror_snapshot_replay_snapshots_time, duration);
     }
-    m_snapshot_bytes = 0;
   }
 
   apply_image_state();
index e3c4c20890287a471d0783fcf0c4cf45e0fb5d5e..17d45f6bc802d693f42835bd6a7a5745f02c7076 100644 (file)
@@ -238,8 +238,11 @@ private:
   DeepCopyHandler* m_deep_copy_handler = nullptr;
 
   TimeRollingMean m_bytes_per_second;
+  uint64_t m_last_snapshot_sync_seconds = 0;
 
   uint64_t m_snapshot_bytes = 0;
+  uint64_t m_last_snapshot_bytes = 0;
+
   boost::accumulators::accumulator_set<
     uint64_t, boost::accumulators::stats<
       boost::accumulators::tag::rolling_mean>> m_bytes_per_snapshot{