implement stable unique inode for passthroughfs#131
implement stable unique inode for passthroughfs#131bergwolf merged 1 commit intocloud-hypervisor:masterfrom
Conversation
1d6ee78 to
8b6c7b2
Compare
src/passthrough/mod.rs
Outdated
| }; | ||
|
|
||
| if unique_inode.ino > MAX_HOST_INO { | ||
| if unique_inode.ino > (MAX_HOST_INO * 2) { |
There was a problem hiding this comment.
In case that unique_inode.ino is bigger than MAX_HOST_INO, we need another allocator for ino, just like UniqueInodeGenerator.
|
Forget does not delete the internal inode state, in this way can also ensure a stable inode, but it requires some memory overhead, 100w different files occupy 60M |
src/passthrough/inode_store.rs
Outdated
| // safe to unwrap, inode must be in data map if found by ids, otherwise unwrap on | ||
| // corruption. | ||
| self.inode_by_ids(ids).map(|inode| self.get(inode).unwrap()) | ||
| match self.inode_by_ids(ids) { |
There was a problem hiding this comment.
Can this be simplified as
let inode = self.inode_by_ids(ids)?;
self.get(inode)
There was a problem hiding this comment.
using map?
self.inode_by_ids(ids).map(|id| self.get(id))
There was a problem hiding this comment.
self.inode_by_ids(ids).map(|id| self.get(id)) don't work, self.get(id) return a another Option, not a value
src/passthrough/inode_store.rs
Outdated
| // safe to unwrap, inode must be in data map if found by ids, otherwise unwrap on | ||
| // corruption. | ||
| self.inode_by_ids(ids).map(|inode| self.get(inode).unwrap()) | ||
| match self.inode_by_ids(ids) { |
There was a problem hiding this comment.
using map?
self.inode_by_ids(ids).map(|id| self.get(id))
| /// it should be noted that the returned host inode will be stored in the lower 47bits, | ||
| /// and for inodes over 47bits, virtual inode will be used instead. | ||
| /// The default value for this option is `false`. | ||
| pub use_host_ino: bool, |
There was a problem hiding this comment.
Why do we need to control this behavior when it has known issues to return the host inode?
There was a problem hiding this comment.
The default implementation is the same as before, allocating a virtual inode at a time, but now when forgetting, it is not removed from memory to ensure consistency. The second way is to use host inode to encode, mainly because the internal hot upgrade will be more complicated under the two inode encoding methods, so the default implementation is retained.
There was a problem hiding this comment.
use_host_ino and libfuse's use_ino options are similar
https://manpages.debian.org/testing/fuse/mount.fuse.8.en.html#use_ino
In the current passthroughfs implementation, temporary inodes are allocated and then stored in memory, But a FORGET request causes the inode to be removed from memory, new anodes are reassigned, resulting in the instability of the inodes of a file. this PR implements a stable inode, Limited by the current implementation limitations of VFS, Host inode + mnt + dev needs to be controlled in 56bit, and it is not supported beyond the range. Signed-off-by: zyfjeff <zyfjeff@linux.alibaba.com>
In the current passthroughfs implementation, temporary inodes are allocated and then stored in memory, But a FORGET request causes the inode to be removed from memory, new inodes are reassigned, resulting in the instability of the inodes of a file. this PR implements a stable inode, Limited by the current implementation limitations of VFS, Host inode + mnt + dev needs to be controlled in 56bit, and it is not supported beyond the range.