From: Ronen Friedman Date: Wed, 29 Apr 2026 04:14:23 +0000 (+0000) Subject: crimson/osd: collect total snap-trim queueus length X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5e4908a02d8a42cbdbb9a7876fd35621f811eb08;p=ceph.git crimson/osd: collect total snap-trim queueus length 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 --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 1ba7669fef6c..77b8f85fb9cb 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -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)); }); diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 730336e6bff9..703ccd3ae5ea 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -127,6 +127,10 @@ class OSD final : public crimson::net::Dispatcher, std::unique_ptr heartbeat; seastar::timer 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 stats_timer; std::vector shard_stats; diff --git a/src/crimson/osd/pg_shard_manager.cc b/src/crimson/osd/pg_shard_manager.cc index e9563e63b687..6467f221a08c 100644 --- a/src/crimson/osd/pg_shard_manager.cc +++ b/src/crimson/osd/pg_shard_manager.cc @@ -117,4 +117,16 @@ seastar::future<> PGShardManager::set_superblock(OSDSuperblock superblock) { }); } +seastar::future +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; +} + } diff --git a/src/crimson/osd/pg_shard_manager.h b/src/crimson/osd/pg_shard_manager.h index 04ab77ee5d00..fcc16ef1ec50 100644 --- a/src/crimson/osd/pg_shard_manager.h +++ b/src/crimson/osd/pg_shard_manager.h @@ -337,6 +337,8 @@ public: }); } + seastar::future calc_snap_trim_queue_total() const; + /** * for_each_pgid *