Skip to content

Commit

Permalink
res_counter: fix off-by-one bug in setting limit
Browse files Browse the repository at this point in the history
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: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Li Zefan authored and Linus Torvalds committed Sep 5, 2008
1 parent 7f62186 commit 11d55d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/res_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static inline int res_counter_set_limit(struct res_counter *cnt,
int ret = -EBUSY;

spin_lock_irqsave(&cnt->lock, flags);
if (cnt->usage < limit) {
if (cnt->usage <= limit) {
cnt->limit = limit;
ret = 0;
}
Expand Down

0 comments on commit 11d55d2

Please sign in to comment.