From b302df6a761fda3ba1ba60c6866eb39dbb36527a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Mar 2023 09:42:44 -0700 Subject: 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. --- lib/btrfsutil/rebuilt_readitem.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/btrfsutil/rebuilt_readitem.go') 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))) -- cgit v1.2.3-2-g168b