]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: flush_space: treat return value of do_chunk_alloc properly
authorAlex Lyakas <alex@zadarastorage.com>
Sun, 6 Dec 2015 10:32:31 +0000 (12:32 +0200)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 1 Jun 2017 06:07:19 +0000 (23:07 -0700)
commitdb313c94fac21de05d136542758d71d1a0f9f02a
treecd5bdd20624168c7beff49da3135f5dc7b722efa
parented01b759c1a1cc077124c61e9d3ba05892f31d3e
btrfs: flush_space: treat return value of do_chunk_alloc properly

Orabug: 25975316`

do_chunk_alloc returns 1 when it succeeds to allocate a new chunk.
But flush_space will not convert this to 0, and will also return 1.
As a result, reserve_metadata_bytes will think that flush_space failed,
and may potentially return this value "1" to the caller (depends how
reserve_metadata_bytes was called). The caller will also treat this as an error.
For example, btrfs_block_rsv_refill does:

int ret = -ENOSPC;
...
ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush);
if (!ret) {
        block_rsv_add_bytes(block_rsv, num_bytes, 0);
        return 0;
}

return ret;

So it will return -ENOSPC.

Signed-off-by: Alex Lyakas <alex@zadarastorage.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit eecba891d38051ebf7f4af6394d188a5fd151a6a)
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
fs/btrfs/extent-tree.c