Skip to content

Commit 2a975d4

Browse files
committed
io_uring/rw: don't allow multishot reads without NOWAIT support
Supporting multishot reads requires support for NOWAIT, as the alternative would be always having io-wq execute the work item whenever the poll readiness triggered. Any fast file type will have NOWAIT support (eg it understands both O_NONBLOCK and IOCB_NOWAIT). If the given file type does not, then simply resort to single shot execution. Cc: [email protected] Fixes: fc68fcd ("io_uring/rw: add support for IORING_OP_READ_MULTISHOT") Signed-off-by: Jens Axboe <[email protected]>
1 parent 39cd87c commit 2a975d4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

io_uring/rw.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,13 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
936936

937937
ret = __io_read(req, issue_flags);
938938

939+
/*
940+
* If the file doesn't support proper NOWAIT, then disable multishot
941+
* and stay in single shot mode.
942+
*/
943+
if (!io_file_supports_nowait(req))
944+
req->flags &= ~REQ_F_APOLL_MULTISHOT;
945+
939946
/*
940947
* If we get -EAGAIN, recycle our buffer and just let normal poll
941948
* handling arm it.
@@ -955,7 +962,7 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)
955962
/*
956963
* Any successful return value will keep the multishot read armed.
957964
*/
958-
if (ret > 0) {
965+
if (ret > 0 && req->flags & REQ_F_APOLL_MULTISHOT) {
959966
/*
960967
* Put our buffer and post a CQE. If we fail to post a CQE, then
961968
* jump to the termination path. This request is then done.

0 commit comments

Comments
 (0)