summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-01-19 13:32:35 +0000
committerJens Axboe <axboe@kernel.dk>2021-02-01 10:02:42 -0700
commitdc2a6e9aa9c349d76c318d22bbe26006fda1ce97 (patch)
treeeeecdb8b894d0222e52497ba71717eafbe518911 /fs/io_uring.c
parentbf6182b6d46e28c3e59b9c0d6097b379cae56b94 (diff)
downloadlwn-dc2a6e9aa9c349d76c318d22bbe26006fda1ce97.tar.gz
lwn-dc2a6e9aa9c349d76c318d22bbe26006fda1ce97.zip
io_uring: refactor io_resubmit_prep()
It's awkward to pass return a value into a function for it to return it back. Check it at the caller site and clean up io_resubmit_prep() a bit. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4a8900d480c5..be2760ae6c23 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2689,17 +2689,16 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res,
}
#ifdef CONFIG_BLOCK
-static bool io_resubmit_prep(struct io_kiocb *req, int error)
+static bool io_resubmit_prep(struct io_kiocb *req)
{
struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
ssize_t ret = -ECANCELED;
struct iov_iter iter;
int rw;
- if (error) {
- ret = error;
- goto end_req;
- }
+ /* already prepared */
+ if (req->async_data)
+ return true;
switch (req->opcode) {
case IORING_OP_READV:
@@ -2715,22 +2714,16 @@ static bool io_resubmit_prep(struct io_kiocb *req, int error)
default:
printk_once(KERN_WARNING "io_uring: bad opcode in resubmit %d\n",
req->opcode);
- goto end_req;
+ return false;
}
- if (!req->async_data) {
- ret = io_import_iovec(rw, req, &iovec, &iter, false);
- if (ret < 0)
- goto end_req;
- ret = io_setup_async_rw(req, iovec, inline_vecs, &iter, false);
- if (!ret)
- return true;
- kfree(iovec);
- } else {
+ ret = io_import_iovec(rw, req, &iovec, &iter, false);
+ if (ret < 0)
+ return false;
+ ret = io_setup_async_rw(req, iovec, inline_vecs, &iter, false);
+ if (!ret)
return true;
- }
-end_req:
- req_set_fail_links(req);
+ kfree(iovec);
return false;
}
#endif
@@ -2751,12 +2744,12 @@ static bool io_rw_reissue(struct io_kiocb *req, long res)
ret = io_sq_thread_acquire_mm_files(req->ctx, req);
- if (io_resubmit_prep(req, ret)) {
+ if (!ret && io_resubmit_prep(req)) {
refcount_inc(&req->refs);
io_queue_async_work(req);
return true;
}
-
+ req_set_fail_links(req);
#endif
return false;
}