]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/rw: preserve partial result for iopoll
authorMichael Wigham <michael@wigham.net>
Sat, 13 Jun 2026 22:52:16 +0000 (23:52 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 16 Jun 2026 12:20:01 +0000 (06:20 -0600)
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>
Link: https://patch.msgid.link/20260613225240.34032-1-michael@wigham.net
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rw.c

index 0c48346452797afb0221cda7b32c08867d744cbb..63b6519e498cd7f9bbb2ef36f422a29d8b3f85c5 100644 (file)
@@ -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);