summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-11-15 20:57:04 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2022-12-20 19:58:11 -0700
commit580189ee3e43d5595a8700ee21b8900b0dd5389d (patch)
tree6f47b5728a9fc4cad3d87578396c30637161fbf2 /lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go
parenta71e1969a1b24500ce9885c4a3f1aeee40c421a8 (diff)
Delete 'inspect visualize-nodes'
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go
index 7be903a..4d93916 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/uuidmap.go
@@ -5,12 +5,8 @@
package rebuildnodes
import (
- "fmt"
- "strings"
-
"git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim"
"git.lukeshu.com/btrfs-progs-ng/lib/containers"
- "git.lukeshu.com/btrfs-progs-ng/lib/maps"
)
type uuidMap struct {
@@ -57,72 +53,3 @@ func (m uuidMap) ParentTree(tree btrfsprim.ObjID) (btrfsprim.ObjID, bool) {
}
return parentObjID, true
}
-
-type fullAncestorLister struct {
- uuidMap uuidMap
- treeAncestors map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID]
-
- memos map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID]
-}
-
-func newFullAncestorLister(uuidMap uuidMap, treeAncestors map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID]) fullAncestorLister {
- return fullAncestorLister{
- uuidMap: uuidMap,
- treeAncestors: treeAncestors,
- memos: make(map[btrfsprim.ObjID]containers.Set[btrfsprim.ObjID]),
- }
-}
-
-type loopError []btrfsprim.ObjID
-
-func (le loopError) Error() string {
- var buf strings.Builder
- buf.WriteString("loop: ")
- for i, treeID := range le {
- if i > 0 {
- buf.WriteString("->")
- }
- fmt.Fprintf(&buf, "%d", treeID)
- }
- return buf.String()
-}
-
-func (fa fullAncestorLister) GetFullAncestors(child btrfsprim.ObjID) containers.Set[btrfsprim.ObjID] {
- if memoized, ok := fa.memos[child]; ok {
- if memoized == nil {
- panic(loopError{child})
- }
- return memoized
- }
- fa.memos[child] = nil
- defer func() {
- if r := recover(); r != nil {
- if le, ok := r.(loopError); ok {
- r = append(loopError{child}, le...)
- }
- panic(r)
- }
- }()
-
- ret := make(containers.Set[btrfsprim.ObjID])
- defer func() {
- fa.memos[child] = ret
- }()
-
- // Try to use '.uuidMap' instead of '.treeAncestors' if possible.
- knownAncestors := make(containers.Set[btrfsprim.ObjID])
- if parent, ok := fa.uuidMap.ParentTree(child); ok {
- if parent == 0 {
- return ret
- }
- knownAncestors.Insert(parent)
- } else {
- knownAncestors.InsertFrom(fa.treeAncestors[child])
- }
-
- for _, ancestor := range maps.SortedKeys(knownAncestors) {
- ret.Insert(ancestor)
- ret.InsertFrom(fa.GetFullAncestors(ancestor))
- }
- return ret
-}