Skip to content

Add io-uring support on tokio::fs::metadata and tokio::fs::symlink_metadata #8211

@asder8215

Description

@asder8215

This issue is mostly for future reference.

Is your feature request related to a problem? Please describe.
Currently, tokio returns Rust std library Metadata for its filesystem methods (e.g. tokio::fs::metadata and tokio::fs::symlink_metadata). This makes it hard to enable io-uring on those methods because there's no supported methods in the Rust's Metadata struct to construct a Metadata given a statx entry/populated statx buffer.

However, in the future, when Metadata::from_statx (or an equivalent method) is merged in and stabilized, it should unblock supporting io-uring on tokio::fs::metadata and tokio::fs::symlink_metadata (and possibly many other tokio filesystem operations).

Describe the solution you'd like
Use Metadata::from_statx to construct Rust's Metadata type within Statx operation in tokio::fs. As a result, we then use the Rust std library Metadata methods to assist with supporting io-uring in many tokio filesystem operations.

Describe alternatives you've considered
For certain methods that rely on one of Metadata's accessor methods to to have io-uring support on that method, we can implement it an internal Metadata struct. This is what's done for tokio::fs::read, which required Metadata::len function. The only con in doing this though is that certain accessor methods might create tech debt or churn (e.g. Metadata::modified, Metadata::accessed, Metadata::created return a Result<SystemTime>, so we'd also need to implement a SystemTime wrapper). However, Metadata::is_dir, Metadata::is_file, and Metadata::is_symlink should be trivial to support. There doesn't seem to be an alternative to support io-uring on tokio::fs::metadata and tokio::fs::symlink_metadata directly (unless we create a tokio::fs::metadata2, but as discussed in the ACP made by Alice for Metadata::from_statx, this function wasn't desired).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-fsModule: tokio/fsT-io-uringTopic: Linux io_uring

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions