diff options
author | Qu Wenruo <wqu@suse.com> | 2024-04-30 00:23:06 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-07-11 15:33:21 +0200 |
commit | c77a8c61002e91d859e118008fd495efbe1d9373 (patch) | |
tree | bdea6b735810f7e578aa2c34c54bd0adce08a25d /fs/btrfs/tests/extent-map-tests.c | |
parent | btrfs: remove extent_map::block_len member (diff) | |
download | linux-c77a8c61002e91d859e118008fd495efbe1d9373.tar.xz linux-c77a8c61002e91d859e118008fd495efbe1d9373.zip |
btrfs: remove extent_map::block_start member
The member extent_map::block_start can be calculated from
extent_map::disk_bytenr + extent_map::offset for regular extents.
And otherwise just extent_map::disk_bytenr.
And this is already validated by the validate_extent_map(). Now we can
remove the member.
However there is a special case in btrfs_create_dio_extent() where we
for NOCOW/PREALLOC ordered extents cannot directly use the resulting
btrfs_file_extent, as btrfs_split_ordered_extent() cannot handle them
yet.
So for that call site, we pass file_extent->disk_bytenr +
file_extent->num_bytes as disk_bytenr for the ordered extent, and 0 for
offset.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tests/extent-map-tests.c')
-rw-r--r-- | fs/btrfs/tests/extent-map-tests.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c index 0dd270d6c506..ebec4ab361b8 100644 --- a/fs/btrfs/tests/extent-map-tests.c +++ b/fs/btrfs/tests/extent-map-tests.c @@ -28,8 +28,8 @@ static int free_extent_map_tree(struct btrfs_inode *inode) if (refcount_read(&em->refs) != 1) { ret = -EINVAL; test_err( -"em leak: em (start %llu len %llu block_start %llu disk_num_bytes %llu offset %llu) refs %d", - em->start, em->len, em->block_start, +"em leak: em (start %llu len %llu disk_bytenr %llu disk_num_bytes %llu offset %llu) refs %d", + em->start, em->len, em->disk_bytenr, em->disk_num_bytes, em->offset, refcount_read(&em->refs)); @@ -77,7 +77,6 @@ static int test_case_1(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* Add [0, 16K) */ em->start = 0; em->len = SZ_16K; - em->block_start = 0; em->disk_bytenr = 0; em->disk_num_bytes = SZ_16K; em->ram_bytes = SZ_16K; @@ -100,7 +99,6 @@ static int test_case_1(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) em->start = SZ_16K; em->len = SZ_4K; - em->block_start = SZ_32K; /* avoid merging */ em->disk_bytenr = SZ_32K; /* avoid merging */ em->disk_num_bytes = SZ_4K; em->ram_bytes = SZ_4K; @@ -123,7 +121,6 @@ static int test_case_1(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* Add [0, 8K), should return [0, 16K) instead. */ em->start = start; em->len = len; - em->block_start = start; em->disk_bytenr = start; em->disk_num_bytes = len; em->ram_bytes = len; @@ -141,11 +138,11 @@ static int test_case_1(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) goto out; } if (em->start != 0 || extent_map_end(em) != SZ_16K || - em->block_start != 0 || em->disk_num_bytes != SZ_16K) { + em->disk_bytenr != 0 || em->disk_num_bytes != SZ_16K) { test_err( -"case1 [%llu %llu]: ret %d return a wrong em (start %llu len %llu block_start %llu disk_num_bytes %llu", +"case1 [%llu %llu]: ret %d return a wrong em (start %llu len %llu disk_bytenr %llu disk_num_bytes %llu", start, start + len, ret, em->start, em->len, - em->block_start, em->disk_num_bytes); + em->disk_bytenr, em->disk_num_bytes); ret = -EINVAL; } free_extent_map(em); @@ -179,7 +176,6 @@ static int test_case_2(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* Add [0, 1K) */ em->start = 0; em->len = SZ_1K; - em->block_start = EXTENT_MAP_INLINE; em->disk_bytenr = EXTENT_MAP_INLINE; em->disk_num_bytes = 0; em->ram_bytes = SZ_1K; @@ -202,7 +198,6 @@ static int test_case_2(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) em->start = SZ_4K; em->len = SZ_4K; - em->block_start = SZ_4K; em->disk_bytenr = SZ_4K; em->disk_num_bytes = SZ_4K; em->ram_bytes = SZ_4K; @@ -225,7 +220,6 @@ static int test_case_2(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* Add [0, 1K) */ em->start = 0; em->len = SZ_1K; - em->block_start = EXTENT_MAP_INLINE; em->disk_bytenr = EXTENT_MAP_INLINE; em->disk_num_bytes = 0; em->ram_bytes = SZ_1K; @@ -242,10 +236,10 @@ static int test_case_2(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) goto out; } if (em->start != 0 || extent_map_end(em) != SZ_1K || - em->block_start != EXTENT_MAP_INLINE) { + em->disk_bytenr != EXTENT_MAP_INLINE) { test_err( -"case2 [0 1K]: ret %d return a wrong em (start %llu len %llu block_start %llu", - ret, em->start, em->len, em->block_start); +"case2 [0 1K]: ret %d return a wrong em (start %llu len %llu disk_bytenr %llu", + ret, em->start, em->len, em->disk_bytenr); ret = -EINVAL; } free_extent_map(em); @@ -275,7 +269,6 @@ static int __test_case_3(struct btrfs_fs_info *fs_info, /* Add [4K, 8K) */ em->start = SZ_4K; em->len = SZ_4K; - em->block_start = SZ_4K; em->disk_bytenr = SZ_4K; em->disk_num_bytes = SZ_4K; em->ram_bytes = SZ_4K; @@ -298,7 +291,6 @@ static int __test_case_3(struct btrfs_fs_info *fs_info, /* Add [0, 16K) */ em->start = 0; em->len = SZ_16K; - em->block_start = 0; em->disk_bytenr = 0; em->disk_num_bytes = SZ_16K; em->ram_bytes = SZ_16K; @@ -321,11 +313,11 @@ static int __test_case_3(struct btrfs_fs_info *fs_info, * em->start. */ if (start < em->start || start + len > extent_map_end(em) || - em->start != em->block_start) { + em->start != extent_map_block_start(em)) { test_err( -"case3 [%llu %llu): ret %d em (start %llu len %llu block_start %llu block_len %llu)", +"case3 [%llu %llu): ret %d em (start %llu len %llu disk_bytenr %llu block_len %llu)", start, start + len, ret, em->start, em->len, - em->block_start, em->disk_num_bytes); + em->disk_bytenr, em->disk_num_bytes); ret = -EINVAL; } free_extent_map(em); @@ -386,7 +378,6 @@ static int __test_case_4(struct btrfs_fs_info *fs_info, /* Add [0K, 8K) */ em->start = 0; em->len = SZ_8K; - em->block_start = 0; em->disk_bytenr = 0; em->disk_num_bytes = SZ_8K; em->ram_bytes = SZ_8K; @@ -409,7 +400,6 @@ static int __test_case_4(struct btrfs_fs_info *fs_info, /* Add [8K, 32K) */ em->start = SZ_8K; em->len = 24 * SZ_1K; - em->block_start = SZ_16K; /* avoid merging */ em->disk_bytenr = SZ_16K; /* avoid merging */ em->disk_num_bytes = 24 * SZ_1K; em->ram_bytes = 24 * SZ_1K; @@ -431,7 +421,6 @@ static int __test_case_4(struct btrfs_fs_info *fs_info, /* Add [0K, 32K) */ em->start = 0; em->len = SZ_32K; - em->block_start = 0; em->disk_bytenr = 0; em->disk_num_bytes = SZ_32K; em->ram_bytes = SZ_32K; @@ -451,9 +440,9 @@ static int __test_case_4(struct btrfs_fs_info *fs_info, } if (start < em->start || start + len > extent_map_end(em)) { test_err( -"case4 [%llu %llu): ret %d, added wrong em (start %llu len %llu block_start %llu disk_num_bytes %llu)", - start, start + len, ret, em->start, em->len, em->block_start, - em->disk_num_bytes); +"case4 [%llu %llu): ret %d, added wrong em (start %llu len %llu disk_bytenr %llu disk_num_bytes %llu)", + start, start + len, ret, em->start, em->len, + em->disk_bytenr, em->disk_num_bytes); ret = -EINVAL; } free_extent_map(em); @@ -517,7 +506,6 @@ static int add_compressed_extent(struct btrfs_inode *inode, em->start = start; em->len = len; - em->block_start = block_start; em->disk_bytenr = block_start; em->disk_num_bytes = SZ_4K; em->ram_bytes = len; @@ -740,7 +728,6 @@ static int test_case_6(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) em->start = SZ_4K; em->len = SZ_4K; - em->block_start = SZ_16K; em->disk_bytenr = SZ_16K; em->disk_num_bytes = SZ_16K; em->ram_bytes = SZ_16K; @@ -795,7 +782,6 @@ static int test_case_7(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* [0, 16K), pinned */ em->start = 0; em->len = SZ_16K; - em->block_start = 0; em->disk_bytenr = 0; em->disk_num_bytes = SZ_4K; em->ram_bytes = SZ_16K; @@ -819,7 +805,6 @@ static int test_case_7(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) /* [32K, 48K), not pinned */ em->start = SZ_32K; em->len = SZ_16K; - em->block_start = SZ_32K; em->disk_bytenr = SZ_32K; em->disk_num_bytes = SZ_16K; em->ram_bytes = SZ_16K; @@ -885,8 +870,9 @@ static int test_case_7(struct btrfs_fs_info *fs_info, struct btrfs_inode *inode) goto out; } - if (em->block_start != SZ_32K + SZ_4K) { - test_err("em->block_start is %llu, expected 36K", em->block_start); + if (extent_map_block_start(em) != SZ_32K + SZ_4K) { + test_err("em->block_start is %llu, expected 36K", + extent_map_block_start(em)); goto out; } |