linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, john.g.garry@oracle.com
Subject: Re: [PATCH 9/9] xfs: return -ENOSPC rather than NULLFSBLOCK from allocation functions
Date: Thu, 5 Oct 2023 05:21:11 -0700	[thread overview]
Message-ID: <ZR6qN3ZguKiZy7pC@infradead.org> (raw)
In-Reply-To: <20231004001943.349265-10-david@fromorbit.com>

> Make sure we don't have a repeat of this situation by changing the
> API to explicitly return ENOSPC when we fail to allocate. If we fail
> to capture this correctly, it will lead to failures being noticed
> either by ENOSPC escaping to userspace or by causing filesystem
> shutdowns when allocations failure where they really shouldn't.

Yes, the retur 0 on ENOSPC has driven me crazy in the past.

Note that you now also drop the XXX comment on xfs_alloc_vextent_finish
about this.

> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 27c62f303488..13fda27fabcb 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -1157,9 +1157,9 @@ xfs_alloc_ag_vextent_small(
>  	 * Can't do the allocation, give up.
>  	 */
>  	if (flen < args->minlen) {
> -		args->agbno = NULLAGBLOCK;
>  		trace_xfs_alloc_small_notenough(args);
> -		flen = 0;
> +		error = -ENOSPC;
> +		goto error;

I suspect a direct return -ENOSPC here might be better, as we already
have the trace_xfs_alloc_small_notenough tracepoint here, and also
hitting trace_xfs_alloc_small_error wouldn't make much sense (and be
a pointles behavior change).

Looking at the callers of xfs_alloc_ag_vextent_small, both seem to
need an update to check for -ENOSPC explicitly, as they first check
for an error and only after that for i == 0 || len == 0 to detect
the no space case.

> @@ -3375,14 +3370,7 @@ xfs_alloc_vextent_finish(
>  	     args->agno > minimum_agno))
>  		args->tp->t_highest_agno = args->agno;
>  
> -	/*
> -	 * If the allocation failed with an error or we had an ENOSPC result,
> -	 * preserve the returned error whilst also marking the allocation result
> -	 * as "no extent allocated". This ensures that callers that fail to
> -	 * capture the error will still treat it as a failed allocation.
> -	 */
> -	if (alloc_error || args->agbno == NULLAGBLOCK) {
> -		args->fsbno = NULLFSBLOCK;
> +	if (alloc_error) {
>  		error = alloc_error;
>  		goto out_drop_perag;
>  	}

Maybe throw in a

	ASSERT(args->agbno != NULLAGBLOCK);

after this conditional to catch backporting errors and the like?


      reply	other threads:[~2023-10-05 13:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  0:19 [RFC PATCH 0/9] xfs: push perags further into allocation routines Dave Chinner
2023-10-04  0:19 ` [PATCH 1/9] xfs: split xfs_bmap_btalloc_at_eof() Dave Chinner
2023-10-04 23:41   ` Darrick J. Wong
2023-10-05  9:41   ` Christoph Hellwig
2023-10-04  0:19 ` [PATCH 2/9] xfs: contiguous EOF allocation across AGs Dave Chinner
2023-10-05  9:43   ` Christoph Hellwig
2023-10-06  5:27   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 3/9] xfs: select the AG with the largest contiguous space Dave Chinner
2023-10-05  9:45   ` Christoph Hellwig
2023-10-05  9:46   ` Christoph Hellwig
2023-10-24 16:25     ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 4/9] xfs: push the perag outwards in initial allocation Dave Chinner
2023-10-05 11:57   ` Christoph Hellwig
2023-10-04  0:19 ` [PATCH 5/9] xfs: aligned EOF allocations don't need to scan AGs anymore Dave Chinner
2023-10-05 11:59   ` Christoph Hellwig
2023-10-06  5:55   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 6/9] xfs: use agno/agbno in xfs_alloc_vextent functions Dave Chinner
2023-10-05 12:02   ` Christoph Hellwig
2023-10-06  5:56   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 7/9] xfs: caller perag always supplied to xfs_alloc_vextent_near_bno Dave Chinner
2023-10-05 12:02   ` Christoph Hellwig
2023-10-06  5:59   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 8/9] xfs: collapse near and exact bno allocation Dave Chinner
2023-10-05 12:03   ` Christoph Hellwig
2023-10-06  6:01   ` Darrick J. Wong
2023-10-04  0:19 ` [PATCH 9/9] xfs: return -ENOSPC rather than NULLFSBLOCK from allocation functions Dave Chinner
2023-10-05 12:21   ` Christoph Hellwig [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZR6qN3ZguKiZy7pC@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).