The buffer ids are bid to bid + nr - 1, all at most 65535 (OSError: E2BIG or OSError: EINVAL otherwise). A request uses the group with IOSQE_BUFFER_SELECT and io_uring_sqe_set_buf_group (reads and socket receives only, OSError: EINVAL otherwise; a vectored one with a single iov); its completion has IORING_CQE_F_BUFFER and the id in cqe.flags >> IORING_CQE_BUFFER_SHIFT.
A consumed buffer is forgotten by the kernel: provide it again to reuse it.
The kernel uses the buffers until they are consumed or removed, so the ring holds addr (locked: no resize) until its exit; giving a part of an area it already holds again takes nothing more.
io_uring_prep_poll_add that stays armed: it posts a completion on every event, until removed.
Note
Linux 5.13+.
Each completion has IORING_CQE_F_MORE in cqe.flags. One without it is the last (an error, a remove or a cancel: cqe.res raises OSError: ECANCELED): submit a new poll to keep watching fd.
The first completion is level triggered, the following ones edge triggered: consume the event (read all the data) before the next one, or expect spurious completions.
Removes the poll request with user_data (the value you gave it).
Note
io_uring_prep_cancel64 that matches poll requests only. cqe.res: 0 when removed (the poll's own cqe.res raises OSError: ECANCELED); OSError: ENOENT when not found (it completed already), OSError: EALREADY when it is completing, too late to remove.
Only the low 16 bits of the events (POLLIN, POLLOUT, ...) can change; EPOLLONESHOT, EPOLLEXCLUSIVE and EPOLLET can not: remove the poll and arm a new one.
cqe.res: 0 when done; OSError: ENOENT when not found (it completed already), OSError: EALREADY when it is completing, too late, OSError: ECANCELED when re-arming with poll_mask failed: the poll ends, its own completion says why.
Completes after the time ts (Timespec, held until the completion) or after count other completions, whichever comes first; flags (default 0) are IORING_TIMEOUT_*.
IORING_TIMEOUT_MULTISHOT count completions, 0: until removed; IORING_CQE_F_MORE set; Linux 6.4+.
Note
Linux 5.4+.
count0: a plain timer, other completions are not counted. cqe.res: 0 when count completions came first; OSError: ETIME when the time passed, OSError: ECANCELED when removed (io_uring_prep_timeout_remove, a cancel).
Removes the timeout request with user_data (the value you gave it); flags (default 0): the kernel accepts none yet.
Note
Linux 5.5+.
cqe.res: 0 when removed (the timeout's own cqe.res raises OSError: ECANCELED); OSError: ENOENT when not found (it fired already), OSError: EALREADY when it is firing, too late to remove.
Updates the time of the timeout request with user_data (the value you gave it) to ts (held until the completion); flags (default 0): IORING_TIMEOUT_ABS for a point in time, the only one accepted.
Note
Linux 5.11+.
cqe.res: 0 when updated; OSError: ENOENT when not found (it fired already), OSError: EALREADY when it is firing, too late to update.
cqe.res: 0 when cancelled (with IORING_ASYNC_CANCEL_ALL / _ANY: how many); OSError: ENOENT when none was found (it completed already), OSError: EALREADY when it is running and past cancelling: wait for its own completion. The cancelled request's cqe.res raises OSError: ECANCELED (OSError: EINTR if it was running); either completion may come first.
Interruptible requests (sockets, poll, timeouts) cancel; disk I/O that has started does not.
Cancels the in-flight request whose object is user_data (io_uring_sqe_set_data: its user_data is the object's address); flags (default 0) are IORING_ASYNC_CANCEL_*. io_uring_prep_cancel64 takes an intuser_data and lists the flags and results.
cqe.res: 0 when cancelled (with IORING_ASYNC_CANCEL_ALL / _ANY: how many); OSError: ENOENT when none was found, OSError: EALREADY when past cancelling: wait for its own completion. The cancelled request's cqe.res raises OSError: ECANCELED (OSError: EINTR if it was running); either completion may come first.
cqe.res: 0 when cancelled (with IORING_ASYNC_CANCEL_ALL: how many); OSError: ENOENT when none was found, OSError: EALREADY when past cancelling: wait for its own completion. Each cancelled request's cqe.res raises OSError: ECANCELED (OSError: EINTR if it was running); the completions come in no fixed order.
Must directly follow the request it limits, and applies to that one only: to limit a whole chain, link it after the chain's last request. A chain of only a link timeout is invalid.
cqe.res raises OSError: ETIME when it expired: the linked request's cqe.res raises OSError: ECANCELED (OSError: EINTR if it was running), and so does the rest of its chain; OSError: ECANCELED when the linked request completed first; OSError: ENOENT when it was gone as the timer expired.
Waits for events of the epoll fd, into events (held until the completion); maxevents is 1 to the size of EpollEvent(no=...), else ValueError. events must be one made with no=, not a single item.
Note
Linux 6.15+.
cqe.res is the number of events filled in, like epoll_wait(2); its errors raise OSError.
For event loops that still have epoll users: they can wait through the ring instead of adding the ring's fd to the epoll set.
epoll_ctl(2) on the epoll epfd: op (EPOLL_CTL_ADD, EPOLL_CTL_MOD, EPOLL_CTL_DEL) for fd with the event ev (held until the completion; ignored by EPOLL_CTL_DEL).
Note
Linux 5.6+.
cqe.res is 0; the errors of epoll_ctl(2) raise OSError.
data is the target's cqe.user_data, below 2**63 (ValueError): Liburing sends it with bit 63 set, which tells the target ring the completion is a message, not one of its own requests.
The kernel may set further bits in the target's cqe.flags.
data is the target's cqe.user_data, below 2**63 (ValueError): Liburing sends it with bit 63 set, which tells the target ring the completion is a message, not one of its own requests.
Linux 5.18+. Any ring you have access to is a target, this one included: a wake-up for whoever waits on it, or a 32 + 64 bit message (len, data).
This ring's cqe.res: 0 when posted; OSError: EBADFD when fd is not a ring or a disabled one, OSError: EOVERFLOW when the target's completion queue is full and overflowing.
Sends the registered file source_fd of this ring to the slot target_fd of the ring fd; the target ring gets a completion with user_datadata; flags (default 0) are IORING_MSG_RING_*.
Note
data is the target's cqe.user_data, below 2**63 (ValueError): Liburing sends it with bit 63 set, which tells the target ring the completion is a message, not one of its own requests.
Linux 6.0+. The target must be another ring (OSError: EINVAL for this one).
This ring's cqe.res: 0 when sent; OSError: EBADFD when fd is not a ring or a disabled one, OSError: ENFILE when the target's table is full, OSError: EOVERFLOW when the target's completion queue is full and overflowing.
data is the target's cqe.user_data, below 2**63 (ValueError): Liburing sends it with bit 63 set, which tells the target ring the completion is a message, not one of its own requests.
Linux 6.0+. This ring's cqe.res: 0 when sent; OSError: ENFILE when the target's table has no free slot (the other errors as in io_uring_prep_msg_ring_fd).
Sends the file-specific command cmd_op to fd (IORING_OP_URING_CMD, an async ioctl(2)).
Note
Linux 5.19+.
Only cmd_op and fd are set (the reserved fields zeroed); a command's own operands live in the entry's command bytes, which SQE does not expose. cqe.res is whatever the driver returns.
Only cmd_op and fd are set (the reserved fields zeroed); the 80 command bytes, which SQE does not expose, carry the command's own operands. cqe.res is whatever the driver returns.
Waits for a child process's state change, like os.waitid: the kernel fills infop at the completion; idtype (os.P_PID, os.P_PGID, os.P_ALL, ...) and id pick the children, options (os.WEXITED, ...) the changes; flags (default 0) has no values yet.
Wakes up to val waiters of futex whose wait mask matches mask; the number woken is returned in cqe.res. futex_flags are FUTEX2_* (default 0); futex is held until the completion.
Note
Linux 6.7+.
Like FUTEX_WAKE_BITSET: a waiter is woken when its mask and this one share a bit; FUTEX_BITSET_MATCH_ANY wakes any waiter. flags (default 0) has no values yet.
cqe.res: 0 when woken; OSError: EAGAIN when the value was not val, OSError: ECANCELED when cancelled. No timeout parameter: link an io_uring_prep_link_timeout after it.
Waits on several futexes at once: Futex made with a vector (else ValueError), held until the completion; flags (default 0) has no values yet.
Note
Linux 6.7+.
Each entry of the vector carries its own value and mask (futex_waitv(2)); at most FUTEX_WAITV_MAX (128) entries.
cqe.res is the index of the entry that was woken; OSError: ECANCELED when cancelled. No timeout parameter: link an io_uring_prep_link_timeout after it.