]> www.infradead.org Git - users/jedix/linux-maple.git/commit
xfs: fix broken variable-sized allocation detection in xfs_rtallocate_extent_block
authorDarrick J. Wong <djwong@kernel.org>
Fri, 30 Aug 2024 22:37:06 +0000 (15:37 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:19 +0000 (08:58 -0700)
commit9e9be9840fad01dec3ee958fc401c4863c360202
tree5e794f5c40ba329131d449fa22adb1972fe6d71c
parent74c234bbe51a1b142400ab018b605e2f16274e10
xfs: fix broken variable-sized allocation detection in xfs_rtallocate_extent_block

This function tries to find a suitable free space extent starting from
a particular rtbitmap block.  Some time ago, I added a clamping function
to prevent the free space scans from running off the end of the bitmap,
but I didn't quite get the logic right.

Let's say there's an allocation request with a minlen of 5 and a maxlen
of 32 and we're scanning the last rtbitmap block.  If we come within 4
rtx of the end of the rt volume, maxlen will get clamped to 4.  If the
next 3 rtx are free, we could have satisfied the allocation, but the
code setting partial besti/bestlen for "minlen < maxlen" will think that
we're doing a non-variable allocation and ignore it.

The root of this problem is overwriting maxlen; I should have stuffed
the results in a different variable, which would not have introduced
this bug.

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