diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-20 20:06:15 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-20 20:06:15 -0700 |
commit | 8ff81c1ed6a50179166ffc4cfb60bef85394265e (patch) | |
tree | f2395593d4d4cfd12b26ba2030bb94930fe4ba56 /lib/btrfs/btrfsvol | |
parent | 7315c38414b3a6840d71f254b7c8192640b41d7c (diff) | |
parent | 94a86a763157327ac969c98e19d7770db477a6a3 (diff) |
Merge branch 'lukeshu/rebuild-nodes-take2'
Diffstat (limited to 'lib/btrfs/btrfsvol')
-rw-r--r-- | lib/btrfs/btrfsvol/chunk.go | 4 | ||||
-rw-r--r-- | lib/btrfs/btrfsvol/lvm.go | 8 |
2 files changed, 5 insertions, 7 deletions
diff --git a/lib/btrfs/btrfsvol/chunk.go b/lib/btrfs/btrfsvol/chunk.go index 8a2d439..5f1baa8 100644 --- a/lib/btrfs/btrfsvol/chunk.go +++ b/lib/btrfs/btrfsvol/chunk.go @@ -70,11 +70,11 @@ func (a chunkMapping) union(rest ...chunkMapping) (chunkMapping, error) { } } // figure out the physical stripes (.PAddrs) - paddrs := make(map[QualifiedPhysicalAddr]struct{}) + paddrs := make(containers.Set[QualifiedPhysicalAddr]) for _, chunk := range chunks { offsetWithinRet := chunk.LAddr.Sub(ret.LAddr) for _, stripe := range chunk.PAddrs { - paddrs[stripe.Add(-offsetWithinRet)] = struct{}{} + paddrs.Insert(stripe.Add(-offsetWithinRet)) } } ret.PAddrs = maps.Keys(paddrs) diff --git a/lib/btrfs/btrfsvol/lvm.go b/lib/btrfs/btrfsvol/lvm.go index e12e53e..c7551fc 100644 --- a/lib/btrfs/btrfsvol/lvm.go +++ b/lib/btrfs/btrfsvol/lvm.go @@ -256,9 +256,7 @@ func (lv *LogicalVolume[PhysicalVolume]) Mappings() []Mapping { return ret } -// paddrs isn't a containers.Set because QualifiedPhysicalAddr is not -// an ordered type. -func (lv *LogicalVolume[PhysicalVolume]) Resolve(laddr LogicalAddr) (paddrs map[QualifiedPhysicalAddr]struct{}, maxlen AddrDelta) { +func (lv *LogicalVolume[PhysicalVolume]) Resolve(laddr LogicalAddr) (paddrs containers.Set[QualifiedPhysicalAddr], maxlen AddrDelta) { node := lv.logical2physical.Search(func(chunk chunkMapping) int { return chunkMapping{LAddr: laddr, Size: 1}.cmpRange(chunk) }) @@ -269,10 +267,10 @@ func (lv *LogicalVolume[PhysicalVolume]) Resolve(laddr LogicalAddr) (paddrs map[ chunk := node.Value offsetWithinChunk := laddr.Sub(chunk.LAddr) - paddrs = make(map[QualifiedPhysicalAddr]struct{}) + paddrs = make(containers.Set[QualifiedPhysicalAddr]) maxlen = chunk.Size - offsetWithinChunk for _, stripe := range chunk.PAddrs { - paddrs[stripe.Add(offsetWithinChunk)] = struct{}{} + paddrs.Insert(stripe.Add(offsetWithinChunk)) } return paddrs, maxlen |