authfs: support multiple threads
This change adds the -j option to let authfs run in multiple threads.
The bad news is even sequential read is sigificantly slower (2x-ish).
Note that this change does not enable -j anywhere.
Bug: 220386264
Test: ls /proc/`pidof authfs`/tasks # show multiple threads
Test: Read large file. Time was ~2x-ish with -j2. (bad)
Change-Id: I82ad727d6af6413c2d1aa22a02416b9f38306fb5
diff --git a/authfs/src/fusefs/mount.rs b/authfs/src/fusefs/mount.rs
index 38503df..7f8bac1 100644
--- a/authfs/src/fusefs/mount.rs
+++ b/authfs/src/fusefs/mount.rs
@@ -16,6 +16,7 @@
use fuse::mount::MountOption;
use std::fs::OpenOptions;
+use std::num::NonZeroU8;
use std::os::unix::io::AsRawFd;
use std::path::Path;
@@ -35,6 +36,7 @@
authfs: AuthFs,
mountpoint: &Path,
extra_options: &Option<String>,
+ threads: Option<NonZeroU8>,
) -> Result<(), fuse::Error> {
let dev_fuse = OpenOptions::new()
.read(true)
@@ -64,5 +66,8 @@
let mut config = fuse::FuseConfig::new();
config.dev_fuse(dev_fuse).max_write(MAX_WRITE_BYTES).max_read(MAX_READ_BYTES);
+ if let Some(num) = threads {
+ config.num_threads(u8::from(num).into());
+ }
config.enter_message_loop(authfs)
}