[PATCH v3 6/9] cgroup: make rebind_subsystems() handle file additions and removals with proper error handling

Li Zefan lizefan at huawei.com
Fri Jul 12 06:13:40 UTC 2013


On 2013/7/12 1:20, Tejun Heo wrote:
>>From 705da98c48f39ebe565439353a5b35a0bab08b23 Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj at kernel.org>
> Date: Fri, 28 Jun 2013 17:07:30 -0700
> 
> Currently, creating and removing cgroup files in the root directory
> are handled separately from the actual subsystem binding and unbinding
> which happens in rebind_subsystems().  Also, rebind_subsystems() users
> aren't handling file creation errors properly.  Let's integrate
> top_cgroup file handling into rebind_subsystems() so that it's simpler
> to use and everyone handles file creation errors correctly.
> 
> * On a successful return, rebind_subsystems() is guaranteed to have
>   created all files of the new subsystems and deleted the ones
>   belonging to the removed subsystems.  After a failure, no file is
>   created or removed.
> 
> * cgroup_remount() no longer needs to make explicit populate/clear
>   calls as it's all handled by rebind_subsystems(), and it gets proper
>   error handling automatically.
> 
> * cgroup_mount() has been updated such that the root dentry and cgroup
>   are linked before rebind_subsystems().  Also, the init_cred dancing
>   and base file handling are moved right above rebind_subsystems()
>   call and proper error handling for the base files is added.  While
>   at it, add a comment explaining what's going on with the cred thing.
> 
> * cgroup_kill_sb() calls rebind_subsystems() to unbind all subsystems
>   which now implies removing all subsystem files which requires the
>   directory's i_mutex.  Grab it.  This means that files on the root
>   cgroup are removed earlier - they used to be deleted from generic
>   super_block cleanup from vfs.  This doesn't lead to any functional
>   difference and it's cleaner to do the clean up explicitly for all
>   files.
> 
> Combined with the previous changes, this makes all cgroup file
> creation errors handled correctly.
> 
> v2: Added comment on init_cred.
> 
> v3: Li spotted that cgroup_mount() wasn't freeing tmp_links after base
>     file addition failure.  Fix it by adding free_tmp_links error
>     handling label.
> 
> Signed-off-by: Tejun Heo <tj at kernel.org>

Acked-by: Li Zefan <lizefan at huawei.com>



More information about the Containers mailing list