From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected],
Bijan Mottahedeh <[email protected]>
Subject: [PATCH 4/9] io_uring: add rsrc_ref locking routines
Date: Fri, 15 Jan 2021 17:37:47 +0000 [thread overview]
Message-ID: <47dd0cf012043678d2b066b3d92580043ff7c76e.1610729503.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
From: Bijan Mottahedeh <[email protected]>
Encapsulate resource reference locking into separate routines.
Signed-off-by: Bijan Mottahedeh <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
Reviewed-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index b46710e88c35..6eeea8d34615 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7274,14 +7274,24 @@ static void io_rsrc_ref_kill(struct percpu_ref *ref)
complete(&data->done);
}
+static inline void io_rsrc_ref_lock(struct io_ring_ctx *ctx)
+{
+ spin_lock_bh(&ctx->rsrc_ref_lock);
+}
+
+static inline void io_rsrc_ref_unlock(struct io_ring_ctx *ctx)
+{
+ spin_unlock_bh(&ctx->rsrc_ref_lock);
+}
+
static void io_sqe_rsrc_set_node(struct io_ring_ctx *ctx,
struct fixed_rsrc_data *rsrc_data,
struct fixed_rsrc_ref_node *ref_node)
{
- spin_lock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_lock(ctx);
rsrc_data->node = ref_node;
list_add_tail(&ref_node->node, &ctx->rsrc_ref_list);
- spin_unlock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_unlock(ctx);
percpu_ref_get(&rsrc_data->refs);
}
@@ -7298,9 +7308,9 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
if (!backup_node)
return -ENOMEM;
- spin_lock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_lock(ctx);
ref_node = data->node;
- spin_unlock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_unlock(ctx);
if (ref_node)
percpu_ref_kill(&ref_node->refs);
@@ -7690,7 +7700,7 @@ static void io_rsrc_data_ref_zero(struct percpu_ref *ref)
data = ref_node->rsrc_data;
ctx = data->ctx;
- spin_lock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_lock(ctx);
ref_node->done = true;
while (!list_empty(&ctx->rsrc_ref_list)) {
@@ -7702,7 +7712,7 @@ static void io_rsrc_data_ref_zero(struct percpu_ref *ref)
list_del(&ref_node->node);
first_add |= llist_add(&ref_node->llist, &ctx->rsrc_put_llist);
}
- spin_unlock_bh(&ctx->rsrc_ref_lock);
+ io_rsrc_ref_unlock(ctx);
if (percpu_ref_is_dying(&data->refs))
delay = 0;
--
2.24.0
next prev parent reply other threads:[~2021-01-15 17:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 17:37 [PATCH 0/9] Bijan's rsrc generalisation + prep parts Pavel Begunkov
2021-01-15 17:37 ` [PATCH 1/9] io_uring: rename file related variables to rsrc Pavel Begunkov
2021-01-15 17:37 ` [PATCH 2/9] io_uring: generalize io_queue_rsrc_removal Pavel Begunkov
2021-01-15 17:37 ` [PATCH 3/9] io_uring: separate ref_list from fixed_rsrc_data Pavel Begunkov
2021-01-15 17:37 ` Pavel Begunkov [this message]
2021-01-15 17:37 ` [PATCH 5/9] io_uring: split alloc_fixed_file_ref_node Pavel Begunkov
2021-01-15 17:37 ` [PATCH 6/9] io_uring: split ref_node alloc and init Pavel Begunkov
2021-01-15 17:37 ` [PATCH 7/9] io_uring: create common fixed_rsrc_ref_node handling routines Pavel Begunkov
2021-01-15 17:37 ` [PATCH 8/9] io_uring: create common fixed_rsrc_data allocation routines Pavel Begunkov
2021-01-15 17:37 ` [PATCH 9/9] io_uring: make percpu_ref_release names consistent Pavel Begunkov
2021-01-15 18:24 ` [PATCH 0/9] Bijan's rsrc generalisation + prep parts Bijan Mottahedeh
2021-01-15 19:08 ` 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=47dd0cf012043678d2b066b3d92580043ff7c76e.1610729503.git.asml.silence@gmail.com \
[email protected] \
[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