From f7917fb1cf855b32deb35fc29715e810bb37b178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 15 Jun 2023 15:16:02 +0200 Subject: [PATCH] drop O_CREATE for messagepack backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/no-o-create-for-messagepack.md | 3 +++ pkg/storage/utils/decomposedfs/tree/tree.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/no-o-create-for-messagepack.md diff --git a/changelog/unreleased/no-o-create-for-messagepack.md b/changelog/unreleased/no-o-create-for-messagepack.md new file mode 100644 index 00000000000..87b5ee453fb --- /dev/null +++ b/changelog/unreleased/no-o-create-for-messagepack.md @@ -0,0 +1,3 @@ +Bugfix: The decomposedfs messagepack backend now dies when trying to propagate metadata to a non existing parent + +https://github.com/cs3org/reva/pull/3980 \ No newline at end of file diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index 5ab6d69af50..bb1be153edb 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -714,10 +714,12 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node, sizeDiff int64) (err // lock parent before reading treesize or tree time switch t.lookup.MetadataBackend().(type) { case metadata.MessagePackBackend: - f, err = lockedfile.OpenFile(t.lookup.MetadataBackend().MetadataPath(n.ParentPath()), os.O_RDWR|os.O_CREATE, 0600) + // no need to O_CREATE the file, we can use the metadata file. Actually, we want to error if the parent does not exist! + f, err = lockedfile.OpenFile(t.lookup.MetadataBackend().MetadataPath(n.ParentPath()), os.O_RDWR, 0600) case metadata.XattrsBackend: // we have to use dedicated lockfiles to lock directories // this only works because the xattr backend also locks folders with separate lock files + // we need to O_CREATE a lockfile if it does not exist, yet f, err = lockedfile.OpenFile(n.ParentPath()+filelocks.LockFileSuffix, os.O_RDWR|os.O_CREATE, 0600) } if err != nil {