@@ -832,6 +832,11 @@ static void io_wqe_insert_work(struct io_wqe *wqe, struct io_wq_work *work)
832
832
wq_list_add_after (& work -> list , & tail -> list , & acct -> work_list );
833
833
}
834
834
835
+ static bool io_wq_work_match_item (struct io_wq_work * work , void * data )
836
+ {
837
+ return work == data ;
838
+ }
839
+
835
840
static void io_wqe_enqueue (struct io_wqe * wqe , struct io_wq_work * work )
836
841
{
837
842
struct io_wqe_acct * acct = io_work_get_acct (wqe , work );
@@ -844,7 +849,6 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
844
849
*/
845
850
if (test_bit (IO_WQ_BIT_EXIT , & wqe -> wq -> state ) ||
846
851
(work -> flags & IO_WQ_WORK_CANCEL )) {
847
- run_cancel :
848
852
io_run_cancel (work , wqe );
849
853
return ;
850
854
}
@@ -864,15 +868,22 @@ static void io_wqe_enqueue(struct io_wqe *wqe, struct io_wq_work *work)
864
868
bool did_create ;
865
869
866
870
did_create = io_wqe_create_worker (wqe , acct );
867
- if (unlikely (!did_create )) {
868
- raw_spin_lock (& wqe -> lock );
869
- /* fatal condition, failed to create the first worker */
870
- if (!acct -> nr_workers ) {
871
- raw_spin_unlock (& wqe -> lock );
872
- goto run_cancel ;
873
- }
874
- raw_spin_unlock (& wqe -> lock );
871
+ if (likely (did_create ))
872
+ return ;
873
+
874
+ raw_spin_lock (& wqe -> lock );
875
+ /* fatal condition, failed to create the first worker */
876
+ if (!acct -> nr_workers ) {
877
+ struct io_cb_cancel_data match = {
878
+ .fn = io_wq_work_match_item ,
879
+ .data = work ,
880
+ .cancel_all = false,
881
+ };
882
+
883
+ if (io_acct_cancel_pending_work (wqe , acct , & match ))
884
+ raw_spin_lock (& wqe -> lock );
875
885
}
886
+ raw_spin_unlock (& wqe -> lock );
876
887
}
877
888
}
878
889
0 commit comments