summaryrefslogtreecommitdiff
path: root/lib/btrfsutil/old_rebuilt_forrest.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-30 10:04:09 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-30 10:04:09 -0600
commitcdc2df19c59965149e11c3a5710458c626ea0668 (patch)
tree2e0bafd99a433d7271bf42e68ab1b5c1eba99e2b /lib/btrfsutil/old_rebuilt_forrest.go
parent0b092a27122fcf19479d6cdeae5f7c9493d9741a (diff)
parent94aa0ec3e9f7145cdf177ad6f6d3d8b7d5bdbef7 (diff)
Merge branch 'lukeshu/node-cache'
Diffstat (limited to 'lib/btrfsutil/old_rebuilt_forrest.go')
-rw-r--r--lib/btrfsutil/old_rebuilt_forrest.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/btrfsutil/old_rebuilt_forrest.go b/lib/btrfsutil/old_rebuilt_forrest.go
index 5b99892..36abe6f 100644
--- a/lib/btrfsutil/old_rebuilt_forrest.go
+++ b/lib/btrfsutil/old_rebuilt_forrest.go
@@ -231,12 +231,7 @@ func (tree oldRebuiltTree) addErrs(fn func(btrfsprim.Key, uint32) int, err error
}
func (bt *OldRebuiltForrest) readNode(nodeInfo nodeInfo) *btrfstree.Node {
- sb, err := bt.inner.Superblock()
- if err != nil {
- panic(fmt.Errorf("should not happen: i/o error: %w", err))
- }
-
- node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](bt.inner, *sb, nodeInfo.LAddr, btrfstree.NodeExpectations{
+ node, err := bt.inner.AcquireNode(bt.ctx, nodeInfo.LAddr, btrfstree.NodeExpectations{
LAddr: containers.OptionalValue(nodeInfo.LAddr),
Level: containers.OptionalValue(nodeInfo.Level),
Generation: containers.OptionalValue(nodeInfo.Generation),
@@ -286,7 +281,7 @@ func (tree oldRebuiltTree) treeSearch(_ context.Context, searcher btrfstree.Tree
}
node := tree.forrest.readNode(indexItem.Value.Node)
- defer node.Free()
+ defer tree.forrest.inner.ReleaseNode(node)
item := node.BodyLeaf[indexItem.Value.Slot]
item.Body = item.Body.CloneItem()
@@ -323,12 +318,12 @@ func (tree oldRebuiltTree) treeSubrange(_ context.Context, min int, searcher btr
func(rbNode *containers.RBNode[oldRebuiltTreeValue]) bool {
cnt++
if node == nil || node.Head.Addr != rbNode.Value.Node.LAddr {
- node.Free()
+ tree.forrest.inner.ReleaseNode(node)
node = tree.forrest.readNode(rbNode.Value.Node)
}
return handleFn(node.BodyLeaf[rbNode.Value.Slot])
})
- node.Free()
+ tree.forrest.inner.ReleaseNode(node)
var err error
if cnt < min {
@@ -371,7 +366,7 @@ func (tree oldRebuiltTree) treeWalk(ctx context.Context, cbs btrfstree.TreeWalkH
return false
}
if node == nil || node.Head.Addr != indexItem.Value.Node.LAddr {
- node.Free()
+ tree.forrest.inner.ReleaseNode(node)
node = tree.forrest.readNode(indexItem.Value.Node)
}
item := node.BodyLeaf[indexItem.Value.Slot]
@@ -404,7 +399,7 @@ func (tree oldRebuiltTree) treeWalk(ctx context.Context, cbs btrfstree.TreeWalkH
}
return ctx.Err() == nil
})
- node.Free()
+ tree.forrest.inner.ReleaseNode(node)
}
// Superblock implements btrfs.ReadableFS.