Skip to content

Commit 5a689b3

Browse files
committed
transport: enable io-uring based async io
Enhance the transport layer to support io-uring based async io. Signed-off-by: Jiang Liu <[email protected]>
1 parent 57d34af commit 5a689b3

File tree

14 files changed

+230
-956
lines changed

14 files changed

+230
-956
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ vm-memory = { version = "0.7", features = ["backend-mmap", "backend-bitmap"] }
4747
[features]
4848
default = ["fusedev"]
4949
#async-io = ["async-trait", "futures", "caps]
50-
async_io = ["async-trait", "futures", "tokio-uring"]
50+
async-io = ["async-trait", "futures", "tokio-uring"]
5151
fusedev = ["vmm-sys-util", "caps", "core-foundation-sys"]
5252
virtiofs = ["virtio-queue", "caps"]
5353
vhost-user-fs = ["virtiofs", "vhost", "caps"]

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ build:
44
cargo build --features="fusedev"
55
cargo build --features="virtiofs"
66
cargo build --features="vhost-user-fs"
7+
cargo build --features="fusedev,async-io"
8+
cargo build --features="virtiofs,async-io"
9+
cargo build --features="vhost-user-fs,async-io"
710

811
build-macos:
912
cargo build --features="fusedev"
@@ -18,9 +21,12 @@ check: build
1821
cargo clippy --features="fusedev" -- -Dwarnings
1922
cargo clippy --features="virtiofs" -- -Dwarnings
2023
cargo clippy --features="vhost-user-fs" -- -Dwarnings
21-
cargo test --features="virtiofs" -- --nocapture --skip integration
2224
cargo test --features="fusedev" -- --nocapture --skip integration
25+
cargo test --features="virtiofs" -- --nocapture --skip integration
2326
cargo test --features="vhost-user-fs" -- --nocapture --skip integration
27+
cargo test --features="fusedev,async-io" -- --nocapture --skip integration
28+
cargo test --features="virtiofs,async-io" -- --nocapture --skip integration
29+
cargo test --features="vhost-user-fs,async-io" -- --nocapture --skip integration
2430

2531
smoke: check
2632
cargo test --features="fusedev" -- --nocapture

src/api/filesystem/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ pub use fuse::ROOT_ID;
2222

2323
use crate::abi::fuse_abi::{ino64_t, stat64};
2424

25-
#[cfg(feature = "async-io")]
25+
#[cfg(feature = "async_io")]
2626
mod async_io;
27-
#[cfg(feature = "async-io")]
27+
#[cfg(feature = "async_io")]
2828
pub use async_io::{AsyncFileSystem, AsyncZeroCopyReader, AsyncZeroCopyWriter};
2929

3030
mod sync_io;
@@ -384,7 +384,7 @@ pub struct Context {
384384
/// The thread group ID of the calling process.
385385
pub pid: libc::pid_t,
386386

387-
#[cfg(feature = "async-io")]
387+
#[cfg(feature = "async_io")]
388388
/// Asynchronous event drive
389389
pub drive: usize,
390390
}
@@ -402,15 +402,15 @@ impl From<&fuse::InHeader> for Context {
402402
uid: source.uid,
403403
gid: source.gid,
404404
pid: source.pid as i32,
405-
#[cfg(feature = "async-io")]
405+
#[cfg(feature = "async_io")]
406406
drive: 0,
407407
}
408408
}
409409
}
410410

411411
// The design is very ugly, but it helps to avoid adding a generic type parameter "D: AsyncDrive"
412412
// to the FileSystem trait.
413-
#[cfg(feature = "async-io")]
413+
#[cfg(feature = "async_io")]
414414
impl Context {
415415
/// Set the asynchronous event drive.
416416
///

src/api/server/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::async_util::{AsyncDrive, AsyncDriver};
3030
use crate::transport::{FileReadWriteVolatile, Reader, Writer};
3131
use crate::{bytes_to_cstr, BitmapSlice, Error, Result};
3232

33-
#[cfg(feature = "async-io")]
33+
#[cfg(feature = "async_io")]
3434
mod async_io;
3535
mod sync_io;
3636

src/api/vfs/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::abi::fuse_abi::*;
3333
use crate::api::filesystem::*;
3434
use crate::async_util::{AsyncDrive, AsyncDriver};
3535

36-
#[cfg(feature = "async-io")]
36+
#[cfg(feature = "async_io")]
3737
mod async_io;
3838
mod sync_io;
3939

@@ -165,7 +165,7 @@ use Either::*;
165165
/// D refers to the type of asynchronous event driver
166166
pub type BackFileSystem<D> = Box<dyn BackendFileSystem<D, Inode = u64, Handle = u64> + Sync + Send>;
167167

168-
#[cfg(not(feature = "async-io"))]
168+
#[cfg(not(feature = "async_io"))]
169169
/// BackendFileSystem abstracts all backend file systems under vfs
170170
pub trait BackendFileSystem<D: AsyncDrive = AsyncDriver>: FileSystem {
171171
/// mount returns the backend file system root inode entry and
@@ -180,7 +180,7 @@ pub trait BackendFileSystem<D: AsyncDrive = AsyncDriver>: FileSystem {
180180
fn as_any(&self) -> &dyn Any;
181181
}
182182

183-
#[cfg(feature = "async-io")]
183+
#[cfg(feature = "async_io")]
184184
/// BackendFileSystem abstracts all backend file systems under vfs
185185
pub trait BackendFileSystem<D: AsyncDrive = AsyncDriver>: AsyncFileSystem<D> {
186186
/// mount returns the backend file system root inode entry and
@@ -639,7 +639,7 @@ mod tests {
639639
assert!(!is_dot_or_dotdot(name));
640640
}
641641

642-
#[cfg(feature = "async-io")]
642+
#[cfg(feature = "async_io")]
643643
mod async_io {
644644
use super::*;
645645
use crate::abi::fuse_abi::{OpenOptions, SetattrValid};
@@ -907,7 +907,7 @@ mod tests {
907907
}
908908
}
909909

910-
#[cfg(not(feature = "async-io"))]
910+
#[cfg(not(feature = "async_io"))]
911911
impl BackendFileSystem<AsyncDriver> for FakeFileSystemOne {
912912
fn mount(&self) -> Result<(Entry, u64)> {
913913
Ok((
@@ -924,7 +924,7 @@ mod tests {
924924
}
925925
}
926926

927-
#[cfg(not(feature = "async-io"))]
927+
#[cfg(not(feature = "async_io"))]
928928
impl BackendFileSystem<AsyncDriver> for FakeFileSystemTwo {
929929
fn mount(&self) -> Result<(Entry, u64)> {
930930
Ok((

0 commit comments

Comments
 (0)