From eb19c7c4d4a1a8b49ea4423b706edff651768447 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Apr 2023 08:09:05 -0600 Subject: btrfsutil: RebuiltTree: Don't have laxAncestors hide UUID errors --- lib/btrfsutil/rebuilt_forrest.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/btrfsutil/rebuilt_forrest.go') diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go index 900e725..5741072 100644 --- a/lib/btrfsutil/rebuilt_forrest.go +++ b/lib/btrfsutil/rebuilt_forrest.go @@ -223,8 +223,11 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI ts.trees[treeID].ParentGen = rootOff parentID, ok := ts.cb.LookupUUID(ctx, rootItem.ParentUUID) if !ok { - if !ts.laxAncestors { - ts.trees[treeID].rootErr = fmt.Errorf("failed to look up UUID: %v", rootItem.ParentUUID) + err := fmt.Errorf("failed to look up UUID: %v", rootItem.ParentUUID) + if ts.laxAncestors { + ts.trees[treeID].parentErr = err + } else { + ts.trees[treeID].rootErr = err } return } -- cgit v1.2.3-2-g168b From 2fec63f72ded515dd51b08245f344385adbe34fb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Apr 2023 15:53:20 -0600 Subject: btrfsutil: RebuiltForrest: Have LookupUUID return an error --- lib/btrfsutil/rebuilt_forrest.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/btrfsutil/rebuilt_forrest.go') diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go index 5741072..3c53af7 100644 --- a/lib/btrfsutil/rebuilt_forrest.go +++ b/lib/btrfsutil/rebuilt_forrest.go @@ -221,9 +221,9 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI ts.trees[treeID].UUID = rootItem.UUID if rootItem.ParentUUID != (btrfsprim.UUID{}) { ts.trees[treeID].ParentGen = rootOff - parentID, ok := ts.cb.LookupUUID(ctx, rootItem.ParentUUID) - if !ok { - err := fmt.Errorf("failed to look up UUID: %v", rootItem.ParentUUID) + parentID, err := ts.cb.LookupUUID(ctx, rootItem.ParentUUID) + if err != nil { + err := fmt.Errorf("failed to look up UUID: %v: %w", rootItem.ParentUUID, err) if ts.laxAncestors { ts.trees[treeID].parentErr = err } else { -- cgit v1.2.3-2-g168b From 6b521d08bbb75430432834e5fcd2cb1da3de1e2e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Apr 2023 18:21:04 -0600 Subject: btrfsutil: RebuiltForrest: Have LookupRoot return an error --- lib/btrfsutil/rebuilt_forrest.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/btrfsutil/rebuilt_forrest.go') diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go index 3c53af7..3e40103 100644 --- a/lib/btrfsutil/rebuilt_forrest.go +++ b/lib/btrfsutil/rebuilt_forrest.go @@ -212,9 +212,9 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI sb, _ := ts.Superblock() ts.trees[treeID].Root = sb.BlockGroupRoot default: - rootOff, rootItem, ok := ts.cb.LookupRoot(ctx, treeID) - if !ok { - ts.trees[treeID].rootErr = btrfstree.ErrNoTree + rootOff, rootItem, err := ts.cb.LookupRoot(ctx, treeID) + if err != nil { + ts.trees[treeID].rootErr = fmt.Errorf("%w: %s", btrfstree.ErrNoTree, err) return } ts.trees[treeID].Root = rootItem.ByteNr -- cgit v1.2.3-2-g168b From 7bd942c1e5f8d4a18f7e1ac866191d8f1aa31d30 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 17 Apr 2023 19:06:26 -0600 Subject: btrfsutil: RebuiltForrest: Fuss with error messages --- lib/btrfsutil/rebuilt_forrest.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/btrfsutil/rebuilt_forrest.go') diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go index 3e40103..79d8beb 100644 --- a/lib/btrfsutil/rebuilt_forrest.go +++ b/lib/btrfsutil/rebuilt_forrest.go @@ -214,7 +214,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI default: rootOff, rootItem, err := ts.cb.LookupRoot(ctx, treeID) if err != nil { - ts.trees[treeID].rootErr = fmt.Errorf("%w: %s", btrfstree.ErrNoTree, err) + ts.trees[treeID].rootErr = fmt.Errorf("tree %s: %w: %s", + treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), btrfstree.ErrNoTree, err) return } ts.trees[treeID].Root = rootItem.ByteNr @@ -223,7 +224,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI ts.trees[treeID].ParentGen = rootOff parentID, err := ts.cb.LookupUUID(ctx, rootItem.ParentUUID) if err != nil { - err := fmt.Errorf("failed to look up UUID: %v: %w", rootItem.ParentUUID, err) + err := fmt.Errorf("tree %s: failed to look up UUID: %v: %w", + treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), rootItem.ParentUUID, err) if ts.laxAncestors { ts.trees[treeID].parentErr = err } else { @@ -238,7 +240,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI ts.trees[treeID].ancestorLoop = true return case !ts.laxAncestors && ts.trees[treeID].Parent.rootErr != nil: - ts.trees[treeID].rootErr = fmt.Errorf("failed to rebuild parent tree: %v: %w", parentID, ts.trees[treeID].Parent.rootErr) + ts.trees[treeID].rootErr = fmt.Errorf("tree %s: failed to rebuild parent: %w", + treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), ts.trees[treeID].Parent.rootErr) return } } -- cgit v1.2.3-2-g168b