aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorGao feng <gaofeng@cn.fujitsu.com>2012-12-02 20:28:18 -0500
committerTejun Heo <tj@kernel.org>2012-12-03 11:33:11 -0500
commit7083d0378a1746f2b45729cae494c6b92e75d73f (patch)
treebc2a732ffe1e9b4337a55b3fb7cc215a27159053 /kernel/cgroup.c
parent879a3d9dbbde823ac77d39131e7a287f31b8296f (diff)
cgroup: remove subsystem files when remounting cgroup
cgroup_clear_directroy is called by cgroup_d_remove_dir and cgroup_remount. when we call cgroup_remount to remount the cgroup,the subsystem may be unlinked from cgroupfs_root->subsys_list in rebind_subsystem,this subsystem's files will not be removed in cgroup_clear_directroy. And the system will panic when we try to access these files. this patch removes subsystems's files before rebind_subsystems, if rebind_subsystems failed, repopulate these removed files. With help from Tejun. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e1293a9189b6..5cc37241a6fb 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1349,14 +1349,21 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1349 goto out_unlock; 1349 goto out_unlock;
1350 } 1350 }
1351 1351
1352 /*
1353 * Clear out the files of subsystems that should be removed, do
1354 * this before rebind_subsystems, since rebind_subsystems may
1355 * change this hierarchy's subsys_list.
1356 */
1357 cgroup_clear_directory(cgrp->dentry, false, removed_mask);
1358
1352 ret = rebind_subsystems(root, opts.subsys_mask); 1359 ret = rebind_subsystems(root, opts.subsys_mask);
1353 if (ret) { 1360 if (ret) {
1361 /* rebind_subsystems failed, re-populate the removed files */
1362 cgroup_populate_dir(cgrp, false, removed_mask);
1354 drop_parsed_module_refcounts(opts.subsys_mask); 1363 drop_parsed_module_refcounts(opts.subsys_mask);
1355 goto out_unlock; 1364 goto out_unlock;
1356 } 1365 }
1357 1366
1358 /* clear out any existing files and repopulate subsystem files */
1359 cgroup_clear_directory(cgrp->dentry, false, removed_mask);
1360 /* re-populate subsystem files */ 1367 /* re-populate subsystem files */
1361 cgroup_populate_dir(cgrp, false, added_mask); 1368 cgroup_populate_dir(cgrp, false, added_mask);
1362 1369