]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
WBThrottle:Draw a common func beyond_limit which whether beyond limit.
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 23 Dec 2014 03:43:46 +0000 (11:43 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 23 Dec 2014 03:43:46 +0000 (11:43 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/WBThrottle.cc
src/os/WBThrottle.h

index 7bf5fcc87cb238d238677e96a610b989409643ae..795033aca26e8bc59729b5eca4da7f5b496d52f7 100644 (file)
@@ -135,10 +135,7 @@ bool WBThrottle::get_next_should_flush(
 {
   assert(lock.is_locked());
   assert(next);
-  while (!stopping &&
-         cur_ios < io_limits.first &&
-         pending_wbs.size() < fd_limits.first &&
-         cur_size < size_limits.first)
+  while (!stopping && !beyond_limit())
          cond.Wait(lock);
   if (stopping)
     return false;
@@ -212,9 +209,7 @@ void WBThrottle::queue_wb(
 
   wbiter->second.first.add(nocache, len, 1);
   insert_object(hoid);
-  if (!(cur_ios < io_limits.first &&
-      pending_wbs.size() < fd_limits.first &&
-      cur_size < size_limits.first))
+  if (beyond_limit())
     cond.Signal();
 }
 
@@ -267,10 +262,7 @@ void WBThrottle::clear_object(const ghobject_t &hoid)
 void WBThrottle::throttle()
 {
   Mutex::Locker l(lock);
-  while (!stopping && !(
-          cur_ios < io_limits.second &&
-          pending_wbs.size() < fd_limits.second &&
-          cur_size < size_limits.second)) {
+  while (!stopping && beyond_limit()) {
     cond.Wait(lock);
   }
 }
index f643e39fad88c2bbfb03c6c255da0ccaa5cbaf59..f1a5c740bfeb89c75198e77f7f8433c6a3cac72e 100644 (file)
@@ -130,6 +130,15 @@ private:
   FS fs;
 
   void set_from_conf();
+  bool beyond_limit() const {
+    if (cur_ios < io_limits.first &&
+       pending_wbs.size() < fd_limits.first &&
+       cur_size < size_limits.first)
+      return false;
+    else
+      return true;
+  }
+
 public:
   WBThrottle(CephContext *cct);
   ~WBThrottle();