public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/rw: preserve partial result for iopoll
@ 2026-06-13 22:52 Michael Wigham
  2026-06-15 16:11 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Wigham @ 2026-06-13 22:52 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Pavel Begunkov, io-uring, linux-kernel, Michael Wigham, stable

A partial read will store the completed byte count in io->bytes_done.
The regular completion path applies io_fixup_rw_res() so that, when the
following operation reaches EOF, the number of bytes already read is
returned.

The iopoll completion path does not apply this fixup to the return value
and can return zero instead.

Use the fixup result when updating the CQE, and the raw result for the
reissue check.

Cc: stable@vger.kernel.org
Fixes: 4d9cb92ca41d ("io_uring/rw: fix short rw error handling")
Signed-off-by: Michael Wigham <michael@wigham.net>
---
pread(), normal io_uring, and io_uring iopoll should return the same
result for a read that extends past EOF. Before this fix, the io_uring
iopoll path returned zero.

To test the fix, a standalone test prepared an 8704 byte file opened
with O_DIRECT and issued a read of 1024 bytes from offset 8192. Before
this change, the IOPOLL path transferred 512 bytes into the buffer but
reported a result of zero. With this change, pread(), normal io_uring,
and io_uring IOPOLL all report 512 bytes read.

All liburing tests passed.

 io_uring/rw.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index 0c4834645279..63b6519e498c 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -601,15 +601,15 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
 {
 	struct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);
 	struct io_kiocb *req = cmd_to_io_kiocb(rw);
+	int final_res = io_fixup_rw_res(req, 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))
-			req->flags |= REQ_F_REISSUE | REQ_F_BL_NO_RECYCLE;
-		else
-			req->cqe.res = res;
-	}
+
+	if (res == -EAGAIN && io_rw_should_reissue(req))
+		req->flags |= REQ_F_REISSUE | REQ_F_BL_NO_RECYCLE;
+	else if (unlikely(final_res != req->cqe.res))
+		req->cqe.res = final_res;
 
 	/* order with io_iopoll_complete() checking ->iopoll_completed */
 	smp_store_release(&req->iopoll_completed, 1);
-- 
2.54.0


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

* Re: [PATCH] io_uring/rw: preserve partial result for iopoll
  2026-06-13 22:52 [PATCH] io_uring/rw: preserve partial result for iopoll Michael Wigham
@ 2026-06-15 16:11 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2026-06-15 16:11 UTC (permalink / raw)
  To: Michael Wigham; +Cc: Pavel Begunkov, io-uring, linux-kernel, stable


On Sat, 13 Jun 2026 23:52:16 +0100, Michael Wigham wrote:
> A partial read will store the completed byte count in io->bytes_done.
> The regular completion path applies io_fixup_rw_res() so that, when the
> following operation reaches EOF, the number of bytes already read is
> returned.
> 
> The iopoll completion path does not apply this fixup to the return value
> and can return zero instead.
> 
> [...]

Applied, thanks!

[1/1] io_uring/rw: preserve partial result for iopoll
      commit: 15a90c358c33871eec14588d4c72b548b4f679b2

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2026-06-15 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 22:52 [PATCH] io_uring/rw: preserve partial result for iopoll Michael Wigham
2026-06-15 16:11 ` Jens Axboe

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