diff options
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildmappings')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildmappings/scan.go | 4 | ||||
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildmappings/unmappedregions.go (renamed from lib/btrfsprogs/btrfsinspect/rebuildmappings/gaps.go) | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildmappings/scan.go b/lib/btrfsprogs/btrfsinspect/rebuildmappings/scan.go index efb1775..6b4cbe7 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildmappings/scan.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildmappings/scan.go @@ -53,7 +53,7 @@ func ScanForExtents(ctx context.Context, fs *btrfs.FS, blockgroups map[btrfsvol. dlog.Info(ctx, "... done pairing") dlog.Info(ctx, "Searching for unmapped blockgroups in unmapped regions...") - gaps := ListPhysicalGaps(fs) + gaps := ListUnmappedPhysicalRegions(fs) bgMatches := make(map[btrfsvol.LogicalAddr][]btrfsvol.QualifiedPhysicalAddr) for i, bgLAddr := range maps.SortedKeys(blockgroups) { bgRun := bgSums[bgLAddr] @@ -63,7 +63,7 @@ func ScanForExtents(ctx context.Context, fs *btrfs.FS, blockgroups map[btrfsvol. continue } - if err := WalkGaps(ctx, sums, gaps, func(devID btrfsvol.DeviceID, gap btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { + if err := WalkUnmappedPhysicalRegions(ctx, sums, gaps, func(devID btrfsvol.DeviceID, gap btrfssum.SumRun[btrfsvol.PhysicalAddr]) error { matches, err := diskio.IndexAll[int64, btrfssum.ShortSum](gap, bgRun) if err != nil { return err diff --git a/lib/btrfsprogs/btrfsinspect/rebuildmappings/gaps.go b/lib/btrfsprogs/btrfsinspect/rebuildmappings/unmappedregions.go index 987aed7..79a14bf 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildmappings/gaps.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildmappings/unmappedregions.go @@ -16,12 +16,12 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/maps" ) -type PhysicalGap struct { +type PhysicalRegion struct { Beg, End btrfsvol.PhysicalAddr } -func ListPhysicalGaps(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalGap { - gaps := make(map[btrfsvol.DeviceID][]PhysicalGap) +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 { @@ -29,7 +29,7 @@ func ListPhysicalGaps(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalGap { }) for _, mapping := range mappings { if pos[mapping.PAddr.Dev] < mapping.PAddr.Addr { - gaps[mapping.PAddr.Dev] = append(gaps[mapping.PAddr.Dev], PhysicalGap{ + regions[mapping.PAddr.Dev] = append(regions[mapping.PAddr.Dev], PhysicalRegion{ Beg: pos[mapping.PAddr.Dev], End: mapping.PAddr.Addr, }) @@ -41,21 +41,21 @@ func ListPhysicalGaps(fs *btrfs.FS) map[btrfsvol.DeviceID][]PhysicalGap { for devID, dev := range fs.LV.PhysicalVolumes() { devSize := dev.Size() if pos[devID] < devSize { - gaps[devID] = append(gaps[devID], PhysicalGap{ + regions[devID] = append(regions[devID], PhysicalRegion{ Beg: pos[devID], End: devSize, }) } } - return gaps + return regions } func roundUp[T constraints.Integer](x, multiple T) T { return ((x + multiple - 1) / multiple) * multiple } -func WalkGaps(ctx context.Context, - sums AllSums, gaps map[btrfsvol.DeviceID][]PhysicalGap, +func WalkUnmappedPhysicalRegions(ctx context.Context, + sums AllSums, gaps map[btrfsvol.DeviceID][]PhysicalRegion, fn func(btrfsvol.DeviceID, btrfssum.SumRun[btrfsvol.PhysicalAddr]) error, ) error { for _, devID := range maps.SortedKeys(gaps) { |