From 0f64f5b9c8bea153171c8070f423b9910820bbb1 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 4 Apr 2021 21:40:58 -0700 Subject: mount: add readOnly option fix https://github.com/chrislusf/seaweedfs/issues/1961 --- weed/filesys/dir_rename.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'weed/filesys/dir_rename.go') diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index d2acad4b2..28316c3bd 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -13,6 +13,10 @@ import ( func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirectory fs.Node) error { + if dir.wfs.option.ReadOnly { + return fuse.EPERM + } + newDir := newDirectory.(*Dir) newPath := util.NewFullPath(newDir.FullPath(), req.NewName) -- cgit v1.2.3 From 54410ca955cf4078684bca17b4363dc33ef433ed Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 18 Apr 2021 10:02:02 -0700 Subject: cleaner way to set readonly --- weed/filesys/dir_rename.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'weed/filesys/dir_rename.go') diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index 28316c3bd..d2acad4b2 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -13,10 +13,6 @@ import ( func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirectory fs.Node) error { - if dir.wfs.option.ReadOnly { - return fuse.EPERM - } - newDir := newDirectory.(*Dir) newPath := util.NewFullPath(newDir.FullPath(), req.NewName) -- cgit v1.2.3 From d9a2a7f1c4593c20ec9a92b98b726af7b32baff3 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 16 Apr 2021 02:55:09 -0700 Subject: WIP no memory issue if some directory is removed, it may have this error $ rm -Rf ~/tmp/m2/s1 rm: fts_read: Device not configured --- weed/filesys/dir_rename.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'weed/filesys/dir_rename.go') diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index d2acad4b2..7bc705102 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -64,19 +64,17 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector return fuse.EIO } - // fmt.Printf("rename path: %v => %v\n", oldPath, newPath) - dir.wfs.fsNodeCache.Move(oldPath, newPath) - // change file handle dir.wfs.handlesLock.Lock() defer dir.wfs.handlesLock.Unlock() inodeId := oldPath.AsInode() existingHandle, found := dir.wfs.handles[inodeId] if !found || existingHandle == nil { - return err + return nil } + glog.V(4).Infof("opened filehandle %s => %s", oldPath, newPath) delete(dir.wfs.handles, inodeId) dir.wfs.handles[newPath.AsInode()] = existingHandle - return err + return nil } -- cgit v1.2.3 From 6cbd786db9b96833248444c42992c239f2424d95 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 17 Apr 2021 10:48:22 -0700 Subject: correctly runs git clone --- weed/filesys/dir_rename.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'weed/filesys/dir_rename.go') diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index 7bc705102..b07710d17 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -64,11 +64,22 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector return fuse.EIO } + oldFsNode := NodeWithId(oldPath.AsInode()) + newFsNode := NodeWithId(newPath.AsInode()) + dir.wfs.Server.InvalidateInternalNode(oldFsNode, newFsNode, func(internalNode fs.Node) { + if file, ok := internalNode.(*File); ok { + glog.V(4).Infof("internal node %s", file.Name) + file.Name = req.NewName + file.id = uint64(newFsNode) + } + }) + // 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 } -- cgit v1.2.3