]> www.infradead.org Git - users/hch/xfs.git/commit
xfs: don't return too-short extents from xfs_rtallocate_extent_block
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Aug 2024 23:03:45 +0000 (16:03 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 27 Aug 2024 03:49:31 +0000 (05:49 +0200)
commit0d3be4a13bdcc9e03b2edd522f1fde445cf4340e
tree8b8fb34160bd9095381d09e5a287bc6cf8e40e86
parent0f1cd252c579b816cb1a5de2b9ffda588134bc90
xfs: don't return too-short extents from xfs_rtallocate_extent_block

If xfs_rtallocate_extent_block is asked for a variable-sized allocation,
it will try to return the best-sized free extent, which is apparently
the largest one that it finds starting in this rtbitmap block.  It will
then trim the size of the extent as needed to align it with prod.

However, it misses one thing -- rounding down the best-fit candidate to
the required alignment could make the extent shorter than minlen.  In
the case where minlen > 1, we'd rather the caller relaxed its alignment
requirements and tried again, as the allocator already supports that.

Returning a too-short extent that causes xfs_bmapi_write to return
ENOSR if there aren't enough nmaps to handle multiple new allocations,
which can then cause filesystem shutdowns.

I haven't seen this happen on any production systems, but then I don't
think it's very common to set a per-file extent size hint on realtime
files.  I tripped it while working on the rtgroups feature and pounding
on the realtime allocator enthusiastically.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_rtalloc.c