From 9be2cb0b2901f22165e55e68c7e87d4e0a6a5bec Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 25 Nov 2026 23:15:12 -0800 Subject: [PATCH] mount: retain a recorded handle path only once it matches the file A path read from the filer record was retained before the lookup checked it, so a stale one kept answering ESTALE without reading the record again. It is now retained right before LookupHandle, and never over a forgotten inode or path the table already holds. Co-Authored-By: Claude Opus 5.5 --- weed/mount/inode_to_path.go | 7 +++++-- weed/mount/weedfs_dir_lookup.go | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) 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)