From 7216f230ea6c888417b9a12bbf163f0033d23fcd Mon Sep 17 00:00:00 2001 From: KAMEZAWA Hiroyuki Date: Fri, 25 Jul 2008 01:47:19 -0700 Subject: [PATCH] --- yaml --- r: 105910 b: refs/heads/master c: 12b9804419cfb1c1bdac413f6c373af3b88d154b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/linux/res_counter.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 79dfcbb65889..a3b733a74ced 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cede86acd8bd5d2205dec28db8ac86410a3a19e8 +refs/heads/master: 12b9804419cfb1c1bdac413f6c373af3b88d154b diff --git a/trunk/include/linux/res_counter.h b/trunk/include/linux/res_counter.h index 290205dfe094..fdeadd9740dc 100644 --- a/trunk/include/linux/res_counter.h +++ b/trunk/include/linux/res_counter.h @@ -158,4 +158,20 @@ static inline void res_counter_reset_failcnt(struct res_counter *cnt) cnt->failcnt = 0; spin_unlock_irqrestore(&cnt->lock, flags); } + +static inline int res_counter_set_limit(struct res_counter *cnt, + unsigned long long limit) +{ + unsigned long flags; + int ret = -EBUSY; + + spin_lock_irqsave(&cnt->lock, flags); + if (cnt->usage < limit) { + cnt->limit = limit; + ret = 0; + } + spin_unlock_irqrestore(&cnt->lock, flags); + return ret; +} + #endif