summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-06 02:03:50 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-02-12 16:20:05 -0700
commit8530a8b7b5f9f27bb5b5c319f285bb5a26470285 (patch)
tree3070f8e76149bc98aeef0572f5147c4d83084acf /lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
parent2643592b0a802f3816a47f8d3425a8f3282eae3b (diff)
rebuildnodes: Rework to be clear about what went wrong when reading
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go24
1 files changed, 3 insertions, 21 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
index 624441f..d11ca58 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
@@ -91,12 +91,6 @@ func NewRebuilder(ctx context.Context, fs *btrfs.FS, nodeScanResults btrfsinspec
return o, nil
}
-func (o *rebuilder) ioErr(ctx context.Context, err error) {
- err = fmt.Errorf("should not happen: i/o error: %w", err)
- dlog.Error(ctx, err)
- panic(err)
-}
-
func (o *rebuilder) ListRoots() map[btrfsprim.ObjID]containers.Set[btrfsvol.LogicalAddr] {
return o.rebuilt.ListRoots()
}
@@ -174,13 +168,9 @@ func (o *rebuilder) Rebuild(_ctx context.Context) error {
return err
}
itemCtx := dlog.WithField(stepCtx, "btrfsinspect.rebuild-nodes.rebuild.process.item", key)
- itemBody, ok := o.rebuilt.Tree(itemCtx, key.TreeID).ReadItem(itemCtx, key.Key)
- if !ok {
- o.ioErr(itemCtx, fmt.Errorf("could not read previously read item: %v", key))
- }
itemChan <- keyAndBody{
keyAndTree: key,
- Body: itemBody,
+ Body: o.rebuilt.Tree(itemCtx, key.TreeID).ReadItem(itemCtx, key.Key),
}
}
return nil
@@ -285,11 +275,7 @@ func (o *rebuilder) cbLookupRoot(ctx context.Context, tree btrfsprim.ObjID) (off
o.enqueueRetry()
return 0, btrfsitem.Root{}, false
}
- itemBody, ok := o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key)
- if !ok {
- o.ioErr(ctx, fmt.Errorf("could not read previously read item: %v", key))
- }
- switch itemBody := itemBody.(type) {
+ switch itemBody := o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key).(type) {
case *btrfsitem.Root:
return btrfsprim.Generation(key.Offset), *itemBody, true
case *btrfsitem.Error:
@@ -310,11 +296,7 @@ func (o *rebuilder) cbLookupUUID(ctx context.Context, uuid btrfsprim.UUID) (id b
o.enqueueRetry()
return 0, false
}
- itemBody, ok := o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key)
- if !ok {
- o.ioErr(ctx, fmt.Errorf("could not read previously read item: %v", key))
- }
- switch itemBody := itemBody.(type) {
+ switch itemBody := o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key).(type) {
case *btrfsitem.UUIDMap:
return itemBody.ObjID, true
case *btrfsitem.Error: