summaryrefslogtreecommitdiff
path: root/lib/btrfs
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-09-05 12:43:46 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-09-05 12:43:46 -0600
commit7fba10e5be51a3fe565a6f69a946ece9f0e59a67 (patch)
tree91bc89b8d1e5dba3ead0319daeef3181ccc6da4d /lib/btrfs
parentabdc8394bcb7080f01859cbfe367beecf5aef06f (diff)
Try to uniformly use containers.Set
Diffstat (limited to 'lib/btrfs')
-rw-r--r--lib/btrfs/btrfsvol/lvm.go2
-rw-r--r--lib/btrfs/io4_fs.go6
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/btrfs/btrfsvol/lvm.go b/lib/btrfs/btrfsvol/lvm.go
index 8003466..e12e53e 100644
--- a/lib/btrfs/btrfsvol/lvm.go
+++ b/lib/btrfs/btrfsvol/lvm.go
@@ -256,6 +256,8 @@ 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) {
node := lv.logical2physical.Search(func(chunk chunkMapping) int {
return chunkMapping{LAddr: laddr, Size: 1}.cmpRange(chunk)
diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go
index 8751078..82d4c87 100644
--- a/lib/btrfs/io4_fs.go
+++ b/lib/btrfs/io4_fs.go
@@ -248,13 +248,13 @@ func (ret *Dir) populate() {
panic(fmt.Errorf("TODO: handle item type %v", item.Key.ItemType))
}
}
- entriesWithIndexes := make(map[string]struct{})
+ entriesWithIndexes := make(containers.Set[string])
nextIndex := uint64(2)
for index, entry := range ret.ChildrenByIndex {
if index+1 > nextIndex {
nextIndex = index + 1
}
- entriesWithIndexes[string(entry.Name)] = struct{}{}
+ entriesWithIndexes.Insert(string(entry.Name))
if other, exists := ret.ChildrenByName[string(entry.Name)]; !exists {
ret.Errs = append(ret.Errs, fmt.Errorf("missing by-name direntry for %q", entry.Name))
ret.ChildrenByName[string(entry.Name)] = entry
@@ -264,7 +264,7 @@ func (ret *Dir) populate() {
}
}
for _, name := range maps.SortedKeys(ret.ChildrenByName) {
- if _, exists := entriesWithIndexes[name]; !exists {
+ if !entriesWithIndexes.Has(name) {
ret.Errs = append(ret.Errs, fmt.Errorf("missing by-index direntry for %q", name))
ret.ChildrenByIndex[nextIndex] = ret.ChildrenByName[name]
nextIndex++