| .. | .. |
|---|
| 8 | 8 | #include "../ctree.h" |
|---|
| 9 | 9 | #include "../disk-io.h" |
|---|
| 10 | 10 | #include "../free-space-cache.h" |
|---|
| 11 | +#include "../block-group.h" |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | #define BITS_PER_BITMAP (PAGE_SIZE * 8UL) |
|---|
| 13 | 14 | |
|---|
| .. | .. |
|---|
| 16 | 17 | * entry and remove space from either end and the middle, and make sure we can |
|---|
| 17 | 18 | * remove space that covers adjacent extent entries. |
|---|
| 18 | 19 | */ |
|---|
| 19 | | -static int test_extents(struct btrfs_block_group_cache *cache) |
|---|
| 20 | +static int test_extents(struct btrfs_block_group *cache) |
|---|
| 20 | 21 | { |
|---|
| 21 | 22 | int ret = 0; |
|---|
| 22 | 23 | |
|---|
| .. | .. |
|---|
| 86 | 87 | return 0; |
|---|
| 87 | 88 | } |
|---|
| 88 | 89 | |
|---|
| 89 | | -static int test_bitmaps(struct btrfs_block_group_cache *cache, |
|---|
| 90 | | - u32 sectorsize) |
|---|
| 90 | +static int test_bitmaps(struct btrfs_block_group *cache, u32 sectorsize) |
|---|
| 91 | 91 | { |
|---|
| 92 | 92 | u64 next_bitmap_offset; |
|---|
| 93 | 93 | int ret; |
|---|
| .. | .. |
|---|
| 155 | 155 | } |
|---|
| 156 | 156 | |
|---|
| 157 | 157 | /* This is the high grade jackassery */ |
|---|
| 158 | | -static int test_bitmaps_and_extents(struct btrfs_block_group_cache *cache, |
|---|
| 158 | +static int test_bitmaps_and_extents(struct btrfs_block_group *cache, |
|---|
| 159 | 159 | u32 sectorsize) |
|---|
| 160 | 160 | { |
|---|
| 161 | 161 | u64 bitmap_offset = (u64)(BITS_PER_BITMAP * sectorsize); |
|---|
| .. | .. |
|---|
| 330 | 330 | |
|---|
| 331 | 331 | /* Used by test_steal_space_from_bitmap_to_extent(). */ |
|---|
| 332 | 332 | static int |
|---|
| 333 | | -check_num_extents_and_bitmaps(const struct btrfs_block_group_cache *cache, |
|---|
| 333 | +check_num_extents_and_bitmaps(const struct btrfs_block_group *cache, |
|---|
| 334 | 334 | const int num_extents, |
|---|
| 335 | 335 | const int num_bitmaps) |
|---|
| 336 | 336 | { |
|---|
| .. | .. |
|---|
| 350 | 350 | } |
|---|
| 351 | 351 | |
|---|
| 352 | 352 | /* Used by test_steal_space_from_bitmap_to_extent(). */ |
|---|
| 353 | | -static int check_cache_empty(struct btrfs_block_group_cache *cache) |
|---|
| 353 | +static int check_cache_empty(struct btrfs_block_group *cache) |
|---|
| 354 | 354 | { |
|---|
| 355 | 355 | u64 offset; |
|---|
| 356 | 356 | u64 max_extent_size; |
|---|
| .. | .. |
|---|
| 392 | 392 | * requests. |
|---|
| 393 | 393 | */ |
|---|
| 394 | 394 | static int |
|---|
| 395 | | -test_steal_space_from_bitmap_to_extent(struct btrfs_block_group_cache *cache, |
|---|
| 395 | +test_steal_space_from_bitmap_to_extent(struct btrfs_block_group *cache, |
|---|
| 396 | 396 | u32 sectorsize) |
|---|
| 397 | 397 | { |
|---|
| 398 | 398 | int ret; |
|---|
| .. | .. |
|---|
| 404 | 404 | }; |
|---|
| 405 | 405 | const struct btrfs_free_space_op *orig_free_space_ops; |
|---|
| 406 | 406 | |
|---|
| 407 | | - test_msg("running space stealing from bitmap to extent"); |
|---|
| 407 | + test_msg("running space stealing from bitmap to extent tests"); |
|---|
| 408 | 408 | |
|---|
| 409 | 409 | /* |
|---|
| 410 | 410 | * For this test, we want to ensure we end up with an extent entry |
|---|
| .. | .. |
|---|
| 828 | 828 | int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize) |
|---|
| 829 | 829 | { |
|---|
| 830 | 830 | struct btrfs_fs_info *fs_info; |
|---|
| 831 | | - struct btrfs_block_group_cache *cache; |
|---|
| 831 | + struct btrfs_block_group *cache; |
|---|
| 832 | 832 | struct btrfs_root *root = NULL; |
|---|
| 833 | 833 | int ret = -ENOMEM; |
|---|
| 834 | 834 | |
|---|
| 835 | 835 | test_msg("running btrfs free space cache tests"); |
|---|
| 836 | 836 | fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize); |
|---|
| 837 | | - if (!fs_info) |
|---|
| 837 | + if (!fs_info) { |
|---|
| 838 | + test_std_err(TEST_ALLOC_FS_INFO); |
|---|
| 838 | 839 | return -ENOMEM; |
|---|
| 839 | | - |
|---|
| 840 | + } |
|---|
| 840 | 841 | |
|---|
| 841 | 842 | /* |
|---|
| 842 | 843 | * For ppc64 (with 64k page size), bytes per bitmap might be |
|---|
| .. | .. |
|---|
| 846 | 847 | cache = btrfs_alloc_dummy_block_group(fs_info, |
|---|
| 847 | 848 | BITS_PER_BITMAP * sectorsize + PAGE_SIZE); |
|---|
| 848 | 849 | if (!cache) { |
|---|
| 849 | | - test_err("couldn't run the tests"); |
|---|
| 850 | + test_std_err(TEST_ALLOC_BLOCK_GROUP); |
|---|
| 850 | 851 | btrfs_free_dummy_fs_info(fs_info); |
|---|
| 851 | 852 | return 0; |
|---|
| 852 | 853 | } |
|---|
| 853 | 854 | |
|---|
| 854 | 855 | root = btrfs_alloc_dummy_root(fs_info); |
|---|
| 855 | 856 | if (IS_ERR(root)) { |
|---|
| 857 | + test_std_err(TEST_ALLOC_ROOT); |
|---|
| 856 | 858 | ret = PTR_ERR(root); |
|---|
| 857 | 859 | goto out; |
|---|
| 858 | 860 | } |
|---|
| .. | .. |
|---|
| 874 | 876 | btrfs_free_dummy_block_group(cache); |
|---|
| 875 | 877 | btrfs_free_dummy_root(root); |
|---|
| 876 | 878 | btrfs_free_dummy_fs_info(fs_info); |
|---|
| 877 | | - test_msg("free space cache tests finished"); |
|---|
| 878 | 879 | return ret; |
|---|
| 879 | 880 | } |
|---|