From 071ff24471839a4aa6933647ad26bcdcefe187b2 Mon Sep 17 00:00:00 2001 From: zhengchenyu001 Date: Thu, 26 Aug 2021 17:28:33 +0800 Subject: [PATCH 1/3] fix rename file failed --- internal/dir.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/dir.go b/internal/dir.go index 687674f0..71deacf7 100644 --- a/internal/dir.go +++ b/internal/dir.go @@ -1072,8 +1072,8 @@ func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error toFullName := appendChildName(toPath, to) - toIsDir, err = parent.isEmptyDir(fs, to) - if err != nil { + toIsDir, err = newParent.isEmptyDir(fs, to) + if err != nil && err != fuse.ENOENT { return } From c5e74e779dc600ea3f509e525e30228f5a1c16e2 Mon Sep 17 00:00:00 2001 From: zhengchenyu001 Date: Tue, 19 Oct 2021 16:01:53 +0800 Subject: [PATCH 2/3] update --- internal/handles.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/handles.go b/internal/handles.go index 210f3b67..fa0268a0 100644 --- a/internal/handles.go +++ b/internal/handles.go @@ -427,7 +427,7 @@ func (inode *Inode) SetXattr(name string, value []byte, flags uint32) error { inode.mu.Lock() defer inode.mu.Unlock() - meta, name, err := inode.getXattrMap(name, true) + meta, name, err := inode.getXattrMap(name, false) if err != nil { return err } @@ -456,7 +456,7 @@ func (inode *Inode) RemoveXattr(name string) error { inode.mu.Lock() defer inode.mu.Unlock() - meta, name, err := inode.getXattrMap(name, true) + meta, name, err := inode.getXattrMap(name, false) if err != nil { return err } From 9e7872344db93bd634e26fa8babfe1d6cd6be50c Mon Sep 17 00:00:00 2001 From: zhengchenyu001 Date: Tue, 19 Oct 2021 16:07:22 +0800 Subject: [PATCH 3/3] add debug --- internal/dir.go | 14 +++++++++++++- internal/goofys.go | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/dir.go b/internal/dir.go index 71deacf7..405bcffc 100644 --- a/internal/dir.go +++ b/internal/dir.go @@ -978,20 +978,24 @@ func (parent *Inode) isEmptyDir(fs *Goofys, name string) (isDir bool, err error) Prefix: &key, }) if err != nil { + s3Log.Debugf("ListBlobs 1 in isEmptyDir, resp is %v, err is %v", resp, err) return false, mapAwsError(err) } if len(resp.Prefixes) > 0 || len(resp.Items) > 1 { err = fuse.ENOTEMPTY isDir = true + s3Log.Debugf("ListBlobs 2 in isEmptyDir, resp is %v, err is %v", resp, err) return } if len(resp.Items) == 1 { isDir = true + s3Log.Debugf("ListBlobs 3 in isEmptyDir") if *resp.Items[0].Key != key { err = fuse.ENOTEMPTY + s3Log.Debugf("ListBlobs 4 in isEmptyDir") } } @@ -1073,7 +1077,10 @@ func (parent *Inode) Rename(from string, newParent *Inode, to string) (err error toFullName := appendChildName(toPath, to) toIsDir, err = newParent.isEmptyDir(fs, to) + s3Log.Debugf("toFullName is %v, toPath is %v, to is %v", toFullName, toPath, to) + s3Log.Debugf("outter toIsDir is %v, err is %v", toIsDir, err) if err != nil && err != fuse.ENOENT { + s3Log.Debugf("inner toIsDir is %v, err is %v", toIsDir, err) return } @@ -1364,6 +1371,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I inode.fillXattrFromHead(&resp) return case err = <-errObjectChan: + s3Log.Debugf("chan error is errObjectChan") checking-- checkErr[0] = err s3Log.Debugf("HEAD %v = %v", fullName, err) @@ -1394,10 +1402,12 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I checking-- } case err = <-errDirChan: + s3Log.Debugf("chan error is errDirChan") checking-- checkErr[2] = err s3Log.Debugf("LIST %v/ = %v", fullName, err) case err = <-errDirBlobChan: + s3Log.Debugf("chan error is errDirBlobChan") checking-- checkErr[1] = err s3Log.Debugf("HEAD %v/ = %v", fullName, err) @@ -1407,6 +1417,7 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I return } + s3Log.Debugf("checking is %v", checking) switch checking { case 2: if parent.fs.flags.Cheap { @@ -1425,7 +1436,8 @@ func (parent *Inode) LookUpInodeMaybeDir(name string, fullName string) (inode *I doneCase: fallthrough case 0: - for _, e := range checkErr { + for x, e := range checkErr { + s3Log.Debugf("checkErr x = %v e = %v", x, e) if e != fuse.ENOENT { err = e return diff --git a/internal/goofys.go b/internal/goofys.go index b3321d4a..87f4eb00 100644 --- a/internal/goofys.go +++ b/internal/goofys.go @@ -602,6 +602,8 @@ func (fs *Goofys) LookUpInode( var ok bool defer func() { fuseLog.Debugf("<-- LookUpInode %v %v %v", op.Parent, op.Name, err) }() + fuseLog.Debugf("<-- do LookUpInode %v %v %v", op.Parent, op.Name) + fs.mu.RLock() parent := fs.getInodeOrDie(op.Parent) fs.mu.RUnlock() @@ -634,6 +636,7 @@ func (fs *Goofys) LookUpInode( var newInode *Inode newInode, err = parent.LookUp(op.Name) + fuseLog.Debugf("<-- parent.LookUp return is %v %v", newInode, err) if err == fuse.ENOENT && inode != nil && inode.isDir() { // we may not be able to look up an implicit // dir if all the children are removed, so we @@ -1159,6 +1162,8 @@ func (fs *Goofys) Rename( defer newParent.mu.Unlock() } + s3Log.Debugf("op is %v, op.OldParent is %v, op.NewParent is %v, parent is %v, newParent is %v", op, op.OldParent, op.NewParent, parent, newParent) + s3Log.Debugf("op.OldName is %v, op.NewName is %v", op.OldName, op.NewName) err = parent.Rename(op.OldName, newParent, op.NewName) if err != nil { if err == fuse.ENOENT {