From dbfb2e1a62a9981a67cc01ff7310981744ec2ac5 Mon Sep 17 00:00:00 2001 From: LI Qing Date: Wed, 9 Aug 2023 11:37:41 +0800 Subject: [PATCH] Fix the logic of cacheable flag for dentry --- services/libs/jinux-std/src/fs/utils/dentry.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/libs/jinux-std/src/fs/utils/dentry.rs b/services/libs/jinux-std/src/fs/utils/dentry.rs index 811940386..eac0cfa0e 100644 --- a/services/libs/jinux-std/src/fs/utils/dentry.rs +++ b/services/libs/jinux-std/src/fs/utils/dentry.rs @@ -531,9 +531,13 @@ impl Children { } pub fn insert_dentry(&mut self, dentry: &Arc) { - if dentry.vnode().is_dentry_cacheable() { - DCACHE.lock().insert(dentry.key(), dentry.clone()); + // Do not cache it in DCACHE and children if is not cacheable. + // When we look up it from the parent, it will always be newly created. + if !dentry.vnode().is_dentry_cacheable() { + return; } + + DCACHE.lock().insert(dentry.key(), dentry.clone()); self.inner.insert(dentry.name(), Arc::downgrade(dentry)); }