io_uring/rw: add support for IORING_OP_READ_MULTISHOT io_uring-mshot-read
authorJens Axboe <axboe@kernel.dk>
Mon, 11 Sep 2023 19:35:42 +0000 (13:35 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Sep 2023 19:11:15 +0000 (13:11 -0600)
commitf5808a142646fc9650e581c5994dc9d809d827d0
treef99456b1b37f7c19945b8e4ba2f15923b3b2c33f
parent96fc4449c66b928e872b7421e0a81401342f9f28
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>
include/uapi/linux/io_uring.h
io_uring/opdef.c
io_uring/rw.c
io_uring/rw.h