From 05c53820b99d20a7123e1583e4853724034970f9 Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 11:49:40 -0700 Subject: [PATCH 01/16] mount: file handler release memory --- weed/mount/filehandle.go | 11 +++++++++-- weed/mount/filehandle_read.go | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go index 49918c104..f0cf2a380 100644 --- a/weed/mount/filehandle.go +++ b/weed/mount/filehandle.go @@ -6,7 +6,6 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" "golang.org/x/exp/slices" - "io" "sync" ) @@ -24,7 +23,7 @@ type FileHandle struct { dirtyMetadata bool dirtyPages *PageWriter entryViewCache []filer.VisibleInterval - reader io.ReaderAt + reader *filer.ChunkReadAt contentType string handle uint64 sync.Mutex @@ -99,8 +98,16 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) { fh.entryViewCache = nil } +func (fh *FileHandle) SetReader(reader *filer.ChunkReadAt) { + if fh.reader != nil { + fh.reader.Close() + } + fh.reader = reader +} + func (fh *FileHandle) Release() { fh.dirtyPages.Destroy() + fh.SetReader(nil) } func lessThan(a, b *filer_pb.FileChunk) bool { diff --git a/weed/mount/filehandle_read.go b/weed/mount/filehandle_read.go index 88ab8612c..202730e88 100644 --- a/weed/mount/filehandle_read.go +++ b/weed/mount/filehandle_read.go @@ -62,7 +62,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { if chunkResolveErr != nil { return 0, fmt.Errorf("fail to resolve chunk manifest: %v", chunkResolveErr) } - fh.reader = nil + fh.SetReader(nil) } reader := fh.reader @@ -74,7 +74,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { } reader = filer.NewChunkReaderAtFromClient(fh.wfs.LookupFn(), chunkViews, fh.wfs.chunkCache, fileSize) } - fh.reader = reader + fh.SetReader(reader) totalRead, err := reader.ReadAt(buff, offset) From f2f0482dd332e13f57f0e39b262fa409dacca02e Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 11:50:28 -0700 Subject: [PATCH 02/16] mount: random read also try to use the local cache first --- weed/filer/reader_at.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index 7d9997761..b938083d8 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -164,6 +164,10 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) { func (c *ChunkReadAt) readChunkSliceAt(buffer []byte, chunkView *ChunkView, nextChunkViews []*ChunkView, offset uint64) (n int, err error) { if c.readerPattern.IsRandomMode() { + n, err := c.readerCache.chunkCache.ReadChunkAt(buffer, chunkView.FileId, offset) + if n > 0 { + return n, err + } return fetchChunkRange(buffer, c.readerCache.lookupFileIdFn, chunkView.FileId, chunkView.CipherKey, chunkView.IsGzipped, int64(offset)) } From b7de5c6c430ac1d8acb79a0dd5197f2463e4266c Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 15:01:23 -0700 Subject: [PATCH 03/16] shell: remove unused filer parameter from shell.toml --- weed/command/scaffold/shell.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/weed/command/scaffold/shell.toml b/weed/command/scaffold/shell.toml index 288ae2efe..0213708a4 100644 --- a/weed/command/scaffold/shell.toml +++ b/weed/command/scaffold/shell.toml @@ -3,8 +3,6 @@ default = "c1" [cluster.c1] master = "localhost:9333" # comma-separated master servers -filer = "localhost:8888" # filer host and port [cluster.c2] master = "" -filer = "" From fa8e33ccb892344c1ea045c32bf3124d7821314b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 7 Jul 2022 22:11:44 -0700 Subject: [PATCH 04/16] Update binaries_dev.yml --- .github/workflows/binaries_dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index a61846127..f906ed2bb 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -17,14 +17,13 @@ jobs: steps: - name: Delete old release assets - uses: mknejp/delete-release-assets@a8aaab13272b1eaac16cc46dddd3f725b97ee05a # v1 + uses: mknejp/delete-release-assets@v1 with: token: ${{ github.token }} tag: dev fail-if-no-assets: false assets: | weed-* - fail-if-no-release: false build_dev_linux_windows: permissions: From 2ea18cdcc8b9ea3c6ba74672f3c18d5d1a9e10fe Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 22:26:03 -0700 Subject: [PATCH 05/16] remove dead code --- weed/filer/filechunks.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.go index 48b344bf8..5a600a188 100644 --- a/weed/filer/filechunks.go +++ b/weed/filer/filechunks.go @@ -3,11 +3,9 @@ package filer import ( "bytes" "fmt" - "math" - "sync" - "github.com/chrislusf/seaweedfs/weed/wdclient" "golang.org/x/exp/slices" + "math" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" @@ -189,12 +187,6 @@ func logPrintf(name string, visibles []VisibleInterval) { */ } -var bufPool = sync.Pool{ - New: func() interface{} { - return new(VisibleInterval) - }, -} - func MergeIntoVisibles(visibles []VisibleInterval, chunk *filer_pb.FileChunk) (newVisibles []VisibleInterval) { newV := newVisibleInterval(chunk.Offset, chunk.Offset+int64(chunk.Size), chunk.GetFileIdString(), chunk.Mtime, 0, chunk.Size, chunk.CipherKey, chunk.IsCompressed) From a85ed3fe8fe8e6d5c69cf96836f6c80ce340ee8c Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 22:27:24 -0700 Subject: [PATCH 06/16] minor --- weed/filer/filechunks.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/filer/filechunks.go b/weed/filer/filechunks.go index 5a600a188..4c732ddcd 100644 --- a/weed/filer/filechunks.go +++ b/weed/filer/filechunks.go @@ -52,11 +52,11 @@ func ETagChunks(chunks []*filer_pb.FileChunk) (etag string) { if len(chunks) == 1 { return fmt.Sprintf("%x", util.Base64Md5ToBytes(chunks[0].ETag)) } - md5_digests := [][]byte{} + var md5Digests [][]byte for _, c := range chunks { - md5_digests = append(md5_digests, util.Base64Md5ToBytes(c.ETag)) + md5Digests = append(md5Digests, util.Base64Md5ToBytes(c.ETag)) } - return fmt.Sprintf("%x-%d", util.Md5(bytes.Join(md5_digests, nil)), len(chunks)) + return fmt.Sprintf("%x-%d", util.Md5(bytes.Join(md5Digests, nil)), len(chunks)) } func CompactFileChunks(lookupFileIdFn wdclient.LookupFileIdFunctionType, chunks []*filer_pb.FileChunk) (compacted, garbage []*filer_pb.FileChunk) { From 1ceab96aba388f9c25d963747de4874189024fb2 Mon Sep 17 00:00:00 2001 From: duanhongyi Date: Fri, 8 Jul 2022 14:23:06 +0800 Subject: [PATCH 07/16] filer tikv support tls --- weed/command/scaffold/filer.toml | 8 ++++++++ weed/filer/tikv/tikv_store.go | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml index c82de8da0..860d8b291 100644 --- a/weed/command/scaffold/filer.toml +++ b/weed/command/scaffold/filer.toml @@ -337,3 +337,11 @@ pdaddrs = "localhost:2379" deleterange_concurrency = 1 # Enable 1PC enable_1pc = false +# Set the CA certificate path +ca_path="" +# Set the certificate path +cert_path="" +# Set the private key path +key_path="" +# The name list used to verify the cn name +verify_cn="" \ No newline at end of file diff --git a/weed/filer/tikv/tikv_store.go b/weed/filer/tikv/tikv_store.go index f8932663d..ca6794f9c 100644 --- a/weed/filer/tikv/tikv_store.go +++ b/weed/filer/tikv/tikv_store.go @@ -15,6 +15,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" + "github.com/tikv/client-go/v2/config" "github.com/tikv/client-go/v2/txnkv" ) @@ -38,21 +39,25 @@ func (store *TikvStore) GetName() string { } func (store *TikvStore) Initialize(config util.Configuration, prefix string) error { - pdAddrs := []string{} - pdAddrsStr := config.GetString(prefix + "pdaddrs") - for _, item := range strings.Split(pdAddrsStr, ",") { - pdAddrs = append(pdAddrs, strings.TrimSpace(item)) - } + ca := config.GetString(prefix + "ca_path") + cert := config.GetString(prefix + "cert_path") + key := config.GetString(prefix + "key_path") + verify_cn := strings.Split(config.GetString(prefix+"verify_cn"), ",") + pdAddrs := strings.Split(config.GetString(prefix+"pdaddrs"), ",") + drc := config.GetInt(prefix + "deleterange_concurrency") if drc <= 0 { drc = 1 } store.onePC = config.GetBool(prefix + "enable_1pc") store.deleteRangeConcurrency = drc - return store.initialize(pdAddrs) + return store.initialize(ca, cert, key, verify_cn, pdAddrs) } -func (store *TikvStore) initialize(pdAddrs []string) error { +func (store *TikvStore) initialize(ca, cert, key string, verify_cn, pdAddrs []string) error { + config.UpdateGlobal(func(conf *config.Config) { + conf.Security = config.NewSecurity(ca, cert, key, verify_cn) + }) client, err := txnkv.NewClient(pdAddrs) store.client = client return err From 28add5a53451aa0be30cc03c2fda22c4056d602b Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 00:29:39 -0700 Subject: [PATCH 08/16] mount: fix racing conditions prevent wrong reading when the SingleChunkCacher is started, but not finished yet --- weed/filer/reader_cache.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/filer/reader_cache.go b/weed/filer/reader_cache.go index bce97cc49..c319f6c78 100644 --- a/weed/filer/reader_cache.go +++ b/weed/filer/reader_cache.go @@ -19,6 +19,7 @@ type ReaderCache struct { type SingleChunkCacher struct { sync.RWMutex + cond *sync.Cond parent *ReaderCache chunkFileId string data []byte @@ -140,6 +141,7 @@ func newSingleChunkCacher(parent *ReaderCache, fileId string, cipherKey []byte, chunkSize: chunkSize, shouldCache: shouldCache, } + t.cond = sync.NewCond(t) return t } @@ -168,6 +170,7 @@ func (s *SingleChunkCacher) startCaching() { if s.shouldCache { s.parent.chunkCache.SetChunk(s.chunkFileId, s.data) } + s.cond.Broadcast() return } @@ -183,6 +186,10 @@ func (s *SingleChunkCacher) readChunkAt(buf []byte, offset int64) (int, error) { s.RLock() defer s.RUnlock() + for s.completedTime.IsZero() { + s.cond.Wait() + } + if s.err != nil { return 0, s.err } From e2ecf137a21b27c34c3b163f09f3660745daceeb Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 01:04:15 -0700 Subject: [PATCH 09/16] fix resetting fh.reader --- weed/mount/filehandle.go | 5 ++--- weed/mount/filehandle_read.go | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go index f0cf2a380..0dfcbd7f6 100644 --- a/weed/mount/filehandle.go +++ b/weed/mount/filehandle.go @@ -98,16 +98,15 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) { fh.entryViewCache = nil } -func (fh *FileHandle) SetReader(reader *filer.ChunkReadAt) { +func (fh *FileHandle) CloseReader() { if fh.reader != nil { fh.reader.Close() } - fh.reader = reader } func (fh *FileHandle) Release() { fh.dirtyPages.Destroy() - fh.SetReader(nil) + fh.CloseReader() } func lessThan(a, b *filer_pb.FileChunk) bool { diff --git a/weed/mount/filehandle_read.go b/weed/mount/filehandle_read.go index 202730e88..45fc10a0b 100644 --- a/weed/mount/filehandle_read.go +++ b/weed/mount/filehandle_read.go @@ -62,21 +62,19 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { if chunkResolveErr != nil { return 0, fmt.Errorf("fail to resolve chunk manifest: %v", chunkResolveErr) } - fh.SetReader(nil) + fh.CloseReader() } - reader := fh.reader - if reader == nil { + if fh.reader == nil { chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, fileSize) glog.V(4).Infof("file handle read %s [%d,%d) from %d views", fileFullPath, offset, offset+int64(len(buff)), len(chunkViews)) for _, chunkView := range chunkViews { glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId) } - reader = filer.NewChunkReaderAtFromClient(fh.wfs.LookupFn(), chunkViews, fh.wfs.chunkCache, fileSize) + fh.reader = filer.NewChunkReaderAtFromClient(fh.wfs.LookupFn(), chunkViews, fh.wfs.chunkCache, fileSize) } - fh.SetReader(reader) - totalRead, err := reader.ReadAt(buff, offset) + totalRead, err := fh.reader.ReadAt(buff, offset) if err != nil && err != io.EOF { glog.Errorf("file handle read %s: %v", fileFullPath, err) From 106dd133065be4a3946c44e1e55a6d34d1d956c6 Mon Sep 17 00:00:00 2001 From: liubaojiang <1838095916@qq.com> Date: Fri, 8 Jul 2022 16:36:45 +0800 Subject: [PATCH 10/16] fix the spelling error --- k8s/helm_charts2/templates/filer-statefulset.yaml | 2 +- k8s/helm_charts2/templates/service-account.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/k8s/helm_charts2/templates/filer-statefulset.yaml b/k8s/helm_charts2/templates/filer-statefulset.yaml index 94003819f..21a4256be 100644 --- a/k8s/helm_charts2/templates/filer-statefulset.yaml +++ b/k8s/helm_charts2/templates/filer-statefulset.yaml @@ -46,7 +46,7 @@ spec: imagePullSecrets: - name: {{ .Values.global.imagePullSecrets }} {{- end }} - serviceAccountName: seaweefds-rw-sa #hack for delete pod master after migration + serviceAccountName: seaweedfs-rw-sa #hack for delete pod master after migration terminationGracePeriodSeconds: 60 {{- if .Values.filer.priorityClassName }} priorityClassName: {{ .Values.filer.priorityClassName | quote }} diff --git a/k8s/helm_charts2/templates/service-account.yaml b/k8s/helm_charts2/templates/service-account.yaml index 978452ca4..22c29b56a 100644 --- a/k8s/helm_charts2/templates/service-account.yaml +++ b/k8s/helm_charts2/templates/service-account.yaml @@ -3,7 +3,7 @@ kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: seaweefds-rw-cr + name: seaweedfs-rw-cr rules: - apiGroups: [""] resources: ["pods"] @@ -12,18 +12,18 @@ rules: apiVersion: v1 kind: ServiceAccount metadata: - name: seaweefds-rw-sa + name: seaweedfs-rw-sa namespace: {{ .Release.Namespace }} --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: system:serviceaccount:seaweefds-rw-sa:default + name: system:serviceaccount:seaweedfs-rw-sa:default subjects: - kind: ServiceAccount - name: seaweefds-rw-sa + name: seaweedfs-rw-sa namespace: {{ .Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: seaweefds-rw-cr + name: seaweedfs-rw-cr From 5b3192344dbf53c5f6f281797c1d32b367844b4d Mon Sep 17 00:00:00 2001 From: guosj <515878133@qq.com> Date: Fri, 8 Jul 2022 17:42:21 +0800 Subject: [PATCH 11/16] fix iam CreatePolicy error --- weed/iamapi/iamapi_server.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/weed/iamapi/iamapi_server.go b/weed/iamapi/iamapi_server.go index 62c7f867c..252d5bd0e 100644 --- a/weed/iamapi/iamapi_server.go +++ b/weed/iamapi/iamapi_server.go @@ -6,6 +6,8 @@ import ( "bytes" "encoding/json" "fmt" + "net/http" + "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" @@ -17,7 +19,6 @@ import ( "github.com/chrislusf/seaweedfs/weed/wdclient" "github.com/gorilla/mux" "google.golang.org/grpc" - "net/http" ) type IamS3ApiConfig interface { @@ -117,10 +118,10 @@ func (iam IamS3ApiConfigure) GetPolicies(policies *Policies) (err error) { } return nil }) - if err != nil { + if err != nil && err != filer_pb.ErrNotFound { return err } - if buf.Len() == 0 { + if err == filer_pb.ErrNotFound || buf.Len() == 0 { policies.Policies = make(map[string]PolicyDocument) return nil } From 4e83e92156846a6cd7f90f8dde31f5e54209cc59 Mon Sep 17 00:00:00 2001 From: liubaojiang <1838095916@qq.com> Date: Fri, 8 Jul 2022 20:27:25 +0800 Subject: [PATCH 12/16] add subscriber clientId if it is the first time --- weed/server/filer_grpc_server_sub_meta.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/server/filer_grpc_server_sub_meta.go b/weed/server/filer_grpc_server_sub_meta.go index da710234b..745379e7c 100644 --- a/weed/server/filer_grpc_server_sub_meta.go +++ b/weed/server/filer_grpc_server_sub_meta.go @@ -263,6 +263,9 @@ func (fs *FilerServer) addClient(clientType string, clientAddress string, client if clientId != 0 { fs.knownListenersLock.Lock() _, alreadyKnown = fs.knownListeners[clientId] + if !alreadyKnown { + fs.knownListeners[clientId] = struct{}{} + } fs.knownListenersLock.Unlock() } return From 48382676d2765ae4facfc60e89b897247c711ef5 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 10:29:24 -0700 Subject: [PATCH 13/16] fix filtering by volume id --- weed/topology/topology_vacuum.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.go index e53aa2853..3850b8916 100644 --- a/weed/topology/topology_vacuum.go +++ b/weed/topology/topology_vacuum.go @@ -185,10 +185,13 @@ func (t *Topology) Vacuum(grpcDialOption grpc.DialOption, garbageThreshold float for _, vl := range c.storageType2VolumeLayout.Items() { if vl != nil { volumeLayout := vl.(*VolumeLayout) - if volumeId > 0 && volumeLayout.Lookup(needle.VolumeId(volumeId)) == nil { - continue + if volumeId > 0 { + if volumeLayout.Lookup(needle.VolumeId(volumeId)) != nil { + t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate) + } + } else { + t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate) } - t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, preallocate) } } } From d685b9410236553d1a23d10a7b8b7b6bfdc02ae0 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 19:07:03 -0700 Subject: [PATCH 14/16] mount: rename also invalidate source inode --- weed/mount/inode_to_path.go | 4 ++-- weed/mount/weedfs_rename.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go index fa17a9261..29635efca 100644 --- a/weed/mount/inode_to_path.go +++ b/weed/mount/inode_to_path.go @@ -152,7 +152,7 @@ func (i *InodeToPath) RemovePath(path util.FullPath) { } } -func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedInode uint64) { +func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (sourceInode, targetInode uint64) { i.Lock() defer i.Unlock() sourceInode, sourceFound := i.path2inode[sourcePath] @@ -178,7 +178,7 @@ func (i *InodeToPath) MovePath(sourcePath, targetPath util.FullPath) (replacedIn } else { glog.Errorf("MovePath %s to %s: sourceInode %d not found", sourcePath, targetPath, sourceInode) } - return targetInode + return } func (i *InodeToPath) Forget(inode, nlookup uint64, onForgetDir func(dir util.FullPath)) { diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.go index 23caa48cd..ef4ff55c2 100644 --- a/weed/mount/weedfs_rename.go +++ b/weed/mount/weedfs_rename.go @@ -233,10 +233,16 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR oldPath := oldParent.Child(oldName) newPath := newParent.Child(newName) - replacedInode := wfs.inodeToPath.MovePath(oldPath, newPath) + sourceInode, targetInode := wfs.inodeToPath.MovePath(oldPath, newPath) + if sourceInode != 0 { + if fh := wfs.fhmap.inode2fh[sourceInode]; foundFh && fh.entry != nil { + fh.entry.Name = newName + } + wfs.fuseServer.InodeNotify(sourceInode, 0, -1) + } // invalidate attr and data - if replacedInode > 0 { - wfs.fuseServer.InodeNotify(replacedInode, 0, -1) + if targetInode != 0 { + wfs.fuseServer.InodeNotify(targetInode, 0, -1) } } else if resp.EventNotification.OldEntry != nil { From 6f00c7f061f5f5b578c3dd13ad5c5f91b1da80ae Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 19:07:31 -0700 Subject: [PATCH 15/16] comments --- weed/mount/weedfs_rename.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.go index ef4ff55c2..5fcd85215 100644 --- a/weed/mount/weedfs_rename.go +++ b/weed/mount/weedfs_rename.go @@ -238,10 +238,11 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR if fh := wfs.fhmap.inode2fh[sourceInode]; foundFh && fh.entry != nil { fh.entry.Name = newName } + // invalidate attr and data wfs.fuseServer.InodeNotify(sourceInode, 0, -1) } - // invalidate attr and data if targetInode != 0 { + // invalidate attr and data wfs.fuseServer.InodeNotify(targetInode, 0, -1) } From 3d0defa66301fd159ad93f699cccb2ebc1b4b4fe Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 8 Jul 2022 19:16:58 -0700 Subject: [PATCH 16/16] fix compilation --- weed/mount/weedfs_rename.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.go index 5fcd85215..0c7de0bbb 100644 --- a/weed/mount/weedfs_rename.go +++ b/weed/mount/weedfs_rename.go @@ -235,7 +235,7 @@ func (wfs *WFS) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR sourceInode, targetInode := wfs.inodeToPath.MovePath(oldPath, newPath) if sourceInode != 0 { - if fh := wfs.fhmap.inode2fh[sourceInode]; foundFh && fh.entry != nil { + if fh, foundFh := wfs.fhmap.inode2fh[sourceInode]; foundFh && fh.entry != nil { fh.entry.Name = newName } // invalidate attr and data