This series expands atomic write support to filesystems, specifically XFS. Extent alignment is based on new feature forcealign. Flag FS_XFLAG_ATOMICWRITES is added as an enabling flag for atomic writes. XFS can be formatted for atomic writes as follows: mkfs.xfs -i forcealign=1 -d extsize=16384 -d atomic-writes=1 /dev/sda atomic-writes=1 just enables atomic writes in the SB, but does not auto- enable atomic writes for each file. Support can be enabled through xfs_io command: $xfs_io -c "lsattr -v" filename [extsize, force-align] $xfs_io -c "extsize" filename [16384] filename $xfs_io -c "chattr +W" filename $xfs_io -c "lsattr -v" filename [extsize, force-align, atomic-writes] filename $xfs_io -c statx filename ... stat.stx_atomic_write_unit_min = 4096 stat.stx_atomic_write_unit_max = 16384 stat.stx_atomic_write_segments_max = 1 ... A couple of patches are marked as RFC, as I am anything but 100% confident in them. Indeed, from testing, there is an issue that I get ENOSPC at what appears to be a moderate FS usage, like ~60%, and spaceman is reporting appropriately-sized free extents. I notice that when I disable any fallocate punch calls in my testing, then this issue goes away. More details available upon request. Stripe alignment testing for forcealign changes should be noted at https://lore.kernel.org/linux-xfs/083f3d88-cd39-41ef-9ee1-cafe04a96cf9@xxxxxxxxxx/ Baseline is following series (which is based on v6.9-rc1): https://lore.kernel.org/linux-block/20240326133813.3224593-1-john.g.garry@xxxxxxxxxx/ Basic xfsprogs support at: https://github.com/johnpgarry/xfsprogs-dev/tree/forcealign_and_atomicwrites_for_v3_xfs_block_atomic_writes Patches for this series can be found at: https://github.com/johnpgarry/linux/commits/atomic-writes-v6.9-v6-fs-v3/ Changes since v2: https://lore.kernel.org/linux-xfs/20240304130428.13026-1-john.g.garry@xxxxxxxxxx/ - Incorporate forcealign patches from https://lore.kernel.org/linux-xfs/20240402233006.1210262-1-david@xxxxxxxxxxxxx/ - Put bdev awu min and max in buftarg - Extra forcealign patches to deal with truncate and fallocate punch, insert, collapse - Add generic_atomic_write_valid_size() - Change iomap.extent_shift -> .extent_size Changes since v1: https://lore.kernel.org/linux-xfs/20240124142645.9334-1-john.g.garry@xxxxxxxxxx/ - Add blk_validate_atomic_write_op_size() (Darrick suggested idea) - Swap forcealign for rtvol support (Dave requested forcealign) - Sub-extent DIO zeroing (Dave wanted rid of XFS_BMAPI_ZERO usage) - Improve coding for XFS statx support (Darrick, Ojaswin) - Improve conditions for setting FMODE_CAN_ATOMIC_WRITE (Darrick) - Improve commit message for FS_XFLAG_ATOMICWRITES flag (Darrick) - Validate atomic writes in xfs_file_dio_write() - Drop IOMAP_ATOMIC Darrick J. Wong (2): xfs: Introduce FORCEALIGN inode flag xfs: Enable file data forcealign feature Dave Chinner (6): xfs: only allow minlen allocations when near ENOSPC xfs: always tail align maxlen allocations xfs: simplify extent allocation alignment xfs: make EOF allocation simpler xfs: introduce forced allocation alignment fs: xfs: align args->minlen for forced allocation alignment John Garry (13): fs: Add generic_atomic_write_valid_size() xfs: Do not free EOF blocks for forcealign xfs: Update xfs_is_falloc_aligned() mask for forcealign xfs: Unmap blocks according to forcealign xfs: Only free full extents for forcealign iomap: Sub-extent zeroing fs: xfs: iomap: Sub-extent zeroing fs: Add FS_XFLAG_ATOMICWRITES flag iomap: Atomic write support xfs: Support FS_XFLAG_ATOMICWRITES for forcealign xfs: Support atomic write for statx xfs: Validate atomic writes xfs: Support setting FMODE_CAN_ATOMIC_WRITE fs/iomap/direct-io.c | 27 ++- fs/xfs/libxfs/xfs_alloc.c | 33 ++-- fs/xfs/libxfs/xfs_alloc.h | 3 +- fs/xfs/libxfs/xfs_bmap.c | 302 ++++++++++++++++++---------------- fs/xfs/libxfs/xfs_format.h | 16 +- fs/xfs/libxfs/xfs_ialloc.c | 12 +- fs/xfs/libxfs/xfs_inode_buf.c | 86 ++++++++++ fs/xfs/libxfs/xfs_inode_buf.h | 3 + fs/xfs/libxfs/xfs_sb.c | 4 + fs/xfs/xfs_bmap_util.c | 14 +- fs/xfs/xfs_buf.c | 15 +- fs/xfs/xfs_buf.h | 4 +- fs/xfs/xfs_file.c | 64 +++++-- fs/xfs/xfs_inode.c | 14 ++ fs/xfs/xfs_inode.h | 15 ++ fs/xfs/xfs_ioctl.c | 55 ++++++- fs/xfs/xfs_iomap.c | 13 +- fs/xfs/xfs_iops.c | 28 ++++ fs/xfs/xfs_mount.h | 4 + fs/xfs/xfs_super.c | 8 + fs/xfs/xfs_trace.h | 8 +- include/linux/fs.h | 12 ++ include/linux/iomap.h | 1 + include/uapi/linux/fs.h | 3 + 24 files changed, 549 insertions(+), 195 deletions(-) -- 2.31.1