All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Dawei Li <set_pte_at@outlook.com>
Cc: brauner@kernel.org, neilb@suse.de, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] vfs: Make vfs_get_super() internal
Date: Sun, 30 Oct 2022 20:28:39 +0000	[thread overview]
Message-ID: <Y17edxOrW81EBh1v@ZenIV> (raw)
In-Reply-To: <TYCP286MB23233CC984811CFD38F69BC1CA349@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM>

On Sun, Oct 30, 2022 at 09:06:08PM +0800, Dawei Li wrote:
> For now there are no external callers of vfs_get_super(),
> so just make it an internal API.
> 
> v1: https://lore.kernel.org/all/TYCP286MB2323D37F4F6400FD07D7C7F7CA319@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
> 
> v2: move vfs_get_super_keying to super.c, as the suggestion
> from Christian Brauner.
> 
> base-commit: 3aca47127a646165965ff52803e2b269eed91afc
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
>  fs/super.c                 | 13 +++++++++++--
>  include/linux/fs_context.h | 14 --------------
>  2 files changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 6a82660e1adb..24e31e458552 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1111,6 +1111,16 @@ static int test_single_super(struct super_block *s, struct fs_context *fc)
>  	return 1;
>  }
>  
> +/*
> + * sget() wrappers to be called from the ->get_tree() op.
> + */
> +enum vfs_get_super_keying {
> +	vfs_get_single_super,	/* Only one such superblock may exist */
> +	vfs_get_single_reconf_super, /* As above, but reconfigure if it exists */
> +	vfs_get_keyed_super,	/* Superblocks with different s_fs_info keys may exist */
> +	vfs_get_independent_super, /* Multiple independent superblocks may exist */
> +};

I would rather kill the "keying" thing completely.

Seriously, what does it buy us?  Consider e.g.
        return vfs_get_super(fc, vfs_get_independent_super, fill_super);
in get_tree_nodev().  If you expand vfs_get_super() there, you'll get
this:
{
        struct super_block *sb = sget_fc(fc, NULL, set_anon_super_fc);
        if (IS_ERR(sb))
                return PTR_ERR(sb);

        if (!sb->s_root) {
                int err = fill_super(sb, fc);
                if (unlikely(err)) {
                        deactivate_locked_super(sb);
			return err;
		}
                sb->s_flags |= SB_ACTIVE;
        }
	fc->root = dget(sb->s_root);
	return 0;
}

Sure, it's several lines long, but it's much easier to follow than
vfs_get_super().  And duplication between these vfs_get_super()
callers is, IMO, not worth eliminating...

  reply	other threads:[~2022-10-30 20:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 13:06 [PATCH v2] vfs: Make vfs_get_super() internal Dawei Li
2022-10-30 20:28 ` Al Viro [this message]
2022-10-31  7:55   ` Christoph Hellwig

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=Y17edxOrW81EBh1v@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=set_pte_at@outlook.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.