diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-28 19:21:37 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-17 22:30:37 -0400 |
commit | ec1b90339bf712d08c417d735faa4ef40e99d452 (patch) | |
tree | e490a935d8a9231563b0136ddea83d548b13eff4 /cmd/btrfs-rec/inspect | |
parent | b97b6962d5027ae3db2bb03db1e5303702c3e9b2 (diff) |
rebuildmappings: Audit identifier names
Diffstat (limited to 'cmd/btrfs-rec/inspect')
8 files changed, 66 insertions, 64 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process.go b/cmd/btrfs-rec/inspect/rebuildmappings/process.go index a93b697..e42acf9 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process.go @@ -117,7 +117,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR // First dedup them, because they change for allocations and // CoW means that they'll bounce around a lot, so you likely // have oodles of duplicates? - bgs, err := DedupBlockGroups(scanResults) + bgs, err := dedupedBlockGroups(scanResults) if err != nil { return err } @@ -162,8 +162,8 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR // slower. ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "5/6") dlog.Infof(_ctx, "5/6: Searching for %d block groups in checksum map (exact)...", len(bgs)) - physicalSums := ExtractPhysicalSums(scanResults) - logicalSums := ExtractLogicalSums(ctx, scanResults) + physicalSums := extractPhysicalSums(scanResults) + logicalSums := extractLogicalSums(ctx, scanResults) if err := matchBlockGroupSumsExact(ctx, fs, bgs, physicalSums, logicalSums); err != nil { return err } @@ -179,7 +179,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "report") dlog.Info(_ctx, "report:") - unmappedPhysicalRegions := ListUnmappedPhysicalRegions(fs) + unmappedPhysicalRegions := listUnmappedPhysicalRegions(fs) var unmappedPhysical btrfsvol.AddrDelta var numUnmappedPhysical int for _, devRegions := range unmappedPhysicalRegions { @@ -190,7 +190,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR } dlog.Infof(ctx, "... %d of unmapped physical space (across %d regions)", textui.IEC(unmappedPhysical, "B"), numUnmappedPhysical) - unmappedLogicalRegions := ListUnmappedLogicalRegions(fs, logicalSums) + unmappedLogicalRegions := listUnmappedLogicalRegions(fs, logicalSums) var unmappedLogical btrfsvol.AddrDelta for _, region := range unmappedLogicalRegions { unmappedLogical += region.Size() diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_blockgroups.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_blockgroups.go index f8d2337..e7cdf0e 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_blockgroups.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_blockgroups.go @@ -13,18 +13,18 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/maps" ) -type BlockGroup struct { +type blockGroup struct { LAddr btrfsvol.LogicalAddr Size btrfsvol.AddrDelta Flags btrfsvol.BlockGroupFlags } -func DedupBlockGroups(scanResults ScanDevicesResult) (map[btrfsvol.LogicalAddr]BlockGroup, error) { +func dedupedBlockGroups(scanResults ScanDevicesResult) (map[btrfsvol.LogicalAddr]blockGroup, error) { // Dedup - bgsSet := make(containers.Set[BlockGroup]) + bgsSet := make(containers.Set[blockGroup]) for _, devResults := range scanResults { for _, bg := range devResults.FoundBlockGroups { - bgsSet.Insert(BlockGroup{ + bgsSet.Insert(blockGroup{ LAddr: btrfsvol.LogicalAddr(bg.Key.ObjectID), Size: btrfsvol.AddrDelta(bg.Key.Offset), Flags: bg.BG.Flags, @@ -49,7 +49,7 @@ func DedupBlockGroups(scanResults ScanDevicesResult) (map[btrfsvol.LogicalAddr]B // Return. We return a map instead of a slice in order to // facilitate easy deletes. - bgsMap := make(map[btrfsvol.LogicalAddr]BlockGroup, len(bgsSet)) + bgsMap := make(map[btrfsvol.LogicalAddr]blockGroup, len(bgsSet)) for bg := range bgsSet { bgsMap[bg.LAddr] = bg } diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go index 533ae67..ef9d9aa 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_exact.go @@ -19,15 +19,15 @@ import ( func matchBlockGroupSumsExact(ctx context.Context, fs *btrfs.FS, - blockgroups map[btrfsvol.LogicalAddr]BlockGroup, + blockgroups map[btrfsvol.LogicalAddr]blockGroup, physicalSums map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr], - logicalSums SumRunWithGaps[btrfsvol.LogicalAddr], + logicalSums sumRunWithGaps[btrfsvol.LogicalAddr], ) error { - regions := ListUnmappedPhysicalRegions(fs) + regions := listUnmappedPhysicalRegions(fs) numBlockgroups := len(blockgroups) for i, bgLAddr := range maps.SortedKeys(blockgroups) { blockgroup := blockgroups[bgLAddr] - bgRun := SumsForLogicalRegion(logicalSums, blockgroup.LAddr, blockgroup.Size) + bgRun := sumsForLogicalRegion(logicalSums, blockgroup.LAddr, blockgroup.Size) if len(bgRun.Runs) == 0 { dlog.Errorf(ctx, "(%v/%v) blockgroup[laddr=%v] can't be matched because it has 0 runs", i+1, numBlockgroups, bgLAddr) @@ -35,7 +35,7 @@ func matchBlockGroupSumsExact(ctx context.Context, } var matches []btrfsvol.QualifiedPhysicalAddr - if err := WalkUnmappedPhysicalRegions(ctx, physicalSums, regions, func(devID btrfsvol.DeviceID, region btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { + if err := walkUnmappedPhysicalRegions(ctx, physicalSums, regions, func(devID btrfsvol.DeviceID, region btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { rawMatches := indexAll[int, btrfssum.ShortSum](region, bgRun) for _, match := range rawMatches { matches = append(matches, btrfsvol.QualifiedPhysicalAddr{ diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go index 00f367f..905211c 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go @@ -39,17 +39,17 @@ func (a fuzzyRecord) Compare(b fuzzyRecord) int { func matchBlockGroupSumsFuzzy(ctx context.Context, fs *btrfs.FS, - blockgroups map[btrfsvol.LogicalAddr]BlockGroup, + blockgroups map[btrfsvol.LogicalAddr]blockGroup, physicalSums map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr], - logicalSums SumRunWithGaps[btrfsvol.LogicalAddr], + logicalSums sumRunWithGaps[btrfsvol.LogicalAddr], ) error { _ctx := ctx ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.substep", "indexing") dlog.Info(ctx, "Indexing physical regions...") // O(m) - regions := ListUnmappedPhysicalRegions(fs) + regions := listUnmappedPhysicalRegions(fs) physicalIndex := make(map[btrfssum.ShortSum][]btrfsvol.QualifiedPhysicalAddr) - if err := WalkUnmappedPhysicalRegions(ctx, physicalSums, regions, func(devID btrfsvol.DeviceID, region btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { + if err := walkUnmappedPhysicalRegions(ctx, physicalSums, regions, func(devID btrfsvol.DeviceID, region btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { return region.Walk(ctx, func(paddr btrfsvol.PhysicalAddr, sum btrfssum.ShortSum) error { physicalIndex[sum] = append(physicalIndex[sum], btrfsvol.QualifiedPhysicalAddr{ Dev: devID, @@ -67,7 +67,7 @@ func matchBlockGroupSumsFuzzy(ctx context.Context, numBlockgroups := len(blockgroups) for i, bgLAddr := range maps.SortedKeys(blockgroups) { blockgroup := blockgroups[bgLAddr] - bgRun := SumsForLogicalRegion(logicalSums, blockgroup.LAddr, blockgroup.Size) + bgRun := sumsForLogicalRegion(logicalSums, blockgroup.LAddr, blockgroup.Size) d := bgRun.PatLen() matches := make(map[btrfsvol.QualifiedPhysicalAddr]int) diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_logical.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_logical.go index 2cdabb7..52f8252 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_logical.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_logical.go @@ -19,8 +19,8 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/slices" ) -func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumRunWithGaps[btrfsvol.LogicalAddr] { - var records []SysExtentCSum +func extractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) sumRunWithGaps[btrfsvol.LogicalAddr] { + var records []FoundExtentCSum for _, devResults := range scanResults { records = append(records, devResults.FoundExtentCSums...) } @@ -37,7 +37,7 @@ func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumR } }) if len(records) == 0 { - return SumRunWithGaps[btrfsvol.LogicalAddr]{} + return sumRunWithGaps[btrfsvol.LogicalAddr]{} } sumSize := records[0].Sums.ChecksumSize @@ -52,10 +52,10 @@ func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumR // "AAAAAAA" shouldn't be present, and if we just discard "BBBBBBBB" // because it conflicts with "CCCCCCC", then we would erroneously // include "AAAAAAA". - addrspace := new(containers.RBTree[SysExtentCSum]) + addrspace := new(containers.RBTree[FoundExtentCSum]) for _, newRecord := range records { for { - conflict := addrspace.Search(func(oldRecord SysExtentCSum) int { + conflict := addrspace.Search(func(oldRecord FoundExtentCSum) int { switch { case newRecord.Sums.Addr.Add(newRecord.Sums.Size()) <= oldRecord.Sums.Addr: // 'newRecord' is wholly to the left of 'oldRecord'. @@ -127,7 +127,7 @@ func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumR case newRecord.Sums.Addr.Add(newRecord.Sums.Size()) > overlapEnd: suffix = newRecord.Sums.Sums[newOverlapEnd:] } - unionRecord := SysExtentCSum{ + unionRecord := FoundExtentCSum{ Generation: oldRecord.Generation, Sums: btrfsitem.ExtentCSum{ SumRun: btrfssum.SumRun[btrfsvol.LogicalAddr]{ @@ -143,11 +143,11 @@ func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumR } } - // Now flatten that RBTree in to a SumRunWithGaps. - var flattened SumRunWithGaps[btrfsvol.LogicalAddr] + // Now flatten that RBTree in to a sumRunWithGaps. + var flattened sumRunWithGaps[btrfsvol.LogicalAddr] var curAddr btrfsvol.LogicalAddr var curSums strings.Builder - addrspace.Range(func(node *containers.RBNode[SysExtentCSum]) bool { + addrspace.Range(func(node *containers.RBNode[FoundExtentCSum]) bool { curEnd := curAddr + (btrfsvol.LogicalAddr(curSums.Len()/sumSize) * btrfssum.BlockSize) if node.Value.Sums.Addr != curEnd { if curSums.Len() > 0 { @@ -178,7 +178,7 @@ func ExtractLogicalSums(ctx context.Context, scanResults ScanDevicesResult) SumR return flattened } -func ListUnmappedLogicalRegions(fs *btrfs.FS, logicalSums SumRunWithGaps[btrfsvol.LogicalAddr]) []btrfssum.SumRun[btrfsvol.LogicalAddr] { +func listUnmappedLogicalRegions(fs *btrfs.FS, logicalSums sumRunWithGaps[btrfsvol.LogicalAddr]) []btrfssum.SumRun[btrfsvol.LogicalAddr] { // There are a lot of ways this algorithm could be made // faster. var ret []btrfssum.SumRun[btrfsvol.LogicalAddr] @@ -221,8 +221,8 @@ func ListUnmappedLogicalRegions(fs *btrfs.FS, logicalSums SumRunWithGaps[btrfsvo return ret } -func SumsForLogicalRegion(sums SumRunWithGaps[btrfsvol.LogicalAddr], beg btrfsvol.LogicalAddr, size btrfsvol.AddrDelta) SumRunWithGaps[btrfsvol.LogicalAddr] { - runs := SumRunWithGaps[btrfsvol.LogicalAddr]{ +func sumsForLogicalRegion(sums sumRunWithGaps[btrfsvol.LogicalAddr], beg btrfsvol.LogicalAddr, size btrfsvol.AddrDelta) sumRunWithGaps[btrfsvol.LogicalAddr] { + runs := sumRunWithGaps[btrfsvol.LogicalAddr]{ Addr: beg, Size: size, } diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_physical.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_physical.go index 392ded9..5f8d932 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_physical.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_sums_physical.go @@ -16,7 +16,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/maps" ) -func ExtractPhysicalSums(scanResults ScanDevicesResult) map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr] { +func extractPhysicalSums(scanResults ScanDevicesResult) map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr] { ret := make(map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr], len(scanResults)) for devID, devResults := range scanResults { ret[devID] = devResults.Checksums @@ -24,12 +24,12 @@ func ExtractPhysicalSums(scanResults ScanDevicesResult) map[btrfsvol.DeviceID]bt return ret } -type PhysicalRegion struct { +type physicalRegion struct { Beg, End btrfsvol.PhysicalAddr } -func ListUnmappedPhysicalRegions(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalRegion { - regions := make(map[btrfsvol.DeviceID][]PhysicalRegion) +func listUnmappedPhysicalRegions(fs *btrfs.FS) map[btrfsvol.DeviceID][]physicalRegion { + regions := make(map[btrfsvol.DeviceID][]physicalRegion) pos := make(map[btrfsvol.DeviceID]btrfsvol.PhysicalAddr) mappings := fs.LV.Mappings() sort.Slice(mappings, func(i, j int) bool { @@ -37,7 +37,7 @@ func ListUnmappedPhysicalRegions(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalR }) for _, mapping := range mappings { if pos[mapping.PAddr.Dev] < mapping.PAddr.Addr { - regions[mapping.PAddr.Dev] = append(regions[mapping.PAddr.Dev], PhysicalRegion{ + regions[mapping.PAddr.Dev] = append(regions[mapping.PAddr.Dev], physicalRegion{ Beg: pos[mapping.PAddr.Dev], End: mapping.PAddr.Addr, }) @@ -49,7 +49,7 @@ func ListUnmappedPhysicalRegions(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalR for devID, dev := range fs.LV.PhysicalVolumes() { devSize := dev.Size() if pos[devID] < devSize { - regions[devID] = append(regions[devID], PhysicalRegion{ + regions[devID] = append(regions[devID], physicalRegion{ Beg: pos[devID], End: devSize, }) @@ -62,9 +62,9 @@ func roundUp[T constraints.Integer](x, multiple T) T { return ((x + multiple - 1) / multiple) * multiple } -func WalkUnmappedPhysicalRegions(ctx context.Context, +func walkUnmappedPhysicalRegions(ctx context.Context, physicalSums map[btrfsvol.DeviceID]btrfssum.SumRun[btrfsvol.PhysicalAddr], - gaps map[btrfsvol.DeviceID][]PhysicalRegion, + gaps map[btrfsvol.DeviceID][]physicalRegion, fn func(btrfsvol.DeviceID, btrfssum.SumRun[btrfsvol.PhysicalAddr]) error, ) error { for _, devID := range maps.SortedKeys(gaps) { diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go index e23314e..76d8a75 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go @@ -29,29 +29,31 @@ type ScanDevicesResult = map[btrfsvol.DeviceID]ScanOneDeviceResult type ScanOneDeviceResult struct { Checksums btrfssum.SumRun[btrfsvol.PhysicalAddr] FoundNodes map[btrfsvol.LogicalAddr][]btrfsvol.PhysicalAddr - FoundChunks []btrfstree.SysChunk - FoundBlockGroups []SysBlockGroup - FoundDevExtents []SysDevExtent - FoundExtentCSums []SysExtentCSum + FoundChunks []FoundChunk + FoundBlockGroups []FoundBlockGroup + FoundDevExtents []FoundDevExtent + FoundExtentCSums []FoundExtentCSum } -type SysBlockGroup struct { +type FoundChunk = btrfstree.SysChunk + +type FoundBlockGroup struct { Key btrfsprim.Key BG btrfsitem.BlockGroup } -type SysDevExtent struct { +type FoundDevExtent struct { Key btrfsprim.Key DevExt btrfsitem.DevExtent } -type SysExtentCSum struct { +type FoundExtentCSum struct { Generation btrfsprim.Generation Sums btrfsitem.ExtentCSum } // Compare implements containers.Ordered. -func (a SysExtentCSum) Compare(b SysExtentCSum) int { +func (a FoundExtentCSum) Compare(b FoundExtentCSum) int { return containers.NativeCompare(a.Sums.Addr, b.Sums.Addr) } @@ -129,7 +131,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic case *btrfsitem.Chunk: dlog.Tracef(ctx, "node@%v: item %v: found chunk", addr, i) - scanner.result.FoundChunks = append(scanner.result.FoundChunks, btrfstree.SysChunk{ + scanner.result.FoundChunks = append(scanner.result.FoundChunks, FoundChunk{ Key: item.Key, Chunk: *itemBody, }) @@ -144,7 +146,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic case *btrfsitem.BlockGroup: dlog.Tracef(ctx, "node@%v: item %v: found block group", addr, i) - scanner.result.FoundBlockGroups = append(scanner.result.FoundBlockGroups, SysBlockGroup{ + scanner.result.FoundBlockGroups = append(scanner.result.FoundBlockGroups, FoundBlockGroup{ Key: item.Key, BG: *itemBody, }) @@ -159,7 +161,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic case *btrfsitem.DevExtent: dlog.Tracef(ctx, "node@%v: item %v: found dev extent", addr, i) - scanner.result.FoundDevExtents = append(scanner.result.FoundDevExtents, SysDevExtent{ + scanner.result.FoundDevExtents = append(scanner.result.FoundDevExtents, FoundDevExtent{ Key: item.Key, DevExt: *itemBody, }) @@ -174,7 +176,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic case *btrfsitem.ExtentCSum: dlog.Tracef(ctx, "node@%v: item %v: found csums", addr, i) - scanner.result.FoundExtentCSums = append(scanner.result.FoundExtentCSums, SysExtentCSum{ + scanner.result.FoundExtentCSums = append(scanner.result.FoundExtentCSums, FoundExtentCSum{ Generation: node.Head.Generation, Sums: *itemBody, }) diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/sumrunwithgaps.go b/cmd/btrfs-rec/inspect/rebuildmappings/sumrunwithgaps.go index f79e2be..3522b3e 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/sumrunwithgaps.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/sumrunwithgaps.go @@ -17,7 +17,7 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/slices" ) -type SumRunWithGaps[Addr btrfsvol.IntAddr[Addr]] struct { +type sumRunWithGaps[Addr btrfsvol.IntAddr[Addr]] struct { // Store the start address and size, in order to facilitate // leading and trailing gaps. Addr Addr @@ -27,16 +27,16 @@ type SumRunWithGaps[Addr btrfsvol.IntAddr[Addr]] struct { } var ( - _ lowmemjson.Encodable = SumRunWithGaps[btrfsvol.LogicalAddr]{} - _ lowmemjson.Decodable = (*SumRunWithGaps[btrfsvol.LogicalAddr])(nil) + _ lowmemjson.Encodable = sumRunWithGaps[btrfsvol.LogicalAddr]{} + _ lowmemjson.Decodable = (*sumRunWithGaps[btrfsvol.LogicalAddr])(nil) ) // PatLen implements kmpPattern[int, ShortSum]. -func (sg SumRunWithGaps[Addr]) PatLen() int { +func (sg sumRunWithGaps[Addr]) PatLen() int { return int(sg.Size / btrfssum.BlockSize) } -func (sg SumRunWithGaps[Addr]) PctFull() float64 { +func (sg sumRunWithGaps[Addr]) PctFull() float64 { total := sg.PatLen() var full int for _, run := range sg.Runs { @@ -45,7 +45,7 @@ func (sg SumRunWithGaps[Addr]) PctFull() float64 { return float64(full) / float64(total) } -func (sg SumRunWithGaps[Addr]) RunForAddr(addr Addr) (btrfssum.SumRun[Addr], Addr, bool) { +func (sg sumRunWithGaps[Addr]) RunForAddr(addr Addr) (btrfssum.SumRun[Addr], Addr, bool) { for _, run := range sg.Runs { if run.Addr > addr { return btrfssum.SumRun[Addr]{}, run.Addr, false @@ -58,7 +58,7 @@ func (sg SumRunWithGaps[Addr]) RunForAddr(addr Addr) (btrfssum.SumRun[Addr], Add return btrfssum.SumRun[Addr]{}, math.MaxInt64, false } -func (sg SumRunWithGaps[Addr]) SumForAddr(addr Addr) (btrfssum.ShortSum, bool) { +func (sg sumRunWithGaps[Addr]) SumForAddr(addr Addr) (btrfssum.ShortSum, bool) { if addr < sg.Addr || addr >= sg.Addr.Add(sg.Size) { return "", false } @@ -80,7 +80,7 @@ func (sg SumRunWithGaps[Addr]) SumForAddr(addr Addr) (btrfssum.ShortSum, bool) { return run.Sums[off : off+run.ChecksumSize], true } -func (sg SumRunWithGaps[Addr]) Walk(ctx context.Context, fn func(Addr, btrfssum.ShortSum) error) error { +func (sg sumRunWithGaps[Addr]) Walk(ctx context.Context, fn func(Addr, btrfssum.ShortSum) error) error { for _, run := range sg.Runs { if err := run.Walk(ctx, fn); err != nil { return err @@ -90,12 +90,12 @@ func (sg SumRunWithGaps[Addr]) Walk(ctx context.Context, fn func(Addr, btrfssum. } // PatGet implements kmpPattern[int, ShortSum]. -func (sg SumRunWithGaps[Addr]) PatGet(sumIdx int) (btrfssum.ShortSum, bool) { +func (sg sumRunWithGaps[Addr]) PatGet(sumIdx int) (btrfssum.ShortSum, bool) { addr := sg.Addr.Add(btrfsvol.AddrDelta(sumIdx) * btrfssum.BlockSize) return sg.SumForAddr(addr) } -func (sg SumRunWithGaps[Addr]) EncodeJSON(w io.Writer) error { +func (sg sumRunWithGaps[Addr]) EncodeJSON(w io.Writer) error { if _, err := fmt.Fprintf(w, `{"Addr":%d,"Size":%d,"Runs":[`, sg.Addr, sg.Size); err != nil { return err } @@ -136,8 +136,8 @@ func (sg SumRunWithGaps[Addr]) EncodeJSON(w io.Writer) error { return nil } -func (sg *SumRunWithGaps[Addr]) DecodeJSON(r io.RuneScanner) error { - *sg = SumRunWithGaps[Addr]{} +func (sg *sumRunWithGaps[Addr]) DecodeJSON(r io.RuneScanner) error { + *sg = sumRunWithGaps[Addr]{} var name string return lowmemjson.DecodeObject(r, func(r io.RuneScanner) error { |