]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: allow "0" cost items to be queued by TokenBucketThrottle
authorMykola Golub <mgolub@suse.com>
Thu, 14 Mar 2019 18:30:31 +0000 (18:30 +0000)
committerMykola Golub <mgolub@suse.com>
Thu, 14 Mar 2019 19:25:08 +0000 (19:25 +0000)
They will be queued if there are already blockers.

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/common/Throttle.h

index f382140e8bfb9fa996a69f5ea9262d9defdf6dc6..1a6acac59d3cc48c417cd7c4dd7b9727a467cc1a 100644 (file)
@@ -410,7 +410,7 @@ public:
   TokenBucketThrottle(CephContext *cct, const std::string &name,
                       uint64_t capacity, uint64_t avg,
                       SafeTimer *timer, Mutex *timer_lock);
-  
+
   ~TokenBucketThrottle();
 
   const std::string &get_name() {
@@ -424,12 +424,9 @@ public:
       });
     m_blockers.emplace_back(c, ctx);
   }
-  
+
   template <typename T, typename I, void(T::*MF)(int, I*, uint64_t)>
   bool get(uint64_t c, T *handler, I *item, uint64_t flag) {
-    if (0 == c)
-      return false;
-
     bool wait = false;
     uint64_t got = 0;
     std::lock_guard lock(m_lock);
@@ -439,7 +436,7 @@ public:
     } else {
       if (0 == m_throttle.max || 0 == m_avg)
         return false;
-  
+
       got = m_throttle.get(c);
       if (got < c) {
         // Not enough tokens, add a blocker for it.
@@ -452,7 +449,7 @@ public:
 
     return wait;
   }
-  
+
   int set_limit(uint64_t average, uint64_t burst);
   void set_schedule_tick_min(uint64_t tick);