]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
throttle: allow large items if we're under our max
authorSage Weil <sage@newdream.net>
Fri, 14 May 2010 17:44:00 +0000 (10:44 -0700)
committerSage Weil <sage@newdream.net>
Mon, 17 May 2010 21:53:59 +0000 (14:53 -0700)
Normally we stay under max, but for large items, take it as long as we're
currently below max.  This avoids deadlock.

src/common/Throttle.h

index 4fe547c9f7d35264f21fcd493554e8abe6cf3172..f05ae377018d130b0f23fbd366acc130b6abb66f 100644 (file)
@@ -19,14 +19,20 @@ private:
       cond.SignalOne();
     max = m;
   }
+  bool _should_wait(uint64_t c) {
+    return
+      max &&
+      ((c < max && count + c > max) ||   // normally stay under max
+       (c >= max && count > max));       // except for large c
+  }
   bool _wait(uint64_t c) {
     bool waited = false;
-    if (max && count + c > max) {    
+    if (_should_wait(c)) {
       waiting += c;
-      while (max && count + c > max) {
+      do {
        waited = true;
        cond.Wait(lock);
-      }
+      } while (_should_wait(c));
       waiting -= c;
 
       // wake up the next guy