@@ -22,8 +22,8 @@ use std::os::fd::{AsFd, BorrowedFd};
22
22
use std:: os:: unix:: ffi:: OsStringExt ;
23
23
use std:: os:: unix:: io:: { AsRawFd , RawFd } ;
24
24
use std:: path:: PathBuf ;
25
- use std:: sync:: atomic:: { AtomicBool , AtomicU32 , AtomicU64 , Ordering } ;
26
- use std:: sync:: { Arc , Mutex , MutexGuard , RwLock , RwLockWriteGuard } ;
25
+ use std:: sync:: atomic:: { AtomicBool , AtomicU64 , Ordering } ;
26
+ use std:: sync:: { Arc , RwLock , RwLockWriteGuard } ;
27
27
use std:: time:: Duration ;
28
28
29
29
use vm_memory:: { bitmap:: BitmapSlice , ByteValued } ;
@@ -35,7 +35,7 @@ use self::mount_fd::MountFds;
35
35
use self :: statx:: { statx, StatExt } ;
36
36
use self :: util:: {
37
37
ebadf, einval, enosys, eperm, is_dir, is_safe_inode, openat, reopen_fd_through_proc, stat_fd,
38
- UniqueInodeGenerator ,
38
+ FileFlagGuard , UniqueInodeGenerator ,
39
39
} ;
40
40
use crate :: abi:: fuse_abi as fuse;
41
41
use crate :: abi:: fuse_abi:: Opcode ;
@@ -256,39 +256,30 @@ impl InodeMap {
256
256
struct HandleData {
257
257
inode : Inode ,
258
258
file : File ,
259
- lock : Mutex < ( ) > ,
260
- open_flags : AtomicU32 ,
259
+ open_flags : RwLock < u32 > ,
261
260
}
262
261
263
262
impl HandleData {
264
263
fn new ( inode : Inode , file : File , flags : u32 ) -> Self {
265
264
HandleData {
266
265
inode,
267
266
file,
268
- lock : Mutex :: new ( ( ) ) ,
269
- open_flags : AtomicU32 :: new ( flags) ,
267
+ open_flags : RwLock :: new ( flags) ,
270
268
}
271
269
}
272
270
273
271
fn get_file ( & self ) -> & File {
274
272
& self . file
275
273
}
276
274
277
- fn get_file_mut ( & self ) -> ( MutexGuard < ( ) > , & File ) {
278
- ( self . lock . lock ( ) . unwrap ( ) , & self . file )
275
+ fn get_file_mut ( & self ) -> ( FileFlagGuard < u32 > , & File ) {
276
+ let guard = self . open_flags . write ( ) . unwrap ( ) ;
277
+ ( FileFlagGuard :: Writer ( guard) , & self . file )
279
278
}
280
279
281
280
fn borrow_fd ( & self ) -> BorrowedFd {
282
281
self . file . as_fd ( )
283
282
}
284
-
285
- fn get_flags ( & self ) -> u32 {
286
- self . open_flags . load ( Ordering :: Relaxed )
287
- }
288
-
289
- fn set_flags ( & self , flags : u32 ) {
290
- self . open_flags . store ( flags, Ordering :: Relaxed ) ;
291
- }
292
283
}
293
284
294
285
struct HandleMap {
0 commit comments