]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/throttle: start using 64-bit values 19995/head
authorIgor Fedotov <ifedotov@suse.com>
Wed, 3 Jan 2018 11:16:19 +0000 (14:16 +0300)
committerPrashant D <pdhange@redhat.com>
Tue, 23 Jan 2018 11:29:13 +0000 (06:29 -0500)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(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
src/common/Throttle.h

index 1d84be68d4f183641f951b9510697f56d04ebe9d..3c25b557ff975c33b0ba69f502ae86056aafc730 100644 (file)
@@ -81,8 +81,9 @@ Throttle::~Throttle()
 
 void Throttle::_reset_max(int64_t m)
 {
+  // lock must be held.
   assert(lock.is_locked());
-  if (static_cast<int64_t>(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<int64_t>(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);
index efc5ba037ae80e0b918641ff0702979118a684c6..0b02c68ef36349c0f81b6e2b93a838172caf5f90 100644 (file)
@@ -30,7 +30,7 @@ class Throttle {
   CephContext *cct;
   const std::string name;
   PerfCounters *logger;
-  std::atomic<unsigned> count = { 0 }, max = { 0 };
+  std::atomic<int64_t> count = { 0 }, max = { 0 };
   Mutex lock;
   list<Cond*> cond;
   const bool use_perf;