Skip to content

Commit

Permalink
io_uring: short circuit -EAGAIN for blocking read attempt
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
axboe committed Aug 15, 2020
1 parent d4e7cd3 commit f91daf5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
ret = 0;
goto out_free;
} else if (ret == -EAGAIN) {
if (!force_nonblock)
goto done;
ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
if (ret)
goto out_free;
Expand All @@ -3195,7 +3197,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
}

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

io_size -= ret;
Expand Down

0 comments on commit f91daf5

Please sign in to comment.