]> www.infradead.org Git - users/hch/xfs.git/commit
xfs: refactor aligning bestlen to prod
authorDarrick J. Wong <djwong@kernel.org>
Fri, 30 Aug 2024 22:37:04 +0000 (15:37 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Sun, 1 Sep 2024 15:58:19 +0000 (08:58 -0700)
commite6a74dcf9bc3f14e4ad4c9c97a47e591a3f3b49f
tree3e038c95c46387641ed13be8c41b2a3b9326d945
parente99aa0401eb4d3b0ce67cc8a9b98595958b0d038
xfs: refactor aligning bestlen to prod

There are two places in xfs_rtalloc.c where we want to make sure that a
count of rt extents is aligned with a particular prod(uct) factor.  In
one spot, we actually use rounddown(), albeit unnecessarily if prod < 2.
In the other case, we open-code this rounding inefficiently by promoting
the 32-bit length value to a 64-bit value and then performing a 64-bit
division to figure out the subtraction.

Refactor this into a single helper that uses the correct types and
division method for the type, and skips the division entirely unless
prod is large enough to make a difference.

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