Skip to content

Commit

Permalink
fix: trickfs fix for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin committed Feb 5, 2025
1 parent 5e377a3 commit 6415348
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 39 deletions.
2 changes: 0 additions & 2 deletions torture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
hex = "0.4.3"
futures-util = "0.3.31"
clap = { version = "4.5.23", features = ["derive"] }

[target.'cfg(target_os = "linux")'.dependencies]
trickfs = { path = "../trickfs" }
9 changes: 8 additions & 1 deletion torture/src/supervisor/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,18 @@ pub fn run(stream: UnixStream) -> (RequestResponse, impl Future<Output = anyhow:
SymmetricalBincode::default(),
);

// macOS is way slower for some reason. Workaround by increasing the timeout.
let timeout = if cfg!(target_os = "macos") {
Duration::from_secs(10)
} else {
Duration::from_secs(5)
};

let shared = Arc::new(Shared {
reqno: AtomicU64::new(0),
wr_stream: Mutex::new(wr_stream),
pending: Mutex::new(HashMap::new()),
timeout: Duration::from_secs(5),
timeout,
});
let rr = RequestResponse {
shared: shared.clone(),
Expand Down
8 changes: 1 addition & 7 deletions torture/src/supervisor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use workload::Workload;
mod cli;
mod comms;
mod controller;
mod trickfs;
mod workload;

/// The entrypoint for the supervisor part of the program.
Expand Down Expand Up @@ -207,14 +206,9 @@ const NON_DETERMINISM_DISCLAIMER: &str = "torture is a non-deterministic fuzzer.
async fn control_loop(
cancel_token: CancellationToken,
seed: u64,
mut workload_params: WorkloadParams,
workload_params: WorkloadParams,
flag_num_limit: usize,
) -> Result<()> {
if workload_params.trickfs && !trickfs::is_supported() {
warn!("TrickFS is not supported on this system. Disabling.");
workload_params.trickfs = false;
}

let mut flags = Vec::new();
let mut workload_cnt = 0;
// TODO: Run workloads in parallel. Make the concurrency factor configurable.
Expand Down
27 changes: 0 additions & 27 deletions torture/src/supervisor/trickfs.rs

This file was deleted.

2 changes: 1 addition & 1 deletion torture/src/supervisor/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub struct Workload {
/// The handle to the trickfs FUSE FS.
///
/// `Some` until the workload is torn down.
trick_handle: Option<super::trickfs::TrickHandle>,
trick_handle: Option<trickfs::TrickHandle>,
/// The currently spawned agent.
///
/// Initially `None`.
Expand Down
6 changes: 6 additions & 0 deletions trickfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ the following commands:
sudo apt update
sudo apt install libfuse3-dev libfuse-dev
```

On macOS you may need to install osxfuse:

```sh
brew install macfuse
```
7 changes: 6 additions & 1 deletion trickfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,11 @@ impl fuser::Filesystem for Trick {
let content = &inode_data.content();
if content.is_empty() {
// The backing buffer has not yet been created. Let's just return an empty buffer.
if has_odirect(flags) {
#[cfg(target_os = "linux")]
let pageworth = has_odirect(flags);
#[cfg(not(target_os = "linux"))]
let pageworth = false;
if pageworth {
reply.data(&[0u8; 4096]);
} else {
reply.data(&[]);
Expand Down Expand Up @@ -854,6 +858,7 @@ impl fuser::Filesystem for Trick {
}
}

#[cfg(target_os = "linux")]
fn has_odirect(flags: i32) -> bool {
(flags & libc::O_DIRECT) != 0
}
Expand Down

0 comments on commit 6415348

Please sign in to comment.