public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: don't submit sqes when ctx->refs is dying
@ 2021-02-19 17:58 Hao Xu
  2021-02-19 18:04 ` Pavel Begunkov
  0 siblings, 1 reply; 2+ messages in thread
From: Hao Xu @ 2021-02-19 17:58 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Pavel Begunkov, Joseph Qi

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(+)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-19 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-19 17:58 [PATCH] io_uring: don't submit sqes when ctx->refs is dying Hao Xu
2021-02-19 18:04 ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox