mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
ext4: kunit: use dynamic inode allocation
Storing an inode structure on the stack pushes some functions over the warning
limit for stack frame size:
In file included from fs/ext4/mballoc.c:7039:
fs/ext4/mballoc-test.c:506:13: error: stack frame size (1032) exceeds limit (1024) in 'test_mark_diskspace_used' [-Werror,-Wframe-larger-than]
506 | static void test_mark_diskspace_used(struct kunit *test)
| ^
Use kunit_kzalloc() for all inodes. There may be a better way to do it by
preallocating the inode, which would result in a larger rework.
Fixes: 2b81493f8e
("ext4: Add unit test for ext4_mb_mark_diskspace_used")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Kemeng Shi <shikemeng@huaweicloud.com>
Link: https://lore.kernel.org/r/20240227161548.2929881-1-arnd@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
07be778c70
commit
d60c53694c
@ -332,14 +332,19 @@ static void mbt_kunit_exit(struct kunit *test)
|
||||
static void test_new_blocks_simple(struct kunit *test)
|
||||
{
|
||||
struct super_block *sb = (struct super_block *)test->priv;
|
||||
struct inode inode = { .i_sb = sb, };
|
||||
struct inode *inode;
|
||||
struct ext4_allocation_request ar;
|
||||
ext4_group_t i, goal_group = TEST_GOAL_GROUP;
|
||||
int err = 0;
|
||||
ext4_fsblk_t found;
|
||||
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||
|
||||
ar.inode = &inode;
|
||||
inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL);
|
||||
if (!inode)
|
||||
return;
|
||||
|
||||
inode->i_sb = sb;
|
||||
ar.inode = inode;
|
||||
|
||||
/* get block at goal */
|
||||
ar.goal = ext4_group_first_block_no(sb, goal_group);
|
||||
@ -441,15 +446,20 @@ test_free_blocks_simple_range(struct kunit *test, ext4_group_t goal_group,
|
||||
{
|
||||
struct super_block *sb = (struct super_block *)test->priv;
|
||||
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||
struct inode inode = { .i_sb = sb, };
|
||||
struct inode *inode;
|
||||
ext4_fsblk_t block;
|
||||
|
||||
inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL);
|
||||
if (!inode)
|
||||
return;
|
||||
inode->i_sb = sb;
|
||||
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
block = ext4_group_first_block_no(sb, goal_group) +
|
||||
EXT4_C2B(sbi, start);
|
||||
ext4_free_blocks_simple(&inode, block, len);
|
||||
ext4_free_blocks_simple(inode, block, len);
|
||||
validate_free_blocks_simple(test, sb, goal_group, start, len);
|
||||
mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb));
|
||||
}
|
||||
@ -506,16 +516,21 @@ test_mark_diskspace_used_range(struct kunit *test,
|
||||
static void test_mark_diskspace_used(struct kunit *test)
|
||||
{
|
||||
struct super_block *sb = (struct super_block *)test->priv;
|
||||
struct inode inode = { .i_sb = sb, };
|
||||
struct inode *inode;
|
||||
struct ext4_allocation_context ac;
|
||||
struct test_range ranges[TEST_RANGE_COUNT];
|
||||
int i;
|
||||
|
||||
mbt_generate_test_ranges(sb, ranges, TEST_RANGE_COUNT);
|
||||
|
||||
inode = kunit_kzalloc(test, sizeof(*inode), GFP_KERNEL);
|
||||
if (!inode)
|
||||
return;
|
||||
inode->i_sb = sb;
|
||||
|
||||
ac.ac_status = AC_STATUS_FOUND;
|
||||
ac.ac_sb = sb;
|
||||
ac.ac_inode = &inode;
|
||||
ac.ac_inode = inode;
|
||||
for (i = 0; i < TEST_RANGE_COUNT; i++)
|
||||
test_mark_diskspace_used_range(test, &ac, ranges[i].start,
|
||||
ranges[i].len);
|
||||
|
Loading…
Reference in New Issue
Block a user