From: Jianpeng Ma Date: Tue, 23 Dec 2014 03:43:46 +0000 (+0800) Subject: WBThrottle:Draw a common func beyond_limit which whether beyond limit. X-Git-Tag: v9.0.2~94^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=573d2cc6dc52158bcdb00f0c001518603b9bfed6;p=ceph.git WBThrottle:Draw a common func beyond_limit which whether beyond limit. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/WBThrottle.cc b/src/os/WBThrottle.cc index 7bf5fcc87cb2..795033aca26e 100644 --- a/src/os/WBThrottle.cc +++ b/src/os/WBThrottle.cc @@ -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); } } diff --git a/src/os/WBThrottle.h b/src/os/WBThrottle.h index f643e39fad88..f1a5c740bfeb 100644 --- a/src/os/WBThrottle.h +++ b/src/os/WBThrottle.h @@ -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();