]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
Btrfs: fix off-by-one error of the reserved size of btrfs_allocate()
authorMiao Xie <miaox@cn.fujitsu.com>
Wed, 28 Nov 2012 10:28:54 +0000 (10:28 +0000)
committerChris Mason <chris.mason@fusionio.com>
Mon, 17 Dec 2012 01:46:15 +0000 (20:46 -0500)
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: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/file.c

index a43d0aef6ee1cf71bfde7e510d0f9085b34b1564..8e3d6788d6dd09e29fe444393661d9a8e532d3d0 100644 (file)
@@ -2072,7 +2072,7 @@ static long btrfs_fallocate(struct file *file, int mode,
         * Make sure we have enough space before we do the
         * 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)
                return ret;
 
@@ -2179,7 +2179,7 @@ static long btrfs_fallocate(struct file *file, int mode,
 out:
        mutex_unlock(&inode->i_mutex);
        /* 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;
 }