linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: return ENOSPC when target space is full
@ 2013-08-05 15:25 Filipe David Borba Manana
  2014-01-19 14:59 ` Alex Lyakas
  0 siblings, 1 reply; 2+ messages in thread
From: Filipe David Borba Manana @ 2013-08-05 15:25 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

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>
---
 fs/btrfs/extent-tree.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e868c35..ef89a66 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3829,8 +3829,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)) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: return ENOSPC when target space is full
  2013-08-05 15:25 [PATCH] Btrfs: return ENOSPC when target space is full Filipe David Borba Manana
@ 2014-01-19 14:59 ` Alex Lyakas
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Lyakas @ 2014-01-19 14:59 UTC (permalink / raw)
  To: Filipe David Borba Manana; +Cc: linux-btrfs

Hi Filipe,
I think in the context of do_chunk_alloc(), 0 doesn't mean "success".
0 means "allocation was not attempted". While 1 means "allocation was
attempted and succeeded". -ENOSPC means "allocation was attempted but
failed". Any other errno deserves transaction abort.
Anyways, the callers are ok with "0" and -ENOSPC and re-search for a
free extent in these cases.

Alex.


On Mon, Aug 5, 2013 at 5:25 PM, Filipe David Borba Manana
<fdmanana@gmail.com> wrote:
> 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>
> ---
>  fs/btrfs/extent-tree.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index e868c35..ef89a66 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3829,8 +3829,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)) {
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-19 14:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-05 15:25 [PATCH] Btrfs: return ENOSPC when target space is full Filipe David Borba Manana
2014-01-19 14:59 ` Alex Lyakas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).