-
Notifications
You must be signed in to change notification settings - Fork 153
WIP: Add Multithreading Support #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
98b1c56
4a19acb
77aab16
b767ba3
2023032
a8d9740
28f21f2
e12c9b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,7 +291,7 @@ impl KernelConfig { | |
| /// implementations are provided here to get a mountable filesystem that does | ||
| /// nothing. | ||
| #[allow(clippy::too_many_arguments)] | ||
| pub trait Filesystem { | ||
| pub trait Filesystem: Clone { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the random drive-by comment. In my opinion, it would be better to require
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I need to figure out exactly what you're referring to and understand it, but that does make sense and does seem better. Something fun to do this weekend! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if a type is if a type is |
||
| /// Initialize filesystem. | ||
| /// Called before any other filesystem method. | ||
| /// The kernel module connection can be configured using the KernelConfig object | ||
|
|
@@ -1036,7 +1036,7 @@ pub fn spawn_mount<'a, FS: Filesystem + Send + 'static + 'a, P: AsRef<Path>>( | |
| .map(|x| Some(MountOption::from_str(x.to_str()?))) | ||
| .collect(); | ||
| let options = options.ok_or(ErrorKind::InvalidData)?; | ||
| Session::new(filesystem, mountpoint.as_ref(), options.as_ref()).and_then(|se| se.spawn()) | ||
| Session::new(filesystem, mountpoint.as_ref(), options.as_ref()).and_then(|se| se.spawn(1)) | ||
| } | ||
|
|
||
| /// Mount the given filesystem to the given mountpoint. This function spawns | ||
|
|
@@ -1047,10 +1047,24 @@ pub fn spawn_mount<'a, FS: Filesystem + Send + 'static + 'a, P: AsRef<Path>>( | |
| /// | ||
| /// NOTE: This is the corresponding function to mount2. | ||
| pub fn spawn_mount2<'a, FS: Filesystem + Send + 'static + 'a, P: AsRef<Path>>( | ||
| filesystem: FS, | ||
| mountpoint: P, | ||
| options: &[MountOption] | ||
| ) -> io::Result<BackgroundSession> { | ||
| check_option_conflicts(options)?; | ||
| Session::new(filesystem, mountpoint.as_ref(), options).and_then(|se| se.spawn(1)) | ||
| } | ||
|
|
||
| /// Mount the given filesystem to the given mountpoint; spawning n number of worker threads. | ||
| /// There is an assumption that the [`Filesystem`] given is thread-safe, and has proper internal | ||
| /// synchronization to prevent deadlocks. | ||
| #[cfg(all(feature = "multithreading", feature = "libfuse3"))] | ||
| pub fn spawn_mount2_threaded<'a, FS: Filesystem + Send + 'static + 'a, P: AsRef<Path>>( | ||
| filesystem: FS, | ||
| mountpoint: P, | ||
| options: &[MountOption], | ||
| threads: u8 | ||
| ) -> io::Result<BackgroundSession> { | ||
| check_option_conflicts(options)?; | ||
| Session::new(filesystem, mountpoint.as_ref(), options).and_then(|se| se.spawn()) | ||
| Session::new(filesystem, mountpoint.as_ref(), options).and_then(|se| se.spawn(threads)) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example,
Arc<AtomicU64>is a totally reasonable way to handle mutability, here - but this example could have easily used a normalu64before these changes and still derivedClone, leading to coinciding file handles.