From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, bfoster@redhat.com
Subject: Re: [PATCH] xfs: fix livelock in delayed allocation at ENOSPC
Date: Fri, 21 Apr 2023 20:53:00 -0700 [thread overview]
Message-ID: <20230422035300.GL360889@frogsfrogsfrogs> (raw)
In-Reply-To: <20230421222440.2722482-1-david@fromorbit.com>
On Sat, Apr 22, 2023 at 08:24:40AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> On a filesystem with a non-zero stripe unit and a large sequential
> write, delayed allocation will set a minimum allocation length of
> the stripe unit. If allocation fails because there are no extents
> long enough for an aligned minlen allocation, it is supposed to
> fall back to unaligned allocation which allows single block extents
> to be allocated.
>
> When the allocator code was rewritting in the 6.3 cycle, this
> fallback was broken - the old code used args->fsbno as the both the
> allocation target and the allocation result, the new code passes the
> target as a separate parameter. The conversion didn't handle the
> aligned->unaligned fallback path correctly - it reset args->fsbno to
> the target fsbno on failure which broke allocation failure detection
> in the high level code and so it never fell back to unaligned
> allocations.
>
> This resulted in a loop in writeback trying to allocate an aligned
> block, getting a false positive success, trying to insert the result
> in the BMBT. This did nothing because the extent already was in the
> BMBT (merge results in an unchanged extent) and so it returned the
> prior extent to the conversion code as the current iomap.
>
> Because the iomap returned didn't cover the offset we tried to map,
> xfs_convert_blocks() then retries the allocation, which fails in the
> same way and now we have a livelock.
>
> Reported-by: Brian Foster <bfoster@redhat.com>
> Fixes: 85843327094f ("xfs: factor xfs_bmap_btalloc()")
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
Will give this one a spin through the test system over the weekend.
In the meantime, can one of you come up with a reproducer? From the
description, it doesn't sound like that should be too hard -- mount with
no stripe unit set, fragment the free space, mount with a stripe unit
set, then run the fs out of space?
--D
> ---
> fs/xfs/libxfs/xfs_bmap.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 1a4e446194dd..b512de0540d5 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3540,7 +3540,6 @@ xfs_bmap_btalloc_at_eof(
> * original non-aligned state so the caller can proceed on allocation
> * failure as if this function was never called.
> */
> - args->fsbno = ap->blkno;
> args->alignment = 1;
> return 0;
> }
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-04-22 3:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 22:24 [PATCH] xfs: fix livelock in delayed allocation at ENOSPC Dave Chinner
2023-04-22 3:53 ` Darrick J. Wong [this message]
2023-04-23 22:14 ` Dave Chinner
2023-04-24 14:27 ` Brian Foster
2023-04-25 15:20 ` Darrick J. Wong
2023-04-26 23:01 ` Dave Chinner
2023-04-26 23:38 ` Darrick J. Wong
2023-04-27 0:11 ` Dave Chinner
2023-04-27 0:53 ` Darrick J. Wong
2023-04-27 5:26 ` Dave Chinner
2023-04-27 15:07 ` Darrick J. Wong
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=20230422035300.GL360889@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bfoster@redhat.com \
--cc=david@fromorbit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.