Commit b420ba7d authored by Tejun Heo's avatar Tejun Heo

cgroup: use for_each_subsys() instead of for_each_root_subsys() in cgroup_populate/clear_dir()

rebind_subsystems() will be updated to handle file creations and
removals with proper error handling and to do that will need to
perform file operations before actually adding the subsystem to the
hierarchy.

To enable such usage, update cgroup_populate/clear_dir() to use
for_each_subsys() instead of for_each_root_subsys() so that they
operate on all subsystems specified by @subsys_mask whether that
subsystem is currently bound to the hierarchy or not.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
parent bee55099
...@@ -965,10 +965,12 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft) ...@@ -965,10 +965,12 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft)
static void cgroup_clear_dir(struct cgroup *cgrp, unsigned long subsys_mask) static void cgroup_clear_dir(struct cgroup *cgrp, unsigned long subsys_mask)
{ {
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
int i;
for_each_root_subsys(cgrp->root, ss) { for_each_subsys(ss, i) {
struct cftype_set *set; struct cftype_set *set;
if (!test_bit(ss->subsys_id, &subsys_mask))
if (!test_bit(i, &subsys_mask))
continue; continue;
list_for_each_entry(set, &ss->cftsets, node) list_for_each_entry(set, &ss->cftsets, node)
cgroup_addrm_files(cgrp, NULL, set->cfts, false); cgroup_addrm_files(cgrp, NULL, set->cfts, false);
...@@ -4177,12 +4179,13 @@ static struct cftype cgroup_base_files[] = { ...@@ -4177,12 +4179,13 @@ static struct cftype cgroup_base_files[] = {
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; int i, ret = 0;
/* process cftsets of each subsystem */ /* process cftsets of each subsystem */
for_each_root_subsys(cgrp->root, ss) { for_each_subsys(ss, i) {
struct cftype_set *set; struct cftype_set *set;
if (!test_bit(ss->subsys_id, &subsys_mask))
if (!test_bit(i, &subsys_mask))
continue; continue;
list_for_each_entry(set, &ss->cftsets, node) { list_for_each_entry(set, &ss->cftsets, node) {
......
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