public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring/rw: forbid multishot async reads
@ 2025-02-17 13:37 Pavel Begunkov
  2025-02-17 13:49 ` Pavel Begunkov
  2025-02-17 13:58 ` Jens Axboe
  0 siblings, 2 replies; 13+ messages in thread
From: Pavel Begunkov @ 2025-02-17 13:37 UTC (permalink / raw)
  To: io-uring; +Cc: asml.silence

At the moment we can't sanely handle queuing an async request from a
multishot context, so disable them. It shouldn't matter as pollable
files / socekts don't normally do async.

Cc: [email protected]
Fixes: fc68fcda04910 ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/rw.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index 96b42c331267..4bda46c5eb20 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -878,7 +878,15 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)
 	if (unlikely(ret))
 		return ret;
 
-	ret = io_iter_do_read(rw, &io->iter);
+	if (unlikely(req->opcode == IORING_OP_READ_MULTISHOT)) {
+		void *cb_copy = rw->kiocb.ki_complete;
+
+		rw->kiocb.ki_complete = NULL;
+		ret = io_iter_do_read(rw, &io->iter);
+		rw->kiocb.ki_complete = cb_copy;
+	} else {
+		ret = io_iter_do_read(rw, &io->iter);
+	}
 
 	/*
 	 * Some file systems like to return -EOPNOTSUPP for an IOCB_NOWAIT
@@ -902,7 +910,8 @@ static int __io_read(struct io_kiocb *req, unsigned int issue_flags)
 	} else if (ret == -EIOCBQUEUED) {
 		return IOU_ISSUE_SKIP_COMPLETE;
 	} else if (ret == req->cqe.res || ret <= 0 || !force_nonblock ||
-		   (req->flags & REQ_F_NOWAIT) || !need_complete_io(req)) {
+		   (req->flags & REQ_F_NOWAIT) || !need_complete_io(req) ||
+		   (issue_flags & IO_URING_F_MULTISHOT)) {
 		/* read all, failed, already did sync or don't want to retry */
 		goto done;
 	}
-- 
2.48.1


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

end of thread, other threads:[~2025-02-19  1:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 13:37 [PATCH 1/1] io_uring/rw: forbid multishot async reads Pavel Begunkov
2025-02-17 13:49 ` Pavel Begunkov
2025-02-17 13:58 ` Jens Axboe
2025-02-17 14:03   ` Pavel Begunkov
2025-02-17 14:04     ` Pavel Begunkov
2025-02-17 14:08   ` Pavel Begunkov
2025-02-17 15:37     ` Jens Axboe
2025-02-19  1:35       ` Pavel Begunkov
2025-02-17 14:12   ` Pavel Begunkov
2025-02-17 15:06     ` Jens Axboe
2025-02-17 15:33       ` Pavel Begunkov
2025-02-17 15:57         ` Jens Axboe
2025-02-17 17:51           ` Pavel Begunkov

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