]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xfs: limit maxlen based on available space in xfs_rtallocate_extent_near()
authorOmar Sandoval <osandov@fb.com>
Mon, 16 Oct 2023 17:45:46 +0000 (10:45 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 19 Oct 2023 15:34:33 +0000 (08:34 -0700)
commitec5857bf07639a03d32b8ecb346df634925f8bc2
tree06c0535ea3f6dda7702cd49ee43783e5637a3d5c
parent1b5d63963f9820b1c14883ee56b387586ff72aa0
xfs: limit maxlen based on available space in xfs_rtallocate_extent_near()

xfs_rtallocate_extent_near() calls xfs_rtallocate_extent_block() with
the minlen and maxlen that were passed to it.
xfs_rtallocate_extent_block() then scans the bitmap block looking for a
free range of size maxlen. If there is none, it has to scan the whole
bitmap block before returning the largest range of at least size minlen.
For a fragmented realtime device and a large allocation request, it's
almost certain that this will have to search the whole bitmap block,
leading to high CPU usage.

However, the realtime summary tells us the maximum size available in the
bitmap block. We can limit the search in xfs_rtallocate_extent_block()
to that size and often stop before scanning the whole bitmap block.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_rtalloc.c