diff mbox series

[11/11] io_uring: cancel works in exec work list for fixed worker

Message ID 20220515131230.155267-12-haoxu.linux@icloud.com (mailing list archive)
State New
Headers show
Series fixed worker | expand

Commit Message

Hao Xu May 15, 2022, 1:12 p.m. UTC
From: Hao Xu <howeyxu@tencent.com>

From: Hao Xu <howeyxu@tencent.com>

When users want to cancel a request, look into the exec work list of
fixed worker as well. It's not sane to ignore it.

Signed-off-by: Hao Xu <howeyxu@tencent.com>
---
 fs/io-wq.c | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/fs/io-wq.c b/fs/io-wq.c
index c6e4179a9961..5345a5f57e4f 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -1287,32 +1287,26 @@  static bool io_acct_cancel_pending_work(struct io_wqe *wqe,
 	return false;
 }
 
-static void io_wqe_cancel_pending_work(struct io_wqe *wqe,
-				       struct io_cb_cancel_data *match)
-{
+static void io_wqe_cancel_pending_work_fixed(struct io_wqe *wqe,
+					     struct io_cb_cancel_data *match,
+					     bool exec) {
 	int i, j;
 	struct io_wqe_acct *acct, *iw_acct;
 
-retry_public:
-	for (i = 0; i < IO_WQ_ACCT_NR; i++) {
-		acct = io_get_acct(wqe, i == 0, false);
-		if (io_acct_cancel_pending_work(wqe, acct, match)) {
-			if (match->cancel_all)
-				goto retry_public;
-			return;
-		}
-	}
-
-retry_private:
+retry:
 	for (i = 0; i < IO_WQ_ACCT_NR; i++) {
 		acct = io_get_acct(wqe, i == 0, true);
 		raw_spin_lock(&acct->lock);
 		for (j = 0; j < acct->nr_fixed; j++) {
-			iw_acct = &acct->fixed_workers[j]->acct;
+			if (exec)
+				iw_acct = &acct->fixed_workers[j]->acct;
+			else
+				iw_acct = &acct->fixed_workers[j]->exec_acct;
+
 			if (io_acct_cancel_pending_work(wqe, iw_acct, match)) {
 				if (match->cancel_all) {
 					raw_spin_unlock(&acct->lock);
-					goto retry_private;
+					goto retry;
 				}
 				break;
 			}
@@ -1321,6 +1315,26 @@  static void io_wqe_cancel_pending_work(struct io_wqe *wqe,
 	}
 }
 
+static void io_wqe_cancel_pending_work(struct io_wqe *wqe,
+				       struct io_cb_cancel_data *match)
+{
+	int i;
+	struct io_wqe_acct *acct;
+
+retry:
+	for (i = 0; i < IO_WQ_ACCT_NR; i++) {
+		acct = io_get_acct(wqe, i == 0, false);
+		if (io_acct_cancel_pending_work(wqe, acct, match)) {
+			if (match->cancel_all)
+				goto retry;
+			return;
+		}
+	}
+
+	io_wqe_cancel_pending_work_fixed(wqe, match, false);
+	io_wqe_cancel_pending_work_fixed(wqe, match, true);
+}
+
 static void io_wqe_cancel_running_work(struct io_wqe *wqe,
 				       struct io_cb_cancel_data *match)
 {