summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-15 09:00:33 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-16 09:35:05 -0600
commit2300adb18820d09f73746f00df0e64ccbba25052 (patch)
tree951abfa0b0bd9cb98c2bfe25b7f3e973d6abf960
parent0322e9e1b9ff017f084555286d1569e88ecaf8a8 (diff)
btrfsutil: RebuiltTree: TreeWalk: Touch up
- Go ahead and have .NodeExpectations fail closed. It shouldn't make a difference at this point, but being stricter here is better. - Add a sanity check that the walker hasn't disagreed from the nodeIndex. At the leafs, the sanity check on items.Load should detect this, but let's detect it earlier to make things easier to debug.
-rw-r--r--lib/btrfsutil/rebuilt_tree.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go
index 70be4c8..8d5921b 100644
--- a/lib/btrfsutil/rebuilt_tree.go
+++ b/lib/btrfsutil/rebuilt_tree.go
@@ -660,7 +660,7 @@ func (walker *rebuiltWalker) walk(ctx context.Context, path btrfstree.Path) {
}
// 001
- nodeAddr, nodeExp, ok := path.NodeExpectations(ctx, true)
+ nodeAddr, nodeExp, ok := path.NodeExpectations(ctx, false)
if !ok {
panic(fmt.Errorf("should not happen: btrfsutil.rebuiltWalker.walk called with non-node path: %v",
path))
@@ -686,6 +686,10 @@ func (walker *rebuiltWalker) walk(ctx context.Context, path btrfstree.Path) {
}
return
}
+ if !maps.HaveAnyKeysInCommon(walker.tree.Roots, walker.nodeIndex.nodeToRoots[nodeAddr]) {
+ panic(fmt.Errorf("should not happen: node@%v is not in the tree, but did not error: path=%#v exp=%#v",
+ nodeAddr, path, nodeExp))
+ }
if walker.visited.Has(nodeAddr) {
return
}