]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttle: Turn off throttle based on max bytes
authorSomnath Roy <somnath.roy@sandisk.com>
Wed, 22 Jan 2014 18:49:50 +0000 (10:49 -0800)
committerGreg Farnum <greg@inktank.com>
Fri, 31 Jan 2014 23:54:40 +0000 (15:54 -0800)
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 <somnath.roy@sandisk.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
src/common/Throttle.cc

index a2b96979d832ee22385bb78752eedc89ed6727a7..026d731e839b59a2ede30442602beb7710d43fce 100644 (file)
@@ -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);