When doing __io_uring_register() and waiting for references to exit, there could be other threads calling io_uring_enter() and submitting sqes which may cause the drain wait endless. So avoid this case by checking if ctx->refs is dying. Signed-off-by: Hao Xu <haoxu@xxxxxxxxxxxxxxxxx> --- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 931671082e61..9aab4d25c2df 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -9356,6 +9356,8 @@ static int io_get_ext_arg(unsigned flags, const void __user *argp, size_t *argsz } submitted = to_submit; } else if (to_submit) { + if (unlikely(percpu_ref_is_dying(&ctx->refs))) + goto out; ret = io_uring_add_task_file(ctx, f.file); if (unlikely(ret)) goto out; -- 1.8.3.1