From 2300adb18820d09f73746f00df0e64ccbba25052 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 15 Apr 2023 09:00:33 -0600 Subject: 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. --- lib/btrfsutil/rebuilt_tree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/btrfsutil') 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 } -- cgit v1.2.3-2-g168b