Commit 6713e7a6 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: refactor io_read for unsupported nowait

!io_file_supports_async() case of io_read() is hard to read, it jumps
somewhere in the middle of the function just to do async setup and fail
on a similar check. Call io_setup_async_rw() directly for this case,
it's much easier to follow.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent eeb60b9a
...@@ -3506,7 +3506,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock, ...@@ -3506,7 +3506,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
struct iov_iter __iter, *iter = &__iter; struct iov_iter __iter, *iter = &__iter;
struct io_async_rw *rw = req->async_data; struct io_async_rw *rw = req->async_data;
ssize_t io_size, ret, ret2; ssize_t io_size, ret, ret2;
bool no_async;
if (rw) { if (rw) {
iter = &rw->iter; iter = &rw->iter;
...@@ -3527,9 +3526,12 @@ static int io_read(struct io_kiocb *req, bool force_nonblock, ...@@ -3527,9 +3526,12 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
kiocb->ki_flags |= IOCB_NOWAIT; kiocb->ki_flags |= IOCB_NOWAIT;
/* If the file doesn't support async, just async punt */ /* If the file doesn't support async, just async punt */
no_async = force_nonblock && !io_file_supports_async(req->file, READ); if (force_nonblock && !io_file_supports_async(req->file, READ)) {
if (no_async) ret = io_setup_async_rw(req, iovec, inline_vecs, iter, true);
goto copy_iov; if (!ret)
return -EAGAIN;
goto out_free;
}
ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size); ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size);
if (unlikely(ret)) if (unlikely(ret))
...@@ -3568,8 +3570,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock, ...@@ -3568,8 +3570,6 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
ret = ret2; ret = ret2;
goto out_free; goto out_free;
} }
if (no_async)
return -EAGAIN;
rw = req->async_data; rw = req->async_data;
/* it's copied and will be cleaned with ->io */ /* it's copied and will be cleaned with ->io */
iovec = NULL; iovec = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment