SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
mount: rename also clear the cache
Chris Lu2f15e9346696
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.goindex 95b26f4095..ac6291319d 100644--- a/weed/filesys/dir.go+++ b/weed/filesys/dir.go@@ -182,7 +182,7 @@ func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.glog.V(4).Infof("dir Lookup %s: %s", dir.Path, req.Name)var entry *filer_pb.Entry- fullFilePath := path.Join(dir.Path, req.Name)+ fullFilePath := string(filer2.NewFullPath(dir.Path, req.Name))item := dir.wfs.listDirectoryEntriesCache.Get(fullFilePath)if item != nil && !item.Expired() {@@ -233,7 +233,7 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) {cacheTtl := 5 * time.MinutereadErr := filer2.ReadDirAllEntries(ctx, dir.wfs, dir.Path, "", func(entry *filer_pb.Entry, isLast bool) {- fullpath := path.Join(dir.Path, entry.Name)+ fullpath := string(filer2.NewFullPath(dir.Path, entry.Name))inode := uint64(util.HashStringToLong(fullpath))if entry.IsDirectory {dirent := fuse.Dirent{Inode: inode, Name: entry.Name, Type: fuse.DT_Dir}@@ -295,7 +295,7 @@ func (dir *Dir) removeOneFile(ctx context.Context, req *fuse.RemoveRequest) errofunc (dir *Dir) removeFolder(ctx context.Context, req *fuse.RemoveRequest) error {- dir.wfs.listDirectoryEntriesCache.Delete(path.Join(dir.Path, req.Name))+ dir.wfs.listDirectoryEntriesCache.Delete(string(filer2.NewFullPath(dir.Path, req.Name)))return dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.goindex 7890d24d96..8309b238ab 100644--- a/weed/filesys/dir_rename.go+++ b/weed/filesys/dir_rename.go@@ -4,6 +4,7 @@ import ("context""fmt"+ "github.com/chrislusf/seaweedfs/weed/filer2""github.com/chrislusf/seaweedfs/weed/glog""github.com/chrislusf/seaweedfs/weed/pb/filer_pb""github.com/seaweedfs/fuse"@@ -15,7 +16,7 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirectornewDir := newDirectory.(*Dir)glog.V(4).Infof("dir Rename %s/%s => %s/%s", dir.Path, req.OldName, newDir.Path, req.NewName)- return dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {+ err := dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error {request := &filer_pb.AtomicRenameEntryRequest{OldDirectory: dir.Path,@@ -33,4 +34,12 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector})+ if err == nil {+ oldpath := string(filer2.NewFullPath(dir.Path, req.OldName))+ newpath := string(filer2.NewFullPath(newDir.Path, req.NewName))+ dir.wfs.listDirectoryEntriesCache.Delete(oldpath)+ dir.wfs.listDirectoryEntriesCache.Delete(newpath)+ }++ return err}diff --git a/weed/filesys/xattr.go b/weed/filesys/xattr.goindex 8857c33d6b..a81f74638a 100644--- a/weed/filesys/xattr.go+++ b/weed/filesys/xattr.go@@ -2,7 +2,6 @@ package filesysimport ("context"- "path/filepath""github.com/chrislusf/seaweedfs/weed/filer2""github.com/chrislusf/seaweedfs/weed/glog"@@ -110,7 +109,7 @@ func listxattr(entry *filer_pb.Entry, req *fuse.ListxattrRequest, resp *fuse.Lisfunc (wfs *WFS) maybeLoadEntry(ctx context.Context, dir, name string) (entry *filer_pb.Entry, err error) {- fullpath := filepath.Join(dir, name)+ fullpath := string(filer2.NewFullPath(dir, name))item := wfs.listDirectoryEntriesCache.Get(fullpath)if item != nil && !item.Expired() {entry = item.Value().(*filer_pb.Entry)