diff options
author | Alex Lyakas <alex@zadarastorage.com> | 2015-12-06 05:32:31 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-08-25 06:58:18 -0400 |
commit | eecba891d38051ebf7f4af6394d188a5fd151a6a (patch) | |
tree | 941a1a6626018519dab16e4373a884bb36ec05a0 | |
parent | f3bca8028bd934e96257b8bd1143e6474fe98465 (diff) |
btrfs: flush_space: treat return value of do_chunk_alloc properly
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>
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e962b0e25324..d2cc16ff3e21 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4882,7 +4882,7 @@ static int flush_space(struct btrfs_root *root, | |||
4882 | btrfs_get_alloc_profile(root, 0), | 4882 | btrfs_get_alloc_profile(root, 0), |
4883 | CHUNK_ALLOC_NO_FORCE); | 4883 | CHUNK_ALLOC_NO_FORCE); |
4884 | btrfs_end_transaction(trans, root); | 4884 | btrfs_end_transaction(trans, root); |
4885 | if (ret == -ENOSPC) | 4885 | if (ret > 0 || ret == -ENOSPC) |
4886 | ret = 0; | 4886 | ret = 0; |
4887 | break; | 4887 | break; |
4888 | case COMMIT_TRANS: | 4888 | case COMMIT_TRANS: |