Re: [BUG] xfs: sparse inode allocation can trip i != 1 after AGFL growth

Matt Fleming <[email protected]>
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.linux-kernel
Message-ID <al33dUXS_8Yr5vEu@matt-Precision-5490>
On Fri, Jul 17, 2026 at 01:55:42PM -0400, Brian Foster wrote:
> On Fri, Jul 17, 2026 at 02:04:29PM +0100, Matt Fleming wrote:
> > 
> > The failure sequence seems to be:
> > 
> > 1. AG0 has no free inodes, so inode allocation needs a new chunk.
> > 2. Full chunk allocation cannot fit.
> > 3. Sparse chunk allocation can fit and passes the old AGFL minimum check.
> > 4. Removing the sparse extent from free space grows both bnobt and cntbt.
> 
> I assume this means we happen to alloc a sparse chunk out of the middle
> of a free extent, causing an additional record and thus splits in both
> trees.
 
Yep, exactly.

> It also looks like we set args.minleft = igeo->inobt_maxlevels in the
> chunk alloc path, presumably with the intent to leave enough blocks
> around for inode record insertion. I assume the above available value is
> prior to the sparse chunk alloc. It would be interesting to see what the
> same values/calculations are after the chunk alloc at the time of the
> inobt block alloc that fails.
 
Before sparse inode allocation:

   pagf_freeblks:    2514
   pagf_flcount:     8
   levels:           bno/cnt/rmap = 1/1/2
   reservation:      2505
   minleft:          2
   min_freelist:     8
   AGFL credit:      min(8, 8) = 8

   available:
     2514 + 8 - 2505 - 8 - 2 = 7

   request:
     minlen=4 align=4 slop=0
     alloc_len = 4 + (4 - 1) + 0 = 7

So the sparse inode allocation only just passes the allocator check.

After sparse inode allocation, at the failing inobt split allocation:

   pagf_freeblks:    2510
   pagf_flcount:     4
   levels:           bno/cnt/rmap = 2/2/2
   reservation:      2505
   minleft:          0
   min_freelist:     12
   AGFL credit:      min(4, 12) = 4

   available:
     2510 + 4 - 2505 - 12 - 0 = -3

   request:
     minlen=1

So after removing the 4-block sparse extent, bnobt/cntbt have grown,
AGFL has dropped, min_freelist has increased from 8 to 12, and the
later single-block inobt allocation has no available space.

Thanks,
Matt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.