From: Somnath Roy Date: Wed, 22 Jan 2014 18:49:50 +0000 (-0800) Subject: Throttle: Turn off throttle based on max bytes X-Git-Tag: v0.78~231^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=98ae0592ed04183b870d8b1a67db5b982400fa68;p=ceph.git Throttle: Turn off throttle based on max bytes If max throttle bytes is 0, throttle should not be doing anything. This check is introduced in the beginning of each throttle function Signed-off-by: Somnath Roy Signed-off-by: Greg Farnum --- diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index a2b96979d832..026d731e839b 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -124,6 +124,10 @@ bool Throttle::_wait(int64_t c) bool Throttle::wait(int64_t m) { + if (0 == max.read()) { + return false; + } + Mutex::Locker l(lock); if (m) { assert(m > 0); @@ -135,6 +139,9 @@ bool Throttle::wait(int64_t m) int64_t Throttle::take(int64_t c) { + if (0 == max.read()) { + return 0; + } assert(c >= 0); ldout(cct, 10) << "take " << c << dendl; { @@ -151,6 +158,10 @@ int64_t Throttle::take(int64_t c) bool Throttle::get(int64_t c, int64_t m) { + if (0 == max.read()) { + return false; + } + assert(c >= 0); ldout(cct, 10) << "get " << c << " (" << count.read() << " -> " << (count.read() + c) << ")" << dendl; bool waited = false; @@ -176,6 +187,10 @@ bool Throttle::get(int64_t c, int64_t m) */ bool Throttle::get_or_fail(int64_t c) { + if (0 == max.read()) { + return true; + } + assert (c >= 0); Mutex::Locker l(lock); if (_should_wait(c) || !cond.empty()) { @@ -199,6 +214,10 @@ bool Throttle::get_or_fail(int64_t c) int64_t Throttle::put(int64_t c) { + if (0 == max.read()) { + return 0; + } + assert(c >= 0); ldout(cct, 10) << "put " << c << " (" << count.read() << " -> " << (count.read()-c) << ")" << dendl; Mutex::Locker l(lock);