summaryrefslogtreecommitdiff
path: root/io_uring/opdef.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-09-11 22:35:42 +0300
committerJens Axboe <axboe@kernel.dk>2023-09-21 21:02:30 +0300
commitfc68fcda049108478ee4704d8a3ad3e05cc72fd0 (patch)
tree628bbba215abe4381465f113adb4fe8959924933 /io_uring/opdef.c
parentd2d778fbf9964e4e5b8d7420eba8ec5ce938e794 (diff)
downloadlinux-fc68fcda049108478ee4704d8a3ad3e05cc72fd0.tar.xz
io_uring/rw: add support for IORING_OP_READ_MULTISHOT
This behaves like IORING_OP_READ, except: 1) It only supports pollable files (eg pipes, sockets, etc). Note that for sockets, you probably want to use recv/recvmsg with multishot instead. 2) It supports multishot mode, meaning it will repeatedly trigger a read and fill a buffer when data is available. This allows similar use to recv/recvmsg but on non-sockets, where a single request will repeatedly post a CQE whenever data is read from it. 3) Because of #2, it must be used with provided buffers. This is uniformly true across any request type that supports multishot and transfers data, with the reason being that it's obviously not possible to pass in a single buffer for the data, as multiple reads may very well trigger before an application has a chance to process previous CQEs and the data passed from them. Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/opdef.c')
-rw-r--r--io_uring/opdef.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index f40904065500..a3fb1f9b3998 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -430,9 +430,17 @@ const struct io_issue_def io_issue_defs[] = {
.prep = io_eopnotsupp_prep,
#endif
},
+ [IORING_OP_READ_MULTISHOT] = {
+ .needs_file = 1,
+ .unbound_nonreg_file = 1,
+ .pollin = 1,
+ .buffer_select = 1,
+ .audit_skip = 1,
+ .prep = io_read_mshot_prep,
+ .issue = io_read_mshot,
+ },
};
-
const struct io_cold_def io_cold_defs[] = {
[IORING_OP_NOP] = {
.name = "NOP",
@@ -650,6 +658,9 @@ const struct io_cold_def io_cold_defs[] = {
.fail = io_sendrecv_fail,
#endif
},
+ [IORING_OP_READ_MULTISHOT] = {
+ .name = "READ_MULTISHOT",
+ },
};
const char *io_uring_get_opcode(u8 opcode)