public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: allow async accept on O_NONBLOCK sockets
@ 2022-03-24 14:34 Dylan Yudaken
  2022-03-24 14:42 ` Jens Axboe
  2022-03-24 18:09 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Dylan Yudaken @ 2022-03-24 14:34 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring; +Cc: kernel-team, Dylan Yudaken

Do not set REQ_F_NOWAIT if the socket is non blocking. When enabled this
causes the accept to immediately post a CQE with EAGAIN, which means you
cannot perform an accept SQE on a NONBLOCK socket asynchronously.

By removing the flag if there is no pending accept then poll is armed as
usual and when a connection comes in the CQE is posted.

note: If multiple accepts are queued up, then when a single connection
comes in they all complete, one with the connection, and the remaining
with EAGAIN. This could be improved in the future but will require a lot
of io_uring changes.

Signed-off-by: Dylan Yudaken <[email protected]>
---
 fs/io_uring.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 88556e654c5a..a2a71e76e0da 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5603,9 +5603,6 @@ static int io_accept(struct io_kiocb *req, unsigned int issue_flags)
 	struct file *file;
 	int ret, fd;
 
-	if (req->file->f_flags & O_NONBLOCK)
-		req->flags |= REQ_F_NOWAIT;
-
 	if (!fixed) {
 		fd = __get_unused_fd_flags(accept->flags, accept->nofile);
 		if (unlikely(fd < 0))

base-commit: 8a3e8ee56417f5e0e66580d93941ed9d6f4c8274
-- 
2.30.2


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

end of thread, other threads:[~2022-03-24 18:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-24 14:34 [PATCH] io_uring: allow async accept on O_NONBLOCK sockets Dylan Yudaken
2022-03-24 14:42 ` Jens Axboe
2022-03-24 14:46   ` Jens Axboe
2022-03-24 14:52     ` Dylan Yudaken
2022-03-24 18:09 ` Jens Axboe

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