]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: no read/write-retry on -EAGAIN error and O_NONBLOCK marked file
authorJens Axboe <axboe@kernel.dk>
Wed, 2 Sep 2020 15:30:31 +0000 (09:30 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Sep 2020 17:14:32 +0000 (19:14 +0200)
commit 355afaeb578abac907217c256a844cfafb0337b2 upstream.

Actually two things that need fixing up here:

- The io_rw_reissue() -EAGAIN retry is explicit to block devices and
  regular files, so don't ever attempt to do that on other types of
  files.

- If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
  it. It should just complete with -EAGAIN.

Cc: stable@vger.kernel.org
Reported-by: Norman Maurer <norman.maurer@googlemail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index 467c4f3dca1d2b23d9c270288a91bea871dc1b44..38f3ec15ba3b10d0e19d836670375137d56f343e 100644 (file)
@@ -2697,8 +2697,15 @@ static int io_read(struct io_kiocb *req, bool force_nonblock)
                else
                        ret2 = -EINVAL;
 
+               /* no retry on NONBLOCK marked file */
+               if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK)) {
+                       ret = 0;
+                       goto done;
+               }
+
                /* Catch -EAGAIN return for forced non-blocking submission */
                if (!force_nonblock || ret2 != -EAGAIN) {
+       done:
                        kiocb_done(kiocb, ret2);
                } else {
 copy_iov:
@@ -2823,7 +2830,13 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
                 */
                if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
                        ret2 = -EAGAIN;
+               /* no retry on NONBLOCK marked file */
+               if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK)) {
+                       ret = 0;
+                       goto done;
+               }
                if (!force_nonblock || ret2 != -EAGAIN) {
+done:
                        kiocb_done(kiocb, ret2);
                } else {
 copy_iov: