]> Pileus Git - ~andy/linux/commitdiff
Btrfs: return ENOSPC when target space is full
authorFilipe David Borba Manana <fdmanana@gmail.com>
Mon, 5 Aug 2013 15:25:12 +0000 (16:25 +0100)
committerChris Mason <chris.mason@fusionio.com>
Sun, 1 Sep 2013 12:04:55 +0000 (08:04 -0400)
In extent-tree.c:do_chunk_alloc(), early on we returned 0 (success)
when the target space was full and when chunk allocation is needed.
However, later on in that same function we return ENOSPC if
btrfs_alloc_chunk() fails (and chunk allocation was needed) and
set the space's full flag.

This was inconsistent, as -ENOSPC should be returned if the space
is full and a chunk allocation needs to performed. If the space is
full but no chunk allocation is needed, just return 0 (success).

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/extent-tree.c

index a073f3ece43a62d6e57f12bb94a9948edeed83c2..277d2c26b03438d6894b60bedc8da9836dd9d6f5 100644 (file)
@@ -3836,8 +3836,12 @@ again:
        if (force < space_info->force_alloc)
                force = space_info->force_alloc;
        if (space_info->full) {
+               if (should_alloc_chunk(extent_root, space_info, force))
+                       ret = -ENOSPC;
+               else
+                       ret = 0;
                spin_unlock(&space_info->lock);
-               return 0;
+               return ret;
        }
 
        if (!should_alloc_chunk(extent_root, space_info, force)) {