Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for io_uring's direct descriptors #102

Merged
merged 55 commits into from
Apr 27, 2024
Merged

Add support for io_uring's direct descriptors #102

merged 55 commits into from
Apr 27, 2024

Conversation

Thomasdezeeuw
Copy link
Owner

@Thomasdezeeuw Thomasdezeeuw commented Feb 18, 2024

Direct descriptors are file descriptors that are private with io_uring
allowing it to avoid some of the avoid by avoiding syncing with the
shared fd tables.

This changes AsyncFd to accept a new generic parameter, D, which
requires to implement the Descriptor trait. This Descriptor traits
defines some behaviour on what to do when making submissions, mainly it
sets the IOSQE_FIXED_FILE flag for direct descriptors.

We still default to a regular file descriptor, AsyncFd (without setting
the generic parameter) still refer to a regular file descriptor (not
direct).

Closes #39
Closes #101

So we have a place to add stuff for fixed/direct fds.
Direct descriptors are file descriptors that are private with io_uring
allowing it to avoid some of the avoid by avoiding syncing with the
shared fd tables.

This changes AsyncFd to accept a new generic parameter, D, which
requires to implement the Descriptor trait. This Descriptor traits
defines some behaviour on what to do when making submissions, mainly it
sets the IOSQE_FIXED_FILE flag for direct descriptors.

We still default to a regular file descriptor, AsyncFd (without setting
the generic parameter) still refer to a regular file descriptor (not
direct).
Not fixed by rustfmt because it's a macro.
Now the op_future! macro can support both regular file descriptors and
direct descriptors.
Now the op_async_iter! macro can support both regular file descriptors
and direct descriptors.

Similar to the change made to op_future!
So it can be used to update the submission.
Creates a new direct file descriptor.
Returns a regular file descriptor for a direct descriptor.
I expected regular file descriptors to be more commonly used in the near
future, so this looks better in the docs.
To match AsyncFd::from_raw_fd.
So it doesn't conflict with new tests that use direct descriptor (for
which I want to use the _direct suffix).
Enables the setup required for direct descriptors.
Converts a regular file descriptor into a direct descriptor.
It requires Linux 6.8, which is unreleased at the time of writing.
Moves the creation methods to be the first impl blocks in the docs for
easier discoverability.
Currently untested as it will be need to added to the other modules to
effectively test.
Still have to do the OpenOptions::open(_temp_file) functions as changing
them would be a breaking change currently as rustc is not able to
default to using File.
Still have to add tests to make sure this all works properly.

Also have to add the generic parameter to socket, but that would be a
breaking change.
Instead of make raw io_uring_register system calls.
Some breaking changes incoming.
To allow opening of direct descriptions.
Sets the submission flags needed to create a direct descriptor (or does
nothing).

Also renames the set_flags to use_flags to not confuse the two methods.
So that we can open files using direct descriptors.
Some of the creation methods are quite far away from the AsyncFd docs,
so link to them to bring them a little closer.
@Thomasdezeeuw
Copy link
Owner Author

At this point I think all API can use direct descriptors except for process::Signals. Next is testing.

@Thomasdezeeuw Thomasdezeeuw marked this pull request as ready for review April 27, 2024 11:50
@Thomasdezeeuw Thomasdezeeuw merged commit dfdb497 into main Apr 27, 2024
6 checks passed
@Thomasdezeeuw Thomasdezeeuw deleted the fixed-fds branch April 27, 2024 11:59
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.

Add Linux kernel v6.8 operations Add support for fixed fds
1 participant