diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-04 09:42:44 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-15 12:01:29 -0600 |
commit | b302df6a761fda3ba1ba60c6866eb39dbb36527a (patch) | |
tree | d144566198f604d91d83196788bca588d99e74db /lib/btrfsutil/rebuilt_readitem.go | |
parent | c2c6fa42233cd3911b81bb9449329816f645cec5 (diff) |
Clean-up made possible by btrfsutil.RebuiltForrest implementing btrfs.ReadableFS
- rebuildtrees: Use .ForrestLookup instead of .RebuiltTree where possible
- btrfsutil: noopRebuiltForrestCallbacks: Use only the generic
btrfstree.Forrest API
- btrfsutil: RebuiltForrest, RebuiltTree: Avoid unnecessarily
reaching into forrest.inner
- btrfsutil: RebuiltTree: Drop the .ReadItem() method; it duplicates
.TreeLookup without benefit.
Diffstat (limited to 'lib/btrfsutil/rebuilt_readitem.go')
-rw-r--r-- | lib/btrfsutil/rebuilt_readitem.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/btrfsutil/rebuilt_readitem.go b/lib/btrfsutil/rebuilt_readitem.go index e5faa45..841b04a 100644 --- a/lib/btrfsutil/rebuilt_readitem.go +++ b/lib/btrfsutil/rebuilt_readitem.go @@ -35,7 +35,7 @@ func (ts *RebuiltForrest) readItem(ctx context.Context, ptr ItemPtr) btrfstree.I panic(fmt.Errorf("should not happen: btrfsutil.RebuiltForrest.readItem called for negative item slot: %v", ptr.Slot)) } - node, err := ts.inner.AcquireNode(ctx, ptr.Node, btrfstree.NodeExpectations{ + node, err := ts.AcquireNode(ctx, ptr.Node, btrfstree.NodeExpectations{ LAddr: containers.OptionalValue(ptr.Node), Level: containers.OptionalValue(graphInfo.Level), Generation: containers.OptionalValue(graphInfo.Generation), @@ -50,13 +50,12 @@ func (ts *RebuiltForrest) readItem(ctx context.Context, ptr ItemPtr) btrfstree.I MinItem: containers.OptionalValue(graphInfo.MinItem(ts.graph)), MaxItem: containers.OptionalValue(graphInfo.MaxItem(ts.graph)), }) - defer ts.inner.ReleaseNode(node) + defer ts.ReleaseNode(node) if err != nil { panic(fmt.Errorf("should not happen: i/o error: %w", err)) } items := node.BodyLeaf - if ptr.Slot >= len(items) { panic(fmt.Errorf("should not happen: btrfsutil.RebuiltForrest.readItem called for out-of-bounds item slot: slot=%v len=%v", ptr.Slot, len(items))) |