pxar/fuse: add pxar cli flag to set single- or multi-threaded session loop

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Christian Ebner 2019-08-22 16:39:04 +02:00 committed by Wolfgang Bumiller
parent de2791868a
commit bcb664cb69
2 changed files with 14 additions and 4 deletions

View File

@ -226,6 +226,7 @@ fn mount_archive(
let archive = tools::required_string_param(&param, "archive")?; let archive = tools::required_string_param(&param, "archive")?;
let mountpoint = tools::required_string_param(&param, "mountpoint")?; let mountpoint = tools::required_string_param(&param, "mountpoint")?;
let verbose = param["verbose"].as_bool().unwrap_or(false); let verbose = param["verbose"].as_bool().unwrap_or(false);
let no_mt = param["no-mt"].as_bool().unwrap_or(false);
let archive = Path::new(archive); let archive = Path::new(archive);
let mountpoint = Path::new(mountpoint); let mountpoint = Path::new(mountpoint);
@ -233,7 +234,7 @@ fn mount_archive(
let mut session = pxar::fuse::Session::new(&archive, &options, verbose) let mut session = pxar::fuse::Session::new(&archive, &options, verbose)
.map_err(|err| format_err!("pxar mount failed: {}", err))?; .map_err(|err| format_err!("pxar mount failed: {}", err))?;
session.mount(&mountpoint)?; session.mount(&mountpoint)?;
session.run_loop()?; session.run_loop(!no_mt)?;
Ok(Value::Null) Ok(Value::Null)
} }
@ -295,7 +296,8 @@ fn main() {
ObjectSchema::new("Mount the archive as filesystem via FUSE.") ObjectSchema::new("Mount the archive as filesystem via FUSE.")
.required("archive", StringSchema::new("Archive name.")) .required("archive", StringSchema::new("Archive name."))
.required("mountpoint", StringSchema::new("Mountpoint for the filesystem root.")) .required("mountpoint", StringSchema::new("Mountpoint for the filesystem root."))
.optional("verbose", BooleanSchema::new("Verbose output, keeps process running in foreground.").default(false)) .optional("verbose", BooleanSchema::new("Verbose output, keeps process running in foreground (for debugging).").default(false))
.optional("no-mt", BooleanSchema::new("Run in single threaded mode (for debugging).").default(false))
)) ))
.arg_param(vec!["archive", "mountpoint"]) .arg_param(vec!["archive", "mountpoint"])
.completion_cb("archive", tools::complete_file_name) .completion_cb("archive", tools::complete_file_name)

View File

@ -46,6 +46,7 @@ extern "C" {
fn fuse_session_mount(session: ConstPtr, mountpoint: StrPtr) -> c_int; fn fuse_session_mount(session: ConstPtr, mountpoint: StrPtr) -> c_int;
fn fuse_session_unmount(session: ConstPtr); fn fuse_session_unmount(session: ConstPtr);
fn fuse_session_loop(session: ConstPtr) -> c_int; fn fuse_session_loop(session: ConstPtr) -> c_int;
fn fuse_session_loop_mt_31(session: ConstPtr, clone_fd: c_int) -> c_int;
fn fuse_session_destroy(session: ConstPtr); fn fuse_session_destroy(session: ConstPtr);
// fn fuse_reply_attr(req: Request, attr: *const libc::stat, timeout: f64) -> c_int; // fn fuse_reply_attr(req: Request, attr: *const libc::stat, timeout: f64) -> c_int;
fn fuse_reply_err(req: Request, errno: c_int) -> c_int; fn fuse_reply_err(req: Request, errno: c_int) -> c_int;
@ -212,11 +213,18 @@ impl Session {
} }
/// Execute session loop which handles requests from kernel. /// Execute session loop which handles requests from kernel.
pub fn run_loop(&mut self) -> Result<(), Error> { ///
/// The multi_threaded flag controls if the session loop runs in
/// singlethreaded or multithreaded.
/// Singlethreaded mode is intended for debugging.
pub fn run_loop(&mut self, multi_threaded: bool) -> Result<(), Error> {
if self.verbose { if self.verbose {
println!("Executing fuse session loop"); println!("Executing fuse session loop");
} }
let result = unsafe { fuse_session_loop(self.ptr) }; let result = match multi_threaded {
true => unsafe { fuse_session_loop_mt_31(self.ptr, 1) },
false => unsafe { fuse_session_loop(self.ptr) },
};
if result < 0 { if result < 0 {
bail!("fuse session loop exited with - {}", result); bail!("fuse session loop exited with - {}", result);
} }