Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Javier Tia <javier@peridio.com>
To: Dave Chinner <dgc@kernel.org>, linux-xfs@vger.kernel.org
Cc: "Darrick J. Wong" <djwong@kernel.org>, Carlos Maiolino <cem@kernel.org>
Subject: Re: [bug v7.3-rc2] dabtree block accounting assertion failure in xfs/286
Date: Tue, 08 Sep 2026 08:45:56 -0600	[thread overview]
Message-ID: <20260908144556.ehhplwwele@jetm.me> (raw)
In-Reply-To: <ap-mIH9nTNkpWq9K@dread>

Hi Dave,

On Tue, Sep 08, 2026 at 06:07:39AM +0000, Dave Chinner wrote:
> [ 5725.316568] XFS: Assertion failed: args->total >= dp->i_nblocks - nblks, file: fs/xfs/libxfs/xfs_da_btree.c, line: 2387
[...]
>  xfs_dir2_sf_to_block+0x143/0x800 [xfs]
>  xrep_dir_swap_prep+0x134/0x170 [xfs]

The assert is right and the caller is wrong. Sorry for the breakage.

xrep_dir_swap_prep() builds its xfs_da_args with .total = 1, but
xfs_dir2_sf_to_block() goes through xfs_dir2_grow_inode(), which
allocates args->geo->fsbcount blocks. m_dir_geo->fsbcount is
1 << sb_dirblklog. Nothing forces those to match. At 4k blocks with a
4k directory block size fsbcount is 1 and the reservation happens to be
exact, which is why the default config never trips it. At 1k blocks
with a 4k directory block size it is 4, and total is short by three.

The non-repair caller of the same conversion already reserves it that
way: xfs_bmap_add_attrfork_local() sets dargs.total to
dargs.geo->fsbcount immediately before calling xfs_dir2_sf_to_block().
The fix mirrors that. The attr side is fine as it stands, because
xrep_xattr_swap_prep() passes 1 for m_attr_geo, whose fsbcount is
hardcoded to 1.

args in xrep_dir_swap_prep() is a stack local used for that one conversion
and then dropped, so the underflowed total never reaches a second
allocation. The understated value did reach xfs_bmapi_write(), as the total
the allocator sizes minleft from. That is a spurious ENOSPC at worst rather
than corruption, which is probably why it sat there since b1991ee3e7cf
without anyone noticing.

I have not run xfs/286, and I do not have a 1k setup here to run it on.
The patch alongside this is untested. Dave, could you put it through the
config that tripped the assert? Carlos, if you would rather have for-next
quiet in the meantime, reverting 0fe77e57588b is fine by me and I will
resend this behind the repair fix.

-- 
Javier Tia

      reply	other threads:[~2026-09-08 18:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  6:07 [bug v7.3-rc2] dabtree block accounting assertion failure in xfs/286 Dave Chinner
2026-09-08 14:45 ` Javier Tia [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=20260908144556.ehhplwwele@jetm.me \
    --to=javier@peridio.com \
    --cc=cem@kernel.org \
    --cc=dgc@kernel.org \
    --cc=djwong@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