btrfs: extent-tree: Remove dead alignment check
PATCH v2 1/1 btrfs: extent-tree: Remove dead alignment check
In find_free_extent() under checks: tag, we have the following code
------
search_start = ALIGN(offset, fs_info->stripesize);
/* move on to the next group */
if (search_start + num_bytes >
block_group->key.objectid + block_group->key.offset) {
btrfs_add_free_space(block_group, offset, num_bytes);
goto loop;
}
if (offset < search_start)
btrfs_add_free_space(block_group, offset,
search_start - offset);
BUG_ON(offset > search_start);------
However ALIGN() is rounding up, thus @search_start >= @offset and that BUG_ON() will never be triggered.
Signed-off-by Qu Wenruo <[email protected]>
---
changelog:
v2:
Fix my stupid error on judging whether ALIGN() is rounding up or down.
--- fs/btrfs/extent-tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/extent-tree.c +1 -2
@@ -7754,7 +7754,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, goto loop; } checks: - search_start =ALIGN (offset, fs_info->stripesize); + search_start =round_up (offset, fs_info->stripesize);/* move on to the next group */ if (search_start + num_bytes >
@@ -7766,7 +7766,6 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,if (offset < search_start)btrfs_add_free_space (block_group, offset, search_start - offset); -BUG_ON (offset > search_start); ret =btrfs_add_reserved_bytes (block_group, ram_bytes, num_bytes, delalloc);
Signature · 1 line
2.18.0
Quoted 14 lines · Qu Wenruo
In
find_free_extent()under checks: tag, we have the following code------
search_start = ALIGN(offset, fs_info->stripesize); /* move on to the next group */ if (search_start + num_bytes > block_group->key.objectid + block_group->key.offset) { btrfs_add_free_space(block_group, offset, num_bytes); goto loop; } if (offset < search_start) btrfs_add_free_space(block_group, offset, search_start - offset); BUG_ON(offset > search_start);
Quoted 6 lines
------
However
ALIGN()is rounding up, thus @search_start >= @offset and thatBUG_ON()will never be triggered.Signed-off-by Qu Wenruo <[email protected]>
Reviewed-by David Sterba <[email protected]>