summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-02 18:52:27 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-05 19:48:17 -0700
commit39dfaa5af4b628eee55b4aa583abf72ef5833f32 (patch)
treece4acde1e7c2c13ce7bd9cb7f0dcad040ce4d360
parentdcb9dbd93bc45cfce2ca8ca9eebf822a128caa97 (diff)
rebuildnodes/btrees: Enhance logging around failure to add a tree
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
index 6f0ac96..3ed27b6 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
@@ -115,12 +115,13 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
ts.trees.Store(treeID, nil)
}
}()
- if slices.Contains(treeID, stack) {
- return false
- }
stack = append(stack, treeID)
ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.add-tree", stack)
dlog.Info(ctx, "adding tree...")
+ if slices.Contains(treeID, stack[:len(stack)-1]) {
+ dlog.Errorf(ctx, "failed to add tree: loop detected: %v", stack)
+ return false
+ }
tree := &RebuiltTree{
ID: treeID,
@@ -140,10 +141,12 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
root = ts.sb.BlockGroupRoot
default:
if !ts.addTree(ctx, btrfsprim.ROOT_TREE_OBJECTID, stack) {
+ dlog.Error(ctx, "failed to add tree: add ROOT_TREE")
return false
}
rootOff, rootItem, ok := ts.cbLookupRoot(ctx, treeID)
if !ok {
+ dlog.Error(ctx, "failed to add tree: lookup ROOT_ITEM")
return false
}
root = rootItem.ByteNr
@@ -155,9 +158,11 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
}
parentID, ok := ts.cbLookupUUID(ctx, rootItem.ParentUUID)
if !ok {
+ dlog.Error(ctx, "failed to add tree: lookup UUID")
return false
}
if !ts.addTree(ctx, parentID, stack) {
+ dlog.Error(ctx, "failed to add tree: add parent tree")
return false
}
tree.Parent, _ = ts.trees.Load(parentID)