diff options
Diffstat (limited to 'fs/btrfs/tests/free-space-tree-tests.c')
-rw-r--r-- | fs/btrfs/tests/free-space-tree-tests.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c index 7cea4462acd5..aac507085ab0 100644 --- a/fs/btrfs/tests/free-space-tree-tests.c +++ b/fs/btrfs/tests/free-space-tree-tests.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Boston, MA 021110-1307, USA. | 16 | * Boston, MA 021110-1307, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/types.h> | ||
19 | #include "btrfs-tests.h" | 20 | #include "btrfs-tests.h" |
20 | #include "../ctree.h" | 21 | #include "../ctree.h" |
21 | #include "../disk-io.h" | 22 | #include "../disk-io.h" |
@@ -30,7 +31,7 @@ struct free_space_extent { | |||
30 | * The test cases align their operations to this in order to hit some of the | 31 | * The test cases align their operations to this in order to hit some of the |
31 | * edge cases in the bitmap code. | 32 | * edge cases in the bitmap code. |
32 | */ | 33 | */ |
33 | #define BITMAP_RANGE (BTRFS_FREE_SPACE_BITMAP_BITS * 4096) | 34 | #define BITMAP_RANGE (BTRFS_FREE_SPACE_BITMAP_BITS * PAGE_SIZE) |
34 | 35 | ||
35 | static int __check_free_space_extents(struct btrfs_trans_handle *trans, | 36 | static int __check_free_space_extents(struct btrfs_trans_handle *trans, |
36 | struct btrfs_fs_info *fs_info, | 37 | struct btrfs_fs_info *fs_info, |
@@ -439,7 +440,8 @@ typedef int (*test_func_t)(struct btrfs_trans_handle *, | |||
439 | struct btrfs_block_group_cache *, | 440 | struct btrfs_block_group_cache *, |
440 | struct btrfs_path *); | 441 | struct btrfs_path *); |
441 | 442 | ||
442 | static int run_test(test_func_t test_func, int bitmaps) | 443 | static int run_test(test_func_t test_func, int bitmaps, |
444 | u32 sectorsize, u32 nodesize) | ||
443 | { | 445 | { |
444 | struct btrfs_root *root = NULL; | 446 | struct btrfs_root *root = NULL; |
445 | struct btrfs_block_group_cache *cache = NULL; | 447 | struct btrfs_block_group_cache *cache = NULL; |
@@ -447,7 +449,7 @@ static int run_test(test_func_t test_func, int bitmaps) | |||
447 | struct btrfs_path *path = NULL; | 449 | struct btrfs_path *path = NULL; |
448 | int ret; | 450 | int ret; |
449 | 451 | ||
450 | root = btrfs_alloc_dummy_root(); | 452 | root = btrfs_alloc_dummy_root(sectorsize, nodesize); |
451 | if (IS_ERR(root)) { | 453 | if (IS_ERR(root)) { |
452 | test_msg("Couldn't allocate dummy root\n"); | 454 | test_msg("Couldn't allocate dummy root\n"); |
453 | ret = PTR_ERR(root); | 455 | ret = PTR_ERR(root); |
@@ -466,7 +468,8 @@ static int run_test(test_func_t test_func, int bitmaps) | |||
466 | root->fs_info->free_space_root = root; | 468 | root->fs_info->free_space_root = root; |
467 | root->fs_info->tree_root = root; | 469 | root->fs_info->tree_root = root; |
468 | 470 | ||
469 | root->node = alloc_test_extent_buffer(root->fs_info, 4096); | 471 | root->node = alloc_test_extent_buffer(root->fs_info, |
472 | nodesize, nodesize); | ||
470 | if (!root->node) { | 473 | if (!root->node) { |
471 | test_msg("Couldn't allocate dummy buffer\n"); | 474 | test_msg("Couldn't allocate dummy buffer\n"); |
472 | ret = -ENOMEM; | 475 | ret = -ENOMEM; |
@@ -474,9 +477,9 @@ static int run_test(test_func_t test_func, int bitmaps) | |||
474 | } | 477 | } |
475 | btrfs_set_header_level(root->node, 0); | 478 | btrfs_set_header_level(root->node, 0); |
476 | btrfs_set_header_nritems(root->node, 0); | 479 | btrfs_set_header_nritems(root->node, 0); |
477 | root->alloc_bytenr += 8192; | 480 | root->alloc_bytenr += 2 * nodesize; |
478 | 481 | ||
479 | cache = btrfs_alloc_dummy_block_group(8 * BITMAP_RANGE); | 482 | cache = btrfs_alloc_dummy_block_group(8 * BITMAP_RANGE, sectorsize); |
480 | if (!cache) { | 483 | if (!cache) { |
481 | test_msg("Couldn't allocate dummy block group cache\n"); | 484 | test_msg("Couldn't allocate dummy block group cache\n"); |
482 | ret = -ENOMEM; | 485 | ret = -ENOMEM; |
@@ -534,17 +537,18 @@ out: | |||
534 | return ret; | 537 | return ret; |
535 | } | 538 | } |
536 | 539 | ||
537 | static int run_test_both_formats(test_func_t test_func) | 540 | static int run_test_both_formats(test_func_t test_func, |
541 | u32 sectorsize, u32 nodesize) | ||
538 | { | 542 | { |
539 | int ret; | 543 | int ret; |
540 | 544 | ||
541 | ret = run_test(test_func, 0); | 545 | ret = run_test(test_func, 0, sectorsize, nodesize); |
542 | if (ret) | 546 | if (ret) |
543 | return ret; | 547 | return ret; |
544 | return run_test(test_func, 1); | 548 | return run_test(test_func, 1, sectorsize, nodesize); |
545 | } | 549 | } |
546 | 550 | ||
547 | int btrfs_test_free_space_tree(void) | 551 | int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize) |
548 | { | 552 | { |
549 | test_func_t tests[] = { | 553 | test_func_t tests[] = { |
550 | test_empty_block_group, | 554 | test_empty_block_group, |
@@ -561,9 +565,11 @@ int btrfs_test_free_space_tree(void) | |||
561 | 565 | ||
562 | test_msg("Running free space tree tests\n"); | 566 | test_msg("Running free space tree tests\n"); |
563 | for (i = 0; i < ARRAY_SIZE(tests); i++) { | 567 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
564 | int ret = run_test_both_formats(tests[i]); | 568 | int ret = run_test_both_formats(tests[i], sectorsize, |
569 | nodesize); | ||
565 | if (ret) { | 570 | if (ret) { |
566 | test_msg("%pf failed\n", tests[i]); | 571 | test_msg("%pf : sectorsize %u failed\n", |
572 | tests[i], sectorsize); | ||
567 | return ret; | 573 | return ret; |
568 | } | 574 | } |
569 | } | 575 | } |