-
Notifications
You must be signed in to change notification settings - Fork 0
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
allow re-use of OpenOptions in other crates #1
base: neon
Are you sure you want to change the base?
Conversation
The `OpenOptions` struct's functionality of mapping the builder pattern APIs to libc-level flags flags is useful outside of `tokio-uring`. Our particular use case is an alternative approach to tokio + io_uring which will be open-sourced soon. We are already re-using the `IoBuf` trait there, so, it makes sense to also re-use `OpenOptions`. So, this PR adds an extension trait for `OpenOptions` that allows producing an `io_uring::squeue::Entry`.
The `OpenOptions` struct's functionality of mapping the builder pattern APIs to libc-level flags flags is useful outside of `tokio-uring`. Our particular use case is an alternative approach to tokio + io_uring which will be open-sourced soon. We are already re-using the `IoBuf` trait there, so, it makes sense to also re-use `OpenOptions`. So, this PR adds an extension trait for `OpenOptions` that allows producing an `io_uring::squeue::Entry`. (This is a back-port of #1 to tokio-uring v0.4.0, the latest official release).
…okio-uring` For [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself.
For [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. This PR starts that effort by vendoring the `IoBuf`/`IoBufMut` traits. `OpenOptions` will follow in a later PR. The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself.
For [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. This PR starts that effort by vendoring the `IoBuf`/`IoBufMut` traits. `OpenOptions` will follow in a later PR. The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself.
I didn't pursue this approach further, rationale see neondatabase/tokio-epoll-uring#21 (comment) |
For [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. This PR starts that effort by vendoring the `IoBuf`/`IoBufMut` traits. `OpenOptions` will follow in a later PR. The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself.
For [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. This PR starts that effort by vendoring the `IoBuf`/`IoBufMut` traits. `OpenOptions` will follow in a later PR. The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself.
pub trait OpenOptionsIoUringExt { | ||
/// Turn `self` into an [`::io_uring::opcode::OpenAt`] SQE for the given `path`. | ||
/// | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// | |
/// |
// Get a reference to the memory. The string will be held by the | ||
// operation state and will not be accessed again until the operation | ||
// completes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Get a reference to the memory. The string will be held by the | |
// operation state and will not be accessed again until the operation | |
// completes. | |
// TODO: SAFETY: | |
// how exactly is the safety requirement fulfilled here? |
Turn formatting to https://rust-lang.github.io/rust-clippy/master/#/undocumented as I could imagine that is expected as the lint has been enabled in pageserver as well. Without re-reading the tokio-uring I am unable to answer this.
Regardless I don't think it makes sense to include "get a reference to the memory" or anything like reading the code aloud, instead the comment should say how are the requirements fulfilled.
Accessing or not accessing the Open::path: CString
does not seem relevant here.
In the draft PR for [`open_at` support](#21) we need an `OpenOptions` struct. Sadly we can't re-use the one from `tokio-uring` because it doesn't have a public API for the conversion of OpenOptions into the relevant libc flags. We created [a PR asking for such an API](neondatabase/tokio-uring#1), but, in the meantime, let's unblock ourselves by vendoring the pieces of `tokio-uring` that we need, and cusotmize them as needed. This PR starts that effort by vendoring the `IoBuf`/`IoBufMut` traits as well as `tokio-uring`'s approach to support slice-like operations. Support for `OpenOptions` will follow as part of [the PR that adds `open_at` support on top of this PR](#25). The files that reproduce the `tokio-uring` LICENSE text at the top are copied from `tokio-uring.git:d5e90539bd6d1c518e848298564a098c300866bc`. Files without it were written by myself. To make `cargo test` pass, I had to remove the examples in the doc comments.
The
OpenOptions
struct's functionality of mapping the builder pattern APIs to libc-level flags flags is useful outside oftokio-uring
.Our particular use case is an alternative approach to tokio + io_uring which will be open-sourced soon. We are already re-using the
IoBuf
trait there, so, it makes sense to also re-useOpenOptions
.So, this PR adds an extension trait for
OpenOptions
that allows producing anio_uring::squeue::Entry
.