summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_file.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-04-16 00:54:12 +0300
committerDarrick J. Wong <djwong@kernel.org>2024-04-16 00:54:12 +0300
commitac5cebeed61351c0a60c65bd20c70120469c46ff (patch)
treeb6273d5aaa91c015b3f85e054639f4a3596ba1aa /fs/xfs/xfs_file.c
parent6b700a5be9b3b69419474622336c63fdc1cc3ca4 (diff)
downloadlinux-ac5cebeed61351c0a60c65bd20c70120469c46ff.tar.xz
xfs: refactor non-power-of-two alignment checks
Create a helper function that can compute if a 64-bit number is an integer multiple of a 32-bit number, where the 32-bit number is not required to be an even power of two. This is needed for some new code for the realtime device, where we can set 37k allocation units and then have to remap them. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r--fs/xfs/xfs_file.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 64278f8acaee..d1d4158441bd 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -47,15 +47,9 @@ xfs_is_falloc_aligned(
{
unsigned int alloc_unit = xfs_inode_alloc_unitsize(ip);
- if (!is_power_of_2(alloc_unit)) {
- u32 mod;
-
- div_u64_rem(pos, alloc_unit, &mod);
- if (mod)
- return false;
- div_u64_rem(len, alloc_unit, &mod);
- return mod == 0;
- }
+ if (!is_power_of_2(alloc_unit))
+ return isaligned_64(pos, alloc_unit) &&
+ isaligned_64(len, alloc_unit);
return !((pos | len) & (alloc_unit - 1));
}