From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH 1/2] io-wq: allow grabbing existing io-wq
Date: Tue, 28 Jan 2020 03:06:51 +0300 [thread overview]
Message-ID: <404c434402d7a41a80f1e4f6bb7dc3ef9123f493.1580169415.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
If the id and user/creds match, return an existing io_wq if we can safely
grab a reference to it.
Reported-by: Jens Axboe <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io-wq.c | 10 ++++++++++
fs/io-wq.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index b45d585cdcc8..36d05503b982 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -1110,6 +1110,16 @@ struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
return ERR_PTR(ret);
}
+bool io_wq_get(struct io_wq *wq, struct io_wq_data *data)
+{
+ if (data->creds != wq->creds || data->user != wq->user)
+ return false;
+ if (data->get_work != wq->get_work || data->put_work != wq->put_work)
+ return false;
+
+ return refcount_inc_not_zero(&wq->use_refs);
+}
+
static bool io_wq_worker_wake(struct io_worker *worker, void *data)
{
wake_up_process(worker->task);
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 167316ad447e..c42602c58c56 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -99,6 +99,7 @@ struct io_wq_data {
};
struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data);
+bool io_wq_get(struct io_wq *wq, struct io_wq_data *data);
void io_wq_destroy(struct io_wq *wq);
void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
--
2.24.0
next prev parent reply other threads:[~2020-01-28 0:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 0:06 [PATCH 0/2] io-wq sharing Pavel Begunkov
2020-01-28 0:06 ` Pavel Begunkov [this message]
2020-01-28 0:06 ` [PATCH 2/2] io_uring: add io-wq workqueue sharing Pavel Begunkov
2020-01-28 0:08 ` [PATCH 0/2] io-wq sharing Pavel Begunkov
2020-01-28 0:15 ` [PATCH v2 " Pavel Begunkov
2020-01-28 0:15 ` [PATCH v2 1/2] io-wq: allow grabbing existing io-wq Pavel Begunkov
2020-01-28 0:18 ` Pavel Begunkov
2020-01-28 0:20 ` Jens Axboe
2020-01-28 0:15 ` [PATCH v2 2/2] io_uring: add io-wq workqueue sharing Pavel Begunkov
2020-01-28 0:22 ` Jens Axboe
2020-01-28 0:29 ` [PATCH v2 0/2] io-wq sharing Jens Axboe
2020-01-28 7:41 ` Pavel Begunkov
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=404c434402d7a41a80f1e4f6bb7dc3ef9123f493.1580169415.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