io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] io_uring: fix short read retries for non-reg files
@ 2021-01-21 12:01 Pavel Begunkov
  2021-01-21 12:41 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-01-21 12:01 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: stable

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: stable@vger.kernel.org # 5.9+
Suggested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---

v2: essentially same, but a bit cleaner check placement and
    extended commit message

 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5f6f1e48954e..18920f9785d2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3552,7 +3552,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;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] io_uring: fix short read retries for non-reg files
  2021-01-21 12:01 [PATCH v2] io_uring: fix short read retries for non-reg files Pavel Begunkov
@ 2021-01-21 12:41 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-01-21 12:41 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring; +Cc: stable

On 1/21/21 5:01 AM, Pavel Begunkov wrote:
> 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.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-21 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 12:01 [PATCH v2] io_uring: fix short read retries for non-reg files Pavel Begunkov
2021-01-21 12:41 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).