count lookup or not

This commit is contained in:
chrislu
2022-02-16 16:49:03 -08:00
parent a129bda7d9
commit 6ac066d1dc
6 changed files with 14 additions and 8 deletions

View File

@@ -30,7 +30,7 @@ func NewInodeToPath() *InodeToPath {
return t
}
func (i *InodeToPath) Lookup(path util.FullPath, isDirectory bool) uint64 {
func (i *InodeToPath) Lookup(path util.FullPath, isDirectory bool, isLookup bool) uint64 {
i.Lock()
defer i.Unlock()
inode, found := i.path2inode[path]
@@ -38,9 +38,15 @@ func (i *InodeToPath) Lookup(path util.FullPath, isDirectory bool) uint64 {
inode = i.nextInodeId
i.nextInodeId++
i.path2inode[path] = inode
i.inode2path[inode] = &InodeEntry{path, 1, isDirectory, false}
if !isLookup {
i.inode2path[inode] = &InodeEntry{path, 0, isDirectory, false}
} else {
i.inode2path[inode] = &InodeEntry{path, 1, isDirectory, false}
}
} else {
i.inode2path[inode].nlookup++
if isLookup {
i.inode2path[inode].nlookup++
}
}
return inode
}