diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/res_counter.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h index 290205dfe094..fdeadd9740dc 100644 --- a/include/linux/res_counter.h +++ b/include/linux/res_counter.h | |||
@@ -158,4 +158,20 @@ static inline void res_counter_reset_failcnt(struct res_counter *cnt) | |||
158 | cnt->failcnt = 0; | 158 | cnt->failcnt = 0; |
159 | spin_unlock_irqrestore(&cnt->lock, flags); | 159 | spin_unlock_irqrestore(&cnt->lock, flags); |
160 | } | 160 | } |
161 | |||
162 | static inline int res_counter_set_limit(struct res_counter *cnt, | ||
163 | unsigned long long limit) | ||
164 | { | ||
165 | unsigned long flags; | ||
166 | int ret = -EBUSY; | ||
167 | |||
168 | spin_lock_irqsave(&cnt->lock, flags); | ||
169 | if (cnt->usage < limit) { | ||
170 | cnt->limit = limit; | ||
171 | ret = 0; | ||
172 | } | ||
173 | spin_unlock_irqrestore(&cnt->lock, flags); | ||
174 | return ret; | ||
175 | } | ||
176 | |||
161 | #endif | 177 | #endif |