On 06/03/2024 05:20, Dave Chinner wrote:
Hi Garry,
I figured that it was simpler just to write the forced extent
alignment allocator patches that to make you struggle through them
and require lots of round trips to understand all the weird corner
cases.
The following 3 patches:
- rework the setup and extent allocation logic a bit to make force
aligned allocation much easier to implement and understand
- move all the alignment adjustments into the setup logic
- rework the alignment slop calculations and greatly simplify the
the exact EOF block allocation case
- add a XFS_ALLOC_FORCEALIGN flag so that the inode config only
needs to be checked once at setup. This also allows other
allocation types (e.g. inode clusters) use forced alignment
allocation semantics in future.
- clearly document when we are turning off allocation alignment and
abort FORCEALIGN allocation at that point rather than doing
unaligned allocation.
I've run this through fstests once so it doesn't let the smoke out,
but I haven't actually tested it against a stripe aligned filesystem
config yet, nor tested the forcealign functionality so it may not be
exactly right yet.
JFYI, I started to test fallocate for FALLOCATE_COLLAPSE. I think that
we need something like this:
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -61,7 +61,11 @@ xfs_is_falloc_aligned(
}
mask = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize) - 1;
} else {
- mask = mp->m_sb.sb_blocksize - 1;
+ if (xfs_inode_has_forcealign(ip))
+ mask = (mp->m_sb.sb_blocksize * ip->i_extsize) - 1;
+ else
+ mask = mp->m_sb.sb_blocksize - 1;
}
return !((pos | len) & mask);
I think that we also need to fix up __xfs_bunmapi() to do similar as
isrt (for forcealign).
Thanks,
John