Skip to content

Commit 7c504e6

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't wait when under-submitting
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e781573 commit 7c504e6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/io_uring.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5135,6 +5135,9 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
51355135
submitted = io_submit_sqes(ctx, to_submit, f.file, fd,
51365136
&cur_mm, false);
51375137
mutex_unlock(&ctx->uring_lock);
5138+
5139+
if (submitted != to_submit)
5140+
goto out;
51385141
}
51395142
if (flags & IORING_ENTER_GETEVENTS) {
51405143
unsigned nr_events = 0;
@@ -5148,6 +5151,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
51485151
}
51495152
}
51505153

5154+
out:
51515155
percpu_ref_put(&ctx->refs);
51525156
out_fput:
51535157
fdput(f);

0 commit comments

Comments
 (0)