diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-07-14 11:06:43 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-10-14 14:16:49 -0700 |
commit | 021348feb8f7d8793a3316d5596d6534698c69be (patch) | |
tree | 90b602cb95d137761e7c1a953ecaf6bfb2ba7934 /fs/xfs/xfs_file.c | |
parent | c6aea2c295ad73535a071ad21c19a7ee4c57266d (diff) |
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>
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r-- | fs/xfs/xfs_file.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index a3d95fb5d523..3a66a1a4623a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -46,15 +46,9 @@ xfs_is_falloc_aligned( { unsigned int alloc_unit = xfs_inode_alloc_unitsize(ip); - if (XFS_IS_REALTIME_INODE(ip) && !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 (XFS_IS_REALTIME_INODE(ip) && !is_power_of_2(alloc_unit)) + return isaligned_64(pos, alloc_unit) && + isaligned_64(len, alloc_unit); return !((pos | len) & (alloc_unit - 1)); } |