VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
author: Hao Xu <haoxu@linux.alibaba.com> 2021-08-08 21:54:33 +0800 committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2021-08-18 09:06:57 +0200 commit: 815a0fe3f415e78ae8678fc1b8864e2dc34b9091 parent: 3cedeb691b74c1c0d85a7241727ad5e62ba53b4e
Commit Summary:
io-wq: fix bug of creating io-wokers unconditionally
Diffstat:
1 file changed, 10 insertions, 2 deletions
diff --git a/fs/io-wq.c b/fs/io-wq.c
index 77026d42cb79..2c8a9a394884 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -283,16 +283,24 @@ static void create_worker_cb(struct callback_head *cb)
 	struct io_wq *wq;
 	struct io_wqe *wqe;
 	struct io_wqe_acct *acct;
+	bool do_create = false;
 
 	cwd = container_of(cb, struct create_worker_data, work);
 	wqe = cwd->wqe;
 	wq = wqe->wq;
 	acct = &wqe->acct[cwd->index];
 	raw_spin_lock_irq(&wqe->lock);
-	if (acct->nr_workers < acct->max_workers)
+	if (acct->nr_workers < acct->max_workers) {
 		acct->nr_workers++;
+		do_create = true;
+	}
 	raw_spin_unlock_irq(&wqe->lock);
-	create_io_worker(wq, cwd->wqe, cwd->index);
+	if (do_create) {
+		create_io_worker(wq, cwd->wqe, cwd->index);
+	} else {
+		atomic_dec(&acct->nr_running);
+		io_worker_ref_put(wq);
+	}
 	kfree(cwd);
 }