From: Hao Xu <howeyxu@xxxxxxxxxxx> 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@xxxxxxxxxxx> --- io_uring/io-wq.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c index 38d88da70a40..9e8ad7455373 100644 --- a/io_uring/io-wq.c +++ b/io_uring/io-wq.c @@ -1285,32 +1285,44 @@ 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_normal(struct io_wqe *wqe, + struct io_cb_cancel_data *match) { - int i, j; - struct io_wqe_acct *acct, *iw_acct; + int i; + struct io_wqe_acct *acct; -retry_public: +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_public; + goto retry; return; } } +} + +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_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; } @@ -1319,6 +1331,20 @@ static void io_wqe_cancel_pending_work(struct io_wqe *wqe, } } +static void io_wqe_cancel_pending_work_fixed(struct io_wqe *wqe, + struct io_cb_cancel_data *match) +{ + __io_wqe_cancel_pending_work_fixed(wqe, match, false); + __io_wqe_cancel_pending_work_fixed(wqe, match, true); +} + +static void io_wqe_cancel_pending_work(struct io_wqe *wqe, + struct io_cb_cancel_data *match) +{ + io_wqe_cancel_pending_work_normal(wqe, match); + io_wqe_cancel_pending_work_fixed(wqe, match); +} + static void io_wqe_cancel_running_work(struct io_wqe *wqe, struct io_cb_cancel_data *match) { -- 2.25.1