eve.sys.linux.uring
Syscall wrappers and submission helpers for Linux io_uring.
This module builds on top of core.sys.linux.io_uring, which provides the structure definitions and constants from the kernel ABI. This module adds:
- The three io_uring syscalls: io_uring_setup,
- SQE preparation helpers for common operations
There is no compile-time version check. Call io_uring_setup and handle ENOSYS to detect kernel support at runtime.
See Also
Types 3
Result of probing io_uring feature support.
Call probeIoUringFeatures to obtain an instance, then query individual feature support. All fields default to false when io_uring is unavailable or probing fails.
bool ioUringAvailablebool sqpollbool nativeReadbool nativeWritebool nativeClosebool splicebool sendbool recvbool readFixedbool writeFixedbool registeredBuffersbool registeredFilesuint kernelVersionbool supportsOpcode(ubyte opcode) const @safe pure nothrow @nogcCheck whether a specific io_uring opcode is supported.Manage registered fixed buffers for zero-copy io_uring I/O.
Registered buffers allow the kernel to perform I/O directly to/from application memory without extra copies. Use io_uring_prep_read_fixed and io_uring_prep_write_fixed to submit operations against registered buffer slots.
Call register to register buffers with the ring, and dispose to release the kernel's references.
Example:
auto table = IoUringBufferTable.create(ringFd);
scope (exit) table.dispose();
ubyte[4096] buf1;
ubyte[4096] buf2;
iovec[2] iov = [
iovec(cast(void*)buf1.ptr, buf1.length),
iovec(cast(void*)buf2.ptr, buf2.length),
];
assert(table.register(iov[]));
// Now use io_uring_prep_read_fixed(sqe, fd, buf1.ptr, 4096, 0, 0, userData);
// buf_index = 0 ^int _ringFduint _countIoUringBufferTable create(int ringFd) static pure @safe nothrow @nogcCreate a buffer table for a given io_uring instance.bool register(scope const(iovec)[] buffers) @trusted nothrow @nogcRegister an array of buffers with the io_uring instance.Manage registered fixed file descriptors for io_uring.
Registered files allow the kernel to avoid looking up file descriptors on each operation, reducing overhead in high-concurrency scenarios. Use io_uring_sqe_set_fixed_file to mark an SQE as using a registered file index.
int _ringFduint _countIoUringFileTable create(int ringFd) static pure @safe nothrow @nogcCreate a file table for a given io_uring instance.bool register(scope const(int)[] files) @trusted nothrow @nogcRegister an array of file descriptors with the io_uring instance.bool updateFile(uint index, int fd) @trusted nothrow @nogcUpdate a single file descriptor in the registered table.Functions 19
int io_uring_enter(int fd, uint to_submit, uint min_complete, uint flags, const sigset_t * sig = null) @systemInitiate and/or complete I/O using the io_uring instance.int io_uring_register(int fd, uint opcode, const void * arg, uint nr_args) @systemRegister files or buffers with the io_uring instance.void io_uring_prep_nop(io_uring_sqe * sqe, ulong user_data) pure @safePrepare an SQE for a NOP operation.void io_uring_prep_poll_add(io_uring_sqe * sqe, int fd, ushort poll_mask, ulong user_data) pure @safePrepare an SQE for a POLL_ADD operation.void io_uring_prep_poll_remove(io_uring_sqe * sqe, ulong target_user_data, ulong user_data) pure @safePrepare an SQE for a POLL_REMOVE operation.void io_uring_prep_read(io_uring_sqe * sqe, int fd, void * buf, uint len, ulong offset, ulong user_data) pure @systemPrepare an SQE for a READ operation.void io_uring_prep_write(io_uring_sqe * sqe, int fd, const void * buf, uint len, ulong offset, ulong user_data) pure @systemPrepare an SQE for a WRITE operation.void io_uring_prep_close(io_uring_sqe * sqe, int fd, ulong user_data) pure @safePrepare an SQE for a CLOSE operation.void io_uring_sqe_set_flags(io_uring_sqe * sqe, ubyte flags) pure @safeSet SQE flags on an existing SQE.void io_uring_prep_splice(io_uring_sqe * sqe, int fd_in, ulong off_in,
int fd_out, ulong off_out, uint len, uint flags,
ulong user_data) pure @systemPrepare an SQE for a SPLICE operation.void io_uring_prep_send(io_uring_sqe * sqe, int fd, const void * buf,
uint len, uint flags, ulong user_data) pure @systemPrepare an SQE for a SEND operation.void io_uring_prep_recv(io_uring_sqe * sqe, int fd, void * buf, uint len,
uint flags, ulong user_data) pure @systemPrepare an SQE for a RECV operation.void io_uring_prep_read_fixed(io_uring_sqe * sqe, int fd, void * buf,
uint len, ulong offset, ushort buf_index,
ulong user_data) pure @systemPrepare an SQE for a READ_FIXED operation (zero-copy using registered buffer).void io_uring_prep_write_fixed(io_uring_sqe * sqe, int fd, const void * buf,
uint len, ulong offset, ushort buf_index,
ulong user_data) pure @systemPrepare an SQE for a WRITE_FIXED operation (zero-copy using registered buffer).void io_uring_sqe_set_fixed_file(io_uring_sqe * sqe) pure @safe nothrow @nogcSet the fixed-file flag on an SQE.IoUringFeatures probeIoUringFeatures() @trusted nothrowProbe the running kernel for io_uring feature support.