Skip to content

Commit

Permalink
io_uring: fix short read retries for non-reg files
Browse files Browse the repository at this point in the history
ANBZ: torvalds#190

commit 9a17334 upstream.

Sockets and other non-regular files may actually expect short reads to
happen, don't retry reads for them. Because non-reg files don't set
FMODE_BUF_RASYNC and so it won't do second/retry do_read, we can filter
out those cases after first do_read() attempt with ret>0.

Cc: [email protected] # 5.9+
Suggested-by: Jens Axboe <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Joseph Qi <[email protected]>
Reviewed-by: Xiaoguang Wang <[email protected]>
Reviewed-by: Hao Xu <[email protected]>
Tested-by: Hao Xu <[email protected]>
  • Loading branch information
isilence authored and josephhz committed Dec 31, 2021
1 parent 3b7f3e0 commit 566241c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3109,7 +3109,7 @@ 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 ||
(req->file->f_flags & O_NONBLOCK))
(req->file->f_flags & O_NONBLOCK) || !(req->flags & REQ_F_ISREG))
goto done;

io_size -= ret;
Expand Down

0 comments on commit 566241c

Please sign in to comment.