io_uring: don't submit sqes when ctx->refs is dying
PATCH 1/1 io_uring: don't submit sqes when ctx->refs is dying
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 <[email protected]>
--- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)
fs/io_uring.c +2 -0
@@ -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;
Signature · 1 line
1.8.3.1
Quoted 4 lines · Hao Xu
When doing
__io_uring_register()and waiting for references to exit, there could be other threads callingio_uring_enter()and submitting sqes which may cause the drain wait endless. So avoid this case by checking ifctx->refsis dying.
IMHO, let's leave it as is because it noticeably changes behaviour. That's nothing that can't be solved in userspace if needed differently.
Quoted 20 lines
Signed-off-by Hao Xu <[email protected]>--- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+)fs/io_uring.c +2
-0@@ -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;
Signature · 1 line
Pavel Begunkov