From e45f2f8716a62bbcc7dbaf6a3917df39d9ba1141 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Tue, 28 Jan 2020 03:15:47 +0300 Subject: [PATCH] io-wq: allow grabbing existing io-wq to #26323588 commit eba6f5a330cf042bb0001f0b5e8cbf21be1b25d6 upstream. Export a helper to attach to an existing io-wq, rather than setting up a new one. This is doable now that we have reference counted io_wq's. Reported-by: Jens Axboe Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Joseph Qi Acked-by: Xiaoguang Wang --- fs/io-wq.c | 8 ++++++++ fs/io-wq.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/io-wq.c b/fs/io-wq.c index 5d089acdcfbd..87498b1e0674 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -1115,6 +1115,14 @@ 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->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 bbc529042190..b4ff96ce7443 100644 --- a/fs/io-wq.h +++ b/fs/io-wq.h @@ -98,6 +98,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); -- GitLab