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: cache on reading remote storage
Chris Lu69655ba8e56c
diff --git a/weed/filesys/file.go b/weed/filesys/file.goindex 7f021619cb..b990b20d1c 100644--- a/weed/filesys/file.go+++ b/weed/filesys/file.go@@ -360,3 +360,30 @@ func (file *File) saveEntry(entry *filer_pb.Entry) error {func (file *File) getEntry() *filer_pb.Entry {return file.entry}++func (file *File) downloadRemoteEntry(entry *filer_pb.Entry) (*filer_pb.Entry, error) {+ err := file.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {++ request := &filer_pb.DownloadToLocalRequest{+ Directory: file.dir.FullPath(),+ Name: entry.Name,+ }++ glog.V(4).Infof("download entry: %v", request)+ resp, err := client.DownloadToLocal(context.Background(), request)+ if err != nil {+ glog.Errorf("DownloadToLocal file %s/%s: %v", file.dir.FullPath(), file.Name, err)+ return fuse.EIO+ }++ entry = resp.Entry++ file.wfs.metaCache.InsertEntry(context.Background(), filer.FromPbEntry(request.Directory, resp.Entry))++ file.dirtyMetadata = false++ return nil+ })++ return entry, err+}diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.goindex 9acede3308..5cd7ca948a 100644--- a/weed/filesys/filehandle.go+++ b/weed/filesys/filehandle.go@@ -114,6 +114,16 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {return 0, io.EOF}+ if entry.IsInRemoteOnly() {+ glog.V(4).Infof("download remote entry %s", fh.f.fullpath())+ newEntry, err := fh.f.downloadRemoteEntry(entry)+ if err != nil {+ glog.V(1).Infof("download remote entry %s: %v", fh.f.fullpath(), err)+ return 0, err+ }+ entry = newEntry+ }+fileSize := int64(filer.FileSize(entry))fileFullPath := fh.f.fullpath()diff --git a/weed/pb/filer_pb/filer_pb_helper.go b/weed/pb/filer_pb/filer_pb_helper.goindex ae282db755..7480d469ac 100644--- a/weed/pb/filer_pb/filer_pb_helper.go+++ b/weed/pb/filer_pb/filer_pb_helper.go@@ -12,6 +12,10 @@ import ("github.com/viant/ptrie")+func (entry *Entry) IsInRemoteOnly() bool {+ return len(entry.Chunks) == 0 && entry.RemoteEntry != nil && entry.RemoteEntry.RemoteSize > 0+}+func ToFileIdObject(fileIdStr string) (*FileId, error) {t, err := needle.ParseFileIdFromString(fileIdStr)if err != nil {diff --git a/weed/server/filer_grpc_server_remote.go b/weed/server/filer_grpc_server_remote.goindex 9cd3c296ba..2cbfd33195 100644--- a/weed/server/filer_grpc_server_remote.go+++ b/weed/server/filer_grpc_server_remote.go@@ -155,7 +155,7 @@ func (fs *FilerServer) DownloadToLocal(ctx context.Context, req *filer_pb.Downlofs.filer.NotifyUpdateEvent(ctx, entry, newEntry, true, false, nil)- resp.Entry = entry.ToProtoEntry()+ resp.Entry = newEntry.ToProtoEntry()return resp, nil