From b886cc2ef8fd001a9e105353d0a0a39f59e0f5b6 Mon Sep 17 00:00:00 2001 From: jiefenghuang Date: Tue, 7 Jan 2025 21:25:39 +0800 Subject: [PATCH] cmd/sync: skip special files in juicefs (#5523) Signed-off-by: jiefenghuang --- cmd/object.go | 3 +++ pkg/sync/sync.go | 4 +++- pkg/utils/errors.go | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/object.go b/cmd/object.go index 6ed029210d71..5b1af9190459 100644 --- a/cmd/object.go +++ b/cmd/object.go @@ -117,6 +117,9 @@ var bufPool = sync.Pool{ } func (j *juiceFS) Put(key string, in io.Reader, getters ...object.AttrGetter) (err error) { + if vfs.IsSpecialName(key) { + return fmt.Errorf("skip special file %s for jfs: %w", key, utils.ErrSkipped) + } p := j.path(key) if strings.HasSuffix(p, "/") { eno := j.jfs.MkdirAll(ctx, p, 0777, j.umask) diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 65645a07fb61..035f2fa0bd0a 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -184,7 +184,7 @@ var bufPool = sync.Pool{ func try(n int, f func() error) (err error) { for i := 0; i < n; i++ { err = f() - if err == nil { + if err == nil || errors.Is(err, utils.ErrSkipped) { return } logger.Debugf("Try %d failed: %s", i+1, err) @@ -697,6 +697,8 @@ func worker(tasks <-chan object.Object, src, dst object.ObjectStorage, config *C copyPerms(dst, obj, config) } copied.Increment() + } else if errors.Is(err, utils.ErrSkipped) { + skipped.Increment() } else { failed.Increment() logger.Errorf("Failed to copy object %s: %s", key, err) diff --git a/pkg/utils/errors.go b/pkg/utils/errors.go index d93bf5b81231..a1da3c790277 100644 --- a/pkg/utils/errors.go +++ b/pkg/utils/errors.go @@ -23,4 +23,5 @@ import ( var ( ENOTSUP = errors.New("not supported") ErrFuncTimeout = errors.New("function timeout") + ErrSkipped = errors.New("skipped") )