Skip to content

Conversation

@rektide
Copy link

@rektide rektide commented Jan 29, 2026

Resolves #380.

Expose the write_stream field from io_uring_sqe for IORING_OP_WRITE. Uses Option<u8> to only set the field when explicitly configured.

caveats

This PR has big caveats, on an otherwise very simple change:

  1. A new write_stream feature is used to enable this capability. This allows kernels <6.16 to still compile, while newer kernel users can enable write_stream to get the feature.
  2. When write_stream feature isn't on we got a dead_code warning, for code inside the opcode! macro. Added an allow(dead_code) there.

Expose the write_stream field from io_uring_sqe for IORING_OP_WRITE.
Uses Option<u8> to only set the field when explicitly configured,
avoiding potential issues on older kernels that don't support this feature.
Make write_stream support optional via cargo feature.
Only compiles write_stream field and setter when feature is enabled,
ensuring compatibility with older kernel versions.
Use cfg_attr to apply allow(dead_code) annotation only when write_stream
feature is disabled. This is more targeted than module-level suppression.
ioprio: u16 = 0,
rw_flags: i32 = 0
rw_flags: i32 = 0,
#[cfg_attr(not(feature = "write_stream"), allow(dead_code))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this need a feature.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more than happy to remove the feature!!

I want to call this out again; I personally think not supporting old kernels is fine, but I expect some people will be kind of unhappy:

A new write_stream feature is used to enable this capability. This allows kernels <6.16 to still compile, while newer kernel users can enable write_stream to get the feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work correctly on older kernels as long as the user doesn't set the flag.

We don't use a feature for every opcode flag.

src/opcode.rs Outdated
rw_flags: i32 = 0
rw_flags: i32 = 0,
#[cfg_attr(not(feature = "write_stream"), allow(dead_code))]
write_stream: Option<u8> = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Option required? can it be u8?

src/opcode.rs Outdated
sqe.__bindgen_anon_3.rw_flags = rw_flags as _;
#[cfg(feature = "write_stream")]
if let Some(stream) = write_stream {
sqe.__bindgen_anon_5.__bindgen_anon_2.write_stream = stream;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we had a test.

Simplify the write_stream API by changing from Option<u8> to a plain
u8 with default value 0. When write_stream is 0, it is not set on the
SQE. This removes the need for conditional compilation in the struct
destructuring and simplifies the code.
Add a test for the write_stream feature to io-uring-test. The test verifies
that write_stream=1 works correctly by performing a write and read operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: write_stream support for Write

2 participants