btrfs: Fix early enospc because 'unused' calculated with wrong sign.
authorArne Jansen <sensille@gmx.net>
Fri, 12 Nov 2010 23:17:56 +0000 (23:17 +0000)
committerChris Mason <chris.mason@oracle.com>
Mon, 22 Nov 2010 03:26:04 +0000 (22:26 -0500)
'unused' calculated with wrong sign in reserve_metadata_bytes().
This might have lead to unwanted over-reservations.

Signed-off-by: Arne Jansen <sensille@gmx.net>
Reviewed-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c

index a541bc87f04c81c1d3d612131e0fdbb14ab22115..ddaf6340fe7f75017a463cc78ae2314b597747d6 100644 (file)
@@ -3413,7 +3413,7 @@ again:
         * our reservation.
         */
        if (unused <= space_info->total_bytes) {
-               unused -= space_info->total_bytes;
+               unused = space_info->total_bytes - unused;
                if (unused >= num_bytes) {
                        if (!reserved)
                                space_info->bytes_reserved += orig_bytes;