Skip to content

fs: add unstable io_uring uring_cmd support for File#7901

Open
SidongYang wants to merge 1 commit intotokio-rs:masterfrom
SidongYang:sidong/uring-cmd
Open

fs: add unstable io_uring uring_cmd support for File#7901
SidongYang wants to merge 1 commit intotokio-rs:masterfrom
SidongYang:sidong/uring-cmd

Conversation

@SidongYang
Copy link
Copy Markdown

Implements File::uring_cmd using UringCmd16 with io_uring runtime/cancellation integration and tests.

Refs #7897

@ADD-SP ADD-SP added A-tokio Area: The main tokio crate M-fs Module: tokio/fs M-runtime Module: tokio/runtime T-io-uring Topic: Linux io_uring labels Feb 12, 2026
Comment thread tokio/src/fs/file.rs
Comment thread tokio/tests/fs_uring.rs Outdated
Comment thread tokio/src/fs/file.rs
Comment thread tokio/src/fs/file.rs Outdated
Comment thread tokio/src/fs/file.rs Outdated
Comment thread tokio/src/fs/file.rs Outdated
@SidongYang
Copy link
Copy Markdown
Author

@martin-g Thanks for the review! I've updated the PR and squashed the changes into a single commit.

Here are the updates based on your feedback and some self-review:

  • unsafe & Safety docs: Marked uring_cmd as unsafe and added a # Safety section, as it allows arbitrary payload submission which can lead to use-after-free or memory corruption.
  • Realistic Example: Added an # Examples section in the docs that demonstrates how to safely pack a #[repr(C)] struct into the 16-byte payload.
  • API Documentation: Explicitly added Builder::enable_io to the required features in the docstring.
  • Unit Test Improvements: Extracted the dummy payload into local variables, wrapped the call in unsafe, and added a specific assertion to check for std::io::ErrorKind::Unsupported (since a standard file without a uring_cmd implementation returns -EOPNOTSUPP).
  • Locking Refactor (Self-review): Simplified the inner locking logic (complete_inflight) to be more idiomatic and match the style used in try_clone().
  • Concurrency: Regarding your question about whether it's OK to start other File ops while uring_cmd16() is still executing: Yes, it is! The operation creates an independent OwnedFd via self.std.try_clone(), so it won't block the inner state of the Tokio file descriptor for subsequent operations.

Let me know if there's anything else that needs adjusting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate M-fs Module: tokio/fs M-runtime Module: tokio/runtime T-io-uring Topic: Linux io_uring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants