diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-02-04 13:52:00 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-02-04 08:05:46 -0700 |
commit | 1a2cc0ce8d18c9e5592733cb6381e9ff5c23d916 (patch) | |
tree | 4a02c915a616874e182bf7c27b89ae7188664f90 /fs | |
parent | 6713e7a6145a4b5a61e33a37f0b4d06ca6d2c6d8 (diff) | |
download | linux-stable-1a2cc0ce8d18c9e5592733cb6381e9ff5c23d916.tar.gz linux-stable-1a2cc0ce8d18c9e5592733cb6381e9ff5c23d916.tar.bz2 linux-stable-1a2cc0ce8d18c9e5592733cb6381e9ff5c23d916.zip |
io_uring: further simplify do_read error parsing
First, instead of checking iov_iter_count(iter) for 0 to find out that
all needed bytes were read, just compare returned code against io_size.
It's more reliable and arguably cleaner.
Also, place the half-read case into an else branch and delete an extra
label.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/io_uring.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 866e0ea83dbe..1d1fa1f77332 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3552,19 +3552,18 @@ static int io_read(struct io_kiocb *req, bool force_nonblock, /* some cases will consume bytes even on error returns */ iov_iter_revert(iter, io_size - iov_iter_count(iter)); ret = 0; - goto copy_iov; - } else if (ret <= 0) { + } else if (ret <= 0 || ret == io_size) { /* make sure -ERESTARTSYS -> -EINTR is done */ goto done; - } + } else { + /* we did blocking attempt. no retry. */ + if (!force_nonblock || (req->file->f_flags & O_NONBLOCK) || + !(req->flags & REQ_F_ISREG)) + goto done; - /* read it all, or we did blocking attempt. no retry. */ - if (!iov_iter_count(iter) || !force_nonblock || - (req->file->f_flags & O_NONBLOCK) || !(req->flags & REQ_F_ISREG)) - goto done; + io_size -= ret; + } - io_size -= ret; -copy_iov: ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true); if (ret2) { ret = ret2; |