mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
ext4: convert mballoc KUnit test to sget_fc()
Same treatment as the extents KUnit test. The mballoc test uses sget() as a thin "give me an initialized superblock" wrapper for a fake file_system_type. Move it onto sget_fc() so sget() can go away. Add a no-op mbt_init_fs_context() so fs_context_for_mount() has something to call on the fake fs_type. mbt_set() now takes a struct fs_context * (still a no-op). mbt_ext4_alloc_super_block() allocates the fc, hands it to sget_fc() and drops the fc reference once the sb is published. No functional change. Link: https://patch.msgid.link/20260529-work-sget-v2-2-57bbe08604e4@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
badb2cc8cf
commit
ed56dc8bbf
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <kunit/test.h>
|
||||
#include <kunit/static_stub.h>
|
||||
#include <linux/fs_context.h>
|
||||
#include <linux/random.h>
|
||||
|
||||
#include "ext4.h"
|
||||
|
|
@ -63,8 +64,14 @@ static void mbt_kill_sb(struct super_block *sb)
|
|||
generic_shutdown_super(sb);
|
||||
}
|
||||
|
||||
static int mbt_init_fs_context(struct fs_context *fc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file_system_type mbt_fs_type = {
|
||||
.name = "mballoc test",
|
||||
.init_fs_context = mbt_init_fs_context,
|
||||
.kill_sb = mbt_kill_sb,
|
||||
};
|
||||
|
||||
|
|
@ -127,7 +134,7 @@ static void mbt_mb_release(struct super_block *sb)
|
|||
kfree(sb->s_bdev);
|
||||
}
|
||||
|
||||
static int mbt_set(struct super_block *sb, void *data)
|
||||
static int mbt_set(struct super_block *sb, struct fs_context *fc)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -136,13 +143,19 @@ static struct super_block *mbt_ext4_alloc_super_block(void)
|
|||
{
|
||||
struct mbt_ext4_super_block *fsb;
|
||||
struct super_block *sb;
|
||||
struct fs_context *fc;
|
||||
struct ext4_sb_info *sbi;
|
||||
|
||||
fsb = kzalloc_obj(*fsb);
|
||||
if (fsb == NULL)
|
||||
return NULL;
|
||||
|
||||
sb = sget(&mbt_fs_type, NULL, mbt_set, 0, NULL);
|
||||
fc = fs_context_for_mount(&mbt_fs_type, 0);
|
||||
if (IS_ERR(fc))
|
||||
goto out;
|
||||
|
||||
sb = sget_fc(fc, NULL, mbt_set);
|
||||
put_fs_context(fc);
|
||||
if (IS_ERR(sb))
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user