Add write_stream support to Write opcode#381
Add write_stream support to Write opcode#381rektide wants to merge 5 commits intotokio-rs:masterfrom
write_stream support to Write opcode#381Conversation
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.
eabcd3b to
8fadf0f
Compare
| ioprio: u16 = 0, | ||
| rw_flags: i32 = 0 | ||
| rw_flags: i32 = 0, | ||
| #[cfg_attr(not(feature = "write_stream"), allow(dead_code))] |
There was a problem hiding this comment.
I don't think this need a feature.
There was a problem hiding this comment.
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_streamfeature 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
It's this line here that had driven me to put in the feature flag. This won't be in the bindings unless the kernel is new enough: https://github.com/tokio-rs/io-uring/pull/381/changes#diff-a91a9fa57b926d127e913cad0a3ede5577f5aca0623066c07c2d2322221a6627R985
Rust won't compile that unless the bindings have it, right? I could definitely be missing something about how macros or how this works! But that seems like the root of the tension to me, that makes me think the feature flag is needed.
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.
Resolves #380.
Expose the write_stream field from
io_uring_sqeforIORING_OP_WRITE. UsesOption<u8>to only set the field when explicitly configured.caveats
This PR has big caveats, on an otherwise very simple change:
write_streamfeature is used to enable this capability. This allows kernels <6.16 to still compile, while newer kernel users can enablewrite_streamto get the feature.write_streamfeature isn't on we got adead_codewarning, for code inside theopcode!macro. Added anallow(dead_code)there.