summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-09-04 12:17:48 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-09-04 12:17:48 -0600
commitc2e3f389ecebd887935c13c76679b0dae8bc366b (patch)
tree8e08a57709cc0de40656cfdb2eefa83b674af807 /lib
parentaf06dd6a02d41eada5ea3f15d5b74d5ace890af6 (diff)
rebuildnodes: Tidy up
Diffstat (limited to 'lib')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go49
1 files changed, 20 insertions, 29 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go
index 9860355..4122b21 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go
@@ -81,7 +81,7 @@ func (m uuidMap) considerAncestors(ctx context.Context, treeAncestors map[btrfsp
ret := make(containers.Set[btrfsprim.ObjID])
fullAncestors[child] = ret
- // Try to use 'm' if possible.
+ // Try to use 'm' instead of 'treeAncestors' if possible.
knownAncestors := make(containers.Set[btrfsprim.ObjID])
if parent, ok := m.ParentTree(child); ok {
if parent == 0 {
@@ -99,36 +99,27 @@ func (m uuidMap) considerAncestors(ctx context.Context, treeAncestors map[btrfsp
return ret
}
- for pass := 1; true; pass++ {
- dlog.Infof(ctx, "... pass %v", pass)
- added := 0
- fullAncestors = make(map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID])
- for _, missingRoot := range maps.SortedKeys(m.missingRootItems()) {
- if _, ok := m.TreeParent[missingRoot]; ok {
- // This one is incomplete because it doesn't have a UUID, not
- // because it doesn't have a parent.
+ fullAncestors = make(map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID])
+ for _, missingRoot := range maps.SortedKeys(m.missingRootItems()) {
+ if _, ok := m.TreeParent[missingRoot]; ok {
+ // This one is incomplete because it doesn't have a UUID, not
+ // because it doesn't have a parent.
+ continue
+ }
+ potentialParents := make(containers.Set[btrfsprim.ObjID])
+ potentialParents.InsertFrom(getFullAncestors(missingRoot))
+ for ancestor := range getFullAncestors(missingRoot) {
+ potentialParents.DeleteFrom(getFullAncestors(ancestor))
+ }
+ if len(potentialParents) == 1 {
+ parent := potentialParents.TakeOne()
+ dlog.Infof(ctx, "... the parent of %v is %v", missingRoot, parent)
+ parentUUID, ok := m.ObjID2UUID[parent]
+ if !ok {
+ dlog.Errorf(ctx, "... but can't synthesize a root item because UUID of %v is unknown", parent)
continue
}
- dlog.Infof(ctx, "... rebuilding %v", missingRoot)
- potentialParents := make(containers.Set[btrfsprim.ObjID])
- potentialParents.InsertFrom(getFullAncestors(missingRoot))
- for ancestor := range getFullAncestors(missingRoot) {
- potentialParents.DeleteFrom(getFullAncestors(ancestor))
- }
- if len(potentialParents) == 1 {
- parent := potentialParents.TakeOne()
- dlog.Infof(ctx, "... ... the parent of %v is %v", missingRoot, parent)
- parentUUID, ok := m.ObjID2UUID[parent]
- if !ok {
- dlog.Errorf(ctx, "... ... but can't synthesize a root item because UUID of %v is unknown", parent)
- continue
- }
- m.TreeParent[missingRoot] = parentUUID
- added++
- }
- }
- if added == 0 {
- break
+ m.TreeParent[missingRoot] = parentUUID
}
}