RE:(2) (2) (2) [PATCH v2] xfs: check the disk address for hardware atomic writes

From: Daejun Park

Date: Mon Nov 16 2026 - 04:55:02 EST


On Mon, Nov 16, 2026 at 08:11:51AM +0000, John Garry wrote:
> Yeah, I was really asking if HW atomic could span 2x extents before we
> catch it.

It is caught before any bio is built. xfs_direct_write_iomap_begin()
checks with xfs_bmap_hw_atomic_write_possible() that one mapping covers
the whole write. For a write over two extents it returns -ENOPROTOOPT,
and xfs_file_dio_write_atomic() redoes the write through COW, which is
still atomic. If a shorter mapping ever got past that check, iomap
fails the write with -EINVAL instead of issuing a partial REQ_ATOMIC
bio.

> Maybe what you have in this patch is ok. I'll wait for v3 and consider
> it more. Sorry for the hesitancy.

I wrote the v3 I described and tested it against v2 before posting it.
v3 sends every write above the group alignment to COW, also when the
extent is aligned on disk, as in AG 0. v2 sends those writes to the
hardware and falls back to COW when the hardware path is not possible,
for example when the extent is misaligned on disk. So I'll keep v2 as
posted and not send v3.

For reference only, on emulated NVMe (QEMU) with a 64 KiB atomic unit
and boundary, non-debug kernels, three runs of 10000 overwrites: a
64 KiB atomic overwrite in AG 0 took 35.2-38.6 us with v2 and
69.4-78.1 us with v3. In a misaligned AG 1 it took 70.5-88.8 us with
v2 and 68.8-88.7 us with v3.

Best regards,
Daejun