Skip to content

Commit 096ad2e

Browse files
committed
transport: concurrently support fusedev and virtiofs
Previously fusedev and virtiofs transport drivers are mutual exclusive, which is a strong constraints. So relax it. Signed-off-by: Jiang Liu <[email protected]>
1 parent 5a689b3 commit 096ad2e

File tree

8 files changed

+359
-156
lines changed

8 files changed

+359
-156
lines changed

Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ check-macos: build-macos
1818

1919
check: build
2020
cargo fmt -- --check
21-
cargo clippy --features="fusedev" -- -Dwarnings
22-
cargo clippy --features="virtiofs" -- -Dwarnings
23-
cargo clippy --features="vhost-user-fs" -- -Dwarnings
24-
cargo test --features="fusedev" -- --nocapture --skip integration
25-
cargo test --features="virtiofs" -- --nocapture --skip integration
26-
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
21+
cargo clippy --features="fusedev" --no-default-features -- -Dwarnings
22+
cargo clippy --features="virtiofs" --no-default-features -- -Dwarnings
23+
cargo clippy --features="vhost-user-fs" --no-default-features -- -Dwarnings
24+
cargo clippy --features="fusedev,virtiofs" --no-default-features -- -Dwarnings
25+
cargo test --features="fusedev" --no-default-features -- --nocapture --skip integration
26+
cargo test --features="virtiofs" --no-default-features -- --nocapture --skip integration
27+
cargo test --features="vhost-user-fs" --no-default-features -- --nocapture --skip integration
28+
cargo test --features="fusedev,virtiofs" --no-default-features -- --nocapture --skip integration
29+
cargo test --features="fusedev,async-io" --no-default-features -- --nocapture --skip integration
30+
cargo test --features="virtiofs,async-io" --no-default-features -- --nocapture --skip integration
31+
cargo test --features="vhost-user-fs,async-io" --no-default-features -- --nocapture --skip integration
32+
cargo test --features="fusedev,virtiofs,async-io" --no-default-features -- --nocapture --skip integration
3033

3134
smoke: check
3235
cargo test --features="fusedev" -- --nocapture

src/transport/fusedev/linux_session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use nix::poll::{poll, PollFd, PollFlags};
2323
use nix::sys::epoll::{epoll_ctl, EpollEvent, EpollFlags, EpollOp};
2424
use nix::unistd::{getgid, getuid, read};
2525

26-
use super::{super::pagesize, Error::SessionFailure, FuseBuf, Reader, Result, Writer};
26+
use super::{super::pagesize, Error::SessionFailure, FuseBuf, FuseDevWriter, Reader, Result};
2727

2828
// These follows definition from libfuse.
2929
const FUSE_KERN_BUF_SIZE: usize = 256;
@@ -223,7 +223,7 @@ impl FuseChannel {
223223
/// - Ok(None): signal has pending on the exiting event channel
224224
/// - Ok(Some((reader, writer))): reader to receive request and writer to send reply
225225
/// - Err(e): error message
226-
pub fn get_request(&mut self) -> Result<Option<(Reader, Writer)>> {
226+
pub fn get_request(&mut self) -> Result<Option<(Reader, FuseDevWriter)>> {
227227
let mut events = Events::with_capacity(POLL_EVENTS_CAPACITY);
228228
let mut need_exit = false;
229229
loop {
@@ -281,7 +281,7 @@ impl FuseChannel {
281281
// Reader::new() and Writer::new() should always return success.
282282
let reader =
283283
Reader::from_fuse_buffer(FuseBuf::new(&mut self.buf[..len])).unwrap();
284-
let writer = Writer::new(fd, buf).unwrap();
284+
let writer = FuseDevWriter::new(fd, buf).unwrap();
285285
return Ok(Some((reader, writer)));
286286
}
287287
Err(e) => match e {

src/transport/fusedev/macos_session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use nix::sys::socket::{
3131
use nix::unistd::{close, execv, fork, getpid, read, ForkResult};
3232
use nix::{cmsg_space, NixPath};
3333

34-
use super::{Error::IoError, Error::SessionFailure, FuseBuf, Reader, Result, Writer};
34+
use super::{Error::IoError, Error::SessionFailure, FuseBuf, FuseDevWriter, Reader, Result};
3535
use crate::transport::pagesize;
3636

3737
// These follows definition from libfuse.
@@ -225,7 +225,7 @@ impl FuseChannel {
225225
/// - Ok(None): signal has pending on the exiting event channel
226226
/// - Ok(Some((reader, writer))): reader to receive request and writer to send reply
227227
/// - Err(e): error message
228-
pub fn get_request(&mut self) -> Result<Option<(Reader, Writer)>> {
228+
pub fn get_request(&mut self) -> Result<Option<(Reader, FuseDevWriter)>> {
229229
let fd = self.file.as_raw_fd();
230230
loop {
231231
match read(fd, &mut self.buf) {
@@ -242,7 +242,7 @@ impl FuseChannel {
242242
// Reader::new() and Writer::new() should always return success.
243243
let reader =
244244
Reader::from_fuse_buffer(FuseBuf::new(&mut self.buf[..len])).unwrap();
245-
let writer = Writer::new(fd, buf).unwrap();
245+
let writer = FuseDevWriter::new(fd, buf).unwrap();
246246
return Ok(Some((reader, writer)));
247247
}
248248
Err(e) => match e {

0 commit comments

Comments
 (0)