提交 bee55099 编写于 作者: T Tejun Heo

cgroup: update error handling in cgroup_populate_dir()

cgroup_populate_dir() didn't use to check whether the actual file
creations were successful and could return success with only subset of
the requested files created, which is nasty.

This patch udpates cgroup_populate_dir() so that it either succeeds
with all files or fails with no file.

v2: The original patch also converted for_each_root_subsys() usages to
    for_each_subsys() without explaining why.  That part has been
    moved to a separate patch.
Signed-off-by: NTejun Heo <tj@kernel.org>
Acked-by: NLi Zefan <lizefan@huawei.com>
上级 628f7cd4
...@@ -4171,10 +4171,13 @@ static struct cftype cgroup_base_files[] = { ...@@ -4171,10 +4171,13 @@ static struct cftype cgroup_base_files[] = {
* cgroup_populate_dir - create subsys files in a cgroup directory * cgroup_populate_dir - create subsys files in a cgroup directory
* @cgrp: target cgroup * @cgrp: target cgroup
* @subsys_mask: mask of the subsystem ids whose files should be added * @subsys_mask: mask of the subsystem ids whose files should be added
*
* On failure, no file is added.
*/ */
static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask) static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask)
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int ret = 0;
/* process cftsets of each subsystem */ /* process cftsets of each subsystem */
for_each_root_subsys(cgrp->root, ss) { for_each_root_subsys(cgrp->root, ss) {
...@@ -4182,8 +4185,11 @@ static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask) ...@@ -4182,8 +4185,11 @@ static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask)
if (!test_bit(ss->subsys_id, &subsys_mask)) if (!test_bit(ss->subsys_id, &subsys_mask))
continue; continue;
list_for_each_entry(set, &ss->cftsets, node) list_for_each_entry(set, &ss->cftsets, node) {
cgroup_addrm_files(cgrp, ss, set->cfts, true); ret = cgroup_addrm_files(cgrp, ss, set->cfts, true);
if (ret < 0)
goto err;
}
} }
/* This cgroup is ready now */ /* This cgroup is ready now */
...@@ -4201,6 +4207,9 @@ static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask) ...@@ -4201,6 +4207,9 @@ static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask)
} }
return 0; return 0;
err:
cgroup_clear_dir(cgrp, subsys_mask);
return ret;
} }
static void css_dput_fn(struct work_struct *work) static void css_dput_fn(struct work_struct *work)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册