Commit ad943758 authored by Kemeng Shi's avatar Kemeng Shi Committed by Theodore Ts'o

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: default avatarKemeng Shi <shikemeng@huaweicloud.com>
Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20240304163543.6700-3-shikemeng@huaweicloud.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 8ffc0cd2
...@@ -716,7 +716,10 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b, ...@@ -716,7 +716,10 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b,
ex.fe_start = start; ex.fe_start = start;
ex.fe_len = len; ex.fe_len = len;
ex.fe_group = TEST_GOAL_GROUP; ex.fe_group = TEST_GOAL_GROUP;
ext4_lock_group(sb, TEST_GOAL_GROUP);
mb_mark_used(e4b, &ex); mb_mark_used(e4b, &ex);
ext4_unlock_group(sb, TEST_GOAL_GROUP);
mb_set_bits(bitmap, start, len); mb_set_bits(bitmap, start, len);
/* bypass bb_free validatoin in ext4_mb_generate_buddy */ /* 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, ...@@ -776,7 +779,9 @@ test_mb_free_blocks_range(struct kunit *test, struct ext4_buddy *e4b,
if (len == 0) if (len == 0)
return; return;
ext4_lock_group(sb, e4b->bd_group);
mb_free_blocks(NULL, e4b, start, len); mb_free_blocks(NULL, e4b, start, len);
ext4_unlock_group(sb, e4b->bd_group);
mb_clear_bits(bitmap, start, len); mb_clear_bits(bitmap, start, len);
/* bypass bb_free validatoin in ext4_mb_generate_buddy */ /* bypass bb_free validatoin in ext4_mb_generate_buddy */
...@@ -820,7 +825,11 @@ static void test_mb_free_blocks(struct kunit *test) ...@@ -820,7 +825,11 @@ static void test_mb_free_blocks(struct kunit *test)
ex.fe_start = 0; ex.fe_start = 0;
ex.fe_len = EXT4_CLUSTERS_PER_GROUP(sb); ex.fe_len = EXT4_CLUSTERS_PER_GROUP(sb);
ex.fe_group = TEST_GOAL_GROUP; ex.fe_group = TEST_GOAL_GROUP;
ext4_lock_group(sb, TEST_GOAL_GROUP);
mb_mark_used(&e4b, &ex); mb_mark_used(&e4b, &ex);
ext4_unlock_group(sb, TEST_GOAL_GROUP);
grp->bb_free = 0; grp->bb_free = 0;
memset(bitmap, 0xff, sb->s_blocksize); memset(bitmap, 0xff, sb->s_blocksize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment