]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs: fix sparse inode limits on runt AG
authorDave Chinner <dchinner@redhat.com>
Mon, 25 Nov 2024 21:15:27 +0000 (13:15 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 28 Nov 2024 02:33:16 +0000 (18:33 -0800)
commitf8ab5309cc0cafb1c683383b0d8b2bc06b997c39
treee6321d64b0efd4a90af3fb63eadde9d928d93a1b
parent5d0eb013899769e0c3af5313b38991b31b8aec67
xfs: fix sparse inode limits on runt AG

Source kernel commit: 13325333582d4820d39b9e8f63d6a54e745585d9

The runt AG at the end of a filesystem is almost always smaller than
the mp->m_sb.sb_agblocks. Unfortunately, when setting the max_agbno
limit for the inode chunk allocation, we do not take this into
account. This means we can allocate a sparse inode chunk that
overlaps beyond the end of an AG. When we go to allocate an inode
from that sparse chunk, the irec fails validation because the
agbno of the start of the irec is beyond valid limits for the runt
AG.

Prevent this from happening by taking into account the size of the
runt AG when allocating inode chunks. Also convert the various
checks for valid inode chunk agbnos to use xfs_ag_block_count()
so that they will also catch such issues in the future.

Fixes: 56d1115c9bc7 ("xfs: allocate sparse inode chunks on full chunk allocation failure")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ialloc.c