Skip to content

Implemented io-uring Op<Statx> and applied to read_uring and fs::try_exists#8080

Open
asder8215 wants to merge 8 commits intotokio-rs:masterfrom
asder8215:io-uring-metadata
Open

Implemented io-uring Op<Statx> and applied to read_uring and fs::try_exists#8080
asder8215 wants to merge 8 commits intotokio-rs:masterfrom
asder8215:io-uring-metadata

Conversation

@asder8215
Copy link
Copy Markdown

Motivation

This builds up on vrtgs PR in their attempt of implementing Statx for io-uring and apply it to fs::try_exists. I used libc instead of linux-raw-sys for the Statx implementation, tried to preserve more of how the original code (prior to vrtgs' changes) looked in certain files. There are some inlining done for the metadata functions for Statx because I thought the body of the code in these functions were pretty small and didn't seem to involve generics (let me know if I should remove that). Some other review comments mentioned in review of vrtgs' PR is addressed such as safety comments, inlining for the try_exists_uring, avoiding using CString literals, etc.

To note, this is my first time contributing to Tokio, so let me know if there's anything that I'm doing incorrectly or if I missed something as per procedure here. Let me know if I should also squash some commits as well.

ccing @Daksh14 since I got to working on this PR per him sharing vrtgs' PR with me.

Comment thread tokio/src/io/uring/statx.rs Outdated
@mattiapitossi mattiapitossi added A-tokio Area: The main tokio crate T-io-uring Topic: Linux io_uring M-fs Module: tokio/fs labels Apr 21, 2026
@asder8215 asder8215 force-pushed the io-uring-metadata branch 3 times, most recently from ff8130b to dd9a2c3 Compare April 21, 2026 23:14
@asder8215
Copy link
Copy Markdown
Author

asder8215 commented Apr 22, 2026

Any reason why libc statx constants are not found for Linux 7.0?

image

Comment thread tokio/src/fs/read.rs Outdated
@Darksonn
Copy link
Copy Markdown
Member

Darksonn commented Apr 23, 2026

The compilation error is probably related to whether the build is using gnu or musl libc. See rust-lang/rust#154981 with similar issue.

Comment thread tokio/src/fs/try_exists.rs Outdated
// status as specified by man:
// https://man7.org/linux/man-pages/man2/statx.2.html
let statx_op = opcode::Statx::new(
types::Fd(file.as_raw_fd()),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does something guarantee that the File won't be dropped during the io uring call ?
It this happens the kernel will try to use a closed fd or worse - a reused fd.
IMO it should use an OwnedFd here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I might need a bit more clarity to understand what you're seeing.

Op::file_metadata doesn't own File, it takes a reference to it. Wouldn't Rust's borrow checker prohibit this file.as_raw_fd() from being invalid since &File has to live for as long as the caller's File?

Moreover, I would assume that the statx syscall populates the buffer with the file metadata once, and doesn't need access to the fd/path after invocation (correct me if I'm wrong though)?

Comment thread tokio/src/fs/open_options.rs Outdated
Comment thread tokio/src/io/uring/utils.rs
Comment thread tokio/src/io/uring/statx.rs Outdated
@asder8215 asder8215 force-pushed the io-uring-metadata branch from b474ac9 to 4e5c5d3 Compare May 4, 2026 20:49
@asder8215 asder8215 requested review from Daksh14 and martin-g May 4, 2026 20:49
…hutdown, stating multiple files, ELOOP, ENAMETOOLONG, EACCES
@asder8215 asder8215 force-pushed the io-uring-metadata branch from 4e5c5d3 to 0d20ca6 Compare May 4, 2026 20:57
…statx is supported on 1.25+ musl, and MSRV that uses 1.25 on all *-linux-musl platforms is 1.93
Comment thread tokio/tests/fs_uring_statx.rs Outdated
asder8215 added 2 commits May 5, 2026 14:42
…ble on Linux <5.1, changed stat permission denied test case to check raw os error code instead
…ble on Linux <5.1, removed stat permission denied test case since it doesn't work on Linux 4.19
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 T-io-uring Topic: Linux io_uring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants