Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: run mballoc test with different layouts setting

Use KUNIT_CASE_PARAM to run mballoc test with different layouts setting.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Link: https://lore.kernel.org/r/20230928160407.142069-13-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Kemeng Shi and committed by
Theodore Ts'o
28b95ee8 7c9fa399

+38 -14
+38 -14
fs/ext4/mballoc-test.c
··· 199 199 return 0; 200 200 } 201 201 202 - #define TEST_BLOCKSIZE_BITS 10 203 - #define TEST_CLUSTER_BITS 3 204 - #define TEST_BLOCKS_PER_GROUP 8192 205 - #define TEST_GROUP_COUNT 4 206 - #define TEST_DESC_SIZE 64 207 202 #define TEST_GOAL_GROUP 1 208 203 static int mbt_kunit_init(struct kunit *test) 209 204 { 210 - struct mbt_ext4_block_layout layout = { 211 - .blocksize_bits = TEST_BLOCKSIZE_BITS, 212 - .cluster_bits = TEST_CLUSTER_BITS, 213 - .blocks_per_group = TEST_BLOCKS_PER_GROUP, 214 - .group_count = TEST_GROUP_COUNT, 215 - .desc_size = TEST_DESC_SIZE, 216 - }; 205 + struct mbt_ext4_block_layout *layout = 206 + (struct mbt_ext4_block_layout *)(test->param_value); 217 207 struct super_block *sb; 218 208 int ret; 219 209 ··· 211 221 if (sb == NULL) 212 222 return -ENOMEM; 213 223 214 - mbt_init_sb_layout(sb, &layout); 224 + mbt_init_sb_layout(sb, layout); 215 225 216 226 ret = mbt_ctx_init(sb); 217 227 if (ret != 0) { ··· 297 307 "unexpectedly get block when no block is available"); 298 308 } 299 309 310 + static const struct mbt_ext4_block_layout mbt_test_layouts[] = { 311 + { 312 + .blocksize_bits = 10, 313 + .cluster_bits = 3, 314 + .blocks_per_group = 8192, 315 + .group_count = 4, 316 + .desc_size = 64, 317 + }, 318 + { 319 + .blocksize_bits = 12, 320 + .cluster_bits = 3, 321 + .blocks_per_group = 8192, 322 + .group_count = 4, 323 + .desc_size = 64, 324 + }, 325 + { 326 + .blocksize_bits = 16, 327 + .cluster_bits = 3, 328 + .blocks_per_group = 8192, 329 + .group_count = 4, 330 + .desc_size = 64, 331 + }, 332 + }; 333 + 334 + static void mbt_show_layout(const struct mbt_ext4_block_layout *layout, 335 + char *desc) 336 + { 337 + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "block_bits=%d cluster_bits=%d " 338 + "blocks_per_group=%d group_count=%d desc_size=%d\n", 339 + layout->blocksize_bits, layout->cluster_bits, 340 + layout->blocks_per_group, layout->group_count, 341 + layout->desc_size); 342 + } 343 + KUNIT_ARRAY_PARAM(mbt_layouts, mbt_test_layouts, mbt_show_layout); 300 344 301 345 static struct kunit_case mbt_test_cases[] = { 302 - KUNIT_CASE(test_new_blocks_simple), 346 + KUNIT_CASE_PARAM(test_new_blocks_simple, mbt_layouts_gen_params), 303 347 {} 304 348 }; 305 349