Skip to content

Commit 94c37f5

Browse files
feat: add support for ReadMulti opcode (6.7+)
1 parent 3373e51 commit 94c37f5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/opcode.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,47 @@ opcode! {
900900
}
901901
}
902902

903+
opcode! {
904+
/// Read multiple times from a file, equivalent to `pread(2)`.
905+
///
906+
/// Parameter:
907+
/// buf_group: The id of the provided buffer pool to use for each received chunk.
908+
///
909+
/// MSG_WAITALL should not be set in flags.
910+
///
911+
/// The multishot version allows the application to issue a single read request, which
912+
/// repeatedly posts a CQE when data is available. Each CQE will take a buffer out of a
913+
/// provided buffer pool for receiving. The application should check the flags of each CQE,
914+
/// regardless of its result. If a posted CQE does not have the IORING_CQE_F_MORE flag set then
915+
/// the multishot read will be done and the application should issue a new request.
916+
///
917+
/// Multishot read is available since kernel 6.7.
918+
/// Multishot read is suggested since kernel 6.7.2, see: https://github.com/axboe/liburing/issues/1041
919+
920+
pub struct ReadMulti {
921+
fd: { impl sealed::UseFixed },
922+
buf_group: { u16 },
923+
;;
924+
ioprio: u16 = 0,
925+
flags: i32 = 0
926+
}
927+
928+
pub const CODE = sys::IORING_OP_READ_MULTISHOT;
929+
930+
pub fn build(self) -> Entry {
931+
let ReadMulti { fd, buf_group, flags, ioprio } = self;
932+
933+
let mut sqe = sqe_zeroed();
934+
sqe.opcode = Self::CODE;
935+
assign_fd!(sqe.fd = fd);
936+
sqe.__bindgen_anon_3.msg_flags = flags as _;
937+
sqe.__bindgen_anon_4.buf_group = buf_group;
938+
sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits();
939+
sqe.ioprio = ioprio;
940+
Entry(sqe)
941+
}
942+
}
943+
903944
opcode! {
904945
/// Issue the equivalent of a `pread(2)` or `pwrite(2)` system call
905946
///

0 commit comments

Comments
 (0)