提交 0abd5b17 编写于 作者: L Liu Bo 提交者: Josef Bacik

Btrfs: return error when we specify wrong start to defrag

We need such a sanity check for wrong start when we defrag a file, otherwise,
even with a wrong start that's larger than file size, we can end up changing
not only inode's force compress flag but also FS's incompat flags.
Signed-off-by: NLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: NDavid Sterba <dsterba@suse.cz>
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
上级 3c59ccd3
......@@ -1154,8 +1154,11 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
u64 new_align = ~((u64)128 * 1024 - 1);
struct page **pages = NULL;
if (extent_thresh == 0)
extent_thresh = 256 * 1024;
if (isize == 0)
return 0;
if (range->start >= isize)
return -EINVAL;
if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
if (range->compress_type > BTRFS_COMPRESS_TYPES)
......@@ -1164,8 +1167,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
compress_type = range->compress_type;
}
if (isize == 0)
return 0;
if (extent_thresh == 0)
extent_thresh = 256 * 1024;
/*
* if we were not given a file, allocate a readahead
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册