]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/WorkQueue: allow io priority to be set for wq
authorSage Weil <sage@redhat.com>
Wed, 18 Jun 2014 18:02:09 +0000 (11:02 -0700)
committerSage Weil <sage@redhat.com>
Thu, 14 Aug 2014 00:21:18 +0000 (17:21 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit dd6badcb5eedfec6748b3e6ca4d46e3b266038f6)

Conflicts:

src/common/WorkQueue.cc

src/common/WorkQueue.cc
src/common/WorkQueue.h

index f47435bf3abc680e7c21b470331be7dcb44f70ce..42f402fe13bf598c46c02e7be205dad7fc7665d3 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "include/types.h"
 #include "include/utime.h"
+#include "common/errno.h"
 #include "WorkQueue.h"
 
 #include "common/config.h"
@@ -33,6 +34,8 @@ ThreadPool::ThreadPool(CephContext *cct_, string nm, int n, const char *option)
     _stop(false),
     _pause(0),
     _draining(0),
+    ioprio_class(-1),
+    ioprio_priority(-1),
     _num_threads(n),
     last_work_queue(0),
     processing(0)
@@ -156,6 +159,11 @@ void ThreadPool::start_threads()
     WorkThread *wt = new WorkThread(this);
     ldout(cct, 10) << "start_threads creating and starting " << wt << dendl;
     _threads.insert(wt);
+
+    int r = wt->set_ioprio(ioprio_class, ioprio_priority);
+    if (r < 0)
+      lderr(cct) << " set_ioprio got " << cpp_strerror(r) << dendl;
+
     wt->create();
   }
 }
@@ -255,3 +263,16 @@ void ThreadPool::drain(WorkQueue_* wq)
   _lock.Unlock();
 }
 
+void ThreadPool::set_ioprio(int cls, int priority)
+{
+  Mutex::Locker l(_lock);
+  ioprio_class = cls;
+  ioprio_priority = priority;
+  for (set<WorkThread*>::iterator p = _threads.begin();
+       p != _threads.end();
+       ++p) {
+    int r = (*p)->set_ioprio(cls, priority);
+    if (r < 0)
+      lderr(cct) << " set_ioprio got " << cpp_strerror(r) << dendl;
+  }
+}
index 794b577a71dabc828071f4999ec0fc16bb61f7e2..cbf49a8bb2e5fedd812a1e0ca60c03089e854f36 100644 (file)
@@ -33,6 +33,7 @@ class ThreadPool : public md_config_obs_t {
   int _pause;
   int _draining;
   Cond _wait_cond;
+  int ioprio_class, ioprio_priority;
 
 public:
   class TPHandle {
@@ -388,6 +389,9 @@ public:
   void unpause();
   /// wait for all work to complete
   void drain(WorkQueue_* wq = 0);
+
+  /// set io priority
+  void set_ioprio(int cls, int priority);
 };
 
 class GenContextWQ :