]> git.itanic.dy.fi Git - linux-stable/commit
xfs: simplify and optimize the RT allocation fallback cascade
authorChristoph Hellwig <hch@lst.de>
Mon, 18 Dec 2023 04:57:36 +0000 (05:57 +0100)
committerChandan Babu R <chandanbabu@kernel.org>
Fri, 22 Dec 2023 05:48:15 +0000 (11:18 +0530)
commitb6bb34588f4c95a56f23160bf3cadee74fa5480b
tree79122058c880396dc464d44a36ab8f362aa12f25
parent26e5eed7802299a666714ee511da58d906e8770c
xfs: simplify and optimize the RT allocation fallback cascade

There are currently multiple levels of fall back if an RT allocation
can not be satisfied:

 1) xfs_rtallocate_extent extends the minlen and reduces the maxlen due
    to the extent size hint.  If that can't be done, it return -ENOSPC
    and let's xfs_bmap_rtalloc retry, which then not only drops the
    extent size hint based alignment, but also the minlen adjustment
 2) if xfs_rtallocate_extent gets -ENOSPC from the underlying functions,
    it only drops the extent size hint based alignment and retries
 3) if that still does not succeed, xfs_rtallocate_extent drops the
    extent size hint (which is a complex no-op at this point) and the
    minlen using the same code as (1) above
 4) if that still doesn't success and the caller wanted an allocation
    near a blkno, drop that blkno hint.

The handling in 1 is rather inefficient as we could just drop the
alignment and continue, and 2/3 interact in really weird ways due to
the duplicate policy.

Move aligning the min and maxlen out of xfs_rtallocate_extent and into
a helper called directly by xfs_bmap_rtalloc.  This allows just
continuing with the allocation if we have to drop the alignment instead
of going through the retry loop and also dropping the perfectly usable
minlen adjustment that didn't cause the problem, and then just use
a single retry that drops both the minlen and alignment requirement
when we really are out of space, thus consolidating cases (2) and (3)
above.

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