diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/btrfs/btrfstree/types_node.go | 8 | ||||
-rw-r--r-- | lib/btrfs/io3_btree.go | 12 | ||||
-rw-r--r-- | lib/btrfsutil/scan.go | 2 |
3 files changed, 13 insertions, 9 deletions
diff --git a/lib/btrfs/btrfstree/types_node.go b/lib/btrfs/btrfstree/types_node.go index 28b93cf..082be2c 100644 --- a/lib/btrfs/btrfstree/types_node.go +++ b/lib/btrfs/btrfstree/types_node.go @@ -446,7 +446,7 @@ var nodePool = typedsync.Pool[*Node]{ // returned. The error returned (if non-nil) is always of type // *NodeError[Addr]. Notable errors that may be inside of the // NodeError are ErrNotANode and *IOError. -func ReadNode[Addr ~int64](fs diskio.ReaderAt[Addr], sb Superblock, addr Addr, exp NodeExpectations) (*Node, error) { +func ReadNode[Addr ~int64](fs diskio.ReaderAt[Addr], sb Superblock, addr Addr) (*Node, error) { if int(sb.NodeSize) < nodeHeaderSize { return nil, &NodeError[Addr]{ Op: "btrfstree.ReadNode", NodeAddr: addr, @@ -512,12 +512,6 @@ func ReadNode[Addr ~int64](fs diskio.ReaderAt[Addr], sb Superblock, addr Addr, e bytePool.Put(nodeBuf) - // sanity checking (that doesn't prevent parsing) - - if err := exp.Check(node); err != nil { - return node, &NodeError[Addr]{Op: "btrfstree.ReadNode", NodeAddr: addr, Err: err} - } - // return return node, nil diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index bb68d7d..4d1ebe3 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -86,7 +86,17 @@ func (fs *FS) ReadNode(_ context.Context, addr btrfsvol.LogicalAddr, exp btrfstr if err != nil { return nil, fmt.Errorf("btrfs.FS.ReadNode: %w", err) } - return btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, addr, exp) + + node, err := btrfstree.ReadNode[btrfsvol.LogicalAddr](fs, *sb, addr) + if err != nil { + return node, err + } + + if err := exp.Check(node); err != nil { + return node, fmt.Errorf("btrfstree.ReadNode: node@%v: %w", addr, err) // fmt.Errorf("btrfs.FS.ReadNode: node@%v: %w", addr, err) + } + + return node, nil } var _ btrfstree.NodeSource = (*FS)(nil) diff --git a/lib/btrfsutil/scan.go b/lib/btrfsutil/scan.go index 05b27d5..12e1dfe 100644 --- a/lib/btrfsutil/scan.go +++ b/lib/btrfsutil/scan.go @@ -122,7 +122,7 @@ func ScanOneDevice[Stats comparable, Result any](ctx context.Context, dev *btrfs } if checkForNode { - node, err := btrfstree.ReadNode[btrfsvol.PhysicalAddr](dev, *sb, pos, btrfstree.NodeExpectations{}) + node, err := btrfstree.ReadNode[btrfsvol.PhysicalAddr](dev, *sb, pos) if err != nil { if !errors.Is(err, btrfstree.ErrNotANode) { dlog.Errorf(ctx, "error: %v", err) |