cgroup: move number_of_cgroups test out of rebind_subsystems() into cgroup_remount()
authorTejun Heo <tj@kernel.org>
Sat, 29 Jun 2013 00:07:30 +0000 (17:07 -0700)
committerTejun Heo <tj@kernel.org>
Fri, 12 Jul 2013 19:34:02 +0000 (12:34 -0700)
rebind_subsystems() currently fails if the hierarchy has any !root
cgroups; however, on the planned unified hierarchy,
rebind_subsystems() will be used while populated.  Move the test to
cgroup_remount(), which is the only place the test is necessary
anyway.

As it's impossible for the other two callers of rebind_subsystems() to
have populated hierarchy, this doesn't make any behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
kernel/cgroup.c

index 4ec8d2da94d1b0c2e6f71ace65d7127608fd5736..c108d3d1ea306af2b19b638dd1e60045213b6f9c 100644 (file)
@@ -1021,13 +1021,6 @@ static int rebind_subsystems(struct cgroupfs_root *root,
                }
        }
 
-       /* Currently we don't handle adding/removing subsystems when
-        * any child cgroups exist. This is theoretically supportable
-        * but involves complex error handling, so it's being left until
-        * later */
-       if (root->number_of_cgroups > 1)
-               return -EBUSY;
-
        ret = cgroup_populate_dir(cgrp, added_mask);
        if (ret)
                return ret;
@@ -1373,6 +1366,12 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
                goto out_unlock;
        }
 
+       /* remounting is not allowed for populated hierarchies */
+       if (root->number_of_cgroups > 1) {
+               ret = -EBUSY;
+               goto out_unlock;
+       }
+
        ret = rebind_subsystems(root, added_mask, removed_mask);
        if (ret)
                goto out_unlock;