Skip to content

Commit ad0b9f2

Browse files
zyfjeffjiangliu
authored andcommitted
Add remove_pseudo_root option to remove all inode when umount
In order to make the hot upgrade of virtiofs easy, VFS will save pseudo inodes when umount for easy recovery. However, in the fuse scenario, if umount does not remove the pseudo inode, it will cause an invalid directory to be seen on the host, which is not friendly to users. So add this option to control this behavior. Signed-off-by: zyfjeff <[email protected]>
1 parent 1de5a18 commit ad0b9f2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/api/vfs/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ pub struct Vfs {
292292
opts: ArcSwap<VfsOptions>,
293293
initialized: AtomicBool,
294294
lock: Mutex<()>,
295+
remove_pseudo_root: bool,
295296
}
296297

297298
impl Default for Vfs {
@@ -311,9 +312,15 @@ impl Vfs {
311312
opts: ArcSwap::new(Arc::new(opts)),
312313
lock: Mutex::new(()),
313314
initialized: AtomicBool::new(false),
315+
remove_pseudo_root: false,
314316
}
315317
}
316318

319+
/// mark remove pseudo root inode when umount
320+
pub fn set_remove_pseudo_root(&mut self) {
321+
self.remove_pseudo_root = true;
322+
}
323+
317324
/// For sake of live-upgrade, only after negotiation is done, it's safe to persist
318325
/// state of vfs.
319326
pub fn initialized(&self) -> bool {
@@ -406,7 +413,14 @@ impl Vfs {
406413
// 1. they can be reused later on
407414
// 2. during live upgrade, it is easier reconstruct pseudofs inodes since
408415
// we do not have to track pseudofs deletions
409-
//self.root.evict_inode(inode);
416+
// In order to make the hot upgrade of virtiofs easy, VFS will save pseudo
417+
// inodes when umount for easy recovery. However, in the fuse scenario, if
418+
// umount does not remove the pseudo inode, it will cause an invalid
419+
// directory to be seen on the host, which is not friendly to users. So add
420+
// this option to control this behavior.
421+
if self.remove_pseudo_root {
422+
self.root.evict_inode(inode);
423+
}
410424
mountpoints.remove(&inode);
411425
self.mountpoints.store(Arc::new(mountpoints));
412426
x.fs_idx

0 commit comments

Comments
 (0)