Commit dc2a6e9a authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

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: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent bf6182b6
...@@ -2689,17 +2689,16 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res, ...@@ -2689,17 +2689,16 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res,
} }
#ifdef CONFIG_BLOCK #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; struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;
ssize_t ret = -ECANCELED; ssize_t ret = -ECANCELED;
struct iov_iter iter; struct iov_iter iter;
int rw; int rw;
if (error) { /* already prepared */
ret = error; if (req->async_data)
goto end_req; return true;
}
switch (req->opcode) { switch (req->opcode) {
case IORING_OP_READV: case IORING_OP_READV:
...@@ -2715,22 +2714,16 @@ static bool io_resubmit_prep(struct io_kiocb *req, int error) ...@@ -2715,22 +2714,16 @@ static bool io_resubmit_prep(struct io_kiocb *req, int error)
default: default:
printk_once(KERN_WARNING "io_uring: bad opcode in resubmit %d\n", printk_once(KERN_WARNING "io_uring: bad opcode in resubmit %d\n",
req->opcode); req->opcode);
goto end_req; return false;
} }
if (!req->async_data) {
ret = io_import_iovec(rw, req, &iovec, &iter, false); ret = io_import_iovec(rw, req, &iovec, &iter, false);
if (ret < 0) if (ret < 0)
goto end_req; return false;
ret = io_setup_async_rw(req, iovec, inline_vecs, &iter, false); ret = io_setup_async_rw(req, iovec, inline_vecs, &iter, false);
if (!ret) if (!ret)
return true; return true;
kfree(iovec); kfree(iovec);
} else {
return true;
}
end_req:
req_set_fail_links(req);
return false; return false;
} }
#endif #endif
...@@ -2751,12 +2744,12 @@ static bool io_rw_reissue(struct io_kiocb *req, long res) ...@@ -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); 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); refcount_inc(&req->refs);
io_queue_async_work(req); io_queue_async_work(req);
return true; return true;
} }
req_set_fail_links(req);
#endif #endif
return false; return false;
} }
......
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