From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/7] io_uring: kill ref get/drop in personality init
Date: Sun, 18 Oct 2020 10:17:38 +0100 [thread overview]
Message-ID: <3a6b087088de6b9fbc1694201a20f8c0951536de.1603011899.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Don't take an identity on personality/creds init only to drop it a few
lines after. Extract a function which prepares req->work but leaves it
without identity.
Note: it's safe to not check REQ_F_WORK_INITIALIZED there because it's
nobody had a chance to init it before io_init_req().
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index fd2fc72c312c..048db9d3002c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1070,6 +1070,12 @@ static void io_init_identity(struct io_identity *id)
refcount_set(&id->count, 1);
}
+static inline void __io_req_init_async(struct io_kiocb *req)
+{
+ memset(&req->work, 0, sizeof(req->work));
+ req->flags |= REQ_F_WORK_INITIALIZED;
+}
+
/*
* Note: must call io_req_init_async() for the first time you
* touch any members of io_wq_work.
@@ -1081,8 +1087,7 @@ static inline void io_req_init_async(struct io_kiocb *req)
if (req->flags & REQ_F_WORK_INITIALIZED)
return;
- memset(&req->work, 0, sizeof(req->work));
- req->flags |= REQ_F_WORK_INITIALIZED;
+ __io_req_init_async(req);
/* Grab a ref if this isn't our static identity */
req->work.identity = tctx->identity;
@@ -6497,12 +6502,12 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
if (id) {
struct io_identity *iod;
- io_req_init_async(req);
iod = idr_find(&ctx->personality_idr, id);
if (unlikely(!iod))
return -EINVAL;
refcount_inc(&iod->count);
- io_put_identity(current->io_uring, req);
+
+ __io_req_init_async(req);
get_cred(iod->creds);
req->work.identity = iod;
req->work.flags |= IO_WQ_WORK_CREDS;
--
2.24.0
next prev parent reply other threads:[~2020-10-18 9:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-18 9:17 [PATCH for-5.10 0/7] another pack of random cleanups Pavel Begunkov
2020-10-18 9:17 ` [PATCH 1/7] io_uring: flags-based creds init in queue Pavel Begunkov
2020-10-18 9:17 ` Pavel Begunkov [this message]
2020-10-18 9:17 ` [PATCH 3/7] io_uring: inline io_fail_links() Pavel Begunkov
2020-10-18 9:17 ` [PATCH 4/7] io_uring: make cached_cq_overflow non atomic_t Pavel Begunkov
2020-10-18 9:17 ` [PATCH 5/7] io_uring: remove extra ->file check in poll prep Pavel Begunkov
2020-10-18 9:17 ` [PATCH 6/7] io_uring: inline io_poll_task_handler() Pavel Begunkov
2020-10-18 9:17 ` [PATCH 7/7] io_uring: do poll's hash_node init in common code Pavel Begunkov
2020-10-20 14:10 ` [PATCH for-5.10 0/7] another pack of random 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=3a6b087088de6b9fbc1694201a20f8c0951536de.1603011899.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