diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go index 19a8efd64b..286fa66287 100644 --- a/weed/mount/inode_to_path.go +++ b/weed/mount/inode_to_path.go @@ -203,16 +203,19 @@ func (i *InodeToPath) moveForgotten(sourcePath, targetPath util.FullPath) bool { } // RememberForgotten retains path as that of a forgotten inode, one an earlier -// mount handed out, unless the inode is live. +// mount handed out, unless the table already knows the inode or the path. func (i *InodeToPath) RememberForgotten(inode uint64, path util.FullPath) { i.Lock() defer i.Unlock() - if i.forgotten == nil { + if i.forgotten == nil || i.forgotten.Contains(inode) { return } if _, live := i.inode2path[inode]; live { return } + if _, taken := i.forgottenInodes[path]; taken { + return + } i.forgotten.Add(inode, path) i.forgottenInodes[path] = inode } diff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.go index 78821a13f8..2460211def 100644 --- a/weed/mount/weedfs_dir_lookup.go +++ b/weed/mount/weedfs_dir_lookup.go @@ -58,7 +58,11 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strin } inode := possibleInode if name == "." { - if !sameFile(inode, fullFilePath, localEntry) || !wfs.inodeToPath.LookupHandle(fullFilePath, inode, localEntry.IsDirectory()) { + if !sameFile(inode, fullFilePath, localEntry) { + return fuse.Status(syscall.ESTALE) + } + wfs.inodeToPath.RememberForgotten(inode, fullFilePath) + if !wfs.inodeToPath.LookupHandle(fullFilePath, inode, localEntry.IsDirectory()) { return fuse.Status(syscall.ESTALE) } } else { @@ -103,7 +107,6 @@ func (wfs *WFS) resolveDotName(ctx context.Context, nodeId uint64, name string) if !forgotten.IsUnder(util.FullPath(wfs.option.FilerMountRootPath)) { return "", 0, fuse.Status(syscall.ESTALE) } - wfs.inodeToPath.RememberForgotten(nodeId, forgotten) } if inode, known := wfs.inodeToPath.GetInode(forgotten); known && inode != nodeId { return "", 0, fuse.Status(syscall.ESTALE)