memcg: fix error path of mem_cgroup_move_parent
authorDaisuke Nishimura <[email protected]>
Thu, 15 Jan 2009 21:51:12 +0000 (13:51 -0800)
committerLinus Torvalds <[email protected]>
Fri, 16 Jan 2009 00:39:39 +0000 (16:39 -0800)
commit40d58138f832a48208cdce57d6572a033b1f7a23
tree740c3ccefa96965cb5e27f4b13dc1e03e6f688a3
parentbd112db872c2f69993c86f458467acb4a14da010
memcg: fix error path of mem_cgroup_move_parent

There is a bug in error path of mem_cgroup_move_parent.

Extra refcnt got from try_charge should be dropped, and usages incremented
by try_charge should be decremented in both error paths:

    A: failure at get_page_unless_zero
    B: failure at isolate_lru_page

This bug makes this parent directory unremovable.

In case of A, rmdir doesn't return, because res.usage doesn't go down to 0
at mem_cgroup_force_empty even after all the pc in lru are removed.

In case of B, rmdir fails and returns -EBUSY, because it has extra ref
counts even after res.usage goes down to 0.

Signed-off-by: Daisuke Nishimura <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Acked-by: Balbir Singh <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Paul Menage <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memcontrol.c