This is a note to let you know that I've just added the patch titled io_uring/net: don't skip notifs for failed requests 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-net-don-t-skip-notifs-for-failed-requests.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 foo@baz Mon Oct 17 11:35:32 AM CEST 2022 From: Pavel Begunkov <asml.silence@xxxxxxxxx> Date: Sun, 16 Oct 2022 21:33:29 +0100 Subject: io_uring/net: don't skip notifs for failed requests To: stable@xxxxxxxxxxxxxxx Cc: Jens Axboe <axboe@xxxxxxxxx>, asml.silence@xxxxxxxxx Message-ID: <6e84a6e0dbfbbb43379a82abd262ce0bd4311ca2.1665951939.git.asml.silence@xxxxxxxxx> From: Pavel Begunkov <asml.silence@xxxxxxxxx> [ upstream commit 6ae91ac9a6aa7d6005c3c6d0f4d263fbab9f377f ] We currently only add a notification CQE when the send succeded, i.e. cqe.res >= 0. However, it'd be more robust to do buffer notifications for failed requests as well in case drivers decide do something fanky. Always return a buffer notification after initial prep, don't hide it. This behaviour is better aligned with documentation and the patch also helps the userspace to respect it. Cc: stable@xxxxxxxxxxxxxxx # 6.0 Suggested-by: Stefan Metzmacher <metze@xxxxxxxxx> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Link: https://lore.kernel.org/r/9c8bead87b2b980fcec441b8faef52188b4a6588.1664292100.git.asml.silence@xxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/net.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) --- a/io_uring/net.c +++ b/io_uring/net.c @@ -879,7 +879,6 @@ void io_send_zc_cleanup(struct io_kiocb { struct io_sr_msg *zc = io_kiocb_to_cmd(req, struct io_sr_msg); - zc->notif->flags |= REQ_F_CQE_SKIP; io_notif_flush(zc->notif); zc->notif = NULL; } @@ -996,7 +995,7 @@ int io_send_zc(struct io_kiocb *req, uns struct msghdr msg; struct iovec iov; struct socket *sock; - unsigned msg_flags, cflags; + unsigned msg_flags; int ret, min_ret = 0; sock = sock_from_file(req->file); @@ -1064,8 +1063,6 @@ int io_send_zc(struct io_kiocb *req, uns req->flags |= REQ_F_PARTIAL_IO; return io_setup_async_addr(req, addr, issue_flags); } - if (ret < 0 && !zc->done_io) - zc->notif->flags |= REQ_F_CQE_SKIP; if (ret == -ERESTARTSYS) ret = -EINTR; req_set_fail(req); @@ -1078,8 +1075,7 @@ int io_send_zc(struct io_kiocb *req, uns io_notif_flush(zc->notif); req->flags &= ~REQ_F_NEED_CLEANUP; - cflags = ret >= 0 ? IORING_CQE_F_MORE : 0; - io_req_set_res(req, ret, cflags); + io_req_set_res(req, ret, IORING_CQE_F_MORE); return IOU_OK; } @@ -1096,17 +1092,11 @@ void io_sendrecv_fail(struct io_kiocb *r void io_send_zc_fail(struct io_kiocb *req) { struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); - int res = req->cqe.res; - if (req->flags & REQ_F_PARTIAL_IO) { - if (req->flags & REQ_F_NEED_CLEANUP) { - io_notif_flush(sr->notif); - sr->notif = NULL; - req->flags &= ~REQ_F_NEED_CLEANUP; - } - res = sr->done_io; - } - io_req_set_res(req, res, req->cqe.flags); + if (req->flags & REQ_F_PARTIAL_IO) + req->cqe.res = sr->done_io; + if (req->flags & REQ_F_NEED_CLEANUP) + req->cqe.flags |= IORING_CQE_F_MORE; } int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 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-fix-notif-cqe-reordering.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-skip-notifs-for-failed-requests.patch queue-6.0/io_uring-net-rename-io_sendzc.patch queue-6.0/io_uring-net-refactor-io_sr_msg-types.patch queue-6.0/io_uring-fix-cqe-reordering.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-net-use-io_sr_msg-for-sendzc.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