Skip to contentSkip to conversation

io_uring/rw: ensure reissue path is correctly handled for IOPOLL

PATCH In review Jens Axboe 2 participants 3 messages Mar 5, 2025 – Mar 6, 2025 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/rw: ensure reissue path is correctly handled for IOPOLL

The IOPOLL path posts CQEs when the io_kiocb is marked as completed, so it cannot rely on the usual retry that non-IOPOLL requests do for read/write requests.

If -EAGAIN is received and the request should be retried, go through the normal completion path and let the normal flush logic catch it and reissue it, like what is done for !IOPOLL reads or writes.

Fixes d803d123948f ("io_uring/rw: handle -EAGAIN retry at IO completion time")

---

io_uring/rw.c +3 -4
index 9edc6baebd01..e5528cebcd06 100644
@@ -560,11 +560,10 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
 	if (kiocb->ki_flags & IOCB_WRITE)
 		io_req_end_write(req);
 	if (unlikely(res != req->cqe.res)) {
-		if (res == -EAGAIN && io_rw_should_reissue(req)) {
+		if (res == -EAGAIN && io_rw_should_reissue(req))
 			req->flags |= REQ_F_REISSUE | REQ_F_BL_NO_RECYCLE;
-			return;
-		}
-		req->cqe.res = res;
+		else
+			req->cqe.res = res;
 	}
 
 	/* order with io_iopoll_complete() checking ->iopoll_completed */
Signature · 1 line
Jens Axboe
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jens Axboe

The IOPOLL path posts CQEs when the io_kiocb is marked as completed, so it cannot rely on the usual retry that non-IOPOLL requests do for read/write requests.

If -EAGAIN is received and the request should be retried, go through the normal completion path and let the normal flush logic catch it and reissue it, like what is done for !IOPOLL reads or writes.

Fixes d803d123948f ("io_uring/rw: handle -EAGAIN retry at IO completion time")
Link https://urldefense.com/v3/__https://lore.kernel.org/io- uring/[email protected]/__;!! ACWV5N9M2RV99hQ!J4rCZomS7jntxigOWFGkQC3hFMb5EZf3-aZG4hZCB6n_quTKHse9g- WSxf46gMXpEfyzjaAQKTff2J9o0pg$ Signed-off-by: Jens Axboe<[email protected]>

This solves the issue which I was seeing, so:

cheers

author maintainer
#2 lore raw
Quoted 9 lines · John Garry
Quoted 8 lines · Jens Axboe

The IOPOLL path posts CQEs when the io_kiocb is marked as completed, so it cannot rely on the usual retry that non-IOPOLL requests do for read/write requests.

If -EAGAIN is received and the request should be retried, go through the normal completion path and let the normal flush logic catch it and reissue it, like what is done for !IOPOLL reads or writes.

Quoted 7 lines
Quoted 3 lines
Fixes d803d123948f ("io_uring/rw: handle -EAGAIN retry at IO completion time")
Link https://urldefense.com/v3/__https://lore.kernel.org/io- uring/[email protected]/__;!! ACWV5N9M2RV99hQ!J4rCZomS7jntxigOWFGkQC3hFMb5EZf3-aZG4hZCB6n_quTKHse9g- WSxf46gMXpEfyzjaAQKTff2J9o0pg$ Signed-off-by: Jens Axboe<[email protected]>

This solves the issue which I was seeing, so:

Great, thanks for testing!

Signature · 1 line
Jens Axboe