[PATCH 0/3] io_uring/rw: bound the -EAGAIN/-EOPNOTSUPP reissue

From: Yun Wang

Date: Sun Nov 29 2026 - 13:33:01 EST


A read or write that completes with -EAGAIN or -EOPNOTSUPP from a
nonblocking attempt is reissued from io-wq. This series fixes two cases
where that reissue has no bound, and stops the retry for dma-buf
requests, where it can never succeed.

I found this while testing the ext4 dma-buf series [1] for bugs. A
direct read into a dma-buf registered buffer that covers [mapped | hole]
of a sparse file fails with -EOPNOTSUPP at the hole every time. The
completion runs outside io-wq, so io_rw_should_reissue() lets the
request be reissued again and again, and the CQE is never posted. An
8 KiB read of 4 KiB of data followed by a hole took 348 device reads
instead of 2 before it returned. A read of 2 MiB of data followed by a
hole had not returned after 5 seconds and had read 15.6 GiB (15932 MiB)
from the device by then. Only exiting the ring stops it.

The loop is not specific to dma-buf or ext4. It happens whenever the
completion of a blocking attempt keeps returning -EAGAIN or -EOPNOTSUPP
and does not run in the io-wq worker that issued it. On v7.4-rc2 it can
be reproduced on a raw NVMe namespace with fault injection (see patch
1), or with a FUSE server that uses FUSE_ASYNC_DIO and FOPEN_DIRECT_IO.
The loop exists since v6.14. Before that, these completions were not
reissued at all.

Patch 1 makes io_rw_should_reissue() look at IOCB_NOWAIT in the kiocb
instead of at the current thread. A request is still reissued once after
a nonblocking attempt, so the nvme multipath case from commit
b08e02045002 and the LVM snapshot case from commit 927069c4ac2c keep
working.

Patch 2 clears REQ_F_FORCE_ASYNC on reissue. Without it, an IOSQE_ASYNC
request on a pollable file (FUSE) is issued nonblocking again from
io-wq, and patch 1 alone does not stop the loop.

Patch 3 stops converting -EOPNOTSUPP to -EAGAIN, and stops reissuing,
for REQ_F_DMABUF requests. dma-buf I/O has no buffered fallback, so the
blocking retry fails the same way. This costs a second device read, and
with RWF_NOWAIT the application is told to retry something that cannot
succeed. Unlike patches 1 and 2, this is only a cost and not a loop, so
it is not marked for stable.

Patches 1 and 2 are needed together to fix the loop for every case.
Patch 3 is independent of them.

Testing, all on v7.4-rc2 unless noted:
- NVMe fault injection in QEMU, raw device and ext4: without the series
a single 4 KiB read uses up every injected failure and then succeeds.
With it, the read fails with -EOPNOTSUPP after two attempts, or one
with IOSQE_ASYNC. The patched kernel gives the same result on a
KIOXIA BG5.
- FUSE reproducer, default and IOSQE_ASYNC, with -EAGAIN and
-EOPNOTSUPP: without the series the request is reissued until the
reproducer's server gives up after 20 failures (21 READs). With it,
the server sees 2 READs. Also run with KASAN and lockdep: no reports.
- dma-buf on a raw NVMe namespace (patch 3): see the patch. A buffered
write from user memory to the same device is still retried and
succeeds.
- With the ext4 dma-buf series: the sparse-file read above returns after
two device reads with patches 1 and 2, and after one with patch 3.

The series is based on v7.4-rc2 and also applies to io_uring-7.4.
Patches 2 and 3 conflict with the io_req_{set,clear}_flags() conversion
in for-7.5/io_uring. I can rebase them onto it if you prefer.

On tool use: Gemini (gemini-4-neon-high) found the IOSQE_ASYNC path that
my first version of patch 1 missed, which patch 2 fixes. The patches,
the changelogs and this cover letter were written with AI assistance
(Claude, claude-opus-5-5). Claude was also used to build the tests that
do not depend on the ext4 series (NVMe fault injection, FUSE, dma-buf on
a raw NVMe namespace), to check that the problem is not caused by that
series. I reviewed the patches and the test results.

[1] https://lore.kernel.org/all/20261113070621.273953-1-mengmeng.zhao@xxxxxxxxx/

Yun Wang (3):
io_uring/rw: don't reissue requests that were issued blocking
io_uring: clear REQ_F_FORCE_ASYNC when reissuing a request
io_uring/rw: don't retry dma-buf requests that fail with -EOPNOTSUPP

io_uring/io_uring.c | 2 +-
io_uring/rw.c | 16 +++++++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)


base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
--
2.56.1