From: Shiyang Ruan Date: Fri, 28 Sep 2018 06:33:13 +0000 (+0800) Subject: librbd: support burst limit configuration. X-Git-Tag: v14.1.0~946^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=761393a955799819c4681d64576e6f941daa05d5;p=ceph.git librbd: support burst limit configuration. Signed-off-by: Shiyang Ruan --- diff --git a/qa/suites/rbd/thrash/workloads/rbd_fsx_rate_limit.yaml b/qa/suites/rbd/thrash/workloads/rbd_fsx_rate_limit.yaml index 6e07e591f59..6d215c62b4b 100644 --- a/qa/suites/rbd/thrash/workloads/rbd_fsx_rate_limit.yaml +++ b/qa/suites/rbd/thrash/workloads/rbd_fsx_rate_limit.yaml @@ -7,3 +7,4 @@ overrides: conf: client: rbd qos iops limit: 50 + rbd qos iops burst: 100 diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 8349347cec8..015ee09c357 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -721,34 +721,25 @@ TokenBucketThrottle::~TokenBucketThrottle() { } } -int TokenBucketThrottle::set_burst(uint64_t burst){ - std::lock_guard lock(m_lock); - if (0 < burst && burst < m_avg) { - // the burst should never less than the average. - return -EINVAL; - } else { - m_burst = burst; - } - // for the default configuration of burst. - m_throttle.set_max(0 == m_burst ? m_avg : m_burst); - return 0; -} - -int TokenBucketThrottle::set_average(uint64_t avg) { +int TokenBucketThrottle::set_limit(uint64_t average, uint64_t burst) { { std::lock_guard lock(m_lock); - m_avg = avg; - if (0 < m_burst && m_burst < avg) { + if (0 < burst && burst < average) { // the burst should never less than the average. return -EINVAL; - } else if (0 == avg) { + } + + m_avg = average; + m_burst = burst; + + if (0 == average) { // The limit is not set, and no tokens will be put into the bucket. // So, we can schedule the timer slowly, or even cancel it. m_tick = 1000; } else { // calculate the tick(ms), don't less than the minimum. - m_tick = 1000 / avg; + m_tick = 1000 / average; if (m_tick < m_tick_min) { m_tick = m_tick_min; } @@ -758,9 +749,7 @@ int TokenBucketThrottle::set_average(uint64_t avg) { m_current_tick = 0; // for the default configuration of burst. - if (0 == m_burst) { - m_throttle.set_max(m_avg); - } + m_throttle.set_max(0 == burst ? average : burst); } // turn millisecond to second m_schedule_tick = m_tick / 1000.0; diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 96d55d13c2e..d66051c1b43 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -445,8 +445,7 @@ public: return wait; } - int set_burst(uint64_t burst); - int set_average(uint64_t avg); + int set_limit(uint64_t average, uint64_t burst); private: uint64_t tokens_filled(double tick); diff --git a/src/common/options.cc b/src/common/options.cc index ffed4884eff..7f75b07b719 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -6676,6 +6676,30 @@ static std::vector