Skip to content

Commit

Permalink
cgroup: use cgroup_addrm_files() in cgroup_clear_directory()
Browse files Browse the repository at this point in the history
cgroup_clear_directory() incorrectly invokes cgroup_rm_file() on each
cftset of the target subsystems, which only removes the first file of
each set.  This leaves dangling files after subsystems are removed
from a cgroup root via remount.

Use cgroup_addrm_files() to remove all files of target subsystems.

tj: Move cgroup_addrm_files() prototype decl upwards next to other
    global declarations.  Commit message updated.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Gao feng authored and Tejun Heo committed Nov 30, 2012
1 parent 1f869e8 commit 879a3d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ static DEFINE_SPINLOCK(hierarchy_id_lock);
static int need_forkexit_callback __read_mostly;

static int cgroup_destroy_locked(struct cgroup *cgrp);
static int cgroup_addrm_files(struct cgroup *cgrp, struct cgroup_subsys *subsys,
struct cftype cfts[], bool is_add);

#ifdef CONFIG_PROVE_LOCKING
int cgroup_lock_is_held(void)
Expand Down Expand Up @@ -964,7 +966,7 @@ static void cgroup_clear_directory(struct dentry *dir, bool base_files,
if (!test_bit(ss->subsys_id, &subsys_mask))
continue;
list_for_each_entry(set, &ss->cftsets, node)
cgroup_rm_file(cgrp, set->cfts);
cgroup_addrm_files(cgrp, NULL, set->cfts, false);
}
if (base_files) {
while (!list_empty(&cgrp->files))
Expand Down

0 comments on commit 879a3d9

Please sign in to comment.