From: Christian Brauner Date: Fri, 29 May 2026 08:43:40 +0000 (+0200) Subject: ext4: convert extents KUnit test to sget_fc() X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=badb2cc8cf4aa37ecd8beda7aa5c003da93a9f74;p=thirdparty%2Fkernel%2Flinux.git ext4: convert extents KUnit test to sget_fc() The extents KUnit test uses sget() to get an initialized superblock for its fake file_system_type. sget() predates fs_context and we want to retire it. Switch this caller over to sget_fc(). Add a no-op ext_init_fs_context() so fs_context_for_mount() has something to call on the fake fs_type. ext_set() now takes a struct fs_context * (still a no-op). extents_kunit_init() allocates the fc, hands it to sget_fc() and drops the fc reference once the sb is published. sget_fc() does not retain a pointer to it. No functional change for the test. Link: https://patch.msgid.link/20260529-work-sget-v2-1-57bbe08604e4@kernel.org Reviewed-by: Jan Kara Signed-off-by: Christian Brauner (Amutable) --- diff --git a/fs/ext4/extents-test.c b/fs/ext4/extents-test.c index 6b53a3f39fcd6..bd7795a82607d 100644 --- a/fs/ext4/extents-test.c +++ b/fs/ext4/extents-test.c @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -130,14 +131,20 @@ static void ext_kill_sb(struct super_block *sb) generic_shutdown_super(sb); } -static int ext_set(struct super_block *sb, void *data) +static int ext_init_fs_context(struct fs_context *fc) +{ + return 0; +} + +static int ext_set(struct super_block *sb, struct fs_context *fc) { return 0; } static struct file_system_type ext_fs_type = { - .name = "extents test", - .kill_sb = ext_kill_sb, + .name = "extents test", + .init_fs_context = ext_init_fs_context, + .kill_sb = ext_kill_sb, }; static void extents_kunit_exit(struct kunit *test) @@ -223,6 +230,7 @@ static int extents_kunit_init(struct kunit *test) struct ext4_inode_info *ei; struct inode *inode; struct super_block *sb; + struct fs_context *fc; struct ext4_sb_info *sbi = NULL; struct kunit_ext_test_param *param = (struct kunit_ext_test_param *)(test->param_value); @@ -232,7 +240,13 @@ static int extents_kunit_init(struct kunit *test) if (sbi == NULL) return -ENOMEM; - sb = sget(&ext_fs_type, NULL, ext_set, 0, NULL); + fc = fs_context_for_mount(&ext_fs_type, 0); + if (IS_ERR(fc)) { + kfree(sbi); + return PTR_ERR(fc); + } + sb = sget_fc(fc, NULL, ext_set); + put_fs_context(fc); if (IS_ERR(sb)) { kfree(sbi); return PTR_ERR(sb);