]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/AsyncReserver: add a min_priority knob
authorSage Weil <sage@inktank.com>
Tue, 17 Jun 2014 20:04:18 +0000 (13:04 -0700)
committerSage Weil <sage@inktank.com>
Tue, 17 Jun 2014 21:35:23 +0000 (14:35 -0700)
To do reserve items that are < the min priority.  Default to 0.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/AsyncReserver.h

index 111db3f26af6f7ea20256ccc354c42c0ad868dcf..fa49cfab8b42daf8bca69bd1fa3847887398ba31 100644 (file)
@@ -33,6 +33,7 @@ template <typename T>
 class AsyncReserver {
   Finisher *f;
   unsigned max_allowed;
+  unsigned min_priority;
   Mutex lock;
 
   map<unsigned, list<pair<T, Context*> > > queues;
@@ -42,7 +43,9 @@ class AsyncReserver {
   void do_queues() {
     typename map<unsigned, list<pair<T, Context*> > >::reverse_iterator it;
     for (it = queues.rbegin();
-         it != queues.rend() && in_progress.size() < max_allowed;
+         it != queues.rend() &&
+          in_progress.size() < max_allowed &&
+          it->first >= min_priority;
          ++it) {
       while (in_progress.size() < max_allowed &&
              !it->second.empty()) {
@@ -57,8 +60,12 @@ class AsyncReserver {
 public:
   AsyncReserver(
     Finisher *f,
-    unsigned max_allowed)
-    : f(f), max_allowed(max_allowed), lock("AsyncReserver::lock") {}
+    unsigned max_allowed,
+    unsigned min_priority = 0)
+    : f(f),
+      max_allowed(max_allowed),
+      min_priority(min_priority),
+      lock("AsyncReserver::lock") {}
 
   void set_max(unsigned max) {
     Mutex::Locker l(lock);
@@ -66,6 +73,12 @@ public:
     do_queues();
   }
 
+  void set_min_priority(unsigned min) {
+    Mutex::Locker l(lock);
+    min_priority = min;
+    do_queues();
+  }
+
   /**
    * Requests a reservation
    *