Skip to content

Commit f91daf5

Browse files
committed
io_uring: short circuit -EAGAIN for blocking read attempt
One case was missed in the short IO retry handling, and that's hitting -EAGAIN on a blocking attempt read (eg from io-wq context). This is a problem on sockets that are marked as non-blocking when created, they don't carry any REQ_F_NOWAIT information to help us terminate them instead of perpetually retrying. Fixes: 227c0c9 ("io_uring: internally retry short reads") Signed-off-by: Jens Axboe <[email protected]>
1 parent d4e7cd3 commit f91daf5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/io_uring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3186,6 +3186,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
31863186
ret = 0;
31873187
goto out_free;
31883188
} else if (ret == -EAGAIN) {
3189+
if (!force_nonblock)
3190+
goto done;
31893191
ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
31903192
if (ret)
31913193
goto out_free;
@@ -3195,7 +3197,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
31953197
}
31963198

31973199
/* read it all, or we did blocking attempt. no retry. */
3198-
if (!iov_iter_count(iter) || !force_nonblock)
3200+
if (!iov_iter_count(iter) || !force_nonblock ||
3201+
(req->file->f_flags & O_NONBLOCK))
31993202
goto done;
32003203

32013204
io_size -= ret;

0 commit comments

Comments
 (0)