From 41eeb4deef02eb7981e01dcba9b6e8469d7fed38 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 23 Jul 2022 13:37:07 -0700 Subject: [PATCH] do not add new inode during link --- weed/mount/inode_to_path.go | 18 ++++++++++++++++++ weed/mount/weedfs_link.go | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go index 39733a1fe..6118d51cf 100644 --- a/weed/mount/inode_to_path.go +++ b/weed/mount/inode_to_path.go @@ -163,6 +163,24 @@ func (i *InodeToPath) HasInode(inode uint64) bool { return found } +func (i *InodeToPath) AddPath(inode uint64, path util.FullPath) { + i.Lock() + defer i.Unlock() + i.path2inode[path] = inode + + ie, found := i.inode2path[inode] + if found { + ie.paths = append(ie.paths, path) + } else { + i.inode2path[inode] = &InodeEntry{ + paths: []util.FullPath{path}, + nlookup: 1, + isDirectory: false, + isChildrenCached: false, + } + } +} + func (i *InodeToPath) RemovePath(path util.FullPath) { i.Lock() defer i.Unlock() diff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.go index 2ab412fd5..56c89dabe 100644 --- a/weed/mount/weedfs_link.go +++ b/weed/mount/weedfs_link.go @@ -102,9 +102,9 @@ func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out * return fuse.EIO } - inode := wfs.inodeToPath.Lookup(newEntryPath, oldEntry.Attributes.Crtime, oldEntry.IsDirectory, true, oldEntry.Attributes.Inode, true) + wfs.inodeToPath.AddPath(oldEntry.Attributes.Inode, newEntryPath) - wfs.outputPbEntry(out, inode, request.Entry) + wfs.outputPbEntry(out, oldEntry.Attributes.Inode, request.Entry) return fuse.OK }