diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-09-05 21:53:35 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-09-05 21:53:35 -0600 |
commit | cd46c745358baa273cbc11e699175dd93031f7a8 (patch) | |
tree | 153800221ff63a25b02cca9c5e6632d807c4cd8c /lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go | |
parent | 205b055a2fc7aa2742bff497f85bbde5880e0584 (diff) |
wip
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go')
-rw-r--r-- | lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go index 3096b46..3ab0881 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/visualizenodes.go @@ -90,22 +90,12 @@ func VisualizeNodes(ctx context.Context, out io.Writer, fs *btrfs.FS, nodeScanRe // Node var treeID btrfsprim.ObjID - var cliqueID btrfsprim.ObjID var nodeStr string if err != nil && (errors.Is(err, btrfstree.ErrNotANode) || errors.As(err, new(*btrfstree.IOError))) { treeID = 0 - func() { - defer func() { - if r := recover(); r != nil { - panic(fmt.Errorf("path=%#v (%s): %v", path, path, r)) - } - }() - cliqueID = getCliqueID(cliques, path.Node(-1).FromTree) - }() nodeStr = fmt.Sprintf(`n%d [shape=star color=red label="%v"]`, addr, addr) } else { treeID = nodeRef.Data.Head.Owner - cliqueID = getCliqueID(cliques, treeID) var buf strings.Builder fmt.Fprintf(&buf, `n%d [shape=record label="%v\ngen=%v\nlvl=%v|{`, addr, @@ -157,6 +147,13 @@ func VisualizeNodes(ctx context.Context, out io.Writer, fs *btrfs.FS, nodeScanRe } else { edge.WriteString(`"]`) } + cliqueID := getCliqueID(cliques, path[0].FromTree) + if treeID != 0 && getCliqueID(cliques, treeID) != cliqueID { + panic(fmt.Errorf("tree %v is not in clique %v", treeID, maps.SortedKeys(*cliques[cliqueID]))) + } + if !cliques[cliqueID].Has(cliqueID) { + panic(fmt.Errorf("clique %v does not contain supposed-member %v", maps.SortedKeys(*cliques[cliqueID]), cliqueID)) + } if _, ok := edges[cliqueID]; !ok { edges[cliqueID] = make(containers.Set[string]) } @@ -211,7 +208,7 @@ func VisualizeNodes(ctx context.Context, out io.Writer, fs *btrfs.FS, nodeScanRe return err } - if _, err := fmt.Fprintf(buf, "digraph clique%d {\n", cliqueID); err != nil { + if _, err := fmt.Fprintf(buf, "strict digraph clique%d {\n", cliqueID); err != nil { return err } clique := cliques[cliqueID] |