Re: [PATCH v5 1/2] fs: rename vfs_get_super() to get_tree_super() and export it

Giuseppe Scrivano <[email protected]>
Newsgroups org.ozlabs.lists.linux-erofs,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
Gao Xiang <[email protected]> writes:

> (+ cc vfs maintainers)
>
> Hi,
>
> On Tue, Aug 11, 2026 at 09:10:50AM +0200, Giuseppe Scrivano wrote:
>> vfs_get_super() already implements the common get_tree pattern of
>> looking up an existing superblock via a test callback and initialising
>> a new one with fill_super otherwise, but it is private to fs/super.c
>> and only reachable through the get_tree_nodev()/get_tree_single()/
>> get_tree_keyed() wrappers, none of which let a filesystem supply its
>> own test callback.
>> 
>> Rename it to get_tree_super() and export it so filesystems that need a
>> custom superblock matching policy can reuse it directly instead of
>> open-coding sget_fc() + fill_super().  No functional change.
>> 
>> This is a preparatory fix for the next patch.
>> 
>> Signed-off-by: Giuseppe Scrivano <[email protected]>
>
> With the new vfs_get_super() helper, it seems much cleaner compared
> to the previous versions.
>
> Since this series interacts with the other erofs ongoing patches.
> So I hope at least [PATCH 2/2] can be routed into the erofs tree to
> avoid unnecessary conflict resolving.
>
> Maybe the simplistic way is vfs maintainers can ack this vfs patch so
> that both patches can go through erofs tree for the next cycle
> directly.
>
>
>> ---
>
> ...
>
>> +/**
>> + * get_tree_super - Get a superblock, optionally sharing an existing one
>> + * @fc: The filesystem context holding the parameters
>> + * @test: Comparison function to find a matching existing superblock, or NULL
>> + * @fill_super: Helper to initialise a new superblock
>> + *
>> + * If @test is non-NULL and matches an existing superblock, that superblock is
>> + * reused; otherwise a new anonymous superblock is created and initialised with
>> + * @fill_super.  Passing NULL for @test always creates a new superblock.
>> + */
>> +int get_tree_super(struct fs_context *fc,
>>  		int (*test)(struct super_block *, struct fs_context *),
>>  		int (*fill_super)(struct super_block *sb,
>>  				  struct fs_context *fc))
>> @@ -1278,12 +1288,13 @@ static int vfs_get_super(struct fs_context *fc,
>>  	deactivate_locked_super(sb);
>>  	return err;
>>  }
>> +EXPORT_SYMBOL(get_tree_super);
>
> btw, some people prefer EXPORT_SYMBOL_GPL() for this kind of helpers.

I am fine with this change, but the rest of the file is using
EXPORT_SYMBOL though, that is why I've used it.

Regards,
Giuseppe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.