Skip to content

Commit bdefd68

Browse files
Kemeng Shitytso
authored andcommitted
ext4: add some kunit stub for mballoc kunit test
Multiblocks allocation will read and write block bitmap and group descriptor which reside on disk. Add kunit stub to function ext4_get_group_desc, ext4_read_block_bitmap_nowait, ext4_wait_block_bitmap and ext4_mb_mark_context to avoid real IO to disk. Signed-off-by: Kemeng Shi <[email protected]> Reviewed-by: "Ritesh Harjani (IBM)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 5c657db commit bdefd68

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

fs/ext4/balloc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mballoc.h"
2323

2424
#include <trace/events/ext4.h>
25+
#include <kunit/static_stub.h>
2526

2627
static unsigned ext4_num_base_meta_clusters(struct super_block *sb,
2728
ext4_group_t block_group);
@@ -272,6 +273,9 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
272273
struct ext4_sb_info *sbi = EXT4_SB(sb);
273274
struct buffer_head *bh_p;
274275

276+
KUNIT_STATIC_STUB_REDIRECT(ext4_get_group_desc,
277+
sb, block_group, bh);
278+
275279
if (block_group >= ngroups) {
276280
ext4_error(sb, "block_group >= groups_count - block_group = %u,"
277281
" groups_count = %u", block_group, ngroups);
@@ -466,6 +470,9 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group,
466470
ext4_fsblk_t bitmap_blk;
467471
int err;
468472

473+
KUNIT_STATIC_STUB_REDIRECT(ext4_read_block_bitmap_nowait,
474+
sb, block_group, ignore_locked);
475+
469476
desc = ext4_get_group_desc(sb, block_group, NULL);
470477
if (!desc)
471478
return ERR_PTR(-EFSCORRUPTED);
@@ -561,6 +568,9 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
561568
{
562569
struct ext4_group_desc *desc;
563570

571+
KUNIT_STATIC_STUB_REDIRECT(ext4_wait_block_bitmap,
572+
sb, block_group, bh);
573+
564574
if (!buffer_new(bh))
565575
return 0;
566576
desc = ext4_get_group_desc(sb, block_group, NULL);

fs/ext4/mballoc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/backing-dev.h>
1919
#include <linux/freezer.h>
2020
#include <trace/events/ext4.h>
21+
#include <kunit/static_stub.h>
2122

2223
/*
2324
* MUSTDO:
@@ -3957,6 +3958,10 @@ ext4_mb_mark_context(handle_t *handle, struct super_block *sb, bool state,
39573958
int err;
39583959
unsigned int i, already, changed = len;
39593960

3961+
KUNIT_STATIC_STUB_REDIRECT(ext4_mb_mark_context,
3962+
handle, sb, state, group, blkoff, len,
3963+
flags, ret_changed);
3964+
39603965
if (ret_changed)
39613966
*ret_changed = 0;
39623967
bitmap_bh = ext4_read_block_bitmap(sb, group);

0 commit comments

Comments
 (0)