io_uring: disable io-wq execution of multishot NOWAIT requests
authorJens Axboe <axboe@kernel.dk>
Mon, 1 Apr 2024 17:30:06 +0000 (11:30 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 1 Apr 2024 17:46:22 +0000 (11:46 -0600)
Do the same check for direct io-wq execution for multishot requests that
commit 2a975d426c82 did for the inline execution, and disable multishot
mode (and revert to single shot) if the file type doesn't support NOWAIT,
and isn't opened in O_NONBLOCK mode. For multishot to work properly, it's
a requirement that nonblocking read attempts can be done.

Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 5d4b448fdc503822cb97ca5ca93d545ade642db5..8baf8afb79c2a53d00e9103cc7b61ad8a3c9fa9b 100644 (file)
@@ -1982,10 +1982,15 @@ fail:
                err = -EBADFD;
                if (!io_file_can_poll(req))
                        goto fail;
-               err = -ECANCELED;
-               if (io_arm_poll_handler(req, issue_flags) != IO_APOLL_OK)
-                       goto fail;
-               return;
+               if (req->file->f_flags & O_NONBLOCK ||
+                   req->file->f_mode & FMODE_NOWAIT) {
+                       err = -ECANCELED;
+                       if (io_arm_poll_handler(req, issue_flags) != IO_APOLL_OK)
+                               goto fail;
+                       return;
+               } else {
+                       req->flags &= ~REQ_F_APOLL_MULTISHOT;
+               }
        }
 
        if (req->flags & REQ_F_FORCE_ASYNC) {