]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttle: complete all m_blockers when we set average or max to 0 24965/head
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Tue, 13 Nov 2018 06:45:27 +0000 (01:45 -0500)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Tue, 13 Nov 2018 06:45:43 +0000 (01:45 -0500)
When we change the average or max to 0, we need to complete all m_blockers
first.

Fixes: http://tracker.ceph.com/issues/36715
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/common/Throttle.cc
src/common/Throttle.h

index f3a3bd02f9b843380d686b3107ee038be5149ae5..d933a86f333d5d83d84ad54bf63d8c2214fbad1e 100644 (file)
@@ -793,6 +793,8 @@ void TokenBucketThrottle::add_tokens() {
     std::lock_guard<Mutex> lock(m_lock);
     // put tokens into bucket.
     m_throttle.put(tokens_this_tick());
+    if (0 == m_avg || 0 == m_throttle.max)
+      tmp_blockers.swap(m_blockers);
     // check the m_blockers from head to tail, if blocker can get
     // enough tokens, let it go.
     while (!m_blockers.empty()) {
index f24c1a03656b4c5e79605b5b59bbaa9f93c1588a..adacb0a5cc365fa79422bf88ae21228ab063deac 100644 (file)
@@ -422,9 +422,9 @@ public:
   
   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 == m_avg)
+    if (0 == c)
       return false;
-  
+
     bool wait = false;
     uint64_t got = 0;
     std::lock_guard<Mutex> lock(m_lock);
@@ -432,6 +432,9 @@ public:
       // Keep the order of requests, add item after previous blocked requests.
       wait = true;
     } 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.