* [PATCH] xfs: wait for direct I/O before swapping extents
@ 2026-11-10 0:38 Daejun Park via B4 Relay
2026-11-11 15:12 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Daejun Park via B4 Relay @ 2026-11-10 0:38 UTC (permalink / raw)
To: Carlos Maiolino, linux-xfs
Cc: Christoph Hellwig, Dave Chinner, Darrick J. Wong, linux-kernel,
stable, Daejun Park
From: Daejun Park <daejun7.park@samsung.com>
An AIO direct write drops the iolock before its bios complete.
XFS_IOC_SWAPEXT does not wait for it. The write can land in blocks that
the swap moved to the temporary file. Once xfs_fsr frees them, the
write corrupts whatever reuses them.
Wait for direct I/O first, as exchange-range does.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
Tested with an AIO direct write held back by cgroup io.max. Before, the
write reached files that reused the freed blocks in 7 of 7 runs. After,
those files were intact. The new fstests case "xfs: test that swapext
waits for in-flight direct I/O" fails before and passes after. Running
fstests -g fsr shows no change.
Applies with or without "xfs: break layouts before swapping extents".
---
fs/xfs/xfs_bmap_util.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 865aec3ae5a..4d214708f9c 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1257,6 +1257,7 @@ xfs_swap_extent_flush(
{
int error;
+ inode_dio_wait(VFS_I(ip));
error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
if (error)
return error;
---
base-commit: 1e17fc56469d62d1c1ac45c137a2456d14456f1d
change-id: 20261109-xfs-swapext-dio-wait-6b700c2a981e
Best regards,
--
Daejun Park <daejun7.park@samsung.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-11 15:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 0:38 [PATCH] xfs: wait for direct I/O before swapping extents Daejun Park via B4 Relay
2026-11-11 15:12 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®