Skip to content

Commit b1ab3d5

Browse files
zyfjeffjiangliu
authored andcommitted
Return parent inode when umount for inval dentry cache
umount returns the parent's inode information, so that it is convenient to call fuse's invali entry interface later to clarify the corresponding dentry cache Signed-off-by: zyfjeff <[email protected]>
1 parent ad0b9f2 commit b1ab3d5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/api/pseudo_fs.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ impl PseudoFs {
235235
self.inodes.store(Arc::new(hashmap));
236236
}
237237

238+
pub fn get_parent_inode(&self, ino: u64) -> Option<u64> {
239+
let _guard = self.lock.lock();
240+
let inodes = self.inodes.load();
241+
inodes.get(&ino).map(|o| o.parent)
242+
}
243+
238244
#[allow(dead_code)]
239245
pub fn evict_inode(&self, ino: u64) {
240246
let _guard = self.lock.lock();

src/api/vfs/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,21 @@ impl Vfs {
395395
}
396396

397397
/// Umount a backend file system at path
398-
pub fn umount(&self, path: &str) -> VfsResult<()> {
398+
pub fn umount(&self, path: &str) -> VfsResult<(u64, u64)> {
399399
// Serialize mount operations. Do not expect poisoned lock here.
400400
let _guard = self.lock.lock().unwrap();
401401
let inode = self
402402
.root
403403
.path_walk(path)
404404
.map_err(VfsError::PathWalk)?
405405
.ok_or_else(|| VfsError::NotFound(path.to_string()))?;
406-
406+
let parent = self
407+
.root
408+
.get_parent_inode(inode)
409+
.ok_or(VfsError::NotFound(format!(
410+
"{}'s parent inode does not exist",
411+
inode
412+
)))?;
407413
let mut mountpoints = self.mountpoints.load().deref().deref().clone();
408414
let fs_idx = mountpoints
409415
.get(&inode)
@@ -437,7 +443,7 @@ impl Vfs {
437443
}
438444
self.superblocks.store(Arc::new(superblocks));
439445

440-
Ok(())
446+
Ok((inode, parent))
441447
}
442448

443449
/// Get the mounted backend file system alongside the path if there's one.

0 commit comments

Comments
 (0)