diff options
Diffstat (limited to 'weed/mount/inode_to_path.go')
| -rw-r--r-- | weed/mount/inode_to_path.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go index 1e914dccd..1e2126b74 100644 --- a/weed/mount/inode_to_path.go +++ b/weed/mount/inode_to_path.go @@ -31,18 +31,20 @@ func NewInodeToPath() *InodeToPath { return t } -func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isCreate bool, possibleInode uint64, isLookup bool) uint64 { +func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isHardlink bool, possibleInode uint64, isLookup bool) uint64 { i.Lock() defer i.Unlock() inode, found := i.path2inode[path] if !found { if possibleInode == 0 { inode = path.AsInode(mode) + } else { + inode = possibleInode + } + if !isHardlink { for _, found := i.inode2path[inode]; found; inode++ { _, found = i.inode2path[inode] } - } else { - inode = possibleInode } } i.path2inode[path] = inode @@ -62,6 +64,19 @@ func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isCreate bool return inode } +func (i *InodeToPath) AllocateInode(path util.FullPath, mode os.FileMode) uint64 { + if path == "/" { + return 1 + } + i.Lock() + defer i.Unlock() + inode := path.AsInode(mode) + for _, found := i.inode2path[inode]; found; inode++ { + _, found = i.inode2path[inode] + } + return inode +} + func (i *InodeToPath) GetInode(path util.FullPath) uint64 { if path == "/" { return 1 @@ -172,7 +187,8 @@ func (i *InodeToPath) Forget(inode, nlookup uint64, onForgetDir func(dir util.Fu } i.Unlock() if found { - if path.isDirectory && onForgetDir != nil { + if path.isDirectory && path.nlookup <= 0 && onForgetDir != nil { + path.isChildrenCached = false onForgetDir(path.FullPath) } } |
