diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-03 21:25:35 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-05 19:48:18 -0700 |
commit | 2aa2b9de6c9f967437dacd8f105e5a66c9bdc667 (patch) | |
tree | bfcc8c2a0de71fe8c26c791fea3ad23c4ea086e3 | |
parent | 58a6dd12470931a7143c47036e8fde32e43c7e51 (diff) |
rebuildnodes: _walkRange: Tidy up
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go index 28591dd..87d9f35 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go @@ -717,18 +717,6 @@ func (o *rebuilder) _walkRange( beg, end uint64, fn func(key btrfsprim.Key, ptr keyio.ItemPtr, beg, end uint64), ) { - sizeFn := func(key btrfsprim.Key) (uint64, error) { - ptr, ok := items.Load(key) - if !ok { - panic(fmt.Errorf("should not happen: could not load key: %v", keyAndTree{TreeID: treeID, Key: key})) - } - sizeAndErr, ok := o.keyIO.Sizes[ptr] - if !ok { - panic(fmt.Errorf("should not happen: %v item did not have a size recorded", typ)) - } - return sizeAndErr.Size, sizeAndErr.Err - } - min := btrfsprim.Key{ ObjectID: objID, ItemType: typ, @@ -751,11 +739,18 @@ func (o *rebuilder) _walkRange( } }, func(runKey btrfsprim.Key, runPtr keyio.ItemPtr) bool { - runSize, err := sizeFn(runKey) - if err != nil { - o.fsErr(ctx, fmt.Errorf("get size: %v: %w", keyAndTree{TreeID: treeID, Key: runKey}, err)) + runSizeAndErr, ok := o.keyIO.Sizes[runPtr] + if !ok { + panic(fmt.Errorf("should not happen: %v (%v) did not have a size recorded", + runPtr, keyAndTree{TreeID: treeID, Key: runKey})) + } + if runSizeAndErr.Err != nil { + o.fsErr(ctx, fmt.Errorf("get size: %v (%v): %w", + runPtr, keyAndTree{TreeID: treeID, Key: runKey}, + runSizeAndErr.Err)) return true } + runSize := runSizeAndErr.Size if runSize == 0 { return true } |