File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,9 @@ impl InodeTable {
165
165
lookups = entry. lookups ;
166
166
if lookups == 0 {
167
167
delete = true ;
168
- self . by_path . remove ( entry. path . as_ref ( ) . unwrap ( ) ) ;
168
+ if let Some ( path) = entry. path . as_ref ( ) {
169
+ self . by_path . remove ( path) ;
170
+ }
169
171
}
170
172
}
171
173
@@ -180,6 +182,12 @@ impl InodeTable {
180
182
/// Change an inode's path to a different one, without changing the inode number.
181
183
/// Lookup counts remain unchanged, even if this is replacing another file.
182
184
pub fn rename ( & mut self , oldpath : & Path , newpath : Arc < PathBuf > ) {
185
+ // unlink the new path from the previous inode holding it
186
+ // otherwise, when kernel signals to forget the replaced inode, the path is removed from the by_path table
187
+ if let Some ( dst) = self . by_path . remove ( Pathish :: new ( & newpath) ) {
188
+ self . table [ dst] . path = None ;
189
+ }
190
+
183
191
let idx = self . by_path . remove ( Pathish :: new ( oldpath) ) . unwrap ( ) ;
184
192
self . table [ idx] . path = Some ( newpath. clone ( ) ) ;
185
193
self . by_path . insert ( newpath, idx) ; // this can replace a path with a new inode
You can’t perform that action at this time.
0 commit comments