xfs: disallow atomic writes on DAX
authorJohn Garry <john.g.garry@oracle.com>
Thu, 24 Jul 2025 08:12:14 +0000 (08:12 +0000)
committerCarlos Maiolino <cem@kernel.org>
Mon, 11 Aug 2025 12:03:44 +0000 (14:03 +0200)
commit68456d05eb57a5d16b4be2d3caf421bdcf2de72e
tree0248d35481b00ae9d19b1d7492affa8cd7df41cd
parente7fb9b71326f43bab25fb8f18c6bfebd7a628696
xfs: disallow atomic writes on DAX

Atomic writes are not currently supported for DAX, but two problems exist:
- we may go down DAX write path for IOCB_ATOMIC, which does not handle
  IOCB_ATOMIC properly
- we report non-zero atomic write limits in statx (for DAX inodes)

We may want atomic writes support on DAX in future, but just disallow for
now.

For this, ensure when IOCB_ATOMIC is set that we check the write size
versus the atomic write min and max before branching off to the DAX write
path. This is not strictly required for DAX, as we should not get this far
in the write path as FMODE_CAN_ATOMIC_WRITE should not be set.

In addition, due to reflink being supported for DAX, we automatically get
CoW-based atomic writes support being advertised. Remedy this by
disallowing atomic writes for a DAX inode for both sw and hw modes.

Reported-by: Darrick J. Wong <djwong@kernel.org>
Fixes: 9dffc58f2384 ("xfs: update atomic write limits")
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_file.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_iops.c