From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring@vger.kernel.org
Subject: [PATCH 6/6] io_uring: refactor io_openat2()
Date: Thu, 24 Jun 2021 15:10:00 +0100 [thread overview]
Message-ID: <f4c84d25c049d0af2adc19c703bbfef607200209.1624543113.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1624543113.git.asml.silence@gmail.com>
Put do_filp_open() fail path of io_openat2() under a single if,
deduplicating put_unused_fd(), making it look better and helping
the hot path.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
fs/io_uring.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index c382182573d5..b0dea0b39ea1 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4021,27 +4021,26 @@ static int io_openat2(struct io_kiocb *req, unsigned int issue_flags)
goto err;
file = do_filp_open(req->open.dfd, req->open.filename, &op);
- /* only retry if RESOLVE_CACHED wasn't already set by application */
- if ((!resolve_nonblock && (issue_flags & IO_URING_F_NONBLOCK)) &&
- file == ERR_PTR(-EAGAIN)) {
+ if (IS_ERR(file)) {
/*
- * We could hang on to this 'fd', but seems like marginal
- * gain for something that is now known to be a slower path.
- * So just put it, and we'll get a new one when we retry.
+ * We could hang on to this 'fd' on retrying, but seems like
+ * marginal gain for something that is now known to be a slower
+ * path. So just put it, and we'll get a new one when we retry.
*/
put_unused_fd(ret);
- return -EAGAIN;
- }
- if (IS_ERR(file)) {
- put_unused_fd(ret);
ret = PTR_ERR(file);
- } else {
- if ((issue_flags & IO_URING_F_NONBLOCK) && !nonblock_set)
- file->f_flags &= ~O_NONBLOCK;
- fsnotify_open(file);
- fd_install(ret, file);
+ /* only retry if RESOLVE_CACHED wasn't already set by application */
+ if (ret == -EAGAIN &&
+ (!resolve_nonblock && (issue_flags & IO_URING_F_NONBLOCK)))
+ return -EAGAIN;
+ goto err;
}
+
+ if ((issue_flags & IO_URING_F_NONBLOCK) && !nonblock_set)
+ file->f_flags &= ~O_NONBLOCK;
+ fsnotify_open(file);
+ fd_install(ret, file);
err:
putname(req->open.filename);
req->flags &= ~REQ_F_NEED_CLEANUP;
--
2.32.0
next prev parent reply other threads:[~2021-06-24 14:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 14:09 [PATCH for-next 0/6] straightforward for-next cleanups Pavel Begunkov
2021-06-24 14:09 ` [PATCH 1/6] io_uring: don't change sqpoll creds if not needed Pavel Begunkov
2021-06-24 14:09 ` [PATCH 2/6] io_uring: refactor io_sq_thread() Pavel Begunkov
2021-06-24 14:09 ` [PATCH 3/6] io_uring: fix code style problems Pavel Begunkov
2021-06-24 14:09 ` [PATCH 4/6] io_uring: update sqe layout build checks Pavel Begunkov
2021-06-24 14:09 ` [PATCH 5/6] io_uring: simplify struct io_uring_sqe layout Pavel Begunkov
2021-06-24 14:10 ` Pavel Begunkov [this message]
2021-06-24 15:35 ` [PATCH for-next 0/6] straightforward for-next cleanups 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=f4c84d25c049d0af2adc19c703bbfef607200209.1624543113.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).