Skip to content

Commit 78a7806

Browse files
committed
io_uring: ensure task_work gets run as part of cancelations
If we successfully cancel a work item but that work item needs to be processed through task_work, then we can be sleeping uninterruptibly in io_uring_cancel_generic() and never process it. Hence we don't make forward progress and we end up with an uninterruptible sleep warning. While in there, correct a comment that should be IFF, not IIF. Reported-and-tested-by: [email protected] Cc: [email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent e47498a commit 78a7806

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/io_uring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9824,7 +9824,7 @@ static __cold void io_uring_drop_tctx_refs(struct task_struct *task)
98249824

98259825
/*
98269826
* Find any io_uring ctx that this task has registered or done IO on, and cancel
9827-
* requests. @sqd should be not-null IIF it's an SQPOLL thread cancellation.
9827+
* requests. @sqd should be not-null IFF it's an SQPOLL thread cancellation.
98289828
*/
98299829
static __cold void io_uring_cancel_generic(bool cancel_all,
98309830
struct io_sq_data *sqd)
@@ -9866,8 +9866,10 @@ static __cold void io_uring_cancel_generic(bool cancel_all,
98669866
cancel_all);
98679867
}
98689868

9869-
prepare_to_wait(&tctx->wait, &wait, TASK_UNINTERRUPTIBLE);
9869+
prepare_to_wait(&tctx->wait, &wait, TASK_INTERRUPTIBLE);
9870+
io_run_task_work();
98709871
io_uring_drop_tctx_refs(current);
9872+
98719873
/*
98729874
* If we've seen completions, retry without waiting. This
98739875
* avoids a race where a completion comes in before we did

0 commit comments

Comments
 (0)