Linux Container Development
 help / color / mirror / Atom feed
From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 5/9] cgroup: update error handling in cgroup_populate_dir()
Date: Thu, 11 Jul 2013 15:08:07 +0800	[thread overview]
Message-ID: <51DE59D7.2000203@huawei.com> (raw)
In-Reply-To: <1372463145-4245-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

On 2013/6/29 7:45, Tejun Heo wrote:
> cgroup_populate_dir() didn't use to check whether the actual file
> creations were successful and could return success with only subset of
> the requested files created, which is nasty.
> 
> This patch udpates cgroup_populate_dir() so that it either succeeds
> with all files or fails with no file.
> 
> Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
>  kernel/cgroup.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 254d54e..3475267 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -965,10 +965,12 @@ static void cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft)
>  static void cgroup_clear_dir(struct cgroup *cgrp, unsigned long subsys_mask)
>  {
>  	struct cgroup_subsys *ss;
> +	int i;
>  
> -	for_each_root_subsys(cgrp->root, ss) {
> +	for_each_subsys(ss, i) {

Why this change?

It even increases object size a bit:

   text    data     bss     dec     hex filename
  42524    5495    6336   54355    d453 kernel/cgroup.o.orig
   text    data     bss     dec     hex filename
  42636    5495    6336   54467    d4c3 kernel/cgroup.o

>  		struct cftype_set *set;
> -		if (!test_bit(ss->subsys_id, &subsys_mask))
> +
> +		if (!test_bit(i, &subsys_mask))
>  			continue;
>  		list_for_each_entry(set, &ss->cftsets, node)
>  			cgroup_addrm_files(cgrp, NULL, set->cfts, false);
> @@ -4171,19 +4173,26 @@ static struct cftype cgroup_base_files[] = {
>   * cgroup_populate_dir - create subsys files in a cgroup directory
>   * @cgrp: target cgroup
>   * @subsys_mask: mask of the subsystem ids whose files should be added
> + *
> + * On failure, no file is added.
>   */
>  static int cgroup_populate_dir(struct cgroup *cgrp, unsigned long subsys_mask)
>  {
>  	struct cgroup_subsys *ss;
> +	int i, ret = 0;
>  
>  	/* process cftsets of each subsystem */
> -	for_each_root_subsys(cgrp->root, ss) {
> +	for_each_subsys(ss, i) {

ditto

  parent reply	other threads:[~2013-07-11  7:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1372463145-4245-1-git-send-email-tj@kernel.org>
     [not found] ` <1372463145-4245-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-28 23:45   ` [PATCH 1/9] cgroup: minor updates around cgroup_clear_directory() Tejun Heo
2013-06-28 23:45   ` [PATCH 2/9] cgroup: fix error path of cgroup_addrm_files() Tejun Heo
2013-06-28 23:45   ` [PATCH 3/9] cgroup: fix cgroup_add_cftypes() error handling Tejun Heo
2013-06-28 23:45   ` [PATCH 4/9] cgroup: separate out cgroup_base_files[] handling out of cgroup_populate/clear_dir() Tejun Heo
2013-06-28 23:45   ` [PATCH 5/9] cgroup: update error handling in cgroup_populate_dir() Tejun Heo
2013-06-28 23:45   ` [PATCH 6/9] cgroup: make rebind_subsystems() handle file additions and removals with proper error handling Tejun Heo
2013-06-28 23:45   ` [PATCH 7/9] cgroup: cosmetic follow-up cleanups Tejun Heo
2013-06-28 23:45   ` [PATCH 8/9] cgroup: move number_of_cgroups test out of rebind_subsystems() into cgroup_remount() Tejun Heo
2013-06-28 23:45   ` [PATCH 9/9] blkcg: make blkcg_policy_register() correctly handle cgroup_add_cftypes() failures Tejun Heo
2013-07-11 17:19   ` [PATCH 5.5/9] cgroup: use for_each_subsys() instead of for_each_root_subsys() in cgroup_populate/clear_dir() Tejun Heo
2013-07-12  7:45   ` [PATCHSET] cgroup: fix and clean up cgroup file creations and removals Tejun Heo
     [not found] ` <1372463145-4245-2-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  6:42     ` [PATCH 1/9] cgroup: minor updates around cgroup_clear_directory() Li Zefan
     [not found] ` <1372463145-4245-3-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  6:43     ` [PATCH 2/9] cgroup: fix error path of cgroup_addrm_files() Li Zefan
     [not found] ` <1372463145-4245-4-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-4-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  6:43     ` [PATCH 3/9] cgroup: fix cgroup_add_cftypes() error handling Li Zefan
     [not found] ` <1372463145-4245-5-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-5-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  6:44     ` [PATCH 4/9] cgroup: separate out cgroup_base_files[] handling out of cgroup_populate/clear_dir() Li Zefan
     [not found] ` <1372463145-4245-6-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-6-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  7:08     ` Li Zefan [this message]
     [not found]       ` <51DE59D7.2000203-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-07-11 17:01         ` [PATCH 5/9] cgroup: update error handling in cgroup_populate_dir() Tejun Heo
     [not found]           ` <20130711170123.GA10195-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-12  6:36             ` Li Zefan
2013-07-11 17:18     ` [PATCH v2 " Tejun Heo
     [not found]   ` <20130711171825.GD10195@mtj.dyndns.org>
     [not found]     ` <20130711171825.GD10195-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-12  6:07       ` Li Zefan
     [not found] ` <1372463145-4245-8-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-8-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-29  0:09     ` [PATCH 7/9] cgroup: cosmetic follow-up cleanups Tejun Heo
2013-07-11  7:10     ` Li Zefan
     [not found] ` <1372463145-4245-9-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-9-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-07-11  7:10     ` [PATCH 8/9] cgroup: move number_of_cgroups test out of rebind_subsystems() into cgroup_remount() Li Zefan
     [not found] ` <20130711171927.GE10195@mtj.dyndns.org>
     [not found]   ` <20130711171927.GE10195-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-12  6:13     ` [PATCH 5.5/9] cgroup: use for_each_subsys() instead of for_each_root_subsys() in cgroup_populate/clear_dir() Li Zefan
     [not found] ` <1372463145-4245-7-git-send-email-tj@kernel.org>
     [not found]   ` <1372463145-4245-7-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-06-29  0:10     ` [PATCH v2 6/9] cgroup: make rebind_subsystems() handle file additions and removals with proper error handling Tejun Heo
2013-07-11  7:09     ` [PATCH " Li Zefan
2013-07-11 17:20     ` [PATCH v3 " Tejun Heo
     [not found]       ` <20130711172001.GF10195-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-12  6:13         ` Li Zefan
2013-07-12 19:37     ` [PATCH v4 " Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51DE59D7.2000203@huawei.com \
    --to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox