public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Christian Brauner
	<brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Heiko Carstens <hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Vasily Gorbik <gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Alexander Gordeev
	<agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>,
	Fenghua Yu <fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Reinette Chatre
	<reinette.chatre-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Miquel Raynal
	<miquel.raynal-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>,
	Richard Weinberger <richard-/L3Ra7n9ekc@public.gmane.org>,
	Vignesh Raghavendra <vigneshr-l0cyMroinI0@public.gmane.org>,
	Dennis Dalessandro
	<dennis.dalessandro-ntyVByD3zXaTtA8H5PvdGFaTQe2KTcn/@public.gmane.org>,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Trond Myklebust
	<trond.myklebust-F/q8l9xzQnoyLce1RVWEUA@public.gmane.org>,
	Anna Schumaker <anna-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Damien Le Moal <dlemoal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Naohiro Aota <naohiro.aota-Sjgp3cTcYWE@public.gmane.org>,
	Greg Kroah-Hartman
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-s39
Subject: Re: [PATCH 09/19] zonefs: remove duplicate cleanup in zonefs_fill_super
Date: Thu, 14 Sep 2023 01:49:00 +0100	[thread overview]
Message-ID: <20230914004900.GE800259@ZenIV> (raw)
In-Reply-To: <20230913111013.77623-10-hch-jcswGhMUV9g@public.gmane.org>

On Wed, Sep 13, 2023 at 08:10:03AM -0300, Christoph Hellwig wrote:
> When ->fill_super fails, ->kill_sb is called which already cleans up
> the inodes and zgroups.

Ugh...  The use of "->" strongly suggests that you are talking about
a method; 'fill_super' here actually refers to callback passed to
mount_bdev().  Have a pity for those who'll be trying to parse it
- that might be yourself a couple of years down the road...

Something like

"If zonefs_fill_super() returns an error, its caller (mount_bdev()) will
make sure to call zonefs_kill_super(), which already cleans up
the inodes and zgroups.", perhaps?

> 
> Drop the extra cleanup code in zonefs_fill_super.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---
>  fs/zonefs/super.c | 21 +++++----------------
>  1 file changed, 5 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 9d1a9808fbbba6..35b2554ce2ac2e 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1309,13 +1309,12 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	/* Initialize the zone groups */
>  	ret = zonefs_init_zgroups(sb);
>  	if (ret)
> -		goto cleanup;
> +		return ret;
>  
>  	/* Create the root directory inode */
> -	ret = -ENOMEM;
>  	inode = new_inode(sb);
>  	if (!inode)
> -		goto cleanup;
> +		return -ENOMEM;
>  
>  	inode->i_ino = bdev_nr_zones(sb->s_bdev);
>  	inode->i_mode = S_IFDIR | 0555;
> @@ -1333,7 +1332,7 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  
>  	sb->s_root = d_make_root(inode);
>  	if (!sb->s_root)
> -		goto cleanup;
> +		return -ENOMEM;
>  
>  	/*
>  	 * Take a reference on the zone groups directory inodes
> @@ -1341,19 +1340,9 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
>  	 */
>  	ret = zonefs_get_zgroup_inodes(sb);
>  	if (ret)
> -		goto cleanup;
> -
> -	ret = zonefs_sysfs_register(sb);
> -	if (ret)
> -		goto cleanup;
> -
> -	return 0;
> -
> -cleanup:
> -	zonefs_release_zgroup_inodes(sb);
> -	zonefs_free_zgroups(sb);
> +		return ret;
>  
> -	return ret;
> +	return zonefs_sysfs_register(sb);
>  }
>  
>  static struct dentry *zonefs_mount(struct file_system_type *fs_type,
> -- 
> 2.39.2
> 

  parent reply	other threads:[~2023-09-14  0:49 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13 11:09 split up ->kill_sb Christoph Hellwig
     [not found] ` <20230913111013.77623-1-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 11:09   ` [PATCH 01/19] fs: reflow deactivate_locked_super Christoph Hellwig
     [not found]     ` <20230913111013.77623-2-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 16:35       ` Christian Brauner
2023-09-26  9:24         ` Christoph Hellwig
2023-09-26  9:24           ` Christoph Hellwig
2023-09-13 11:09   ` [PATCH 02/19] fs: make ->kill_sb optional Christoph Hellwig
2023-09-13 11:09   ` [PATCH 04/19] NFS: remove the s_dev field from struct nfs_server Christoph Hellwig
2023-09-13 11:09   ` [PATCH 05/19] fs: assign an anon dev_t in common code Christoph Hellwig
     [not found]     ` <20230913111013.77623-6-hch-jcswGhMUV9g@public.gmane.org>
2023-09-14  0:34       ` Al Viro
2023-09-13 11:10   ` [PATCH 06/19] qibfs: use simple_release_fs Christoph Hellwig
     [not found]     ` <20230913111013.77623-7-hch-jcswGhMUV9g@public.gmane.org>
2023-09-18 11:41       ` Leon Romanovsky
2023-09-13 11:10   ` [PATCH 07/19] hypfs: use d_genocide to kill fs entries Christoph Hellwig
2023-09-13 11:10   ` [PATCH 08/19] pstore: shrink the pstore_sb_lock critical section in pstore_kill_sb Christoph Hellwig
     [not found]     ` <20230913111013.77623-9-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 22:07       ` Kees Cook
2023-09-13 11:10   ` [PATCH 09/19] zonefs: remove duplicate cleanup in zonefs_fill_super Christoph Hellwig
     [not found]     ` <20230913111013.77623-10-hch-jcswGhMUV9g@public.gmane.org>
2023-09-14  0:33       ` Damien Le Moal
2023-09-14  0:49       ` Al Viro [this message]
2023-09-13 11:10   ` [PATCH 10/19] USB: gadget/legacy: remove sb_mutex Christoph Hellwig
     [not found]     ` <20230913111013.77623-11-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 16:10       ` Alan Stern
     [not found]         ` <7f839be1-4898-41ad-8eda-10d5a0350bdf-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
2023-09-26  9:24           ` Christoph Hellwig
2023-09-26  9:24             ` Christoph Hellwig
2023-09-14 10:22     ` Sergey Shtylyov
2023-09-13 11:10   ` [PATCH 11/19] fs: add new shutdown_sb and free_sb methods Christoph Hellwig
     [not found]     ` <20230913111013.77623-12-hch-jcswGhMUV9g@public.gmane.org>
2023-09-14  2:07       ` Al Viro
2023-09-13 11:10   ` [PATCH 12/19] fs: convert kill_litter_super to litter_shutdown_sb Christoph Hellwig
     [not found]     ` <20230913111013.77623-13-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 22:07       ` Kees Cook
2023-09-13 11:10   ` [PATCH 13/19] fs: convert kill_block_super to block_free_sb Christoph Hellwig
     [not found]     ` <20230913111013.77623-14-hch-jcswGhMUV9g@public.gmane.org>
2023-09-14  2:29       ` Al Viro
2023-09-13 11:10   ` [PATCH 14/19] jffs2: convert to ->shutdown_sb and ->free_sb Christoph Hellwig
2023-09-13 11:10   ` [PATCH 15/19] kernfs: split ->kill_sb Christoph Hellwig
     [not found]     ` <20230913111013.77623-16-hch-jcswGhMUV9g@public.gmane.org>
2023-09-18 15:24       ` Michal Koutný
2023-09-13 11:10   ` [PATCH 16/19] x86/resctrl: release rdtgroup_mutex and the CPU hotplug lock in rdt_shutdown_sb Christoph Hellwig
2023-09-13 11:10   ` [PATCH 17/19] NFS: move nfs_kill_super to fs_context.c Christoph Hellwig
2023-09-13 11:10   ` [PATCH 18/19] fs: simple ->shutdown_sb and ->free_sb conversions Christoph Hellwig
2023-09-13 11:10   ` [PATCH 19/19] fs: remove ->kill_sb Christoph Hellwig
2023-09-13 11:09 ` [PATCH 03/19] fs: release anon dev_t in deactivate_locked_super Christoph Hellwig
     [not found]   ` <20230913111013.77623-4-hch-jcswGhMUV9g@public.gmane.org>
2023-09-13 23:27     ` Al Viro
2023-09-14  2:37       ` Al Viro
2023-09-14  5:38         ` Al Viro
2023-09-14  7:56           ` Christian Brauner
2023-09-26  9:31             ` Christoph Hellwig
2023-09-26  9:31               ` Christoph Hellwig
2023-09-14 14:02           ` Christian Brauner
2023-09-14 16:58             ` Al Viro
2023-09-14 19:23               ` Al Viro
2023-09-15  7:40                 ` Christian Brauner
2023-09-15  9:44               ` Christian Brauner
2023-09-15 14:12                 ` Christian Brauner
2023-09-15 14:28                   ` Al Viro
2023-09-15 14:33                     ` Al Viro
2023-09-15 14:40                     ` Christian Brauner
2023-09-26  9:41           ` Christoph Hellwig
2023-09-26  9:41             ` Christoph Hellwig
2023-09-26  9:38       ` Christoph Hellwig
2023-09-26  9:38         ` Christoph Hellwig
2023-09-26 21:25         ` Al Viro
2023-09-27 22:29           ` Al Viro
2023-10-02  6:46           ` Christoph Hellwig
2023-10-09 21:57             ` Al Viro
2023-10-10  8:44               ` Christian Brauner
2023-10-17 19:50                 ` Al Viro

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=20230914004900.GE800259@ZenIV \
    --to=viro-rmsdqhl/ynmifsdqtta3olvcufugdwfn@public.gmane.org \
    --cc=agordeev-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=anna-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=brauner-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=dennis.dalessandro-ntyVByD3zXaTtA8H5PvdGFaTQe2KTcn/@public.gmane.org \
    --cc=dlemoal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=fenghua.yu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=gor-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=hca-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=miquel.raynal-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org \
    --cc=naohiro.aota-Sjgp3cTcYWE@public.gmane.org \
    --cc=reinette.chatre-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=richard-/L3Ra7n9ekc@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=trond.myklebust-F/q8l9xzQnoyLce1RVWEUA@public.gmane.org \
    --cc=vigneshr-l0cyMroinI0@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