From: Giuseppe Scrivano <gscrivan@redhat.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, linux-fsdevel@vger.kernel.org,
amir73il@gmail.com, gscrivan@redhat.com, brauner@kernel.org
Subject: [PATCH v5 1/2] fs: rename vfs_get_super() to get_tree_super() and export it
Date: Tue, 11 Aug 2026 09:10:50 +0200 [thread overview]
Message-ID: <20260811071241.389589-2-gscrivan@redhat.com> (raw)
In-Reply-To: <20260811071241.389589-1-gscrivan@redhat.com>
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 <gscrivan@redhat.com>
---
fs/super.c | 19 +++++++++++++++----
include/linux/fs_context.h | 4 ++++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index a8fd61136aaf..84b878317364 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1251,7 +1251,17 @@ static int test_single_super(struct super_block *s, struct fs_context *fc)
return 1;
}
-static int vfs_get_super(struct fs_context *fc,
+/**
+ * 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);
int get_tree_nodev(struct fs_context *fc,
int (*fill_super)(struct super_block *sb,
struct fs_context *fc))
{
- return vfs_get_super(fc, NULL, fill_super);
+ return get_tree_super(fc, NULL, fill_super);
}
EXPORT_SYMBOL(get_tree_nodev);
@@ -1291,7 +1302,7 @@ int get_tree_single(struct fs_context *fc,
int (*fill_super)(struct super_block *sb,
struct fs_context *fc))
{
- return vfs_get_super(fc, test_single_super, fill_super);
+ return get_tree_super(fc, test_single_super, fill_super);
}
EXPORT_SYMBOL(get_tree_single);
@@ -1301,7 +1312,7 @@ int get_tree_keyed(struct fs_context *fc,
void *key)
{
fc->s_fs_info = key;
- return vfs_get_super(fc, test_keyed_super, fill_super);
+ return get_tree_super(fc, test_keyed_super, fill_super);
}
EXPORT_SYMBOL(get_tree_keyed);
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index 0d6c8a6d7be2..c920aba5177c 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -150,6 +150,10 @@ extern int vfs_parse_fs_param_source(struct fs_context *fc,
struct fs_parameter *param);
extern void fc_drop_locked(struct fs_context *fc);
+extern 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));
extern int get_tree_nodev(struct fs_context *fc,
int (*fill_super)(struct super_block *sb,
struct fs_context *fc));
--
2.55.0
next prev parent reply other threads:[~2026-08-11 7:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 7:10 [PATCH v5 0/2] erofs: share the superblock for file-backed mounts Giuseppe Scrivano
2026-08-11 7:10 ` Giuseppe Scrivano [this message]
2026-08-11 15:44 ` [PATCH v5 1/2] fs: rename vfs_get_super() to get_tree_super() and export it Gao Xiang
2026-08-11 15:59 ` Giuseppe Scrivano
2026-08-25 12:32 ` Christian Brauner
2026-08-25 13:07 ` Gao Xiang
2026-08-11 7:10 ` [PATCH v5 2/2] erofs: reuse superblock for file-backed mounts Giuseppe Scrivano
2026-08-11 15:31 ` Gao Xiang
2026-08-11 15:57 ` Giuseppe Scrivano
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=20260811071241.389589-2-gscrivan@redhat.com \
--to=gscrivan@redhat.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=xiang@kernel.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