]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: collect total snap-trim queueus length
authorRonen Friedman <rfriedma@redhat.com>
Wed, 29 Apr 2026 04:14:23 +0000 (04:14 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Thu, 21 May 2026 18:10:17 +0000 (18:10 +0000)
Periodically collect the total snap-trim
queue length across all PGs. Expose it through
OSDService::get_snap_trim_queue_total().

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h
src/crimson/osd/pg_shard_manager.cc
src/crimson/osd/pg_shard_manager.h

index 1ba7669fef6c30757c9f5c763808d7170fe5eb7b..77b8f85fb9cb69d54f98039e38f9ff471330f116 100644 (file)
@@ -69,6 +69,7 @@ SET_SUBSYS(osd);
 
 namespace {
   static constexpr int TICK_INTERVAL = 1;
+  static constexpr int TRIM_QLENGTHS_UPDATE_PERIOD = 5;
 }
 
 using std::make_unique;
@@ -122,6 +123,15 @@ OSD::OSD(int id, uint32_t nonce,
       ).then([this] {
        update_stats();
         mgrc->update_daemon_health(get_health_metrics());
+       if (++trim_queue_length_countdown >= TRIM_QLENGTHS_UPDATE_PERIOD) {
+         trim_queue_length_countdown = 0;
+         std::ignore = pg_shard_manager.calc_snap_trim_queue_total(
+         ).then([this](uint64_t total) {
+           LOG_PREFIX(OSD::tick);
+           snap_trim_queue_total = total;
+           DEBUG("snap_trim_queue_total: {}", total);
+         });
+       }
        tick_timer.arm(
          std::chrono::seconds(TICK_INTERVAL));
       });
index 730336e6bff99bad5ad2acb2f25dd42b538c3c3a..703ccd3ae5ea5b74d6722dd104c5e0723ad1afb8 100644 (file)
@@ -127,6 +127,10 @@ class OSD final : public crimson::net::Dispatcher,
 
   std::unique_ptr<Heartbeat> heartbeat;
   seastar::timer<seastar::lowres_clock> tick_timer;
+  uint_fast16_t trim_queue_length_countdown = 0;
+  /// caching the total snap trim queue length across all PGs,
+  /// updated periodically by the tick_timer
+  uint64_t snap_trim_queue_total = 0;
 
   seastar::timer<seastar::lowres_clock> stats_timer;
   std::vector<ShardServices::shard_stats_t> shard_stats;
index e9563e63b687bc620b4e49b1191d10be081e3ec7..6467f221a08cf80c9a84c88e738f0144f0eea9b9 100644 (file)
@@ -117,4 +117,16 @@ seastar::future<> PGShardManager::set_superblock(OSDSuperblock superblock) {
   });
 }
 
+seastar::future<uint64_t>
+PGShardManager::calc_snap_trim_queue_total() const
+{
+  uint64_t total = 0;
+  co_await for_each_pg([&total](const auto&, const auto &pg) {
+    if (pg->is_primary()) {
+      total += pg->get_snap_trimq_size();
+    }
+  });
+  co_return total;
+}
+
 }
index 04ab77ee5d00ccdf9251f3cc85bc2ce847c1e988..fcc16ef1ec5049a0a58df85e7241fa76ac15461e 100644 (file)
@@ -337,6 +337,8 @@ public:
       });
   }
 
+  seastar::future<uint64_t> calc_snap_trim_queue_total() const;
+
   /**
    * for_each_pgid
    *