[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <c38a2421e15e3aaa5c55e3e0d7ddca4c77d178e1.1584898199.git.asml.silence@gmail.com>
Date: Sun, 22 Mar 2020 20:33:16 +0300
From: Pavel Begunkov <asml.silence@...il.com>
To: Jens Axboe <axboe@...nel.dk>, io-uring@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] io-wq: close cancel gap for hashed linked work
After io_assign_current_work() of a linked work, it can be decided to
offloaded to another thread so doing io_wqe_enqueue(). However, until
next io_assign_current_work() it can be cancelled, that isn't handled.
Don't assign it, if it's not going to be executed.
Fixes: 60cf46ae605446feb0c43c472c0 ("io-wq: hash dependent work")
Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
---
fs/io-wq.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 9541df2729de..b3fb61ec0870 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -485,7 +485,7 @@ static void io_worker_handle_work(struct io_worker *worker)
struct io_wq *wq = wqe->wq;
do {
- struct io_wq_work *work;
+ struct io_wq_work *work, *assign_work;
unsigned int hash;
get_next:
/*
@@ -522,10 +522,14 @@ static void io_worker_handle_work(struct io_worker *worker)
hash = io_get_work_hash(work);
work->func(&work);
work = (old_work == work) ? NULL : work;
- io_assign_current_work(worker, work);
+
+ assign_work = work;
+ if (work && io_wq_is_hashed(work))
+ assign_work = NULL;
+ io_assign_current_work(worker, assign_work);
wq->free_work(old_work);
- if (work && io_wq_is_hashed(work)) {
+ if (work && !assign_work) {
io_wqe_enqueue(wqe, work);
work = NULL;
}
--
2.24.0
Powered by blists - more mailing lists