summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2018-02-15 18:07:59 +0800
committerDavid Sterba <dsterba@suse.com>2018-03-26 15:09:35 +0200
commit566b1760b42be7c99c02e894b1ec9a707c2e83d1 (patch)
tree6cee8bc71b76d1b0c6e43de1f78f28ebaa25cae7 /fs
parent3752d22fcea160cc2493e34f5e0e41cdd7fdd921 (diff)
downloadlinux-566b1760b42be7c99c02e894b1ec9a707c2e83d1.tar.bz2
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: Anand Jain <anand.jain@oracle.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/inode.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e90d7c597ef3..28491a82e645 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -978,6 +978,7 @@ static noinline int cow_file_range(struct inode *inode,
num_bytes = ALIGN(end - start + 1, blocksize);
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);
@@ -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);
btrfs_drop_extent_cache(BTRFS_I(inode), start,
start + num_bytes - 1, 0);