fix(client): update fullpath and pinos when excuting rename opration

close:#21990545

Signed-off-by: chihe <chihe@oppo.com>
This commit is contained in:
chihe 2025-02-13 17:23:20 +08:00 committed by zhumingze1108
parent 77979034f5
commit f36f62b80c
5 changed files with 28 additions and 6 deletions

View File

@ -702,17 +702,26 @@ func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Nod
}
d.super.fslock.Lock()
node, ok := d.super.nodeCache[srcInode]
fullPath := path.Join(dstDir.fullPath, req.NewName)
if ok && srcInode != 0 {
if dir, ok := node.(*Dir); ok {
dir.name = req.NewName
dir.parentIno = dstDir.info.Inode
dir.pinos = append(dstDir.pinos, dir.info.Inode)
dir.setFullPath(fullPath)
} else {
file := node.(*File)
file.name = req.NewName
file.parentIno = dstDir.info.Inode
file.pinos = dstDir.pinos
file.setFullPath(fullPath)
}
}
for _, node := range d.super.nodeCache {
for ino, node := range d.super.nodeCache {
// fullPath is already changed
if ino == srcInode {
continue
}
if dir, ok := node.(*Dir); ok {
if containsInode(dir.pinos, srcInode) {
dir.fullPath = replacePathPart(dir.fullPath, req.OldName, req.NewName)
@ -1055,7 +1064,7 @@ func (d *Dir) Removexattr(ctx context.Context, req *fuse.RemovexattrRequest) err
}
func (d *Dir) setFullPath(fullPath string) {
d.fullPath = fullPath
d.fullPath = fixUnixPath(fullPath)
}
func (d *Dir) addParentInode(inos []uint64) {
@ -1110,7 +1119,7 @@ func replacePathPart(path, oldPart, newPart string) string {
parts[i] = strings.ReplaceAll(part, oldPart, newPart)
}
}
return filepath.Join(parts...)
return fixUnixPath(filepath.Join(parts...))
}
func containsInode(pinos []uint64, inode uint64) bool {
@ -1121,3 +1130,14 @@ func containsInode(pinos []uint64, inode uint64) bool {
}
return false
}
func isValidUnixPath(path string) bool {
return strings.HasPrefix(path, "/")
}
func fixUnixPath(path string) string {
if !isValidUnixPath(path) {
return "/" + path
}
return path
}

View File

@ -127,7 +127,7 @@ func (f *File) getParentPath() string {
}
func (f *File) setFullPath(fullPath string) {
f.fullPath = fullPath
f.fullPath = fixUnixPath(fullPath)
}
func (f *File) addParentInode(inos []uint64) {

View File

@ -369,7 +369,7 @@ func (s *Super) Root() (fs.Node, error) {
root := NewDir(s, inode, inode.Inode, "")
root.(*Dir).setFullPath(s.subDir)
root.(*Dir).addParentInode([]uint64{inode.Inode})
log.LogInfof("Super:root patch is(%v)", s.subDir)
log.LogInfof("Super:root path is(%v)", s.subDir)
return root, nil
}

View File

@ -399,7 +399,8 @@ retry:
if config.NeedRemoteCache {
client.RemoteCache.Init(client)
} else {
log.LogInfof("NewExtentClient not init remoteCache, config.NeedRemoteCahe %v", config.NeedRemoteCache)
log.LogInfof("NewExtentClient for (%v) not init remoteCache, config.NeedRemoteCache %v", client.volumeName,
config.NeedRemoteCache)
}
return

View File

@ -63,6 +63,7 @@ type Streamer struct {
aheadReadEnable bool
bloomStatus bool
aheadReadWindow *AheadReadWindow
fullPath string
}
type bcacheKey struct {