提交 09fb99a6 编写于 作者: F Filipe David Borba Manana 提交者: Chris Mason

Btrfs: return ENOSPC when target space is full

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: NFilipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
Signed-off-by: NChris Mason <chris.mason@fusionio.com>
上级 ada9af21
...@@ -3836,8 +3836,12 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, ...@@ -3836,8 +3836,12 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
if (force < space_info->force_alloc) if (force < space_info->force_alloc)
force = space_info->force_alloc; force = space_info->force_alloc;
if (space_info->full) { if (space_info->full) {
if (should_alloc_chunk(extent_root, space_info, force))
ret = -ENOSPC;
else
ret = 0;
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
return 0; return ret;
} }
if (!should_alloc_chunk(extent_root, space_info, force)) { if (!should_alloc_chunk(extent_root, space_info, force)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册