From 144d26e78c35e6742f958e1f85429770d6dd6fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 9 Mar 2023 20:45:07 +0100 Subject: [PATCH] remove error debug, save some locks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- pkg/storage/utils/decomposedfs/node/node.go | 4 +-- pkg/storage/utils/decomposedfs/tree/tree.go | 30 +++++++++---------- .../utils/decomposedfs/upload/processing.go | 3 +- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/pkg/storage/utils/decomposedfs/node/node.go b/pkg/storage/utils/decomposedfs/node/node.go index 225d04247ae..51712a7f0a9 100644 --- a/pkg/storage/utils/decomposedfs/node/node.go +++ b/pkg/storage/utils/decomposedfs/node/node.go @@ -193,7 +193,6 @@ func (n *Node) WriteAllNodeMetadata(ctx context.Context) (err error) { attribs[prefixes.BlobIDAttr] = n.BlobID attribs[prefixes.BlobsizeAttr] = strconv.FormatInt(n.Blobsize, 10) - appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Msg("Setting parent id") return n.SetXattrs(attribs, true) } @@ -316,9 +315,8 @@ func ReadNode(ctx context.Context, lu PathLookup, spaceID, nodeID string, canLis n.Name = attrs[prefixes.NameAttr] n.ParentID = attrs[prefixes.ParentidAttr] if n.ParentID == "" { - appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Interface("attrs", attrs).Msg("missing parent id") d, _ := os.ReadFile(n.InternalPath() + ".ini") - appctx.GetLogger(ctx).Error().Str("ini", string(d)).Msg("missing parent id") + appctx.GetLogger(ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Interface("attrs", attrs).Str("ini", string(d)).Msg("missing parent id") return nil, errtypes.InternalError("Missing parent ID on node") } // TODO why do we stat the parent? to determine if the current node is in the trash we would need to traverse all parents... diff --git a/pkg/storage/utils/decomposedfs/tree/tree.go b/pkg/storage/utils/decomposedfs/tree/tree.go index 9037c7c57e0..aeb0f53f687 100644 --- a/pkg/storage/utils/decomposedfs/tree/tree.go +++ b/pkg/storage/utils/decomposedfs/tree/tree.go @@ -387,12 +387,11 @@ func (t *Tree) Move(ctx context.Context, oldNode *node.Node, newNode *node.Node) } // update target parentid and name - appctx.GetLogger(ctx).Error().Str("nodeid", oldNode.ID).Str("parentid", newNode.ParentID).Msg("Setting parent id11111") - if err := oldNode.SetXattr(prefixes.ParentidAttr, newNode.ParentID); err != nil { - return errors.Wrap(err, "Decomposedfs: could not set parentid attribute") - } - if err := oldNode.SetXattr(prefixes.NameAttr, newNode.Name); err != nil { - return errors.Wrap(err, "Decomposedfs: could not set name attribute") + if err := oldNode.SetXattrs(map[string]string{ + prefixes.ParentidAttr: newNode.ParentID, + prefixes.NameAttr: newNode.Name, + }, true); err != nil { + return errors.Wrap(err, "Decomposedfs: could not update old node attributes") } // the size diff is the current treesize or blobsize of the old/source node @@ -618,17 +617,18 @@ func (t *Tree) RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPa } targetNode.Exists = true - // update name attribute - if err := recycleNode.SetXattr(prefixes.NameAttr, targetNode.Name); err != nil { - return errors.Wrap(err, "Decomposedfs: could not set name attribute") - } - // set ParentidAttr to restorePath's node parent id + attrs := map[string]string{ + // update name attribute + prefixes.NameAttr: targetNode.Name, + } if trashPath != "" { - appctx.GetLogger(ctx).Error().Str("nodeid", recycleNode.ID).Str("parentid", targetNode.ParentID).Msg("Setting parent id22222222") - if err := recycleNode.SetXattr(prefixes.ParentidAttr, targetNode.ParentID); err != nil { - return errors.Wrap(err, "Decomposedfs: could not set name attribute") - } + // set ParentidAttr to restorePath's node parent id + attrs[prefixes.ParentidAttr] = targetNode.ParentID + } + + if err = recycleNode.SetXattrs(attrs, true); err != nil { + return errors.Wrap(err, "Decomposedfs: could not update recycle node") } // delete item link in trash diff --git a/pkg/storage/utils/decomposedfs/upload/processing.go b/pkg/storage/utils/decomposedfs/upload/processing.go index 6027d9fb9e1..187757bb4ea 100644 --- a/pkg/storage/utils/decomposedfs/upload/processing.go +++ b/pkg/storage/utils/decomposedfs/upload/processing.go @@ -291,7 +291,6 @@ func CreateNodeForUpload(upload *Upload, initAttrs map[string]string) (*node.Nod initAttrs[prefixes.StatusPrefix] = node.ProcessingStatus + upload.Info.ID // update node metadata with new blobid etc - appctx.GetLogger(upload.Ctx).Error().Str("nodeid", n.ID).Str("parentid", n.ParentID).Msg("Setting parent id") err = n.SetXattrs(initAttrs, false) if err != nil { return nil, errors.Wrap(err, "Decomposedfs: could not write metadata") @@ -336,7 +335,7 @@ func initNewNode(upload *Upload, n *node.Node, fsize uint64) (*lockedfile.File, if _, ok := upload.lu.MetadataBackend().(metadata.IniBackend); ok { // for the ini backend we also need to touch the actual node file here. - // it stores the mtime of thge resource, which must not change when we update the ini file + // it stores the mtime of the resource, which must not change when we update the ini file h, err := os.OpenFile(n.InternalPath(), os.O_CREATE, 0600) if err != nil { return f, err