Commit 11d55d2c authored by Li Zefan's avatar Li Zefan Committed by Linus Torvalds

res_counter: fix off-by-one bug in setting limit

I found we can no longer set limit to 0 with 2.6.27-rcX:
 # mount -t cgroup -omemory xxx /mnt
 # mkdir /mnt/0
 # echo 0 > /mnt/0/memory.limit_in_bytes
 bash: echo: write error: Device or resource busy

It turned out 'limit' can't be set to 'usage', which is wrong IMO.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: default avatarBalbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7f621861
...@@ -166,7 +166,7 @@ static inline int res_counter_set_limit(struct res_counter *cnt, ...@@ -166,7 +166,7 @@ static inline int res_counter_set_limit(struct res_counter *cnt,
int ret = -EBUSY; int ret = -EBUSY;
spin_lock_irqsave(&cnt->lock, flags); spin_lock_irqsave(&cnt->lock, flags);
if (cnt->usage < limit) { if (cnt->usage <= limit) {
cnt->limit = limit; cnt->limit = limit;
ret = 0; ret = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment