Skip to content

Commit b184b83

Browse files
authored
io_uring cleanups and updates for new flags in Linux 6.2 (#553)
- Rename `IoringSetupFlags`'s `SETUP_SINGLE_ISSUER` and `SETUP_DEFER_TASKRUN` to `SINGLE_ISSUER` and `DEFER_TASKRUN`, because the `SETUP_` is omitted in the other `IoringSetupFlags` flags. - Split `IoringRecvsendFlags` into `IoringSendFlags` and `IoringRecvFlags`, and add the new `ZC_REPORT_USAGE` send flag. - Add a public re-export of the new `IORING_NOTIF_USAGE_ZC_COPIED` flag. In theory we could convert `cqe.res` into a union and use a bitflags type for `IORING_NOTIF_USAGE_ZC_COPIED`, though my rough guess is that that's not worth it until it gets more complex.
1 parent 352cc4e commit b184b83

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

src/io_uring.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,10 @@ bitflags::bitflags! {
439439
const TASKRUN_FLAG = sys::IORING_SETUP_TASKRUN_FLAG;
440440

441441
/// `IORING_SETUP_SINGLE_ISSUER`
442-
const SETUP_SINGLE_ISSUER = sys::IORING_SETUP_SINGLE_ISSUER;
442+
const SINGLE_ISSUER = sys::IORING_SETUP_SINGLE_ISSUER;
443443

444444
/// `IORING_SETUP_DEFER_TASKRUN`
445-
const SETUP_DEFER_TASKRUN = sys::IORING_SETUP_DEFER_TASKRUN;
445+
const DEFER_TASKRUN = sys::IORING_SETUP_DEFER_TASKRUN;
446446
}
447447
}
448448

@@ -673,16 +673,39 @@ bitflags::bitflags! {
673673
}
674674

675675
bitflags::bitflags! {
676-
/// send/sendmsg & recv/recvmsg flags (`sqe.ioprio`)
676+
/// send/sendmsg flags (`sqe.ioprio`)
677677
#[derive(Default)]
678-
pub struct IoringRecvsendFlags: u16 {
678+
pub struct IoringSendFlags: u16 {
679+
/// `IORING_RECVSEND_POLL_FIRST`.
680+
///
681+
/// See also [`IoringRecvFlags::POLL_FIRST`].
682+
const POLL_FIRST = sys::IORING_RECVSEND_POLL_FIRST as _;
683+
684+
/// `IORING_RECVSEND_FIXED_BUF`
685+
///
686+
/// See also [`IoringRecvFlags::FIXED_BUF`].
687+
const FIXED_BUF = sys::IORING_RECVSEND_FIXED_BUF as _;
688+
689+
/// `IORING_SEND_ZC_REPORT_USAGE`
690+
const ZC_REPORT_USAGE = sys::IORING_SEND_ZC_REPORT_USAGE as _;
691+
}
692+
}
693+
694+
bitflags::bitflags! {
695+
/// recv/recvmsg flags (`sqe.ioprio`)
696+
#[derive(Default)]
697+
pub struct IoringRecvFlags: u16 {
679698
/// `IORING_RECVSEND_POLL_FIRST`
699+
///
700+
/// See also [`IoringSendFlags::POLL_FIRST`].
680701
const POLL_FIRST = sys::IORING_RECVSEND_POLL_FIRST as _;
681702

682703
/// `IORING_RECV_MULTISHOT`
683704
const MULTISHOT = sys::IORING_RECV_MULTISHOT as _;
684705

685706
/// `IORING_RECVSEND_FIXED_BUF`
707+
///
708+
/// See also [`IoringSendFlags::FIXED_BUF`].
686709
const FIXED_BUF = sys::IORING_RECVSEND_FIXED_BUF as _;
687710
}
688711
}
@@ -742,6 +765,9 @@ pub const fn io_uring_register_files_skip() -> BorrowedFd<'static> {
742765
unsafe { BorrowedFd::<'static>::borrow_raw(files_skip) }
743766
}
744767

768+
/// `IORING_NOTIF_USAGE_ZC_COPIED`
769+
pub const IORING_NOTIF_USAGE_ZC_COPIED: i32 = sys::IORING_NOTIF_USAGE_ZC_COPIED as _;
770+
745771
/// A pointer in the io_uring API.
746772
///
747773
/// `io_uring`'s native API represents pointers as `u64` values. In order to
@@ -878,7 +904,8 @@ pub struct io_uring_sqe {
878904
#[repr(C)]
879905
#[derive(Copy, Clone)]
880906
pub union ioprio_union {
881-
pub recvsend_flags: IoringRecvsendFlags,
907+
pub recv_flags: IoringRecvFlags,
908+
pub send_flags: IoringSendFlags,
882909
pub accept_flags: IoringAcceptFlags,
883910
pub ioprio: u16,
884911
}

0 commit comments

Comments
 (0)