@@ -4,12 +4,13 @@ use std::os::fd::{AsFd, AsRawFd};
4
4
use std:: path:: Path ;
5
5
use std:: sync:: Arc ;
6
6
7
- use fuser:: { BackgroundSession , Mount , MountOption , Session } ;
7
+ use fuser:: { Mount , MountOption , Session } ;
8
8
use mountpoint_s3_client:: ObjectClient ;
9
9
use mountpoint_s3_client:: checksums:: crc32c;
10
10
use mountpoint_s3_client:: config:: S3ClientAuthConfig ;
11
11
use mountpoint_s3_client:: types:: { Checksum , PutObjectSingleParams , UploadChecksum } ;
12
12
use mountpoint_s3_fs:: data_cache:: DataCache ;
13
+ use mountpoint_s3_fs:: fuse:: session:: FuseSession ;
13
14
use mountpoint_s3_fs:: fuse:: { ErrorLogger , S3FuseFilesystem } ;
14
15
#[ cfg( feature = "manifest" ) ]
15
16
use mountpoint_s3_fs:: manifest:: { Manifest , ManifestMetablock } ;
@@ -68,6 +69,7 @@ pub struct TestSessionConfig {
68
69
// If true, the test session will be created by opening and passing
69
70
// FUSE device using `Session::from_fd`, otherwise `Session::new` will be used.
70
71
pub pass_fuse_fd : bool ,
72
+ pub max_worker_threads : usize ,
71
73
pub error_logger : Option < Box < dyn ErrorLogger + Send + Sync > > ,
72
74
pub cache_block_size : usize ,
73
75
#[ cfg( feature = "manifest" ) ]
@@ -84,6 +86,7 @@ impl Default for TestSessionConfig {
84
86
filesystem_config : Default :: default ( ) ,
85
87
auth_config : Default :: default ( ) ,
86
88
pass_fuse_fd : false ,
89
+ max_worker_threads : 16 ,
87
90
error_logger : None ,
88
91
cache_block_size,
89
92
#[ cfg( feature = "manifest" ) ]
@@ -110,15 +113,15 @@ pub struct TestSession {
110
113
test_client : Box < dyn TestClient > ,
111
114
prefix : String ,
112
115
// Option so we can explicitly unmount
113
- session : Option < BackgroundSession > ,
116
+ session : Option < FuseSession > ,
114
117
// Only set if `pass_fuse_fd` is true, will unmount the filesystem on drop.
115
118
mount : Option < Mount > ,
116
119
}
117
120
118
121
impl TestSession {
119
122
pub fn new (
120
123
mount_dir : TempDir ,
121
- session : BackgroundSession ,
124
+ session : FuseSession ,
122
125
test_client : impl TestClient + ' static ,
123
126
prefix : String ,
124
127
mount : Option < Mount > ,
@@ -150,8 +153,13 @@ impl Drop for TestSession {
150
153
// If the session created with a pre-existing mount (e.g., with `pass_fuse_fd`),
151
154
// this will unmount it explicitly...
152
155
drop ( self . mount . take ( ) ) ;
153
- // ...if not, the background session will have a mount here, and dropping it will unmount it.
154
- self . session . take ( ) ;
156
+ // ...if not, the fuse session will unmount on shutdown.
157
+ if let Some ( session) = self . session . take ( ) {
158
+ session. shutdown_fn ( ) ( ) ;
159
+ if let Err ( error) = session. join ( ) {
160
+ tracing:: warn!( ?error, "error while unmounting" ) ;
161
+ }
162
+ }
155
163
}
156
164
}
157
165
@@ -213,7 +221,7 @@ pub fn create_fuse_session<Client>(
213
221
s3_path : S3Path ,
214
222
mount_dir : & Path ,
215
223
test_config : TestSessionConfig ,
216
- ) -> ( BackgroundSession , Option < Mount > )
224
+ ) -> ( FuseSession , Option < Mount > )
217
225
where
218
226
Client : ObjectClient + Clone + Send + Sync + ' static ,
219
227
{
@@ -245,7 +253,10 @@ where
245
253
( Session :: new ( fs, mount_dir, & options) . unwrap ( ) , None )
246
254
} ;
247
255
248
- ( BackgroundSession :: new ( session) . unwrap ( ) , mount)
256
+ (
257
+ FuseSession :: from_session ( session, test_config. max_worker_threads ) . unwrap ( ) ,
258
+ mount,
259
+ )
249
260
}
250
261
251
262
/// Open `/dev/fuse` and call `mount` syscall with given `mount_point`.
0 commit comments