Skip to content

Commit 023464f

Browse files
committed
Revert "io_uring: fix IO hang in io_wq_put_and_exit from do_exit()"
This reverts commit b484a40. This commit cancels all requests with io-wq, not just the ones from the originating task. This breaks use cases that have thread pools, or just multiple tasks issuing requests on the same ring. The liburing regression test for this also shows that problem: $ test/thread-exit.t cqe->res=-125, Expected 512 where an IO thread gets its request canceled rather than complete successfully. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 27122c0 commit 023464f

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

io_uring/io_uring.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,37 +3317,6 @@ static s64 tctx_inflight(struct io_uring_task *tctx, bool tracked)
33173317
return percpu_counter_sum(&tctx->inflight);
33183318
}
33193319

3320-
static void io_uring_cancel_wq(struct io_uring_task *tctx)
3321-
{
3322-
int ret;
3323-
3324-
if (!tctx->io_wq)
3325-
return;
3326-
3327-
/*
3328-
* FIXED_FILE request isn't tracked in do_exit(), and these
3329-
* requests may be submitted to our io_wq as iopoll, so have to
3330-
* cancel them before destroying io_wq for avoiding IO hang
3331-
*/
3332-
do {
3333-
struct io_tctx_node *node;
3334-
unsigned long index;
3335-
3336-
ret = 0;
3337-
xa_for_each(&tctx->xa, index, node) {
3338-
struct io_ring_ctx *ctx = node->ctx;
3339-
struct io_task_cancel cancel = { .task = current, .all = true, };
3340-
enum io_wq_cancel cret;
3341-
3342-
io_iopoll_try_reap_events(ctx);
3343-
cret = io_wq_cancel_cb(tctx->io_wq, io_cancel_task_cb,
3344-
&cancel, true);
3345-
ret |= (cret != IO_WQ_CANCEL_NOTFOUND);
3346-
cond_resched();
3347-
}
3348-
} while (ret);
3349-
}
3350-
33513320
/*
33523321
* Find any io_uring ctx that this task has registered or done IO on, and cancel
33533322
* requests. @sqd should be not-null IFF it's an SQPOLL thread cancellation.
@@ -3419,7 +3388,6 @@ __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd)
34193388
finish_wait(&tctx->wait, &wait);
34203389
} while (1);
34213390

3422-
io_uring_cancel_wq(tctx);
34233391
io_uring_clean_tctx(tctx);
34243392
if (cancel_all) {
34253393
/*

0 commit comments

Comments
 (0)