From 07a122a3fda26c7b65ecf0879f24a8380568b47f Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 3 Jan 2018 14:16:19 +0300 Subject: [PATCH] common/throttle: start using 64-bit values Signed-off-by: Igor Fedotov (cherry picked from commit fa37ed1a48fd804ac199509bd78c470480ecbb22) Conflicts: src/common/Throttle.cc : Resolved in _reset_max and put func src/common/Throttle.h : Retained only count var changes --- src/common/Throttle.cc | 6 ++++-- src/common/Throttle.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 1d84be68d4f1..3c25b557ff97 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -81,8 +81,9 @@ Throttle::~Throttle() void Throttle::_reset_max(int64_t m) { + // lock must be held. assert(lock.is_locked()); - if (static_cast(max) == m) + if (max == m) return; if (!cond.empty()) cond.front()->SignalOne(); @@ -229,7 +230,8 @@ int64_t Throttle::put(int64_t c) if (c) { if (!cond.empty()) cond.front()->SignalOne(); - assert(static_cast(count) >= c); // if count goes negative, we failed somewhere! + // if count goes negative, we failed somewhere! + assert(count >= c); count -= c; if (logger) { logger->inc(l_throttle_put); diff --git a/src/common/Throttle.h b/src/common/Throttle.h index efc5ba037ae8..0b02c68ef363 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -30,7 +30,7 @@ class Throttle { CephContext *cct; const std::string name; PerfCounters *logger; - std::atomic count = { 0 }, max = { 0 }; + std::atomic count = { 0 }, max = { 0 }; Mutex lock; list cond; const bool use_perf; -- 2.47.3