diff options
author | Kemeng Shi <shikemeng@huaweicloud.com> | 2024-03-05 00:35:42 +0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-03-07 13:32:54 -0500 |
commit | ad943758e0ebd881d031b657a3f389315bf3a101 (patch) | |
tree | feedcf114c03e38b52c17418a5812a61f3fc0d5c /fs/ext4 | |
parent | 8ffc0cd24c2a3ea340743db18b1a1e999176fbd3 (diff) |
ext4: hold group lock in ext4 kunit test
Although there is no concurrent block allocation/free in unit test,
internal functions mb_mark_used and mb_free_blocks assert group
lock is always held. Acquire group before calling mb_mark_used and
mb_free_blocks in unit test to avoid the assertion.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240304163543.6700-3-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/mballoc-test.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c index f7a511b21162..8188d18ca09d 100644 --- a/fs/ext4/mballoc-test.c +++ b/fs/ext4/mballoc-test.c @@ -716,7 +716,10 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b, ex.fe_start = start; ex.fe_len = len; ex.fe_group = TEST_GOAL_GROUP; + + ext4_lock_group(sb, TEST_GOAL_GROUP); mb_mark_used(e4b, &ex); + ext4_unlock_group(sb, TEST_GOAL_GROUP); mb_set_bits(bitmap, start, len); /* bypass bb_free validatoin in ext4_mb_generate_buddy */ @@ -776,7 +779,9 @@ test_mb_free_blocks_range(struct kunit *test, struct ext4_buddy *e4b, if (len == 0) return; + ext4_lock_group(sb, e4b->bd_group); mb_free_blocks(NULL, e4b, start, len); + ext4_unlock_group(sb, e4b->bd_group); mb_clear_bits(bitmap, start, len); /* bypass bb_free validatoin in ext4_mb_generate_buddy */ @@ -820,7 +825,11 @@ static void test_mb_free_blocks(struct kunit *test) ex.fe_start = 0; ex.fe_len = EXT4_CLUSTERS_PER_GROUP(sb); ex.fe_group = TEST_GOAL_GROUP; + + ext4_lock_group(sb, TEST_GOAL_GROUP); mb_mark_used(&e4b, &ex); + ext4_unlock_group(sb, TEST_GOAL_GROUP); + grp->bb_free = 0; memset(bitmap, 0xff, sb->s_blocksize); |