[PATCH] cgroup_rm_file: don't delete the uncreated files

Gao feng gaofeng at cn.fujitsu.com
Thu Dec 6 06:12:31 UTC 2012


于 2012年12月06日 14:02, Li Zefan 写道:
> On 2012/12/6 11:09, Gao feng wrote:
>> in cgroup_add_file,when creating files for cgroup,
>> some of creation may be skipped. So we need to avoid
>> deleting these uncreated files in cgroup_rm_file,
>> otherwise the warning msg will be triggered.
>>
>> "cgroup_addrm_files: failed to remove memory_pressure_enabled, err=-2"
>>
>> Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
>> ---
>>  kernel/cgroup.c |    6 ++++++
>>  1 files changed, 6 insertions(+), 0 deletions(-)
>>
>> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
>> index 5cc3724..6928b3e 100644
>> --- a/kernel/cgroup.c
>> +++ b/kernel/cgroup.c
>> @@ -932,6 +932,12 @@ static int cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft)
>>  	lockdep_assert_held(&cgrp->dentry->d_inode->i_mutex);
>>  	lockdep_assert_held(&cgroup_mutex);
>>  
>> +	/* does @cft->flags tell us this file isn't created on @cgrp? */
>> +	if ((cft->flags & CFTYPE_NOT_ON_ROOT) && !cgrp->parent)
>> +		return 0;
>> +	if ((cft->flags & CFTYPE_ONLY_ON_ROOT) && cgrp->parent)
>> +		return 0;
>> +
> 
> We should move those checks to cgroup_addrm_files() to avoid code duplication.
> 

Get it,and the null check of cft in cgroup_rm_file is no need too.
Thanks!



More information about the Containers mailing list