@@ -138,16 +138,16 @@ impl InodeStat {
138
138
}
139
139
140
140
#[ derive( Debug ) ]
141
- enum FileOrHandle {
141
+ enum InodeHandle {
142
142
File ( File ) ,
143
143
Handle ( Arc < OpenableFileHandle > ) ,
144
144
}
145
145
146
- impl FileOrHandle {
146
+ impl InodeHandle {
147
147
fn handle ( & self ) -> Option < & FileHandle > {
148
148
match self {
149
- FileOrHandle :: File ( _) => None ,
150
- FileOrHandle :: Handle ( h) => Some ( h. file_handle ( ) . deref ( ) ) ,
149
+ InodeHandle :: File ( _) => None ,
150
+ InodeHandle :: Handle ( h) => Some ( h. file_handle ( ) . deref ( ) ) ,
151
151
}
152
152
}
153
153
}
@@ -181,7 +181,7 @@ impl AsRawFd for InodeFile<'_> {
181
181
pub struct InodeData {
182
182
inode : Inode ,
183
183
// Most of these aren't actually files but ¯\_(ツ)_/¯.
184
- file_or_handle : FileOrHandle ,
184
+ handle : InodeHandle ,
185
185
id : InodeId ,
186
186
refcount : AtomicU64 ,
187
187
// File type and mode, not used for now
@@ -200,20 +200,20 @@ fn is_dir(mode: u32) -> bool {
200
200
}
201
201
202
202
impl InodeData {
203
- fn new ( inode : Inode , f : FileOrHandle , refcount : u64 , id : InodeId , mode : u32 ) -> Self {
203
+ fn new ( inode : Inode , f : InodeHandle , refcount : u64 , id : InodeId , mode : u32 ) -> Self {
204
204
InodeData {
205
205
inode,
206
- file_or_handle : f,
206
+ handle : f,
207
207
id,
208
208
refcount : AtomicU64 :: new ( refcount) ,
209
209
mode,
210
210
}
211
211
}
212
212
213
213
fn get_file ( & self ) -> io:: Result < InodeFile < ' _ > > {
214
- match & self . file_or_handle {
215
- FileOrHandle :: File ( f) => Ok ( InodeFile :: Ref ( f) ) ,
216
- FileOrHandle :: Handle ( h) => {
214
+ match & self . handle {
215
+ InodeHandle :: File ( f) => Ok ( InodeFile :: Ref ( f) ) ,
216
+ InodeHandle :: Handle ( h) => {
217
217
let f = h. open ( libc:: O_PATH ) ?;
218
218
Ok ( InodeFile :: Owned ( f) )
219
219
}
@@ -283,7 +283,7 @@ impl InodeMap {
283
283
// inode ID.
284
284
// (This can happen when we look up a new file that has reused the inode ID
285
285
// of some previously unlinked inode we still have in `.inodes`.)
286
- handle. is_none ( ) || data. file_or_handle . handle ( ) . is_none ( )
286
+ handle. is_none ( ) || data. handle . handle ( ) . is_none ( )
287
287
} )
288
288
} )
289
289
. map ( Arc :: clone)
@@ -715,7 +715,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
715
715
pub fn import ( & self ) -> io:: Result < ( ) > {
716
716
let root = CString :: new ( self . cfg . root_dir . as_str ( ) ) . expect ( "CString::new failed" ) ;
717
717
718
- let ( file_or_handle , st, id) = Self :: open_file_or_handle (
718
+ let ( handle , st, id) = Self :: open_file_or_handle (
719
719
self . cfg . inode_file_handles ,
720
720
self . cfg . enable_mntid ,
721
721
libc:: AT_FDCWD ,
@@ -740,7 +740,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
740
740
// Not sure why the root inode gets a refcount of 2 but that's what libfuse does.
741
741
self . inode_map . insert ( Arc :: new ( InodeData :: new (
742
742
fuse:: ROOT_ID ,
743
- file_or_handle ,
743
+ handle ,
744
744
2 ,
745
745
id,
746
746
st. get_stat ( ) . st_mode ,
@@ -893,7 +893,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
893
893
name : & CStr ,
894
894
mount_fds : & MountFds ,
895
895
reopen_dir : F ,
896
- ) -> io:: Result < ( FileOrHandle , InodeStat , InodeId ) >
896
+ ) -> io:: Result < ( InodeHandle , InodeStat , InodeId ) >
897
897
where
898
898
F : FnOnce ( RawFd , libc:: c_int , u32 ) -> io:: Result < File > ,
899
899
{
@@ -904,8 +904,8 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
904
904
} ;
905
905
906
906
// Ignore errors, because having a handle is optional
907
- let file_or_handle = if let Ok ( h) = handle {
908
- FileOrHandle :: Handle ( Arc :: new ( h) )
907
+ let handle = if let Ok ( h) = handle {
908
+ InodeHandle :: Handle ( Arc :: new ( h) )
909
909
} else {
910
910
let f = Self :: open_file (
911
911
dir_fd,
@@ -914,11 +914,11 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
914
914
0 ,
915
915
) ?;
916
916
917
- FileOrHandle :: File ( f)
917
+ InodeHandle :: File ( f)
918
918
} ;
919
919
920
- let inode_stat = match & file_or_handle {
921
- FileOrHandle :: File ( f) => {
920
+ let inode_stat = match & handle {
921
+ InodeHandle :: File ( f) => {
922
922
// Count mount ID as part of alt key if use_mntid is true. Note that using
923
923
// name_to_handle_at() to get mntid is kind of expensive in Lookup intensive
924
924
// workloads, e.g. when cache is none and accessing lots of files.
@@ -940,15 +940,15 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
940
940
mnt_id,
941
941
}
942
942
}
943
- FileOrHandle :: Handle ( h) => InodeStat {
943
+ InodeHandle :: Handle ( h) => InodeStat {
944
944
stat : Self :: stat_fd ( dir_fd, Some ( name) ) ?,
945
945
mnt_id : h. mount_id ( ) ,
946
946
} ,
947
947
} ;
948
948
949
949
let id = InodeId :: from_stat ( & inode_stat) ;
950
950
951
- Ok ( ( file_or_handle , inode_stat, id) )
951
+ Ok ( ( handle , inode_stat, id) )
952
952
}
953
953
954
954
fn allocate_inode_locked (
@@ -988,7 +988,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
988
988
989
989
let dir = self . inode_map . get ( parent) ?;
990
990
let dir_file = dir. get_file ( ) ?;
991
- let ( file_or_handle , st, id) = Self :: open_file_or_handle (
991
+ let ( handle , st, id) = Self :: open_file_or_handle (
992
992
self . cfg . inode_file_handles ,
993
993
self . cfg . enable_mntid ,
994
994
dir_file. as_raw_fd ( ) ,
@@ -1000,7 +1000,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
1000
1000
// Note that this will always be `None` if `cfg.inode_file_handles` is false, but we only
1001
1001
// really need this alt key when we do not have an `O_PATH` fd open for every inode. So if
1002
1002
// `cfg.inode_file_handles` is false, we do not need this key anyway.
1003
- let handle_opt = file_or_handle . handle ( ) ;
1003
+ let handle_opt = handle . handle ( ) ;
1004
1004
1005
1005
// Whether to enable file DAX according to the value of dax_file_size
1006
1006
let mut attr_flags: u32 = 0 ;
@@ -1070,13 +1070,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
1070
1070
1071
1071
InodeMap :: insert_locked (
1072
1072
inodes. deref_mut ( ) ,
1073
- Arc :: new ( InodeData :: new (
1074
- inode,
1075
- file_or_handle,
1076
- 1 ,
1077
- id,
1078
- st. get_stat ( ) . st_mode ,
1079
- ) ) ,
1073
+ Arc :: new ( InodeData :: new ( inode, handle, 1 , id, st. get_stat ( ) . st_mode ) ) ,
1080
1074
) ;
1081
1075
inode
1082
1076
}
@@ -1510,7 +1504,7 @@ mod tests {
1510
1504
1511
1505
// Following test depends on host fs, it's not reliable.
1512
1506
//let data = fs.inode_map.get(c_entry.inode).unwrap();
1513
- //assert_eq!(matches!(data.file_or_handle, FileOrHandle ::Handle(_)), true);
1507
+ //assert_eq!(matches!(data.handle, InodeHandle ::Handle(_)), true);
1514
1508
1515
1509
let ( _, duration) = fs. getattr ( & ctx, c_entry. inode , None ) . unwrap ( ) ;
1516
1510
assert_eq ! ( duration, fs. cfg. attr_timeout) ;
@@ -1857,7 +1851,7 @@ mod tests {
1857
1851
let file = TempFile :: new ( ) . expect ( "Cannot create temporary file." ) ;
1858
1852
let mode = file. as_file ( ) . metadata ( ) . unwrap ( ) . mode ( ) ;
1859
1853
let inode_data =
1860
- InodeData :: new ( inode, FileOrHandle :: File ( file. into_file ( ) ) , 1 , id, mode) ;
1854
+ InodeData :: new ( inode, InodeHandle :: File ( file. into_file ( ) ) , 1 , id, mode) ;
1861
1855
m. insert ( Arc :: new ( inode_data) ) ;
1862
1856
let inode = fs. allocate_inode_locked ( & m, & id, None ) . unwrap ( ) ;
1863
1857
assert_eq ! ( inode & MAX_HOST_INO , 2 ) ;
0 commit comments