diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-29 10:00:18 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-30 10:03:50 -0600 |
commit | 94aa0ec3e9f7145cdf177ad6f6d3d8b7d5bdbef7 (patch) | |
tree | 2e0bafd99a433d7271bf42e68ab1b5c1eba99e2b /cmd | |
parent | 2eb7033431866cb05d235eb10c280a4810bf88a7 (diff) |
btrfstree: Change the NodeSource API so that it can do caching
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/btrfs-rec/inspect/rebuildtrees/scan.go | 6 | ||||
-rw-r--r-- | cmd/btrfs-rec/inspect_lstrees.go | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go index 86d3741..a6f9c7a 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go @@ -71,17 +71,17 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, nodeList []btrfsvol.LogicalA if err := ctx.Err(); err != nil { return ScanDevicesResult{}, err } - node, err := fs.ReadNode(ctx, laddr, btrfstree.NodeExpectations{ + node, err := fs.AcquireNode(ctx, laddr, btrfstree.NodeExpectations{ LAddr: containers.OptionalValue(laddr), }) if err != nil { - node.Free() + fs.ReleaseNode(node) return ScanDevicesResult{}, err } ret.insertNode(node) - node.Free() + fs.ReleaseNode(node) stats.N++ progressWriter.Set(stats) diff --git a/cmd/btrfs-rec/inspect_lstrees.go b/cmd/btrfs-rec/inspect_lstrees.go index 9639a2e..bdbdca2 100644 --- a/cmd/btrfs-rec/inspect_lstrees.go +++ b/cmd/btrfs-rec/inspect_lstrees.go @@ -106,10 +106,11 @@ func init() { continue } visitedNodes.Insert(laddr) - node, err := fs.ReadNode(ctx, laddr, btrfstree.NodeExpectations{ + node, err := fs.AcquireNode(ctx, laddr, btrfstree.NodeExpectations{ LAddr: containers.OptionalValue(laddr), }) if err != nil { + fs.ReleaseNode(node) treeErrCnt++ continue } @@ -117,6 +118,7 @@ func init() { typ := item.Key.ItemType treeItemCnt[typ]++ } + fs.ReleaseNode(node) } flush() } |