|
@@ -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
|