-
Notifications
You must be signed in to change notification settings - Fork 164
feat: add support for ReadMulti opcode (6.7+) #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -900,6 +900,47 @@ opcode! { | |
} | ||
} | ||
|
||
opcode! { | ||
/// Read multiple times from a file, equivalent to `pread(2)`. | ||
/// | ||
/// Parameter: | ||
/// buf_group: The id of the provided buffer pool to use for each received chunk. | ||
/// | ||
/// MSG_WAITALL should not be set in flags. | ||
/// | ||
/// The multishot version allows the application to issue a single read request, which | ||
/// repeatedly posts a CQE when data is available. Each CQE will take a buffer out of a | ||
/// provided buffer pool for receiving. The application should check the flags of each CQE, | ||
/// regardless of its result. If a posted CQE does not have the IORING_CQE_F_MORE flag set then | ||
/// the multishot read will be done and the application should issue a new request. | ||
/// | ||
/// Multishot read is available since kernel 6.7. | ||
/// Multishot read is suggested since kernel 6.7.2, see: https://github.com/axboe/liburing/issues/1041 | ||
|
||
pub struct ReadMulti { | ||
fd: { impl sealed::UseFixed }, | ||
buf_group: { u16 }, | ||
;; | ||
ioprio: u16 = 0, | ||
flags: i32 = 0 | ||
} | ||
|
||
pub const CODE = sys::IORING_OP_READ_MULTISHOT; | ||
|
||
pub fn build(self) -> Entry { | ||
let ReadMulti { fd, buf_group, flags, ioprio } = self; | ||
|
||
let mut sqe = sqe_zeroed(); | ||
sqe.opcode = Self::CODE; | ||
assign_fd!(sqe.fd = fd); | ||
sqe.__bindgen_anon_3.msg_flags = flags as _; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above - the API is similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the kernel doesn't read |
||
sqe.__bindgen_anon_4.buf_group = buf_group; | ||
sqe.flags |= crate::squeue::Flags::BUFFER_SELECT.bits(); | ||
sqe.ioprio = ioprio; | ||
Entry(sqe) | ||
} | ||
} | ||
|
||
opcode! { | ||
/// Issue the equivalent of a `pread(2)` or `pwrite(2)` system call | ||
/// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to provide a way to specify len and offset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it should act the exact same as
RecvMulti
- you cannot specify anything other then which buffer-group to use, fd and flags (which I think none are not used at kernel-side right now)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not true, ReadMulti is more similar to Read than to RecvMulti.
see https://github.com/torvalds/linux/blob/v6.13/io_uring/rw.c#L366 and https://github.com/axboe/liburing/blob/liburing-2.9/src/include/liburing.h#L801