From 3eccb5c73125e45c24f9cfdb7270a95d77e46ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 29 May 2024 14:32:51 +0200 Subject: [PATCH 1/7] Do not ever set older mtimes --- pkg/storage/fs/posix/tree/assimilation.go | 12 ++++++++---- pkg/storage/utils/decomposedfs/node/xattrs.go | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/storage/fs/posix/tree/assimilation.go b/pkg/storage/fs/posix/tree/assimilation.go index 9070432ded..16f9de16f5 100644 --- a/pkg/storage/fs/posix/tree/assimilation.go +++ b/pkg/storage/fs/posix/tree/assimilation.go @@ -217,15 +217,19 @@ assimilate: return nil, errors.Wrap(err, "failed to stat item") } - previousAttribs, err := t.lookup.MetadataBackend().All(context.Background(), path) + attrs, err := t.lookup.MetadataBackend().All(context.Background(), path) if err != nil && !metadata.IsAttrUnset(err) { return nil, errors.Wrap(err, "failed to get item attribs") } + previousAttribs := node.Attributes(attrs) attributes := node.Attributes{ - prefixes.IDAttr: []byte(id), - prefixes.NameAttr: []byte(filepath.Base(path)), - prefixes.MTimeAttr: []byte(fi.ModTime().Format(time.RFC3339)), + prefixes.IDAttr: []byte(id), + prefixes.NameAttr: []byte(filepath.Base(path)), + } + prevMtime, err := previousAttribs.Time(prefixes.MTimeAttr) + if err != nil || prevMtime.Before(fi.ModTime()) { + attributes[prefixes.MTimeAttr] = []byte(fi.ModTime().Format(time.RFC3339Nano)) } if len(parentID) > 0 { attributes[prefixes.ParentidAttr] = []byte(parentID) diff --git a/pkg/storage/utils/decomposedfs/node/xattrs.go b/pkg/storage/utils/decomposedfs/node/xattrs.go index 79ba71f708..0e5d186b34 100644 --- a/pkg/storage/utils/decomposedfs/node/xattrs.go +++ b/pkg/storage/utils/decomposedfs/node/xattrs.go @@ -22,6 +22,7 @@ import ( "context" "io" "strconv" + "time" "github.com/pkg/xattr" ) @@ -59,6 +60,11 @@ func (md Attributes) SetUInt64(key string, val uint64) { md[key] = []byte(strconv.FormatUint(val, 10)) } +// Time reads a time value +func (md Attributes) Time(key string) (time.Time, error) { + return time.Parse(time.RFC3339Nano, string(md[key])) +} + // SetXattrs sets multiple extended attributes on the write-through cache/node func (n *Node) SetXattrsWithContext(ctx context.Context, attribs map[string][]byte, acquireLock bool) (err error) { if n.xattrsCache != nil { From 55444f3e6330bac8daa642336984e0b7916bac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 29 May 2024 15:38:38 +0200 Subject: [PATCH 2/7] Be more robust when the cache returns no error but an empty list --- pkg/storage/fs/posix/lookup/store_idcache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/fs/posix/lookup/store_idcache.go b/pkg/storage/fs/posix/lookup/store_idcache.go index a7690052c0..b695cde61a 100644 --- a/pkg/storage/fs/posix/lookup/store_idcache.go +++ b/pkg/storage/fs/posix/lookup/store_idcache.go @@ -58,7 +58,7 @@ func (c *StoreIDCache) Set(_ context.Context, spaceID, nodeID, val string) error // Get returns the value for a given key func (c *StoreIDCache) Get(_ context.Context, spaceID, nodeID string) (string, bool) { records, err := c.cache.Read(cacheKey(spaceID, nodeID)) - if err != nil { + if err != nil || len(records) == 0 { return "", false } return string(records[0].Value), true From 13cfbeb65beec1bd8a6fda1e428f95852c834f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 29 May 2024 15:39:03 +0200 Subject: [PATCH 3/7] Do not try to scope the space gid when the flag is off --- pkg/storage/fs/posix/lookup/lookup.go | 48 ++++++++++++--------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/pkg/storage/fs/posix/lookup/lookup.go b/pkg/storage/fs/posix/lookup/lookup.go index 7dc9780db5..9fe369c30f 100644 --- a/pkg/storage/fs/posix/lookup/lookup.go +++ b/pkg/storage/fs/posix/lookup/lookup.go @@ -98,7 +98,21 @@ func (lu *Lookup) GetCachedID(ctx context.Context, spaceID, nodeID string) (stri func (lu *Lookup) WarmupIDCache(root string) error { spaceID := []byte("") - var gid int + scopeSpace := func(spaceCandidate string) error { + if !lu.Options.UseSpaceGroups { + return nil + } + + // set the uid and gid for the space + fi, err := os.Stat(spaceCandidate) + if err != nil { + return err + } + sys := fi.Sys().(*syscall.Stat_t) + gid := int(sys.Gid) + _, err = lu.userMapper.ScopeUserByIds(-1, gid) + return err + } return filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err != nil { @@ -107,41 +121,23 @@ func (lu *Lookup) WarmupIDCache(root string) error { attribs, err := lu.metadataBackend.All(context.Background(), path) if err == nil { - nodeSpaceID, ok := attribs[prefixes.SpaceIDAttr] - if ok { + nodeSpaceID := attribs[prefixes.SpaceIDAttr] + if len(nodeSpaceID) > 0 { spaceID = nodeSpaceID - // set the uid and gid for the space - fi, err := os.Stat(path) + err = scopeSpace(path) if err != nil { return err } - sys := fi.Sys().(*syscall.Stat_t) - gid = int(sys.Gid) - _, err = lu.userMapper.ScopeUserByIds(-1, gid) - if err != nil { - return err - } - } - - if len(spaceID) == 0 { + } else { // try to find space spaceCandidate := path for strings.HasPrefix(spaceCandidate, lu.Options.Root) { spaceID, err = lu.MetadataBackend().Get(context.Background(), spaceCandidate, prefixes.SpaceIDAttr) if err == nil { - if lu.Options.UseSpaceGroups { - // set the uid and gid for the space - fi, err := os.Stat(spaceCandidate) - if err != nil { - return err - } - sys := fi.Sys().(*syscall.Stat_t) - gid := int(sys.Gid) - _, err = lu.userMapper.ScopeUserByIds(-1, gid) - if err != nil { - return err - } + err = scopeSpace(path) + if err != nil { + return err } break } From c22ef64a749495b885b7fe3e4bc4a848621d2ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Mon, 3 Jun 2024 08:40:49 +0200 Subject: [PATCH 4/7] Add changelog --- changelog/unreleased/improve-posixfs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog/unreleased/improve-posixfs.md b/changelog/unreleased/improve-posixfs.md index 5e920bcc5a..e17a12d9d6 100644 --- a/changelog/unreleased/improve-posixfs.md +++ b/changelog/unreleased/improve-posixfs.md @@ -2,4 +2,5 @@ Enhancement: Improve posixfs storage driver Improve the posixfs storage driver by fixing several issues and adding missing features. +https://github.com/cs3org/reva/pull/4708 https://github.com/cs3org/reva/pull/4562 From 202ed8bea5b25ff33bfe693fd7bd72bfd6d08920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Mon, 3 Jun 2024 11:56:21 +0200 Subject: [PATCH 5/7] Fix the flakiness --- pkg/storage/fs/posix/tree/tree_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/storage/fs/posix/tree/tree_test.go b/pkg/storage/fs/posix/tree/tree_test.go index 4b85cd44eb..1f7c31086c 100644 --- a/pkg/storage/fs/posix/tree/tree_test.go +++ b/pkg/storage/fs/posix/tree/tree_test.go @@ -59,12 +59,11 @@ var _ = SynchronizedBeforeSuite(func() { } if strings.Contains(name, "inotifywait") { + // Give it some time to setup the watches + time.Sleep(2 * time.Second) return true } } - - // Give it some time to setup the watches - time.Sleep(2 * time.Second) return false }).Should(BeTrue()) }, func() {}) From 0a2683352b4527a8dfb55315963107d094540616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 4 Jun 2024 08:30:56 +0200 Subject: [PATCH 6/7] Fix ceph docker build --- Dockerfile.revad-ceph | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.revad-ceph b/Dockerfile.revad-ceph index b3c22996e9..007f564c48 100644 --- a/Dockerfile.revad-ceph +++ b/Dockerfile.revad-ceph @@ -20,7 +20,8 @@ FROM quay.io/ceph/ceph:v18 # replace repo url with one that allows downloading the repo metadata # if http://download.ceph.com/rpm-reef/el8/x86_64/repodata/repomd.xml works again this can be dropped -RUN sed -i 's/download.ceph.com/fr.ceph.com/' /etc/yum.repos.d/ceph.repo +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* RUN mkdir -p /etc/selinux/config RUN dnf update --exclude=ceph-iscsi,chrony -y && dnf install -y \ From 5fb051815fbdc58413c4e6c6f6f83c26aa5e9f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 4 Jun 2024 09:22:28 +0200 Subject: [PATCH 7/7] Do not stat the spaceroot again. we already know the GID --- pkg/storage/utils/decomposedfs/upload.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index 95758fdbfb..33b077972c 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -24,7 +24,6 @@ import ( "os" "path/filepath" "strings" - "syscall" "time" "github.com/google/uuid" @@ -181,12 +180,10 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere session.SetStorageValue("SpaceRoot", n.SpaceRoot.ID) // TODO SpaceRoot -> SpaceID session.SetStorageValue("SpaceOwnerOrManager", n.SpaceOwnerOrManager(ctx).GetOpaqueId()) // TODO needed for what? - // remember the gid of the space - fi, err := os.Stat(n.SpaceRoot.InternalPath()) - if err != nil { - return nil, err + spaceGID, ok := ctx.Value(CtxKeySpaceGID).(uint32) + if ok { + session.SetStorageValue("SpaceGid", fmt.Sprintf("%d", spaceGID)) } - session.SetStorageValue("SpaceGid", fmt.Sprintf("%d", (fi.Sys().(*syscall.Stat_t).Gid))) iid, _ := ctxpkg.ContextGetInitiator(ctx) session.SetMetadata("initiatorid", iid)