aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-07-03 02:59:35 -0700
committerChris Lu <chris.lu@gmail.com>2021-07-03 02:59:35 -0700
commitfa0dab60299e73acfb8bca72b50184722db8e3ab (patch)
tree487d5ee618c79689c5d05e5a1258016e841134f0 /weed/filesys
parent8fe75692ee9adaae3c2fc0a735ae4d8a172d97ae (diff)
downloadseaweedfs-fa0dab60299e73acfb8bca72b50184722db8e3ab.tar.xz
seaweedfs-fa0dab60299e73acfb8bca72b50184722db8e3ab.zip
mount: rename also recursively move file handles
related to https://github.com/chrislusf/seaweedfs/issues/2169
Diffstat (limited to 'weed/filesys')
-rw-r--r--weed/filesys/dir_rename.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go
index 27a14d5c6..f69339a14 100644
--- a/weed/filesys/dir_rename.go
+++ b/weed/filesys/dir_rename.go
@@ -63,18 +63,6 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
return fuse.EIO
}
- // change file handle
- dir.wfs.handlesLock.Lock()
- defer dir.wfs.handlesLock.Unlock()
- inodeId := oldPath.AsInode()
- existingHandle, found := dir.wfs.handles[inodeId]
- glog.V(4).Infof("has open filehandle %s: %v", oldPath, found)
- if !found || existingHandle == nil {
- return nil
- }
- glog.V(4).Infof("opened filehandle %s => %s", oldPath, newPath)
- delete(dir.wfs.handles, inodeId)
- dir.wfs.handles[newPath.AsInode()] = existingHandle
return nil
}
@@ -83,10 +71,12 @@ func (dir *Dir) moveEntry(ctx context.Context, oldParent util.FullPath, entry *f
oldName := entry.Name()
+ oldPath := oldParent.Child(oldName)
+ newPath := newParent.Child(newName)
if err := dir.moveSelfEntry(ctx, oldParent, entry, newParent, newName, func() error {
- oldFsNode := NodeWithId(oldParent.Child(oldName).AsInode())
- newFsNode := NodeWithId(newParent.Child(newName).AsInode())
+ oldFsNode := NodeWithId(oldPath.AsInode())
+ newFsNode := NodeWithId(newPath.AsInode())
newDirNode, found := dir.wfs.Server.FindInternalNode(NodeWithId(newParent.AsInode()))
var newDir *Dir
if found {
@@ -111,6 +101,16 @@ func (dir *Dir) moveEntry(ctx context.Context, oldParent util.FullPath, entry *f
}
})
+ // change file handle
+ inodeId := oldPath.AsInode()
+ dir.wfs.handlesLock.Lock()
+ if existingHandle, found := dir.wfs.handles[inodeId]; found && existingHandle == nil {
+ glog.V(4).Infof("opened file handle %s => %s", oldPath, newPath)
+ delete(dir.wfs.handles, inodeId)
+ dir.wfs.handles[newPath.AsInode()] = existingHandle
+ }
+ dir.wfs.handlesLock.Unlock()
+
if entry.IsDirectory() {
if err := dir.moveFolderSubEntries(ctx, oldParent, oldName, newParent, newName); err != nil {
return err
@@ -118,7 +118,7 @@ func (dir *Dir) moveEntry(ctx context.Context, oldParent util.FullPath, entry *f
}
return nil
}); err != nil {
- return fmt.Errorf("fail to move %s => %s: %v", oldParent.Child(oldName), newParent.Child(newName), err)
+ return fmt.Errorf("fail to move %s => %s: %v", oldPath, newPath, err)
}
return nil