]> 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)
committerDarrick J. Wong <djwong@kernel.org>
Sat, 10 Aug 2024 06:57:19 +0000 (23:57 -0700)
commit5fdd56af3eb788b62c642cba0e90fc4c1cf1fdb4
tree318762137fa687359a0e4b267caeb3b9bbd811ff
parent16e3ecd0c1337e42de9ab5cce4a05adba8b268ed
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