summaryrefslogtreecommitdiff
path: root/lib/btrfs/csums.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-16 08:29:36 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-16 08:29:36 -0600
commitc0f33186aa7a8903c5e7406024f13fad48cd14e3 (patch)
treec8361c8278b07839be9af2ccee3507d324a7a216 /lib/btrfs/csums.go
parentc2925f0f8a5d69369b43de0d2d201291fe5ed9d1 (diff)
parent17833fa13d5a7dcd79ad507fe4abf96b4a4a898b (diff)
Merge branch 'lukeshu/errs'
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
}