Skip to content

Commit

Permalink
fix by_id not free when use_host_ino=true
Browse files Browse the repository at this point in the history
When use_host_ino mode is turned on, we only need to save the by_id
relationship if the host inode of the file is larger than MAX_HOST_INO,
and don't remove it. however, the previous code used a virtual inode
combining the host inode, dev, mnt, and other parts of the file,
and this inode is a 56bit inode, which is always larger than MAX_HOST_INO,
and so it resulted in the by_id relationship not being cleaned up.

Signed-off-by: zyfjeff <zyfjeff@linux.alibaba.com>
  • Loading branch information
zyfjeff authored and eryugey committed Mar 27, 2024
1 parent 9faa6d2 commit 68df7ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/passthrough/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,8 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
if new == 0 {
// We just removed the last refcount for this inode.
// The allocated inode number should be kept in the map when use_host_ino
// is false or inode is bigger than MAX_HOST_INO.
let keep_mapping = !self.cfg.use_host_ino || inode > MAX_HOST_INO;
// is false or host inode(don't use the virtual 56bit inode) is bigger than MAX_HOST_INO.
let keep_mapping = !self.cfg.use_host_ino || data.id.ino > MAX_HOST_INO;
inodes.remove(&inode, keep_mapping);
}
break;
Expand Down Expand Up @@ -1373,7 +1373,18 @@ mod tests {
fs.import().unwrap();
let entry = fs.lookup(&ctx, ROOT_ID, &child).unwrap();
assert_eq!(entry.inode & MAX_HOST_INO, meta.ino());
let inode_store = fs.inode_map.get_map_mut();
let inode_data = inode_store.get(&entry.inode).unwrap();
assert!(inode_store.inode_by_id(&inode_data.id).is_some());
let id = inode_data.id.clone();
drop(inode_store);

fs.forget(&ctx, entry.inode, 1);
let inode_store = fs.inode_map.get_map_mut();
assert!(inode_store.get(&entry.inode).is_none());
assert!(inode_store.inode_by_id(&id).is_none());
drop(inode_store);

let entry = fs.lookup(&ctx, ROOT_ID, &child).unwrap();
assert_eq!(entry.inode & MAX_HOST_INO, meta.ino());
}
Expand Down

0 comments on commit 68df7ba

Please sign in to comment.