* [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
` (3 more replies)
0 siblings, 4 replies; 7+ 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] 7+ messages in thread* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
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
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-01 4:06 UTC (permalink / raw)
To: Fengnan Chang; +Cc: linux-ext4, tytso
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201034922.203226-1-changfengnan@bytedance.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
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
2026-12-01 13:25 ` Christian Brauner
2026-12-01 13:26 ` Christian Brauner
3 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2026-12-01 8:08 UTC (permalink / raw)
To: Fengnan Chang
Cc: Christian Brauner, Ming Lei, Christoph Hellwig, Darrick J . Wong,
linux-xfs, linux-fsdevel, linux-ext4
On Tue, Dec 01, 2026 at 03:49:22AM +0000, Fengnan Chang wrote:
> 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.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
I've seen you've also posted various other polling fixes. Any chance
you could try to wire up your tests in blktests or xfstests so that we
get test coverage for these cases?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
2026-12-01 8:08 ` Christoph Hellwig
@ 2026-12-01 8:48 ` Fengnan Chang
0 siblings, 0 replies; 7+ messages in thread
From: Fengnan Chang @ 2026-12-01 8:48 UTC (permalink / raw)
To: Christoph Hellwig, Fengnan Chang
Cc: Christian Brauner, Darrick J . Wong, linux-xfs, linux-fsdevel,
linux-ext4, tom.leiming
在 01/12/26 16:08, Christoph Hellwig 写道:
> On Tue, Dec 01, 2026 at 03:49:22AM +0000, Fengnan Chang wrote:
>> 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.
>
> Looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> I've seen you've also posted various other polling fixes. Any chance
> you could try to wire up your tests in blktests or xfstests so that we
> get test coverage for these cases?
Sure, I'll do it later.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
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 13:25 ` Christian Brauner
2026-12-01 13:26 ` Christian Brauner
3 siblings, 0 replies; 7+ messages in thread
From: Christian Brauner @ 2026-12-01 13:25 UTC (permalink / raw)
To: Fengnan Chang
Cc: Ming Lei, Christoph Hellwig, Darrick J . Wong, linux-xfs,
linux-fsdevel, linux-ext4
On Tue, 01 Dec 2026 03:49:22 +0000, Fengnan Chang wrote:
> 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.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] iomap: disable I/O polling when direct I/O must wait
https://git.kernel.org/vfs/vfs/c/a302736c8c0a
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
2026-12-01 3:49 [PATCH] iomap: disable I/O polling when direct I/O must wait Fengnan Chang
` (2 preceding siblings ...)
2026-12-01 13:25 ` Christian Brauner
@ 2026-12-01 13:26 ` Christian Brauner
2026-12-02 1:56 ` Fengnan
3 siblings, 1 reply; 7+ messages in thread
From: Christian Brauner @ 2026-12-01 13:26 UTC (permalink / raw)
To: Fengnan Chang
Cc: Ming Lei, Christoph Hellwig, Darrick J . Wong, linux-xfs,
linux-fsdevel, linux-ext4
On Tue, Dec 01, 2026 at 03:49:22AM +0000, Fengnan Chang wrote:
> + if (wait_for_completion)
> + iocb->ki_flags &= ~IOCB_HIPRI;
One question. wait_for_completion can also flip to true after we've
already submitted, no?
* partial -EFAULT with IOMAP_DIO_PARTIAL
* -ENOTBLK fallback
In both cases it's set after the iomap_iter() loop.
By then the first bio might have gone out with REQ_POLLED. Can't that
end up in the same stall? I might misunderstand.
--
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] iomap: disable I/O polling when direct I/O must wait
2026-12-01 13:26 ` Christian Brauner
@ 2026-12-02 1:56 ` Fengnan
0 siblings, 0 replies; 7+ messages in thread
From: Fengnan @ 2026-12-02 1:56 UTC (permalink / raw)
To: Christian Brauner
Cc: Christoph Hellwig, Darrick J . Wong, linux-xfs, linux-fsdevel,
linux-ext4, tom.leiming
在 01/12/26 21:26, Christian Brauner 写道:
> On Tue, Dec 01, 2026 at 03:49:22AM +0000, Fengnan Chang wrote:
>> + if (wait_for_completion)
>> + iocb->ki_flags &= ~IOCB_HIPRI;
>
> One question. wait_for_completion can also flip to true after we've
> already submitted, no?
>
> * partial -EFAULT with IOMAP_DIO_PARTIAL
> * -ENOTBLK fallback
>
> In both cases it's set after the iomap_iter() loop.
>
> By then the first bio might have gone out with REQ_POLLED. Can't that
> end up in the same stall? I might misunderstand.
>
Yes, you're right, thanks. Both the IOMAP_DIO_PARTIAL -EFAULT case and
the -ENOTBLK fallback set wait_for_completion after the iomap_iter()
loop, when the first bio may already have been submitted with
REQ_POLLED, so they can hit the same stall.
Clearing IOCB_HIPRI up front can't cover those. For v2 I plan to poll
from the wait loop instead, i.e. call iocb_bio_iopoll() while
iocb->private is set and fall back to blk_io_schedule() otherwise,
similar to what the loop did before sync polling was removed. That
covers the FORCE_WAIT case and both late paths. I'll send v2 after
testing it.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-02 1:56 UTC | newest]
Thread overview: 7+ 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
2026-12-01 13:25 ` Christian Brauner
2026-12-01 13:26 ` Christian Brauner
2026-12-02 1:56 ` Fengnan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.