This is a note to let you know that I've just added the patch titled io_uring/rw: don't lose partial IO result on fail to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-rw-don-t-lose-partial-io-result-on-fail.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 47b4c68660752facfa6247b1fc9ca9d722b8b601 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov <asml.silence@xxxxxxxxx> Date: Wed, 21 Sep 2022 12:17:47 +0100 Subject: io_uring/rw: don't lose partial IO result on fail From: Pavel Begunkov <asml.silence@xxxxxxxxx> commit 47b4c68660752facfa6247b1fc9ca9d722b8b601 upstream. A partially done read/write may end up in io_req_complete_failed() and loose the result, make sure we return the number of bytes processed. Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Link: https://lore.kernel.org/r/05e0879c226bcd53b441bf92868eadd4bf04e2fc.1663668091.git.asml.silence@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/opdef.c | 6 ++++++ io_uring/rw.c | 8 ++++++++ io_uring/rw.h | 1 + 3 files changed, 15 insertions(+) --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -69,6 +69,7 @@ const struct io_op_def io_op_defs[] = { .issue = io_read, .prep_async = io_readv_prep_async, .cleanup = io_readv_writev_cleanup, + .fail = io_rw_fail, }, [IORING_OP_WRITEV] = { .needs_file = 1, @@ -85,6 +86,7 @@ const struct io_op_def io_op_defs[] = { .issue = io_write, .prep_async = io_writev_prep_async, .cleanup = io_readv_writev_cleanup, + .fail = io_rw_fail, }, [IORING_OP_FSYNC] = { .needs_file = 1, @@ -105,6 +107,7 @@ const struct io_op_def io_op_defs[] = { .name = "READ_FIXED", .prep = io_prep_rw, .issue = io_read, + .fail = io_rw_fail, }, [IORING_OP_WRITE_FIXED] = { .needs_file = 1, @@ -119,6 +122,7 @@ const struct io_op_def io_op_defs[] = { .name = "WRITE_FIXED", .prep = io_prep_rw, .issue = io_write, + .fail = io_rw_fail, }, [IORING_OP_POLL_ADD] = { .needs_file = 1, @@ -273,6 +277,7 @@ const struct io_op_def io_op_defs[] = { .name = "READ", .prep = io_prep_rw, .issue = io_read, + .fail = io_rw_fail, }, [IORING_OP_WRITE] = { .needs_file = 1, @@ -287,6 +292,7 @@ const struct io_op_def io_op_defs[] = { .name = "WRITE", .prep = io_prep_rw, .issue = io_write, + .fail = io_rw_fail, }, [IORING_OP_FADVISE] = { .needs_file = 1, --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -984,6 +984,14 @@ static void io_cqring_ev_posted_iopoll(s io_cqring_wake(ctx); } +void io_rw_fail(struct io_kiocb *req) +{ + int res; + + res = io_fixup_rw_res(req, req->cqe.res); + io_req_set_res(req, res, req->cqe.flags); +} + int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin) { struct io_wq_work_node *pos, *start, *prev; --- a/io_uring/rw.h +++ b/io_uring/rw.h @@ -21,3 +21,4 @@ int io_readv_prep_async(struct io_kiocb int io_write(struct io_kiocb *req, unsigned int issue_flags); int io_writev_prep_async(struct io_kiocb *req); void io_readv_writev_cleanup(struct io_kiocb *req); +void io_rw_fail(struct io_kiocb *req); Patches currently in stable-queue which might be from asml.silence@xxxxxxxxx are queue-6.0/io_uring-correct-pinned_vm-accounting.patch queue-6.0/io_uring-net-don-t-update-msg_name-if-not-provided.patch queue-6.0/io_uring-rw-fix-unexpected-link-breakage.patch queue-6.0/io_uring-net-don-t-lose-partial-send-recv-on-fail.patch queue-6.0/io_uring-rw-don-t-lose-partial-io-result-on-fail.patch queue-6.0/io_uring-net-fix-fast_iov-assignment-in-io_setup_async_msg.patch queue-6.0/io_uring-net-don-t-lose-partial-send_zc-on-fail.patch queue-6.0/io_uring-limit-registration-w-single_issuer.patch queue-6.0/io_uring-add-custom-opcode-hooks-on-fail.patch queue-6.0/io_uring-rw-don-t-lose-short-results-on-io_setup_async_rw.patch queue-6.0/io_uring-af_unix-defer-registered-files-gc-to-io_uring-release.patch