From d3df37a61ba6bccdd1b88effb060680bea5d1a40 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 24 Jun 2026 18:10:41 +0800 Subject: [PATCH] crimson/osd: mark ThrottleReleaser [[nodiscard]] OperationThrottler::get_throttle() returns a ThrottleReleaser guard whose destructor calls release_throttle(), the mClock RequestCompletion that decrements in_progress. The guard has to be held for the whole operation: a caller that discards it at acquisition releases the slot in the same step, so the operation never counts against max_in_progress and the throttle does nothing. Mark the type [[nodiscard]] so the compiler flags a discarded co_await of get_throttle(). Signed-off-by: Kefu Chai --- src/crimson/osd/osd_operation.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/crimson/osd/osd_operation.h b/src/crimson/osd/osd_operation.h index 000cf4057ef..e41cc1abf52 100644 --- a/src/crimson/osd/osd_operation.h +++ b/src/crimson/osd/osd_operation.h @@ -376,7 +376,11 @@ public: return !max_in_progress || in_progress < max_in_progress; } - class ThrottleReleaser { + // The returned guard's destructor is the mClock RequestCompletion + // (release_throttle), so it must be held for the throttled operation's whole + // lifetime. Dropping it at acquisition frees the slot immediately and the + // operation never counts against max_in_progress. + class [[nodiscard("discarding the guard releases the throttle slot immediately")]] ThrottleReleaser { OperationThrottler *parent = nullptr; public: ThrottleReleaser(OperationThrottler *parent) : parent(parent) {} -- 2.47.3