Skip to content

Commit 68df7ba

Browse files
zyfjefferyugey
authored andcommitted
fix by_id not free when use_host_ino=true
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>
1 parent 9faa6d2 commit 68df7ba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/passthrough/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
776776
if new == 0 {
777777
// We just removed the last refcount for this inode.
778778
// The allocated inode number should be kept in the map when use_host_ino
779-
// is false or inode is bigger than MAX_HOST_INO.
780-
let keep_mapping = !self.cfg.use_host_ino || inode > MAX_HOST_INO;
779+
// is false or host inode(don't use the virtual 56bit inode) is bigger than MAX_HOST_INO.
780+
let keep_mapping = !self.cfg.use_host_ino || data.id.ino > MAX_HOST_INO;
781781
inodes.remove(&inode, keep_mapping);
782782
}
783783
break;
@@ -1373,7 +1373,18 @@ mod tests {
13731373
fs.import().unwrap();
13741374
let entry = fs.lookup(&ctx, ROOT_ID, &child).unwrap();
13751375
assert_eq!(entry.inode & MAX_HOST_INO, meta.ino());
1376+
let inode_store = fs.inode_map.get_map_mut();
1377+
let inode_data = inode_store.get(&entry.inode).unwrap();
1378+
assert!(inode_store.inode_by_id(&inode_data.id).is_some());
1379+
let id = inode_data.id.clone();
1380+
drop(inode_store);
1381+
13761382
fs.forget(&ctx, entry.inode, 1);
1383+
let inode_store = fs.inode_map.get_map_mut();
1384+
assert!(inode_store.get(&entry.inode).is_none());
1385+
assert!(inode_store.inode_by_id(&id).is_none());
1386+
drop(inode_store);
1387+
13771388
let entry = fs.lookup(&ctx, ROOT_ID, &child).unwrap();
13781389
assert_eq!(entry.inode & MAX_HOST_INO, meta.ino());
13791390
}

0 commit comments

Comments
 (0)