diff --git a/Cargo.toml b/Cargo.toml index ad72288d4..5f1587f84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,8 +65,8 @@ rustls = ["actix-http/rustls", "actix-tls/accept", "actix-tls/rustls"] # Don't rely on these whatsoever. They may disappear at anytime. __compress = [] -# io-uring feature only avaiable for linux OS. -io-uring = ["actix-server/io-uring"] +# io-uring feature only avaiable for Linux OSes. +experimental-io-uring = ["actix-server/io-uring"] [dependencies] actix-codec = "0.4.1" diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 41336c21c..aadcd062e 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -1,8 +1,10 @@ # Changes ## Unreleased - 2021-xx-xx +* Add crate feature `experimental-io-uring`, enabling async file I/O to be utilized. This feature is only available on Linux OSes with recent kernel versions. This feature is semver-exempt. [#2408] * Fix 304 Not Modified responses to omit the Content-Length header, as per the spec. [#2453] +[#2408]: https://github.com/actix/actix-web/pull/2408 [#2453]: https://github.com/actix/actix-web/pull/2453 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 978ef0c78..c0ff18678 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -15,7 +15,7 @@ name = "actix_files" path = "src/lib.rs" [features] -io-uring = ["actix-web/io-uring", "tokio-uring"] +experimental-io-uring = ["actix-web/experimental-io-uring", "tokio-uring"] [dependencies] actix-web = { version = "4.0.0-beta.11", default-features = false } diff --git a/actix-files/src/chunked.rs b/actix-files/src/chunked.rs index 81bc41b43..4a47a8b53 100644 --- a/actix-files/src/chunked.rs +++ b/actix-files/src/chunked.rs @@ -27,7 +27,7 @@ pin_project! { } } -#[cfg(not(feature = "io-uring"))] +#[cfg(not(feature = "experimental-io-uring"))] pin_project! { #[project = ChunkedReadFileStateProj] #[project_replace = ChunkedReadFileStateProjReplace] @@ -42,7 +42,7 @@ pin_project! { } } -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] pin_project! { #[project = ChunkedReadFileStateProj] #[project_replace = ChunkedReadFileStateProjReplace] @@ -71,9 +71,9 @@ pub(crate) fn new_chunked_read( ChunkedReadFile { size, offset, - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] state: ChunkedReadFileState::File { file: Some(file) }, - #[cfg(feature = "io-uring")] + #[cfg(feature = "experimental-io-uring")] state: ChunkedReadFileState::File { file: Some((file, BytesMut::new())), }, @@ -82,7 +82,7 @@ pub(crate) fn new_chunked_read( } } -#[cfg(not(feature = "io-uring"))] +#[cfg(not(feature = "experimental-io-uring"))] async fn chunked_read_file_callback( mut file: File, offset: u64, @@ -109,7 +109,7 @@ async fn chunked_read_file_callback( Ok(res) } -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] async fn chunked_read_file_callback( file: File, offset: u64, @@ -129,7 +129,7 @@ async fn chunked_read_file_callback( Ok((file, bytes, bytes_mut)) } -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] impl Stream for ChunkedReadFile where F: Fn(File, u64, usize, BytesMut) -> Fut, @@ -178,7 +178,7 @@ where } } -#[cfg(not(feature = "io-uring"))] +#[cfg(not(feature = "experimental-io-uring"))] impl Stream for ChunkedReadFile where F: Fn(File, u64, usize) -> Fut, @@ -226,12 +226,12 @@ where } } -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] use bytes_mut::BytesMut; // TODO: remove new type and use bytes::BytesMut directly #[doc(hidden)] -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] mod bytes_mut { use std::ops::{Deref, DerefMut}; diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index c8dc92c0d..100c84c59 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -215,12 +215,12 @@ mod tests { #[actix_rt::test] async fn test_named_file_non_ascii_file_name() { let file = { - #[cfg(feature = "io-uring")] + #[cfg(feature = "experimental-io-uring")] { crate::named::File::open("Cargo.toml").await.unwrap() } - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] { crate::named::File::open("Cargo.toml").unwrap() } diff --git a/actix-files/src/named.rs b/actix-files/src/named.rs index c64d89bc9..7e91bf2b6 100644 --- a/actix-files/src/named.rs +++ b/actix-files/src/named.rs @@ -88,11 +88,11 @@ impl fmt::Debug for NamedFile { .field("path", &self.path) .field( "file", - #[cfg(feature = "io-uring")] + #[cfg(feature = "experimental-io-uring")] { &"File" }, - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] { &self.file }, @@ -108,9 +108,9 @@ impl fmt::Debug for NamedFile { } } -#[cfg(not(feature = "io-uring"))] +#[cfg(not(feature = "experimental-io-uring"))] pub(crate) use std::fs::File; -#[cfg(feature = "io-uring")] +#[cfg(feature = "experimental-io-uring")] pub(crate) use tokio_uring::fs::File; impl NamedFile { @@ -183,12 +183,12 @@ impl NamedFile { }; let md = { - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] { file.metadata()? } - #[cfg(feature = "io-uring")] + #[cfg(feature = "experimental-io-uring")] { use std::os::unix::prelude::{AsRawFd, FromRawFd}; @@ -220,7 +220,7 @@ impl NamedFile { }) } - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] /// Attempts to open a file in read-only mode. /// /// # Examples @@ -248,12 +248,12 @@ impl NamedFile { /// ``` pub async fn open_async>(path: P) -> io::Result { let file = { - #[cfg(not(feature = "io-uring"))] + #[cfg(not(feature = "experimental-io-uring"))] { File::open(&path)? } - #[cfg(feature = "io-uring")] + #[cfg(feature = "experimental-io-uring")] { File::open(&path).await? }