From: "Darrick J. Wong" <djwong@kernel.org>
To: Javier Tia <javier@peridio.com>
Cc: Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Dave Chinner <dgc@kernel.org>
Subject: Re: [PATCH] xfs: reserve a full directory block when repair expands the tempdir
Date: Tue, 8 Sep 2026 11:56:46 -0700 [thread overview]
Message-ID: <20260908185646.GG127607@frogsfrogsfrogs> (raw)
In-Reply-To: <20260908-b4-xrep-dir-total-v1-1-b982f1652fd7@peridio.com>
On Tue, Sep 08, 2026 at 10:16:12AM -0600, Javier Tia wrote:
> xrep_dir_swap_prep() passes args.total = 1 to xfs_dir2_sf_to_block(),
> but the conversion allocates args->geo->fsbcount filesystem blocks,
> which is 1 << sb_dirblklog. The two agree only when the directory
> block size equals the filesystem block size, so the shortfall is
> invisible on a 4k block filesystem and is four blocks on a 1k block
> filesystem carrying a 4k directory block size. xfs_da_grow_inode_int()
> then subtracts more blocks than total ever held, underflowing it, and
> hands the understated value to xfs_bmapi_write() as the remaining-space
> hint the allocator sizes minleft from.
>
> fsbcount is what the other caller of this conversion already reserves:
> xfs_bmap_add_attrfork_local() sets dargs.total the same way, and it is
> exactly what the single xfs_dir2_grow_inode() call underneath consumes.
> The attribute counterpart in xrep_xattr_swap_prep() keeps its literal 1
> because m_attr_geo->fsbcount is always 1.
>
> Found by the reservation assert in xfs_da_grow_inode_int(), which Dave
> Chinner hit running xfs/286 at 1k block size.
>
> Fixes: b1991ee3e7cf ("xfs: online repair of directories")
> Reported-by: Dave Chinner <dgc@kernel.org>
> Closes: https://lore.kernel.org/linux-xfs/ap-mIH9nTNkpWq9K@dread/
> Signed-off-by: Javier Tia <javier@peridio.com>
> ---
> fs/xfs/scrub/dir_repair.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/scrub/dir_repair.c b/fs/xfs/scrub/dir_repair.c
> index 31a23c5f386a..0a3d02d8f041 100644
> --- a/fs/xfs/scrub/dir_repair.c
> +++ b/fs/xfs/scrub/dir_repair.c
> @@ -1488,7 +1488,7 @@ xrep_dir_swap_prep(
> .geo = sc->mp->m_dir_geo,
> .whichfork = XFS_DATA_FORK,
> .trans = sc->tp,
> - .total = 1,
> + .total = sc->mp->m_dir_geo->fsbcount,
This is enough to shut up the assertion, but it doesn't fix the
additional problem that the block reservation in sc->tp can also
underrun for this same reason. I'm testing a fixpatch for both, please
be patient...
--D
> .owner = I_INO(sc->ip),
> };
>
>
> ---
> base-commit: 0ca15a1a115132dfebeee5447fd6abe46f66d61d
> change-id: 20260908-b4-xrep-dir-total-3c77d0bcff51
>
> Best regards,
> --
> Javier Tia <javier@peridio.com>
>
prev parent reply other threads:[~2026-09-08 18:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 16:16 [PATCH] xfs: reserve a full directory block when repair expands the tempdir Javier Tia
2026-09-08 18:56 ` Darrick J. Wong [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=20260908185646.GG127607@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=dgc@kernel.org \
--cc=javier@peridio.com \
--cc=linux-kernel@vger.kernel.org \
--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