The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <stable@xxxxxxxxxxxxxxx>. To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x a9be202269580ca611c6cebac90eaf1795497800 # <resolve conflicts, build, test, etc.> git commit -s git send-email --to '<stable@xxxxxxxxxxxxxxx>' --in-reply-to '2023072352-book-slab-df31@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: a9be20226958 ("io_uring: treat -EAGAIN for REQ_F_NOWAIT as final for io-wq") ed29b0b4fd83 ("io_uring: move to separate directory") d01905db14eb ("io_uring: clean iowq submit work cancellation") 255657d23704 ("io_uring: clean io_wq_submit_work()'s main loop") 90fa02883f06 ("io_uring: implement async hybrid mode for pollable requests") 3b44b3712c5b ("io_uring: split logic of force_nonblock") 9882131cd9de ("io_uring: kill io_wq_current_is_worker() in iopoll") 9983028e7660 ("io_uring: optimise req->ctx reloads") 5e49c973fc39 ("io_uring: clean up io_import_iovec") 51aac424aef9 ("io_uring: optimise io_import_iovec nonblock passing") c88598a92a58 ("io_uring: optimise read/write iov state storing") 538941e2681c ("io_uring: encapsulate rw state") d886e185a128 ("io_uring: control ->async_data with a REQ_F flag") 30d51dd4ad20 ("io_uring: clean up buffer select") ef05d9ebcc92 ("io_uring: kill off ->inflight_entry field") 6f33b0bc4ea4 ("io_uring: use slist for completion batching") c450178d9be9 ("io_uring: dedup CQE flushing non-empty checks") 4c928904ff77 ("block: move CONFIG_BLOCK guard to top Makefile") 14cfbb7a7856 ("io_uring: fix wrong condition to grab uring lock") 7df778be2f61 ("io_uring: make OP_CLOSE consistent with direct open") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a9be202269580ca611c6cebac90eaf1795497800 Mon Sep 17 00:00:00 2001 From: Jens Axboe <axboe@xxxxxxxxx> Date: Thu, 20 Jul 2023 13:16:53 -0600 Subject: [PATCH] io_uring: treat -EAGAIN for REQ_F_NOWAIT as final for io-wq io-wq assumes that an issue is blocking, but it may not be if the request type has asked for a non-blocking attempt. If we get -EAGAIN for that case, then we need to treat it as a final result and not retry or arm poll for it. Cc: stable@xxxxxxxxxxxxxxx # 5.10+ Link: https://github.com/axboe/liburing/issues/897 Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index a9923676d16d..5e97235a82d6 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1948,6 +1948,14 @@ void io_wq_submit_work(struct io_wq_work *work) ret = io_issue_sqe(req, issue_flags); if (ret != -EAGAIN) break; + + /* + * If REQ_F_NOWAIT is set, then don't wait or retry with + * poll. -EAGAIN is final for that case. + */ + if (req->flags & REQ_F_NOWAIT) + break; + /* * We can get EAGAIN for iopolled IO even though we're * forcing a sync submission from here, since we can't