summaryrefslogtreecommitdiff
path: root/lib/btrfs/csums.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 15:17:11 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-15 20:42:51 -0600
commitd7e086766e0f4396f29987d3798cefc1bb675d1c (patch)
treee45cc733519e5fc540a3b28ef36ebd354ed001cc /lib/btrfs/csums.go
parent56e44b0630448d44f7aa7f85b2098007ddbae06f (diff)
btrfstree: Have errors include context of what was being searched for
Diffstat (limited to 'lib/btrfs/csums.go')
-rw-r--r--lib/btrfs/csums.go14
1 files changed, 1 insertions, 13 deletions
diff --git a/lib/btrfs/csums.go b/lib/btrfs/csums.go
index 9e0b755..8515d12 100644
--- a/lib/btrfs/csums.go
+++ b/lib/btrfs/csums.go
@@ -48,19 +48,7 @@ func ChecksumQualifiedPhysical(fs *FS, alg btrfssum.CSumType, paddr btrfsvol.Qua
}
func LookupCSum(fs btrfstree.TreeOperator, alg btrfssum.CSumType, laddr btrfsvol.LogicalAddr) (btrfssum.SumRun[btrfsvol.LogicalAddr], error) {
- item, err := fs.TreeSearch(btrfsprim.CSUM_TREE_OBJECTID, func(key btrfsprim.Key, size uint32) int {
- itemBeg := btrfsvol.LogicalAddr(key.Offset)
- numSums := int64(size) / int64(alg.Size())
- itemEnd := itemBeg + btrfsvol.LogicalAddr(numSums*btrfssum.BlockSize)
- switch {
- case itemEnd <= laddr:
- return 1
- case laddr < itemBeg:
- return -1
- default:
- return 0
- }
- })
+ item, err := fs.TreeSearch(btrfsprim.CSUM_TREE_OBJECTID, btrfstree.SearchCSum(laddr, alg.Size()))
if err != nil {
return btrfssum.SumRun[btrfsvol.LogicalAddr]{}, err
}