io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] io-wq: remove io_wq_flush and IO_WQ_WORK_INTERNAL
@ 2020-03-02 20:46 Pavel Begunkov
  2020-03-02 20:57 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2020-03-02 20:46 UTC (permalink / raw)
  To: Jens Axboe, io-uring

io_wq_flush() is buggy, during cancellation an flush associated work may
be passed to user's (i.e. io_uring) @match callback, which doesn't a
work of a different layout. Neither sounds right cancellation of
internal work by io-wq users.

As it's not used anyway, delete it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io-wq.c | 38 +-------------------------------------
 fs/io-wq.h |  2 --
 2 files changed, 1 insertion(+), 39 deletions(-)

diff --git a/fs/io-wq.c b/fs/io-wq.c
index f74a105ab968..042c7e2057ef 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -497,7 +497,7 @@ static void io_worker_handle_work(struct io_worker *worker)
 		if (test_bit(IO_WQ_BIT_CANCEL, &wq->state))
 			work->flags |= IO_WQ_WORK_CANCEL;
 
-		if (wq->get_work && !(work->flags & IO_WQ_WORK_INTERNAL)) {
+		if (wq->get_work) {
 			put_work = work;
 			wq->get_work(work);
 		}
@@ -1052,42 +1052,6 @@ enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid)
 	return ret;
 }
 
-struct io_wq_flush_data {
-	struct io_wq_work work;
-	struct completion done;
-};
-
-static void io_wq_flush_func(struct io_wq_work **workptr)
-{
-	struct io_wq_work *work = *workptr;
-	struct io_wq_flush_data *data;
-
-	data = container_of(work, struct io_wq_flush_data, work);
-	complete(&data->done);
-}
-
-/*
- * Doesn't wait for previously queued work to finish. When this completes,
- * it just means that previously queued work was started.
- */
-void io_wq_flush(struct io_wq *wq)
-{
-	struct io_wq_flush_data data;
-	int node;
-
-	for_each_node(node) {
-		struct io_wqe *wqe = wq->wqes[node];
-
-		if (!node_online(node))
-			continue;
-		init_completion(&data.done);
-		INIT_IO_WORK(&data.work, io_wq_flush_func);
-		data.work.flags |= IO_WQ_WORK_INTERNAL;
-		io_wqe_enqueue(wqe, &data.work);
-		wait_for_completion(&data.done);
-	}
-}
-
 struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data)
 {
 	int ret = -ENOMEM, node;
diff --git a/fs/io-wq.h b/fs/io-wq.h
index 001194aef6ae..a0978d6958f0 100644
--- a/fs/io-wq.h
+++ b/fs/io-wq.h
@@ -7,7 +7,6 @@ enum {
 	IO_WQ_WORK_CANCEL	= 1,
 	IO_WQ_WORK_HASHED	= 4,
 	IO_WQ_WORK_UNBOUND	= 32,
-	IO_WQ_WORK_INTERNAL	= 64,
 	IO_WQ_WORK_NO_CANCEL	= 256,
 	IO_WQ_WORK_CONCURRENT	= 512,
 
@@ -98,7 +97,6 @@ void io_wq_destroy(struct io_wq *wq);
 
 void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
 void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val);
-void io_wq_flush(struct io_wq *wq);
 
 void io_wq_cancel_all(struct io_wq *wq);
 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork);
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] io-wq: remove io_wq_flush and IO_WQ_WORK_INTERNAL
  2020-03-02 20:46 [PATCH 1/1] io-wq: remove io_wq_flush and IO_WQ_WORK_INTERNAL Pavel Begunkov
@ 2020-03-02 20:57 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-03-02 20:57 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 3/2/20 1:46 PM, Pavel Begunkov wrote:
> io_wq_flush() is buggy, during cancellation an flush associated work may
> be passed to user's (i.e. io_uring) @match callback, which doesn't a
> work of a different layout. Neither sounds right cancellation of
> internal work by io-wq users.
> 
> As it's not used anyway, delete it.

Thanks - and yes, it's unused now, so easy enough to just kill it
off. Applied for 5.6.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-02 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02 20:46 [PATCH 1/1] io-wq: remove io_wq_flush and IO_WQ_WORK_INTERNAL Pavel Begunkov
2020-03-02 20:57 ` Jens Axboe

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).