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
added context to filer_client method calls (#6808)
Aleksey Kosov165af32d6b73
diff --git a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.goindex 2b63d5d592..0544e5f2bf 100644--- a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go+++ b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go@@ -1,18 +1,19 @@package mainimport (+ "context""flag""fmt""github.com/seaweedfs/seaweedfs/weed/glog""github.com/seaweedfs/seaweedfs/weed/pb""github.com/seaweedfs/seaweedfs/weed/pb/filer_pb""github.com/seaweedfs/seaweedfs/weed/util"+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http""google.golang.org/grpc""google.golang.org/grpc/credentials/insecure""strconv""strings""time"- util_http "github.com/seaweedfs/seaweedfs/weed/util/http")var (@@ -60,7 +61,7 @@ func startGenerateMetadata() {for i := 0; i < *n; i++ {name := fmt.Sprintf("file%d", i)glog.V(0).Infof("write %s/%s", *dir, name)- if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ if err := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: *dir,Entry: &filer_pb.Entry{Name: name,diff --git a/weed/command/filer_cat.go b/weed/command/filer_cat.goindex ba3625b0d4..2c0f84ddc5 100644--- a/weed/command/filer_cat.go+++ b/weed/command/filer_cat.go@@ -102,7 +102,7 @@ func runFilerCat(cmd *Command, args []string) bool {Name: name,Directory: dir,}- respLookupEntry, err := filer_pb.LookupEntry(client, request)+ respLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, request)if err != nil {return err}diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.goindex 9b195e4e80..547e46c4f0 100644--- a/weed/command/filer_copy.go+++ b/weed/command/filer_copy.go@@ -394,7 +394,7 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err},}- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {return fmt.Errorf("update fh: %v", err)}return nil@@ -511,7 +511,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,},}- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {return fmt.Errorf("update fh: %v", err)}return nildiff --git a/weed/command/filer_remote_gateway_buckets.go b/weed/command/filer_remote_gateway_buckets.goindex f6fe9a99c0..aa38691715 100644--- a/weed/command/filer_remote_gateway_buckets.go+++ b/weed/command/filer_remote_gateway_buckets.go@@ -1,6 +1,7 @@package commandimport (+ "context""fmt""github.com/seaweedfs/seaweedfs/weed/filer""github.com/seaweedfs/seaweedfs/weed/glog"@@ -408,7 +409,7 @@ func (option *RemoteGatewayOptions) collectRemoteStorageConf() (err error) {option.remoteConfs = make(map[string]*remote_pb.RemoteConf)var lastConfName string- err = filer_pb.List(option, filer.DirectoryEtcRemote, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.List(context.Background(), option, filer.DirectoryEtcRemote, "", func(entry *filer_pb.Entry, isLast bool) error {if !strings.HasSuffix(entry.Name, filer.REMOTE_STORAGE_CONF_SUFFIX) {return nil}diff --git a/weed/command/filer_remote_sync_dir.go b/weed/command/filer_remote_sync_dir.goindex 186523e452..c85ba03af2 100644--- a/weed/command/filer_remote_sync_dir.go+++ b/weed/command/filer_remote_sync_dir.go@@ -230,7 +230,7 @@ func collectLastSyncOffset(filerClient filer_pb.FilerClient, grpcDialOption grpc// 3. directory creation timevar lastOffsetTs time.Timeif timeAgo == 0 {- mountedDirEntry, err := filer_pb.GetEntry(filerClient, util.FullPath(mountedDir))+ mountedDirEntry, err := filer_pb.GetEntry(context.Background(), filerClient, util.FullPath(mountedDir))if err != nil {glog.V(0).Infof("get mounted directory %s: %v", mountedDir, err)return time.Now()diff --git a/weed/command/mount_std.go b/weed/command/mount_std.goindex f00daba8a3..631091e80a 100644--- a/weed/command/mount_std.go+++ b/weed/command/mount_std.go@@ -255,7 +255,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {// create mount rootmountRootPath := util.FullPath(mountRoot)mountRootParent, mountDir := mountRootPath.DirAndName()- if err = filer_pb.Mkdir(seaweedFileSystem, mountRootParent, mountDir, nil); err != nil {+ if err = filer_pb.Mkdir(context.Background(), seaweedFileSystem, mountRootParent, mountDir, nil); err != nil {fmt.Printf("failed to create dir %s on filer %s: %v\n", mountRoot, filerAddresses, err)return false}diff --git a/weed/filer/read_write.go b/weed/filer/read_write.goindex dc4f3d0d8a..66f4c0bf8a 100644--- a/weed/filer/read_write.go+++ b/weed/filer/read_write.go@@ -2,6 +2,7 @@ package filerimport ("bytes"+ "context""time""github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"@@ -14,7 +15,7 @@ func ReadEntry(masterClient *wdclient.MasterClient, filerClient filer_pb.SeaweedDirectory: dir,Name: name,}- respLookupEntry, err := filer_pb.LookupEntry(filerClient, request)+ respLookupEntry, err := filer_pb.LookupEntry(context.Background(), filerClient, request)if err != nil {return err}@@ -32,7 +33,7 @@ func ReadInsideFiler(filerClient filer_pb.SeaweedFilerClient, dir, name string)Directory: dir,Name: name,}- respLookupEntry, err := filer_pb.LookupEntry(filerClient, request)+ respLookupEntry, err := filer_pb.LookupEntry(context.Background(), filerClient, request)if err != nil {return}@@ -42,13 +43,13 @@ func ReadInsideFiler(filerClient filer_pb.SeaweedFilerClient, dir, name string)func SaveInsideFiler(client filer_pb.SeaweedFilerClient, dir, name string, content []byte) error {- resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{+ resp, err := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{Directory: dir,Name: name,})if err == filer_pb.ErrNotFound {- err = filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ err = filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: dir,Entry: &filer_pb.Entry{Name: name,@@ -68,7 +69,7 @@ func SaveInsideFiler(client filer_pb.SeaweedFilerClient, dir, name string, conteentry.Content = contententry.Attributes.Mtime = time.Now().Unix()entry.Attributes.FileSize = uint64(len(content))- err = filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{+ err = filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{Directory: dir,Entry: entry,})diff --git a/weed/mount/meta_cache/meta_cache_init.go b/weed/mount/meta_cache/meta_cache_init.goindex 1cab499e04..068daa3f91 100644--- a/weed/mount/meta_cache/meta_cache_init.go+++ b/weed/mount/meta_cache/meta_cache_init.go@@ -44,7 +44,7 @@ func doEnsureVisited(mc *MetaCache, client filer_pb.FilerClient, path util.FullPglog.V(4).Infof("ReadDirAllEntries %s ...", path)err := util.Retry("ReadDirAllEntries", func() error {- return filer_pb.ReadDirAllEntries(client, path, "", func(pbEntry *filer_pb.Entry, isLast bool) error {+ return filer_pb.ReadDirAllEntries(context.Background(), client, path, "", func(pbEntry *filer_pb.Entry, isLast bool) error {entry := filer.FromPbEntry(string(path), pbEntry)if IsHiddenSystemEntry(string(path), entry.Name()) {return nildiff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.goindex 7fc10ef28f..7af989b808 100644--- a/weed/mount/weedfs_dir_lookup.go+++ b/weed/mount/weedfs_dir_lookup.go@@ -41,7 +41,7 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strinif localEntry == nil {// glog.V(3).Infof("dir Lookup cache miss %s", fullFilePath)- entry, err := filer_pb.GetEntry(wfs, fullFilePath)+ entry, err := filer_pb.GetEntry(context.Background(), wfs, fullFilePath)if err != nil {glog.V(1).Infof("dir GetEntry %s: %v", fullFilePath, err)return fuse.ENOENTdiff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.goindex e69c9796ef..503d6a0767 100644--- a/weed/mount/weedfs_dir_mkrm.go+++ b/weed/mount/weedfs_dir_mkrm.go@@ -63,7 +63,7 @@ func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out}glog.V(1).Infof("mkdir: %v", request)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {glog.V(0).Infof("mkdir %s: %v", entryFullPath, err)return err}@@ -107,7 +107,7 @@ func (wfs *WFS) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name stringglog.V(3).Infof("remove directory: %v", entryFullPath)ignoreRecursiveErr := true // ignore recursion error since the OS should manage it- err := filer_pb.Remove(wfs, string(dirFullPath), name, true, false, ignoreRecursiveErr, false, []int32{wfs.signature})+ err := filer_pb.Remove(context.Background(), wfs, string(dirFullPath), name, true, false, ignoreRecursiveErr, false, []int32{wfs.signature})if err != nil {glog.V(0).Infof("remove %s: %v", entryFullPath, err)if strings.Contains(err.Error(), filer.MsgFailDelNonEmptyFolder) {diff --git a/weed/mount/weedfs_file_mkrm.go b/weed/mount/weedfs_file_mkrm.goindex e6139e88ee..e48d5af406 100644--- a/weed/mount/weedfs_file_mkrm.go+++ b/weed/mount/weedfs_file_mkrm.go@@ -83,7 +83,7 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out}glog.V(1).Infof("mknod: %v", request)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {glog.V(0).Infof("mknod %s: %v", entryFullPath, err)return err}@@ -137,7 +137,7 @@ func (wfs *WFS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name strin// first, ensure the filer store can correctly deleteglog.V(3).Infof("remove file: %v", entryFullPath)isDeleteData := entry != nil && entry.HardLinkCounter <= 1- err := filer_pb.Remove(wfs, string(dirFullPath), name, isDeleteData, false, false, false, []int32{wfs.signature})+ err := filer_pb.Remove(context.Background(), wfs, string(dirFullPath), name, isDeleteData, false, false, false, []int32{wfs.signature})if err != nil {glog.V(0).Infof("remove %s: %v", entryFullPath, err)return fuse.OKdiff --git a/weed/mount/weedfs_file_sync.go b/weed/mount/weedfs_file_sync.goindex e13ab198d6..541270ff5d 100644--- a/weed/mount/weedfs_file_sync.go+++ b/weed/mount/weedfs_file_sync.go@@ -159,7 +159,7 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {wfs.mapPbIdFromLocalToFiler(request.Entry)defer wfs.mapPbIdFromFilerToLocal(request.Entry)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {glog.Errorf("fh flush create %s: %v", fileFullPath, err)return fmt.Errorf("fh flush create %s: %v", fileFullPath, err)}diff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.goindex 8c5b67ce21..344b907b41 100644--- a/weed/mount/weedfs_link.go+++ b/weed/mount/weedfs_link.go@@ -88,12 +88,12 @@ func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *wfs.mapPbIdFromLocalToFiler(request.Entry)defer wfs.mapPbIdFromFilerToLocal(request.Entry)- if err := filer_pb.UpdateEntry(client, updateOldEntryRequest); err != nil {+ if err := filer_pb.UpdateEntry(context.Background(), client, updateOldEntryRequest); err != nil {return err}wfs.metaCache.UpdateEntry(context.Background(), filer.FromPbEntry(updateOldEntryRequest.Directory, updateOldEntryRequest.Entry))- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {return err}diff --git a/weed/mount/weedfs_symlink.go b/weed/mount/weedfs_symlink.goindex 8842ec3e6e..80081c31c6 100644--- a/weed/mount/weedfs_symlink.go+++ b/weed/mount/weedfs_symlink.go@@ -53,7 +53,7 @@ func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target stwfs.mapPbIdFromLocalToFiler(request.Entry)defer wfs.mapPbIdFromFilerToLocal(request.Entry)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {return fmt.Errorf("symlink %s: %v", entryFullPath, err)}diff --git a/weed/mq/broker/broker_write.go b/weed/mq/broker/broker_write.goindex 9999529fbd..9f3c7b50f2 100644--- a/weed/mq/broker/broker_write.go+++ b/weed/mq/broker/broker_write.go@@ -1,6 +1,7 @@package brokerimport (+ "context""fmt""github.com/seaweedfs/seaweedfs/weed/filer""github.com/seaweedfs/seaweedfs/weed/operation"@@ -20,7 +21,7 @@ func (b *MessageQueueBroker) appendToFile(targetFile string, data []byte) error// find out existing entryfullpath := util.FullPath(targetFile)dir, name := fullpath.DirAndName()- entry, err := filer_pb.GetEntry(b, fullpath)+ entry, err := filer_pb.GetEntry(context.Background(), b, fullpath)var offset int64 = 0if err == filer_pb.ErrNotFound {entry = &filer_pb.Entry{@@ -45,7 +46,7 @@ func (b *MessageQueueBroker) appendToFile(targetFile string, data []byte) error// update the entryreturn b.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- return filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ return filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: dir,Entry: entry,})diff --git a/weed/mq/logstore/log_to_parquet.go b/weed/mq/logstore/log_to_parquet.goindex 30cad8cc16..b2ee2ae00d 100644--- a/weed/mq/logstore/log_to_parquet.go+++ b/weed/mq/logstore/log_to_parquet.go@@ -1,6 +1,7 @@package logstoreimport (+ "context""encoding/binary""fmt""github.com/parquet-go/parquet-go"@@ -50,7 +51,7 @@ func CompactTopicPartitions(filerClient filer_pb.FilerClient, t topic.Topic, tim}func collectTopicVersions(filerClient filer_pb.FilerClient, t topic.Topic, timeAgo time.Duration) (partitionVersions []time.Time, err error) {- err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(t.Dir()), "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(t.Dir()), "", func(entry *filer_pb.Entry, isLast bool) error {t, err := topic.ParseTopicVersion(entry.Name)if err != nil {// skip non-partition directories@@ -66,7 +67,7 @@ func collectTopicVersions(filerClient filer_pb.FilerClient, t topic.Topic, timeAfunc collectTopicVersionsPartitions(filerClient filer_pb.FilerClient, t topic.Topic, topicVersion time.Time) (partitions []topic.Partition, err error) {version := topicVersion.Format(topic.PartitionGenerationFormat)- err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(t.Dir()).Child(version), "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(t.Dir()).Child(version), "", func(entry *filer_pb.Entry, isLast bool) error {if !entry.IsDirectory {return nil}@@ -151,7 +152,7 @@ func groupFilesBySize(logFiles []*filer_pb.Entry, maxGroupSize int64) (logFileGr}func readAllLogFiles(filerClient filer_pb.FilerClient, partitionDir string, timeAgo time.Duration, minTsNs, maxTsNs int64) (logFiles []*filer_pb.Entry, err error) {- err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(partitionDir), "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(partitionDir), "", func(entry *filer_pb.Entry, isLast bool) error {if strings.HasSuffix(entry.Name, ".parquet") {return nil}@@ -173,7 +174,7 @@ func readAllLogFiles(filerClient filer_pb.FilerClient, partitionDir string, time}func readAllParquetFiles(filerClient filer_pb.FilerClient, partitionDir string) (minTsNs, maxTsNs int64, err error) {- err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(partitionDir), "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(partitionDir), "", func(entry *filer_pb.Entry, isLast bool) error {if !strings.HasSuffix(entry.Name, ".parquet") {return nil}@@ -354,7 +355,7 @@ func saveParquetFileToPartitionDir(filerClient filer_pb.FilerClient, sourceFile// write the entry to partitionDirif err := filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- return filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ return filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: partitionDir,Entry: entry,})diff --git a/weed/mq/logstore/read_log_from_disk.go b/weed/mq/logstore/read_log_from_disk.goindex 71ba58c1f0..2c8a7c1dea 100644--- a/weed/mq/logstore/read_log_from_disk.go+++ b/weed/mq/logstore/read_log_from_disk.go@@ -1,6 +1,7 @@package logstoreimport (+ "context""fmt""github.com/seaweedfs/seaweedfs/weed/filer""github.com/seaweedfs/seaweedfs/weed/glog"@@ -113,7 +114,7 @@ func GenLogOnDiskReadFunc(filerClient filer_pb.FilerClient, t topic.Topic, p topstopTime := time.Unix(0, stopTsNs)var processedTsNs int64err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- return filer_pb.SeaweedList(client, partitionDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ return filer_pb.SeaweedList(context.Background(), client, partitionDir, "", func(entry *filer_pb.Entry, isLast bool) error {if entry.IsDirectory {return nil}diff --git a/weed/mq/logstore/read_parquet_to_log.go b/weed/mq/logstore/read_parquet_to_log.goindex 4811d6c806..6c69b9f129 100644--- a/weed/mq/logstore/read_parquet_to_log.go+++ b/weed/mq/logstore/read_parquet_to_log.go@@ -1,6 +1,7 @@package logstoreimport (+ "context""encoding/binary""fmt""github.com/parquet-go/parquet-go"@@ -115,7 +116,7 @@ func GenParquetReadFunc(filerClient filer_pb.FilerClient, t topic.Topic, p topicerr = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- return filer_pb.SeaweedList(client, partitionDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ return filer_pb.SeaweedList(context.Background(), client, partitionDir, "", func(entry *filer_pb.Entry, isLast bool) error {if entry.IsDirectory {return nil}diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.goindex 35cea71b3a..60a7c637cb 100644--- a/weed/pb/filer_pb/filer_client.go+++ b/weed/pb/filer_pb/filer_client.go@@ -20,12 +20,12 @@ var ()type FilerClient interface {- WithFilerClient(streamingMode bool, fn func(SeaweedFilerClient) error) error+ WithFilerClient(streamingMode bool, fn func(SeaweedFilerClient) error) error // 15 implementationAdjustedUrl(location *Location) stringGetDataCenter() string}-func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry, err error) {+func GetEntry(ctx context.Context, filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry, err error) {dir, name := fullFilePath.DirAndName()@@ -37,7 +37,7 @@ func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry}// glog.V(3).Infof("read %s request: %v", fullFilePath, request)- resp, err := LookupEntry(client, request)+ resp, err := LookupEntry(ctx, client, request)if err != nil {glog.V(3).Infof("read %s %v: %v", fullFilePath, resp, err)return err@@ -57,7 +57,7 @@ func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entrytype EachEntryFunction func(entry *Entry, isLast bool) error-func ReadDirAllEntries(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction) (err error) {+func ReadDirAllEntries(ctx context.Context, filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction) (err error) {var counter uint32var startFrom string@@ -69,13 +69,13 @@ func ReadDirAllEntries(filerClient FilerClient, fullDirPath util.FullPath, prefivar paginationLimit uint32 = 10000- if err = doList(filerClient, fullDirPath, prefix, counterFunc, "", false, paginationLimit); err != nil {+ if err = doList(ctx, filerClient, fullDirPath, prefix, counterFunc, "", false, paginationLimit); err != nil {return err}for counter == paginationLimit {counter = 0- if err = doList(filerClient, fullDirPath, prefix, counterFunc, startFrom, false, paginationLimit); err != nil {+ if err = doList(ctx, filerClient, fullDirPath, prefix, counterFunc, startFrom, false, paginationLimit); err != nil {return err}}@@ -83,23 +83,23 @@ func ReadDirAllEntries(filerClient FilerClient, fullDirPath util.FullPath, prefireturn nil}-func List(filerClient FilerClient, parentDirectoryPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {+func List(ctx context.Context, filerClient FilerClient, parentDirectoryPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {- return doSeaweedList(client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)+ return doSeaweedList(ctx, client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)})}-func doList(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {+func doList(ctx context.Context, filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {- return doSeaweedList(client, fullDirPath, prefix, fn, startFrom, inclusive, limit)+ return doSeaweedList(ctx, client, fullDirPath, prefix, fn, startFrom, inclusive, limit)})}-func SeaweedList(client SeaweedFilerClient, parentDirectoryPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {- return doSeaweedList(client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)+func SeaweedList(ctx context.Context, client SeaweedFilerClient, parentDirectoryPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {+ return doSeaweedList(ctx, client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)}-func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {+func doSeaweedList(ctx context.Context, client SeaweedFilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunction, startFrom string, inclusive bool, limit uint32) (err error) {// Redundancy limit to make it correctly judge whether it is the last file.redLimit := limit@@ -118,7 +118,7 @@ func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix}glog.V(4).Infof("read directory: %v", request)- ctx, cancel := context.WithCancel(context.Background())+ ctx, cancel := context.WithCancel(ctx)defer cancel()stream, err := client.ListEntries(ctx, request)if err != nil {@@ -156,7 +156,7 @@ func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefixreturn nil}-func Exists(filerClient FilerClient, parentDirectoryPath string, entryName string, isDirectory bool) (exists bool, err error) {+func Exists(ctx context.Context, filerClient FilerClient, parentDirectoryPath string, entryName string, isDirectory bool) (exists bool, err error) {err = filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {@@ -166,7 +166,7 @@ func Exists(filerClient FilerClient, parentDirectoryPath string, entryName strin}glog.V(4).Infof("exists entry %v/%v: %v", parentDirectoryPath, entryName, request)- resp, err := LookupEntry(client, request)+ resp, err := LookupEntry(ctx, client, request)if err != nil {if err == ErrNotFound {exists = false@@ -184,7 +184,7 @@ func Exists(filerClient FilerClient, parentDirectoryPath string, entryName strinreturn}-func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string, entry *Entry) (err error) {+func Touch(ctx context.Context, filerClient FilerClient, parentDirectoryPath string, entryName string, entry *Entry) (err error) {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {@@ -194,7 +194,7 @@ func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string}glog.V(4).Infof("touch entry %v/%v: %v", parentDirectoryPath, entryName, request)- if err := UpdateEntry(client, request); err != nil {+ if err := UpdateEntry(ctx, client, request); err != nil {glog.V(0).Infof("touch exists entry %v: %v", request, err)return fmt.Errorf("touch exists entry %s/%s: %v", parentDirectoryPath, entryName, err)}@@ -204,13 +204,13 @@ func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string}-func Mkdir(filerClient FilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {+func Mkdir(ctx context.Context, filerClient FilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {- return DoMkdir(client, parentDirectoryPath, dirName, fn)+ return DoMkdir(ctx, client, parentDirectoryPath, dirName, fn)})}-func DoMkdir(client SeaweedFilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {+func DoMkdir(ctx context.Context, client SeaweedFilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {entry := &Entry{Name: dirName,IsDirectory: true,@@ -233,7 +233,7 @@ func DoMkdir(client SeaweedFilerClient, parentDirectoryPath string, dirName stri}glog.V(1).Infof("mkdir: %v", request)- if err := CreateEntry(client, request); err != nil {+ if err := CreateEntry(ctx, client, request); err != nil {glog.V(0).Infof("mkdir %v: %v", request, err)return fmt.Errorf("mkdir %s/%s: %v", parentDirectoryPath, dirName, err)}@@ -241,7 +241,7 @@ func DoMkdir(client SeaweedFilerClient, parentDirectoryPath string, dirName strireturn nil}-func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk, fn func(entry *Entry)) error {+func MkFile(ctx context.Context, filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk, fn func(entry *Entry)) error {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {entry := &Entry{@@ -267,7 +267,7 @@ func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string}glog.V(1).Infof("create file: %s/%s", parentDirectoryPath, fileName)- if err := CreateEntry(client, request); err != nil {+ if err := CreateEntry(ctx, client, request); err != nil {glog.V(0).Infof("create file %v:%v", request, err)return fmt.Errorf("create file %s/%s: %v", parentDirectoryPath, fileName, err)}@@ -276,13 +276,13 @@ func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string})}-func Remove(filerClient FilerClient, parentDirectoryPath, name string, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster bool, signatures []int32) error {+func Remove(ctx context.Context, filerClient FilerClient, parentDirectoryPath, name string, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster bool, signatures []int32) error {return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {- return DoRemove(client, parentDirectoryPath, name, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster, signatures)+ return DoRemove(ctx, client, parentDirectoryPath, name, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster, signatures)})}-func DoRemove(client SeaweedFilerClient, parentDirectoryPath string, name string, isDeleteData bool, isRecursive bool, ignoreRecursiveErr bool, isFromOtherCluster bool, signatures []int32) error {+func DoRemove(ctx context.Context, client SeaweedFilerClient, parentDirectoryPath string, name string, isDeleteData bool, isRecursive bool, ignoreRecursiveErr bool, isFromOtherCluster bool, signatures []int32) error {deleteEntryRequest := &DeleteEntryRequest{Directory: parentDirectoryPath,Name: name,@@ -292,7 +292,7 @@ func DoRemove(client SeaweedFilerClient, parentDirectoryPath string, name stringIsFromOtherCluster: isFromOtherCluster,Signatures: signatures,}- if resp, err := client.DeleteEntry(context.Background(), deleteEntryRequest); err != nil {+ if resp, err := client.DeleteEntry(ctx, deleteEntryRequest); err != nil {if strings.Contains(err.Error(), ErrNotFound.Error()) {return nil}diff --git a/weed/pb/filer_pb/filer_client_bfs.go b/weed/pb/filer_pb/filer_client_bfs.goindex e434437063..55d492aca1 100644--- a/weed/pb/filer_pb/filer_client_bfs.go+++ b/weed/pb/filer_pb/filer_client_bfs.go@@ -52,7 +52,7 @@ func TraverseBfs(filerClient FilerClient, parentPath util.FullPath, fn func(parefunc processOneDirectory(filerClient FilerClient, parentPath util.FullPath, queue *util.Queue[util.FullPath], jobQueueWg *sync.WaitGroup, fn func(parentPath util.FullPath, entry *Entry)) (err error) {- return ReadDirAllEntries(filerClient, parentPath, "", func(entry *Entry, isLast bool) error {+ return ReadDirAllEntries(context.Background(), filerClient, parentPath, "", func(entry *Entry, isLast bool) error {fn(parentPath, entry)diff --git a/weed/pb/filer_pb/filer_pb_helper.go b/weed/pb/filer_pb/filer_pb_helper.goindex 0ec31420ce..b45d999ad0 100644--- a/weed/pb/filer_pb/filer_pb_helper.go+++ b/weed/pb/filer_pb/filer_pb_helper.go@@ -108,8 +108,8 @@ func AfterEntryDeserialization(chunks []*FileChunk) {}}-func CreateEntry(client SeaweedFilerClient, request *CreateEntryRequest) error {- resp, err := client.CreateEntry(context.Background(), request)+func CreateEntry(ctx context.Context, client SeaweedFilerClient, request *CreateEntryRequest) error {+ resp, err := client.CreateEntry(ctx, request)if err != nil {glog.V(1).Infof("create entry %s/%s %v: %v", request.Directory, request.Entry.Name, request.OExcl, err)return fmt.Errorf("CreateEntry: %v", err)@@ -121,8 +121,8 @@ func CreateEntry(client SeaweedFilerClient, request *CreateEntryRequest) error {return nil}-func UpdateEntry(client SeaweedFilerClient, request *UpdateEntryRequest) error {- _, err := client.UpdateEntry(context.Background(), request)+func UpdateEntry(ctx context.Context, client SeaweedFilerClient, request *UpdateEntryRequest) error {+ _, err := client.UpdateEntry(ctx, request)if err != nil {glog.V(1).Infof("update entry %s/%s :%v", request.Directory, request.Entry.Name, err)return fmt.Errorf("UpdateEntry: %v", err)@@ -130,8 +130,8 @@ func UpdateEntry(client SeaweedFilerClient, request *UpdateEntryRequest) error {return nil}-func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) {- resp, err := client.LookupDirectoryEntry(context.Background(), request)+func LookupEntry(ctx context.Context, client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) {+ resp, err := client.LookupDirectoryEntry(ctx, request)if err != nil {if err == ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) {return nil, ErrNotFounddiff --git a/weed/replication/sink/filersink/filer_sink.go b/weed/replication/sink/filersink/filer_sink.goindex 49f6877a05..2254ca2f70 100644--- a/weed/replication/sink/filersink/filer_sink.go+++ b/weed/replication/sink/filersink/filer_sink.go@@ -95,7 +95,7 @@ func (fs *FilerSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bodir, name := util.FullPath(key).DirAndName()glog.V(4).Infof("delete entry: %v", key)- err := filer_pb.Remove(fs, dir, name, deleteIncludeChunks, true, true, true, signatures)+ err := filer_pb.Remove(context.Background(), fs, dir, name, deleteIncludeChunks, true, true, true, signatures)if err != nil {glog.V(0).Infof("delete entry %s: %v", key, err)return fmt.Errorf("delete entry %s: %v", key, err)@@ -115,7 +115,7 @@ func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry, signatures [Name: name,}// glog.V(1).Infof("lookup: %v", lookupRequest)- if resp, err := filer_pb.LookupEntry(client, lookupRequest); err == nil {+ if resp, err := filer_pb.LookupEntry(context.Background(), client, lookupRequest); err == nil {if filer.ETag(resp.Entry) == filer.ETag(entry) {glog.V(3).Infof("already replicated %s", key)return nil@@ -152,7 +152,7 @@ func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry, signatures [}glog.V(3).Infof("create: %v", request)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {glog.V(0).Infof("create entry %s: %v", key, err)return fmt.Errorf("create entry %s: %v", key, err)}@@ -175,7 +175,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent}glog.V(4).Infof("lookup entry: %v", request)- resp, err := filer_pb.LookupEntry(client, request)+ resp, err := filer_pb.LookupEntry(context.Background(), client, request)if err != nil {glog.V(0).Infof("lookup %s: %v", key, err)return errdiff --git a/weed/s3api/bucket_metadata.go b/weed/s3api/bucket_metadata.goindex d1f487104e..a65fe54045 100644--- a/weed/s3api/bucket_metadata.go+++ b/weed/s3api/bucket_metadata.go@@ -1,6 +1,7 @@package s3apiimport (+ "context""encoding/json""github.com/aws/aws-sdk-go/service/s3""github.com/seaweedfs/seaweedfs/weed/glog"@@ -13,7 +14,7 @@ import ()var loadBucketMetadataFromFiler = func(r *BucketRegistry, bucketName string) (*BucketMetaData, error) {- entry, err := filer_pb.GetEntry(r.s3a, util.NewFullPath(r.s3a.option.BucketsPath, bucketName))+ entry, err := filer_pb.GetEntry(context.Background(), r.s3a, util.NewFullPath(r.s3a.option.BucketsPath, bucketName))if err != nil {return nil, err}@@ -64,7 +65,7 @@ func NewBucketRegistry(s3a *S3ApiServer) *BucketRegistry {}func (r *BucketRegistry) init() error {- err := filer_pb.List(r.s3a, r.s3a.option.BucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {+ err := filer_pb.List(context.Background(), r.s3a, r.s3a.option.BucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {r.LoadBucketMetadata(entry)return nil}, "", false, math.MaxUint32)diff --git a/weed/s3api/filer_util.go b/weed/s3api/filer_util.goindex 8ae8f780ad..38400140fe 100644--- a/weed/s3api/filer_util.go+++ b/weed/s3api/filer_util.go@@ -11,19 +11,19 @@ import (func (s3a *S3ApiServer) mkdir(parentDirectoryPath string, dirName string, fn func(entry *filer_pb.Entry)) error {- return filer_pb.Mkdir(s3a, parentDirectoryPath, dirName, fn)+ return filer_pb.Mkdir(context.Background(), s3a, parentDirectoryPath, dirName, fn)}func (s3a *S3ApiServer) mkFile(parentDirectoryPath string, fileName string, chunks []*filer_pb.FileChunk, fn func(entry *filer_pb.Entry)) error {- return filer_pb.MkFile(s3a, parentDirectoryPath, fileName, chunks, fn)+ return filer_pb.MkFile(context.Background(), s3a, parentDirectoryPath, fileName, chunks, fn)}func (s3a *S3ApiServer) list(parentDirectoryPath, prefix, startFrom string, inclusive bool, limit uint32) (entries []*filer_pb.Entry, isLast bool, err error) {- err = filer_pb.List(s3a, parentDirectoryPath, prefix, func(entry *filer_pb.Entry, isLastEntry bool) error {+ err = filer_pb.List(context.Background(), s3a, parentDirectoryPath, prefix, func(entry *filer_pb.Entry, isLastEntry bool) error {entries = append(entries, entry)if isLastEntry {isLast = true@@ -76,19 +76,19 @@ func doDeleteEntry(client filer_pb.SeaweedFilerClient, parentDirectoryPath strinfunc (s3a *S3ApiServer) exists(parentDirectoryPath string, entryName string, isDirectory bool) (exists bool, err error) {- return filer_pb.Exists(s3a, parentDirectoryPath, entryName, isDirectory)+ return filer_pb.Exists(context.Background(), s3a, parentDirectoryPath, entryName, isDirectory)}func (s3a *S3ApiServer) touch(parentDirectoryPath string, entryName string, entry *filer_pb.Entry) (err error) {- return filer_pb.Touch(s3a, parentDirectoryPath, entryName, entry)+ return filer_pb.Touch(context.Background(), s3a, parentDirectoryPath, entryName, entry)}func (s3a *S3ApiServer) getEntry(parentDirectoryPath, entryName string) (entry *filer_pb.Entry, err error) {fullPath := util.NewFullPath(parentDirectoryPath, entryName)- return filer_pb.GetEntry(s3a, fullPath)+ return filer_pb.GetEntry(context.Background(), s3a, fullPath)}func (s3a *S3ApiServer) updateEntry(parentDirectoryPath string, newEntry *filer_pb.Entry) error {@@ -98,7 +98,7 @@ func (s3a *S3ApiServer) updateEntry(parentDirectoryPath string, newEntry *filer_}err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- err := filer_pb.UpdateEntry(client, updateEntryRequest)+ err := filer_pb.UpdateEntry(context.Background(), client, updateEntryRequest)if err != nil {return err}diff --git a/weed/s3api/filer_util_tags.go b/weed/s3api/filer_util_tags.goindex c2bdc72944..d33e46c2e5 100644--- a/weed/s3api/filer_util_tags.go+++ b/weed/s3api/filer_util_tags.go@@ -1,6 +1,7 @@package s3apiimport (+ "context""github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants""strings"@@ -15,7 +16,7 @@ func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (terr = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{+ resp, err := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{Directory: parentDirectoryPath,Name: entryName,})@@ -37,7 +38,7 @@ func (s3a *S3ApiServer) setTags(parentDirectoryPath string, entryName string, tareturn s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{+ resp, err := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{Directory: parentDirectoryPath,Name: entryName,})@@ -58,7 +59,7 @@ func (s3a *S3ApiServer) setTags(parentDirectoryPath string, entryName string, taresp.Entry.Extended[S3TAG_PREFIX+k] = []byte(v)}- return filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{+ return filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{Directory: parentDirectoryPath,Entry: resp.Entry,IsFromOtherCluster: false,@@ -73,7 +74,7 @@ func (s3a *S3ApiServer) rmTags(parentDirectoryPath string, entryName string) (erreturn s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{+ resp, err := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{Directory: parentDirectoryPath,Name: entryName,})@@ -93,7 +94,7 @@ func (s3a *S3ApiServer) rmTags(parentDirectoryPath string, entryName string) (erreturn nil}- return filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{+ return filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{Directory: parentDirectoryPath,Entry: resp.Entry,IsFromOtherCluster: false,diff --git a/weed/s3api/s3api_object_handlers_list.go b/weed/s3api/s3api_object_handlers_list.goindex 6a4740fefe..5233b7c302 100644--- a/weed/s3api/s3api_object_handlers_list.go+++ b/weed/s3api/s3api_object_handlers_list.go@@ -471,7 +471,7 @@ func (s3a *S3ApiServer) ensureDirectoryAllEmpty(filerClient filer_pb.SeaweedFilevar isExhausted boolvar foundEntry boolfor fileCounter == 0 && !isExhausted && err == nil {- err = filer_pb.SeaweedList(filerClient, currentDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.SeaweedList(context.Background(), filerClient, currentDir, "", func(entry *filer_pb.Entry, isLast bool) error {foundEntry = trueif entry.IsOlderDir() {subDirs = append(subDirs, entry.Name)diff --git a/weed/s3api/s3api_object_handlers_multipart.go b/weed/s3api/s3api_object_handlers_multipart.goindex dfd9f58448..ccad9d942c 100644--- a/weed/s3api/s3api_object_handlers_multipart.go+++ b/weed/s3api/s3api_object_handlers_multipart.go@@ -93,7 +93,6 @@ func (s3a *S3ApiServer) CompleteMultipartUploadHandler(w http.ResponseWriter, r}stats_collect.RecordBucketActiveTime(bucket)stats_collect.S3UploadedObjectsCounter.WithLabelValues(bucket).Inc()-writeSuccessResponseXML(w, r, response)}diff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.goindex dbe6dfed54..2b7493ee68 100644--- a/weed/server/webdav_server.go+++ b/weed/server/webdav_server.go@@ -209,7 +209,7 @@ func (fs *WebDavFileSystem) Mkdir(ctx context.Context, fullDirPath string, perm}glog.V(1).Infof("mkdir: %v", request)- if err := filer_pb.CreateEntry(client, request); err != nil {+ if err := filer_pb.CreateEntry(context.Background(), client, request); err != nil {return fmt.Errorf("mkdir %s/%s: %v", dir, name, err)}@@ -240,7 +240,7 @@ func (fs *WebDavFileSystem) OpenFile(ctx context.Context, fullFilePath string, fdir, name := util.FullPath(fullFilePath).DirAndName()err = fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {- if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ if err := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: dir,Entry: &filer_pb.Entry{Name: name,@@ -299,7 +299,7 @@ func (fs *WebDavFileSystem) removeAll(ctx context.Context, fullFilePath string)dir, name := util.FullPath(fullFilePath).DirAndName()- return filer_pb.Remove(fs, dir, name, true, false, false, false, []int32{fs.signature})+ return filer_pb.Remove(context.Background(), fs, dir, name, true, false, false, false, []int32{fs.signature})}@@ -371,7 +371,7 @@ func (fs *WebDavFileSystem) stat(ctx context.Context, fullFilePath string) (os.Ffullpath := util.FullPath(fullFilePath)var fi FileInfo- entry, err := filer_pb.GetEntry(fs, fullpath)+ entry, err := filer_pb.GetEntry(context.Background(), fs, fullpath)if err != nil {if err == filer_pb.ErrNotFound {return nil, os.ErrNotExist@@ -452,7 +452,7 @@ func (f *WebDavFile) Write(buf []byte) (int, error) {var getErr errorctx := context.Background()if f.entry == nil {- f.entry, getErr = filer_pb.GetEntry(f.fs, fullPath)+ f.entry, getErr = filer_pb.GetEntry(context.Background(), f.fs, fullPath)}if f.entry == nil {@@ -543,7 +543,7 @@ func (f *WebDavFile) Read(p []byte) (readSize int, err error) {glog.V(2).Infof("WebDavFileSystem.Read %v", f.name)if f.entry == nil {- f.entry, err = filer_pb.GetEntry(f.fs, util.FullPath(f.name))+ f.entry, err = filer_pb.GetEntry(context.Background(), f.fs, util.FullPath(f.name))}if f.entry == nil {return 0, err@@ -583,7 +583,7 @@ func (f *WebDavFile) Readdir(count int) (ret []os.FileInfo, err error) {dir, _ := util.FullPath(f.name).DirAndName()- err = filer_pb.ReadDirAllEntries(f.fs, util.FullPath(dir), "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), f.fs, util.FullPath(dir), "", func(entry *filer_pb.Entry, isLast bool) error {fi := FileInfo{size: int64(filer.FileSize(entry)),name: entry.Name,diff --git a/weed/sftpd/sftp_filer.go b/weed/sftpd/sftp_filer.goindex dbe6a438d9..4cc709390a 100644--- a/weed/sftpd/sftp_filer.go+++ b/weed/sftpd/sftp_filer.go@@ -322,7 +322,7 @@ func (fs *SftpServer) makeDir(r *sftp.Request) error {return err}// default mode and ownership- err := filer_pb.Mkdir(fs, string(dir), name, func(entry *filer_pb.Entry) {+ err := filer_pb.Mkdir(context.Background(), fs, string(dir), name, func(entry *filer_pb.Entry) {mode := uint32(0755 | os.ModeDir)if strings.HasPrefix(r.Filepath, fs.user.HomeDir) {mode = uint32(0700 | os.ModeDir)diff --git a/weed/sftpd/user/homemanager.go b/weed/sftpd/user/homemanager.goindex c9051939cf..c0e29ca73b 100644--- a/weed/sftpd/user/homemanager.go+++ b/weed/sftpd/user/homemanager.go@@ -104,7 +104,7 @@ func (hm *HomeManager) createSingleDirectory(dirPath string, user *User) error {// Directory doesn't exist, create itglog.V(0).Infof("Creating directory %s for user %s", dirPath, user.Username)- err = filer_pb.Mkdir(hm, string(dir), name, func(entry *filer_pb.Entry) {+ err = filer_pb.Mkdir(context.Background(), hm, string(dir), name, func(entry *filer_pb.Entry) {// Set appropriate permissionsentry.Attributes.FileMode = uint32(0700 | os.ModeDir) // rwx------ for userentry.Attributes.Uid = user.Uiddiff --git a/weed/shell/command_fs_cat.go b/weed/shell/command_fs_cat.goindex 47a7f3be88..cf1395a2f8 100644--- a/weed/shell/command_fs_cat.go+++ b/weed/shell/command_fs_cat.go@@ -1,6 +1,7 @@package shellimport (+ "context""fmt""github.com/seaweedfs/seaweedfs/weed/filer""github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"@@ -49,7 +50,7 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.WriteName: name,Directory: dir,}- respLookupEntry, err := filer_pb.LookupEntry(client, request)+ respLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, request)if err != nil {return err}diff --git a/weed/shell/command_fs_du.go b/weed/shell/command_fs_du.goindex c35179f88f..456f6bab63 100644--- a/weed/shell/command_fs_du.go+++ b/weed/shell/command_fs_du.go@@ -1,6 +1,7 @@package shellimport (+ "context""fmt""io"@@ -58,7 +59,7 @@ func (c *commandFsDu) Do(args []string, commandEnv *CommandEnv, writer io.Writerfunc duTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dir, name string) (blockCount, byteCount uint64, err error) {- err = filer_pb.ReadDirAllEntries(filerClient, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error {var fileBlockCount, fileByteCount uint64diff --git a/weed/shell/command_fs_log.go b/weed/shell/command_fs_log.goindex e6b7a6f9ad..66f143030e 100644--- a/weed/shell/command_fs_log.go+++ b/weed/shell/command_fs_log.go@@ -1,6 +1,7 @@package shellimport (+ "context""flag""fmt""github.com/seaweedfs/seaweedfs/weed/filer"@@ -41,11 +42,11 @@ func (c *commandFsLogPurge) Do(args []string, commandEnv *CommandEnv, writer io.}modificationTimeAgo := time.Now().Add(-time.Hour * 24 * time.Duration(*daysAgo)).Unix()- err = filer_pb.ReadDirAllEntries(commandEnv, filer.SystemLogDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), commandEnv, filer.SystemLogDir, "", func(entry *filer_pb.Entry, isLast bool) error {if entry.Attributes.Mtime > modificationTimeAgo {return nil}- if errDel := filer_pb.Remove(commandEnv, filer.SystemLogDir, entry.Name, true, true, true, false, nil); errDel != nil {+ if errDel := filer_pb.Remove(context.Background(), commandEnv, filer.SystemLogDir, entry.Name, true, true, true, false, nil); errDel != nil {return errDel}if *verbose {diff --git a/weed/shell/command_fs_ls.go b/weed/shell/command_fs_ls.goindex e007b4c9ef..442702693b 100644--- a/weed/shell/command_fs_ls.go+++ b/weed/shell/command_fs_ls.go@@ -1,6 +1,7 @@package shellimport (+ "context""fmt""io""os"@@ -66,7 +67,7 @@ func (c *commandFsLs) Do(args []string, commandEnv *CommandEnv, writer io.Writerdir, name := util.FullPath(path).DirAndName()entryCount := 0- err = filer_pb.ReadDirAllEntries(commandEnv, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), commandEnv, util.FullPath(dir), name, func(entry *filer_pb.Entry, isLast bool) error {if !showHidden && strings.HasPrefix(entry.Name, ".") {return nildiff --git a/weed/shell/command_fs_merge_volumes.go b/weed/shell/command_fs_merge_volumes.goindex 31d9d62943..f31ec10f4d 100644--- a/weed/shell/command_fs_merge_volumes.go+++ b/weed/shell/command_fs_merge_volumes.go@@ -134,7 +134,7 @@ func (c *commandFsMergeVolumes) Do(args []string, commandEnv *CommandEnv, writercontinue}- if err = filer_pb.UpdateEntry(filerClient, &filer_pb.UpdateEntryRequest{+ if err = filer_pb.UpdateEntry(context.Background(), filerClient, &filer_pb.UpdateEntryRequest{Directory: string(parentPath),Entry: entry,}); err != nil {diff --git a/weed/shell/command_fs_meta_cat.go b/weed/shell/command_fs_meta_cat.goindex e47d8faa60..2abb4d2b96 100644--- a/weed/shell/command_fs_meta_cat.go+++ b/weed/shell/command_fs_meta_cat.go@@ -1,6 +1,7 @@package shellimport (+ "context""fmt""github.com/seaweedfs/seaweedfs/weed/filer""google.golang.org/protobuf/proto"@@ -49,7 +50,7 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.WName: name,Directory: dir,}- respLookupEntry, err := filer_pb.LookupEntry(client, request)+ respLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, request)if err != nil {return err}diff --git a/weed/shell/command_fs_meta_change_volume_id.go b/weed/shell/command_fs_meta_change_volume_id.goindex f1c148f5bd..167d642887 100644--- a/weed/shell/command_fs_meta_change_volume_id.go+++ b/weed/shell/command_fs_meta_change_volume_id.go@@ -1,6 +1,7 @@package shellimport (+ "context""flag""fmt""github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"@@ -86,7 +87,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv,if hasChanges {println("Updating", parentPath, entry.Name)if *isForce {- if updateErr := filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{+ if updateErr := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{Directory: string(parentPath),Entry: entry,}); updateErr != nil {diff --git a/weed/shell/command_fs_meta_load.go b/weed/shell/command_fs_meta_load.goindex d56274362b..f43574f499 100644--- a/weed/shell/command_fs_meta_load.go+++ b/weed/shell/command_fs_meta_load.go@@ -1,6 +1,7 @@package shellimport (+ "context""flag""fmt""io"@@ -117,7 +118,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.fullEntry.Entry.Name = strings.ReplaceAll(fullEntry.Entry.Name, "/", "x")if fullEntry.Entry.IsDirectory {wg.Wait()- if errEntry := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ if errEntry := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: fullEntry.Dir,Entry: fullEntry.Entry,}); errEntry != nil {@@ -128,7 +129,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.wg.Add(1)waitChan <- struct{}{}go func(entry *filer_pb.FullEntry) {- if errEntry := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ if errEntry := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: entry.Dir,Entry: entry.Entry,}); errEntry != nil {diff --git a/weed/shell/command_fs_mv.go b/weed/shell/command_fs_mv.goindex cb966571c4..2d44e4b586 100644--- a/weed/shell/command_fs_mv.go+++ b/weed/shell/command_fs_mv.go@@ -65,7 +65,7 @@ func (c *commandFsMv) Do(args []string, commandEnv *CommandEnv, writer io.WriterName: destinationDir,Directory: destinationName,}- respDestinationLookupEntry, err := filer_pb.LookupEntry(client, destinationRequest)+ respDestinationLookupEntry, err := filer_pb.LookupEntry(context.Background(), client, destinationRequest)var targetDir, targetName stringdiff --git a/weed/shell/command_fs_rm.go b/weed/shell/command_fs_rm.goindex 0af75f048d..2e3f191216 100644--- a/weed/shell/command_fs_rm.go+++ b/weed/shell/command_fs_rm.go@@ -74,7 +74,7 @@ func (c *commandFsRm) Do(args []string, commandEnv *CommandEnv, writer io.WriterDirectory: targetDir,Name: targetName,}- _, err = filer_pb.LookupEntry(client, lookupRequest)+ _, err = filer_pb.LookupEntry(context.Background(), client, lookupRequest)if err != nil {fmt.Fprintf(writer, "rm: %s: %v\n", targetPath, err)continuediff --git a/weed/shell/command_fs_tree.go b/weed/shell/command_fs_tree.goindex 21e352af25..628c95b302 100644--- a/weed/shell/command_fs_tree.go+++ b/weed/shell/command_fs_tree.go@@ -1,6 +1,7 @@package shellimport (+ "context""fmt""io""strings"@@ -55,7 +56,7 @@ func treeTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dprefix.addMarker(level)- err = filer_pb.ReadDirAllEntries(filerClient, dir, name, func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, dir, name, func(entry *filer_pb.Entry, isLast bool) error {if level < 0 && name != "" {if entry.Name != name {return nildiff --git a/weed/shell/command_remote_cache.go b/weed/shell/command_remote_cache.goindex da19af0cf0..987502c140 100644--- a/weed/shell/command_remote_cache.go+++ b/weed/shell/command_remote_cache.go@@ -1,6 +1,7 @@package shellimport (+ "context""flag""fmt""github.com/seaweedfs/seaweedfs/weed/filer"@@ -100,7 +101,7 @@ func (c *commandRemoteCache) doCacheOneDirectory(commandEnv *CommandEnv, writerfunc recursivelyTraverseDirectory(filerClient filer_pb.FilerClient, dirPath util.FullPath, visitEntry func(dir util.FullPath, entry *filer_pb.Entry) bool) (err error) {- err = filer_pb.ReadDirAllEntries(filerClient, dirPath, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.ReadDirAllEntries(context.Background(), filerClient, dirPath, "", func(entry *filer_pb.Entry, isLast bool) error {if entry.IsDirectory {if !visitEntry(dirPath, entry) {return nildiff --git a/weed/shell/command_remote_configure.go b/weed/shell/command_remote_configure.goindex dbc44c8bfe..aa2f3d1d4b 100644--- a/weed/shell/command_remote_configure.go+++ b/weed/shell/command_remote_configure.go@@ -141,7 +141,7 @@ func (c *commandRemoteConfigure) Do(args []string, commandEnv *CommandEnv, writefunc (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandEnv, writer io.Writer) error {- return filer_pb.ReadDirAllEntries(commandEnv, util.FullPath(filer.DirectoryEtcRemote), "", func(entry *filer_pb.Entry, isLast bool) error {+ return filer_pb.ReadDirAllEntries(context.Background(), commandEnv, util.FullPath(filer.DirectoryEtcRemote), "", func(entry *filer_pb.Entry, isLast bool) error {if len(entry.Content) == 0 {fmt.Fprintf(writer, "skipping %s\n", entry.Name)return nildiff --git a/weed/shell/command_remote_meta_sync.go b/weed/shell/command_remote_meta_sync.goindex 1b2e33c14c..4d430bc769 100644--- a/weed/shell/command_remote_meta_sync.go+++ b/weed/shell/command_remote_meta_sync.go@@ -136,7 +136,7 @@ func pullMetadata(commandEnv *CommandEnv, writer io.Writer, localMountedDir utillocalDir := filer.MapRemoteStorageLocationPathToFullPath(localMountedDir, remoteMountedLocation, remoteDir)fmt.Fprint(writer, localDir.Child(name))- lookupResponse, lookupErr := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{+ lookupResponse, lookupErr := filer_pb.LookupEntry(context.Background(), client, &filer_pb.LookupDirectoryEntryRequest{Directory: string(localDir),Name: name,})diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.goindex cfe89ddce1..2892852e94 100644--- a/weed/shell/command_remote_mount.go+++ b/weed/shell/command_remote_mount.go@@ -138,7 +138,7 @@ func syncMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty}mountToDirIsEmpty := true- listErr := filer_pb.SeaweedList(client, dir, "", func(entry *filer_pb.Entry, isLast bool) error {+ listErr := filer_pb.SeaweedList(context.Background(), client, dir, "", func(entry *filer_pb.Entry, isLast bool) error {mountToDirIsEmpty = falsereturn nil}, "", false, 1)diff --git a/weed/shell/command_remote_unmount.go b/weed/shell/command_remote_unmount.goindex 6de92e612b..87487481a9 100644--- a/weed/shell/command_remote_unmount.go+++ b/weed/shell/command_remote_unmount.go@@ -88,6 +88,7 @@ func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir stri// find existing directory, and ensure the directory is emptyerr := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {+ ctx := context.Background()parent, name := util.FullPath(dir).DirAndName()lookupResp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{Directory: parent,@@ -99,12 +100,12 @@ func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir strioldEntry := lookupResp.Entry- deleteError := filer_pb.DoRemove(client, parent, name, true, true, true, false, nil)+ deleteError := filer_pb.DoRemove(ctx, client, parent, name, true, true, true, false, nil)if deleteError != nil {return fmt.Errorf("delete %s: %v", dir, deleteError)}- mkdirErr := filer_pb.DoMkdir(client, parent, name, func(entry *filer_pb.Entry) {+ mkdirErr := filer_pb.DoMkdir(ctx, client, parent, name, func(entry *filer_pb.Entry) {entry.Attributes = oldEntry.Attributesentry.Extended = oldEntry.Extendedentry.Attributes.Crtime = time.Now().Unix()diff --git a/weed/shell/command_s3_bucket_create.go b/weed/shell/command_s3_bucket_create.goindex 86c788b0d5..be17591e4e 100644--- a/weed/shell/command_s3_bucket_create.go+++ b/weed/shell/command_s3_bucket_create.go@@ -71,7 +71,7 @@ func (c *commandS3BucketCreate) Do(args []string, commandEnv *CommandEnv, writer},}- if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{+ if err := filer_pb.CreateEntry(context.Background(), client, &filer_pb.CreateEntryRequest{Directory: filerBucketsPath,Entry: entry,}); err != nil {diff --git a/weed/shell/command_s3_bucket_delete.go b/weed/shell/command_s3_bucket_delete.goindex 6f8c9c4b5c..ecd83d1c25 100644--- a/weed/shell/command_s3_bucket_delete.go+++ b/weed/shell/command_s3_bucket_delete.go@@ -66,6 +66,6 @@ func (c *commandS3BucketDelete) Do(args []string, commandEnv *CommandEnv, writerreturn}- return filer_pb.Remove(commandEnv, filerBucketsPath, *bucketName, false, true, true, false, nil)+ return filer_pb.Remove(context.Background(), commandEnv, filerBucketsPath, *bucketName, false, true, true, false, nil)}diff --git a/weed/shell/command_s3_bucket_list.go b/weed/shell/command_s3_bucket_list.goindex 7939f20861..e6fa44303a 100644--- a/weed/shell/command_s3_bucket_list.go+++ b/weed/shell/command_s3_bucket_list.go@@ -57,7 +57,7 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer ireturn fmt.Errorf("read buckets: %v", err)}- err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {if !entry.IsDirectory {return nil}diff --git a/weed/shell/command_s3_bucket_quota.go b/weed/shell/command_s3_bucket_quota.goindex 3301a8d0e1..f6562453fb 100644--- a/weed/shell/command_s3_bucket_quota.go+++ b/weed/shell/command_s3_bucket_quota.go@@ -83,7 +83,7 @@ func (c *commandS3BucketQuota) Do(args []string, commandEnv *CommandEnv, writer}}- if err := filer_pb.UpdateEntry(client, &filer_pb.UpdateEntryRequest{+ if err := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{Directory: filerBucketsPath,Entry: bucketEntry,}); err != nil {diff --git a/weed/shell/command_s3_bucket_quota_check.go b/weed/shell/command_s3_bucket_quota_check.goindex 04708a0e75..27b9034054 100644--- a/weed/shell/command_s3_bucket_quota_check.go+++ b/weed/shell/command_s3_bucket_quota_check.go@@ -2,6 +2,7 @@ package shellimport ("bytes"+ "context""flag""fmt""github.com/seaweedfs/seaweedfs/weed/filer"@@ -65,7 +66,7 @@ func (c *commandS3BucketQuotaEnforce) Do(args []string, commandEnv *CommandEnv,// process each buckethasConfChanges := false- err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {if !entry.IsDirectory {return nil}diff --git a/weed/shell/command_s3_clean_uploads.go b/weed/shell/command_s3_clean_uploads.goindex bfce5d54df..c77f3cd740 100644--- a/weed/shell/command_s3_clean_uploads.go+++ b/weed/shell/command_s3_clean_uploads.go@@ -1,6 +1,7 @@package shellimport (+ "context""flag""fmt""io"@@ -54,7 +55,7 @@ func (c *commandS3CleanUploads) Do(args []string, commandEnv *CommandEnv, writer}var buckets []string- err = filer_pb.List(commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {+ err = filer_pb.List(context.Background(), commandEnv, filerBucketsPath, "", func(entry *filer_pb.Entry, isLast bool) error {buckets = append(buckets, entry.Name)return nil}, "", false, math.MaxUint32)@@ -75,7 +76,7 @@ func (c *commandS3CleanUploads) cleanupUploads(commandEnv *CommandEnv, writer iouploadsDir := filerBucketsPath + "/" + bucket + "/" + s3_constants.MultipartUploadsFoldervar staleUploads []stringnow := time.Now()- err := filer_pb.List(commandEnv, uploadsDir, "", func(entry *filer_pb.Entry, isLast bool) error {+ err := filer_pb.List(context.Background(), commandEnv, uploadsDir, "", func(entry *filer_pb.Entry, isLast bool) error {ctime := time.Unix(entry.Attributes.Crtime, 0)if ctime.Add(timeAgo).Before(now) {staleUploads = append(staleUploads, entry.Name)diff --git a/weed/shell/commands.go b/weed/shell/commands.goindex 264dd48180..40be210a29 100644--- a/weed/shell/commands.go+++ b/weed/shell/commands.go@@ -91,7 +91,7 @@ func (ce *CommandEnv) checkDirectory(path string) error {dir, name := util.FullPath(path).DirAndName()- exists, err := filer_pb.Exists(ce, dir, name, true)+ exists, err := filer_pb.Exists(context.Background(), ce, dir, name, true)if !exists {return fmt.Errorf("%s is not a directory", path)