From: Pavel Begunkov Date: Wed, 18 Dec 2019 16:53:45 +0000 (+0300) Subject: io_uring: don't wait when under-submitting X-Git-Tag: v5.4.11~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=002352747481b28287e0285fe95b31206391460c;p=thirdparty%2Fkernel%2Fstable.git io_uring: don't wait when under-submitting [ Upstream commit 7c504e65206a4379ff38fe41d21b32b6c2c3e53e ] There is no reliable way to submit and wait in a single syscall, as io_submit_sqes() may under-consume sqes (in case of an early error). Then it will wait for not-yet-submitted requests, deadlocking the user in most cases. Don't wait/poll if can't submit all sqes Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- diff --git a/fs/io_uring.c b/fs/io_uring.c index a60c6315a348a..709671faaed62 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3721,6 +3721,9 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, mutex_lock(&ctx->uring_lock); submitted = io_ring_submit(ctx, to_submit); mutex_unlock(&ctx->uring_lock); + + if (submitted != to_submit) + goto out; } if (flags & IORING_ENTER_GETEVENTS) { unsigned nr_events = 0; @@ -3734,6 +3737,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, } } +out: percpu_ref_put(&ctx->refs); out_fput: fdput(f);