Commit 0ff6fabd authored by Miao Xie's avatar Miao Xie Committed by Chris Mason

Btrfs: fix off-by-one error of the reserved size of btrfs_allocate()

alloc_end is not the real end of the current extent, it is the start of the
next adjoining extent. So we needn't +1 when calculating the size the space
that is about to be reserved.
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 797f4277
...@@ -2072,7 +2072,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -2072,7 +2072,7 @@ static long btrfs_fallocate(struct file *file, int mode,
* Make sure we have enough space before we do the * Make sure we have enough space before we do the
* allocation. * allocation.
*/ */
ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start + 1); ret = btrfs_check_data_free_space(inode, alloc_end - alloc_start);
if (ret) if (ret)
return ret; return ret;
...@@ -2179,7 +2179,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -2179,7 +2179,7 @@ static long btrfs_fallocate(struct file *file, int mode,
out: out:
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
/* Let go of our reservation. */ /* Let go of our reservation. */
btrfs_free_reserved_data_space(inode, alloc_end - alloc_start + 1); btrfs_free_reserved_data_space(inode, alloc_end - alloc_start);
return ret; return ret;
} }
......
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