From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 02/14] io_uring: refactor io_resubmit_prep()
Date: Tue, 19 Jan 2021 13:32:35 +0000 [thread overview]
Message-ID: <9b6b370cbbde34b467079c42aedca0a6e884a199.1611062505.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
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 <[email protected]>
---
fs/io_uring.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7f4bc5092b5c..eb8bee704374 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2664,17 +2664,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:
@@ -2690,22 +2689,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
@@ -2726,12 +2719,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;
}
--
2.24.0
next prev parent reply other threads:[~2021-01-19 14:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 13:32 [PATCH for-next 00/14] mostly cleanups for 5.12 Pavel Begunkov
2021-01-19 13:32 ` [PATCH 01/14] io_uring: optimise io_rw_reissue() Pavel Begunkov
2021-01-19 13:32 ` Pavel Begunkov [this message]
2021-01-19 13:32 ` [PATCH 03/14] io_uring: cleanup personalities under uring_lock Pavel Begunkov
2021-01-19 13:32 ` [PATCH 04/14] io_uring: inline io_async_submit() Pavel Begunkov
2021-01-19 13:32 ` [PATCH 05/14] io_uring: inline __io_commit_cqring() Pavel Begunkov
2021-01-19 13:32 ` [PATCH 06/14] io_uring: further deduplicate #CQ events calc Pavel Begunkov
2021-01-19 13:32 ` [PATCH 07/14] io_uring: simplify io_alloc_req() Pavel Begunkov
2021-01-19 13:32 ` [PATCH 08/14] io_uring: remove __io_state_file_put Pavel Begunkov
2021-01-19 13:32 ` [PATCH 09/14] io_uring: deduplicate failing task_work_add Pavel Begunkov
2021-01-19 13:32 ` [PATCH 10/14] io_uring: don't block resource recycle by oveflows Pavel Begunkov
2021-01-19 22:59 ` Jens Axboe
2021-01-19 23:08 ` Pavel Begunkov
2021-01-19 13:32 ` [PATCH 11/14] io_uring: add a helper timeout mode calculation Pavel Begunkov
2021-01-19 13:32 ` [PATCH 12/14] io_uring: help inlining of io_req_complete() Pavel Begunkov
2021-01-19 13:32 ` [PATCH 13/14] io_uring: don't flush CQEs deep down the stack Pavel Begunkov
2021-01-19 13:32 ` [PATCH 14/14] io_uring: save atomic dec for inline executed reqs Pavel Begunkov
2021-01-19 23:01 ` [PATCH for-next 00/14] mostly cleanups for 5.12 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b6b370cbbde34b467079c42aedca0a6e884a199.1611062505.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox