Commit 566b1760 authored by Anand Jain's avatar Anand Jain Committed by David Sterba

btrfs: use ASSERT to report logical error in cow_file_range()

Use ASSERT to report logical error in cow_file_range(), also move it a
bit closer to when the num_bytes is derived.

The extent start could be (u64)-1 in some cases, the assert should catch
that we do not accidentally pass it to cow_file_range.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3752d22f
...@@ -978,6 +978,7 @@ static noinline int cow_file_range(struct inode *inode, ...@@ -978,6 +978,7 @@ static noinline int cow_file_range(struct inode *inode,
num_bytes = ALIGN(end - start + 1, blocksize); num_bytes = ALIGN(end - start + 1, blocksize);
num_bytes = max(blocksize, num_bytes); num_bytes = max(blocksize, num_bytes);
ASSERT(num_bytes <= btrfs_super_total_bytes(fs_info->super_copy));
inode_should_defrag(BTRFS_I(inode), start, end, num_bytes, SZ_64K); inode_should_defrag(BTRFS_I(inode), start, end, num_bytes, SZ_64K);
...@@ -1008,8 +1009,6 @@ static noinline int cow_file_range(struct inode *inode, ...@@ -1008,8 +1009,6 @@ static noinline int cow_file_range(struct inode *inode,
} }
} }
BUG_ON(num_bytes > btrfs_super_total_bytes(fs_info->super_copy));
alloc_hint = get_extent_allocation_hint(inode, start, num_bytes); alloc_hint = get_extent_allocation_hint(inode, start, num_bytes);
btrfs_drop_extent_cache(BTRFS_I(inode), start, btrfs_drop_extent_cache(BTRFS_I(inode), start,
start + num_bytes - 1, 0); start + num_bytes - 1, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment