summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 08:09:05 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 19:52:26 -0600
commiteb19c7c4d4a1a8b49ea4423b706edff651768447 (patch)
tree0aec03605440b55e6d96b3228c8cb264eb16d5be
parent1efce3f90371d12bbb429b1810ce3a5c53e4d4f6 (diff)
btrfsutil: RebuiltTree: Don't have laxAncestors hide UUID errors
-rw-r--r--lib/btrfsutil/rebuilt_forrest.go7
-rw-r--r--lib/btrfsutil/rebuilt_tree.go9
2 files changed, 12 insertions, 4 deletions
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
}
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go
index a0f5932..0598e05 100644
--- a/lib/btrfsutil/rebuilt_tree.go
+++ b/lib/btrfsutil/rebuilt_tree.go
@@ -34,6 +34,7 @@ type RebuiltTree struct {
Root btrfsvol.LogicalAddr
Parent *RebuiltTree
ParentGen btrfsprim.Generation // offset of this tree's root item
+ parentErr error
forrest *RebuiltForrest
// mutable
@@ -553,10 +554,14 @@ var _ btrfstree.Tree = (*RebuiltTree)(nil)
// TreeParentID implements btrfstree.Tree.
func (tree *RebuiltTree) TreeParentID(_ context.Context) (btrfsprim.ObjID, btrfsprim.Generation, error) {
- if tree.Parent == nil {
+ switch {
+ case tree.parentErr != nil:
+ return 0, 0, tree.parentErr
+ case tree.Parent == nil:
return 0, 0, nil
+ default:
+ return tree.Parent.ID, tree.ParentGen, nil
}
- return tree.Parent.ID, tree.ParentGen, nil
}
// TreeLookup implements btrfstree.Tree.