Btrfs: fix chunk allocate size calculation
authorJosef Bacik <josef@redhat.com>
Wed, 17 Mar 2010 20:45:56 +0000 (20:45 +0000)
committerChris Mason <chris.mason@oracle.com>
Wed, 31 Mar 2010 01:19:09 +0000 (21:19 -0400)
If the amount of free space left in a device is less than what we think should
be the minimum size, just ignore the minimum size and use the amount we have.  I
ran into this running tests on a 600mb volume, the chunk allocator wouldn't let
me allocate the last 52mb of the disk for data because we want to have at least
64mb chunks for data.  This patch fixes that problem.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index bf3bec3..9bf1f58 100644 (file)
@@ -2244,8 +2244,10 @@ again:
                do_div(calc_size, stripe_len);
                calc_size *= stripe_len;
        }
+
        /* we don't want tiny stripes */
-       calc_size = max_t(u64, min_stripe_size, calc_size);
+       if (!looped)
+               calc_size = max_t(u64, min_stripe_size, calc_size);
 
        do_div(calc_size, stripe_len);
        calc_size *= stripe_len;