aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-07-08 19:07:03 -0700
committerchrislu <chris.lu@gmail.com>2022-07-08 19:07:03 -0700
commitd685b9410236553d1a23d10a7b8b7b6bfdc02ae0 (patch)
treedd16e4d23eb497930d7a20842dfae164c5410180
parent48382676d2765ae4facfc60e89b897247c711ef5 (diff)
downloadseaweedfs-d685b9410236553d1a23d10a7b8b7b6bfdc02ae0.tar.xz
seaweedfs-d685b9410236553d1a23d10a7b8b7b6bfdc02ae0.zip
mount: rename also invalidate source inode
-rw-r--r--weed/mount/inode_to_path.go4
-rw-r--r--weed/mount/weedfs_rename.go12
2 files changed, 11 insertions, 5 deletions
diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go
index fa17a9261..29635efca 100644
--- a/weed/mount/inode_to_path.go
+++ b/weed/mount/inode_to_path.go
@@ -152,7 +152,7 @@ func (i *InodeToPath) RemovePath(path util.FullPath) {
}
}
-func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedInode uint64) {
+func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (sourceInode, targetInode uint64) {
i.Lock()
defer i.Unlock()
sourceInode, sourceFound := i.path2inode[sourcePath]
@@ -178,7 +178,7 @@ func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedIn
} else {
glog.Errorf("MovePath %s to %s: sourceInode %d not found", sourcePath, targetPath, sourceInode)
}
- return targetInode
+ return
}
func (i *InodeToPath) Forget(inode, nlookup uint64, onForgetDir func(dir util.FullPath)) {
diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.go
index 23caa48cd..ef4ff55c2 100644
--- a/weed/mount/weedfs_rename.go
+++ b/weed/mount/weedfs_rename.go
@@ -233,10 +233,16 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR
oldPath := oldParent.Child(oldName)
newPath := newParent.Child(newName)
- replacedInode := wfs.inodeToPath.MovePath(oldPath, newPath)
+ sourceInode, targetInode := wfs.inodeToPath.MovePath(oldPath, newPath)
+ if sourceInode != 0 {
+ if fh := wfs.fhmap.inode2fh[sourceInode]; foundFh && fh.entry != nil {
+ fh.entry.Name = newName
+ }
+ wfs.fuseServer.InodeNotify(sourceInode, 0, -1)
+ }
// invalidate attr and data
- if replacedInode > 0 {
- wfs.fuseServer.InodeNotify(replacedInode, 0, -1)
+ if targetInode != 0 {
+ wfs.fuseServer.InodeNotify(targetInode, 0, -1)
}
} else if resp.EventNotification.OldEntry != nil {