From: Dongsheng Yang Date: Tue, 13 Nov 2018 06:45:27 +0000 (-0500) Subject: Throttle: complete all m_blockers when we set average or max to 0 X-Git-Tag: v14.1.0~846^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c13d8835fc0fe24770f80f28f396ab2bbbf262c4;p=ceph.git Throttle: complete all m_blockers when we set average or max to 0 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 --- diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index f3a3bd02f9b8..d933a86f333d 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -793,6 +793,8 @@ void TokenBucketThrottle::add_tokens() { std::lock_guard 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()) { diff --git a/src/common/Throttle.h b/src/common/Throttle.h index f24c1a03656b..adacb0a5cc36 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -422,9 +422,9 @@ public: template 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 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.