Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7083d037 authored by Gao feng's avatar Gao feng Committed by Tejun Heo
Browse files

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: default avatarGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 879a3d9d
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -1349,14 +1349,21 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
		goto out_unlock;
	}

	/*
	 * Clear out the files of subsystems that should be removed, do
	 * this before rebind_subsystems, since rebind_subsystems may
	 * change this hierarchy's subsys_list.
	 */
	cgroup_clear_directory(cgrp->dentry, false, removed_mask);

	ret = rebind_subsystems(root, opts.subsys_mask);
	if (ret) {
		/* rebind_subsystems failed, re-populate the removed files */
		cgroup_populate_dir(cgrp, false, removed_mask);
		drop_parsed_module_refcounts(opts.subsys_mask);
		goto out_unlock;
	}

	/* clear out any existing files and repopulate subsystem files */
	cgroup_clear_directory(cgrp->dentry, false, removed_mask);
	/* re-populate subsystem files */
	cgroup_populate_dir(cgrp, false, added_mask);