Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] iomap: disable I/O polling when direct I/O must wait
@ 2026-12-01  3:49 Fengnan Chang
  2026-12-01  4:06 ` sashiko-bot
  2026-12-01  8:08 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Fengnan Chang @ 2026-12-01  3:49 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Ming Lei, Christoph Hellwig, Darrick J . Wong, linux-xfs,
	linux-fsdevel, linux-ext4, Fengnan Chang

With IOMAP_DIO_FORCE_WAIT, __iomap_dio_rw() waits for the bios of an
asynchronous kiocb in the submission path. That wait does not poll, and
the caller, such as io_uring, cannot poll before __iomap_dio_rw()
returns.

Such writes usually do not poll, because a mapping that needs
completion work clears IOCB_HIPRI. But IOCB_HIPRI is only cleared once
that mapping is reached, and a bio for an earlier mapping may already
have been submitted as polled.

For example, an ext4 unaligned write that covers a written block
followed by an unwritten block needs sub-block zeroing, so ext4 passes
IOMAP_DIO_FORCE_WAIT. The bio for the written block is submitted as
polled, and the task then waits for it without polling. On a poll
queue the write stalls until the request times out; NVMe then reaps
the completion from its timeout handler, after 30 seconds by default.

Like synchronous kiocbs, do not poll the bios if the caller will wait
for them: clear IOCB_HIPRI before submitting any bio.

Reproduced with an io_uring IOPOLL write of 4 KiB at offset 2 KiB to
such an ext4 file on a null_blk device with poll queues: the write
failed with -ETIMEDOUT after the request timeout. With this change it
completes and reads back correctly.

Fixes: 9650b453a3d4 ("block: ignore RWF_HIPRI hint for sync dio")
Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
---
 fs/iomap/direct-io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index f00b0841fdd08..1326cb0af0d32 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -733,6 +733,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	dio->submit.iter = iter;
 	dio->submit.waiter = current;
 
+	if (wait_for_completion)
+		iocb->ki_flags &= ~IOCB_HIPRI;
+
 	if (iocb->ki_flags & IOCB_NOWAIT)
 		iomi.flags |= IOMAP_NOWAIT;
 
-- 
2.39.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  3:49 [PATCH] iomap: disable I/O polling when direct I/O must wait Fengnan Chang
2026-12-01  4:06 ` sashiko-bot
2026-12-01  8:08 ` Christoph Hellwig
2026-12-01  8:48   ` Fengnan Chang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox