]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: mark ThrottleReleaser [[nodiscard]] 69697/head
authorKefu Chai <k.chai@proxmox.com>
Wed, 24 Jun 2026 10:10:41 +0000 (18:10 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 24 Jun 2026 10:22:09 +0000 (18:22 +0800)
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 <k.chai@proxmox.com>
src/crimson/osd/osd_operation.h

index 000cf4057efb20a9dc800b1c6f3bc6b541976fdf..e41cc1abf525eaf240d5b2cf73c7b3ab34bcbba3 100644 (file)
@@ -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) {}