summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-12 17:09:41 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-14 19:45:07 -0600
commite92796fed05143239733d3feec0231a69af2f617 (patch)
tree1aed8e061590b90a3158511a6e9a098851344516 /lib
parentfb3595976840203649ce898efd7b14af924b86f0 (diff)
Update log field names to reflect new file/package names
Diffstat (limited to 'lib')
-rw-r--r--lib/btrfsutil/graph.go9
-rw-r--r--lib/btrfsutil/rebuilt_forrest.go2
-rw-r--r--lib/btrfsutil/rebuilt_tree.go8
-rw-r--r--lib/textui/log.go88
4 files changed, 58 insertions, 49 deletions
diff --git a/lib/btrfsutil/graph.go b/lib/btrfsutil/graph.go
index b4a8b72..8debe9d 100644
--- a/lib/btrfsutil/graph.go
+++ b/lib/btrfsutil/graph.go
@@ -193,10 +193,8 @@ func (g Graph) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.No
func (g Graph) FinalCheck(ctx context.Context, fs diskio.File[btrfsvol.LogicalAddr], sb btrfstree.Superblock) error {
var stats textui.Portion[int]
- _ctx := ctx
- ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-nodes.read.substep", "check-keypointers")
- dlog.Info(_ctx, "Checking keypointers for dead-ends...")
+ dlog.Info(ctx, "Checking keypointers for dead-ends...")
progressWriter := textui.NewProgress[textui.Portion[int]](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
stats.D = len(g.EdgesTo)
progressWriter.Set(stats)
@@ -217,8 +215,7 @@ func (g Graph) FinalCheck(ctx context.Context, fs diskio.File[btrfsvol.LogicalAd
progressWriter.Done()
dlog.Info(ctx, "... done checking keypointers")
- ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-nodes.read.substep", "check-for-loops")
- dlog.Info(_ctx, "Checking for btree loops...")
+ dlog.Info(ctx, "Checking for btree loops...")
stats.D = len(g.Nodes)
stats.N = 0
progressWriter = textui.NewProgress[textui.Portion[int]](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second))
@@ -255,7 +252,7 @@ func (g Graph) FinalCheck(ctx context.Context, fs diskio.File[btrfsvol.LogicalAd
if numLoops > 0 {
return fmt.Errorf("%d btree loops", numLoops)
}
- dlog.Info(_ctx, "... done checking for loops")
+ dlog.Info(ctx, "... done checking for loops")
return nil
}
diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go
index 3dfb24c..70ece13 100644
--- a/lib/btrfsutil/rebuilt_forrest.go
+++ b/lib/btrfsutil/rebuilt_forrest.go
@@ -118,7 +118,7 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
}
}()
stack = append(stack, treeID)
- ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.add-tree", stack)
+ ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-forrest.add-tree", stack)
dlog.Info(ctx, "adding tree...")
if slices.Contains(treeID, stack[:len(stack)-1]) {
dlog.Errorf(ctx, "failed to add tree: loop detected: %v", stack)
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go
index 2f6afbe..1009204 100644
--- a/lib/btrfsutil/rebuilt_tree.go
+++ b/lib/btrfsutil/rebuilt_tree.go
@@ -48,7 +48,7 @@ type RebuiltTree struct {
// .isOwnerOK, whether or not they're in the tree.
func (tree *RebuiltTree) leafToRoots(ctx context.Context) map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr] {
return containers.LoadOrElse[btrfsprim.ObjID, map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr]](&tree.forrest.leafs, tree.ID, func(btrfsprim.ObjID) map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr] {
- ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.index-nodes", fmt.Sprintf("tree=%v", tree.ID))
+ ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.index-nodes", fmt.Sprintf("tree=%v", tree.ID))
nodeToRoots := make(map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr])
@@ -136,7 +136,7 @@ func (tree *RebuiltTree) isOwnerOK(owner btrfsprim.ObjID, gen btrfsprim.Generati
// Do not mutate the returned map; it is a pointer to the
// RebuiltTree's internal map!
func (tree *RebuiltTree) Items(ctx context.Context) *containers.SortedMap[btrfsprim.Key, ItemPtr] {
- ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.index-inc-items", fmt.Sprintf("tree=%v", tree.ID))
+ ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.index-inc-items", fmt.Sprintf("tree=%v", tree.ID))
return tree.items(ctx, &tree.forrest.incItems, tree.Roots.HasAny)
}
@@ -146,7 +146,7 @@ func (tree *RebuiltTree) Items(ctx context.Context) *containers.SortedMap[btrfsp
// Do not mutate the returned map; it is a pointer to the
// RebuiltTree's internal map!
func (tree *RebuiltTree) PotentialItems(ctx context.Context) *containers.SortedMap[btrfsprim.Key, ItemPtr] {
- ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.index-exc-items", fmt.Sprintf("tree=%v", tree.ID))
+ ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.index-exc-items", fmt.Sprintf("tree=%v", tree.ID))
return tree.items(ctx, &tree.forrest.excItems,
func(roots containers.Set[btrfsvol.LogicalAddr]) bool {
return !tree.Roots.HasAny(roots)
@@ -267,7 +267,7 @@ func (s rootStats) String() string {
func (tree *RebuiltTree) AddRoot(ctx context.Context, rootNode btrfsvol.LogicalAddr) {
tree.mu.Lock()
defer tree.mu.Unlock()
- ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.add-root", fmt.Sprintf("tree=%v rootNode=%v", tree.ID, rootNode))
+ ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.add-root", fmt.Sprintf("tree=%v rootNode=%v", tree.ID, rootNode))
dlog.Info(ctx, "adding root...")
leafToRoots := tree.leafToRoots(ctx)
diff --git a/lib/textui/log.go b/lib/textui/log.go
index 2a6fdd4..0a10ef6 100644
--- a/lib/textui/log.go
+++ b/lib/textui/log.go
@@ -289,57 +289,59 @@ func fieldOrd(key string) int {
case "dexec.err":
return -95
- // btrfsinspect scandevices ////////////////////////////////////////////
- case "btrfsinspect.scandevices.dev":
+ // btrfs inspect rebuild-mappings scan /////////////////////////////////
+ case "btrfs.inspect.rebuild-mappings.scan.dev":
return -1
- // btrfsinspect rebuild-mappings ///////////////////////////////////////
- case "btrfsinspect.rebuild-mappings.step":
+ // btrfs inspect rebuild-mappings process //////////////////////////////
+ case "btrfs.inspect.rebuild-mappings.process.step":
return -2
- case "btrfsinspect.rebuild-mappings.substep":
+ case "btrfs.inspect.rebuild-mappings.process.substep":
return -1
- // btrfsinspect rebuild-nodes //////////////////////////////////////////
- case "btrfsinspect.rebuild-nodes.step":
+ // btrfs inspect rebuild-trees /////////////////////////////////////////
+ case "btrfs.inspect.rebuild-trees.step":
return -50
// step=read-fs-data
- case "btrfsinspect.rebuild-nodes.read.substep":
+ case "btrfs.inspect.rebuild-trees.read.substep":
return -1
// step=rebuild
- case "btrfsinspect.rebuild-nodes.rebuild.pass":
+ case "btrfs.inspect.rebuild-trees.rebuild.pass":
return -49
- case "btrfsinspect.rebuild-nodes.rebuild.substep":
+ case "btrfs.inspect.rebuild-trees.rebuild.substep":
return -48
- case "btrfsinspect.rebuild-nodes.rebuild.substep.progress":
+ case "btrfs.inspect.rebuild-trees.rebuild.substep.progress":
return -47
// step=rebuild, substep=collect-items (1/3)
// step=rebuild, substep=settle-items (2a/3)
- case "btrfsinspect.rebuild-nodes.rebuild.settle.item":
+ case "btrfs.inspect.rebuild-trees.rebuild.settle.item":
return -25
// step=rebuild, substep=process-items (2b/3)
- case "btrfsinspect.rebuild-nodes.rebuild.process.item":
+ case "btrfs.inspect.rebuild-trees.rebuild.process.item":
return -25
// step=rebuild, substep=apply-augments (3/3)
- case "btrfsinspect.rebuild-nodes.rebuild.augment.tree":
+ case "btrfs.inspect.rebuild-trees.rebuild.augment.tree":
return -25
// step=rebuild (any substep)
- case "btrfsinspect.rebuild-nodes.rebuild.want.key":
+ case "btrfs.inspect.rebuild-trees.rebuild.want.key":
return -9
- case "btrfsinspect.rebuild-nodes.rebuild.want.reason":
+ case "btrfs.inspect.rebuild-trees.rebuild.want.reason":
return -8
- case "btrfsinspect.rebuild-nodes.rebuild.add-tree":
+
+ // btrfsutil.RebuiltForrest ////////////////////////////////////////////
+ case "btrfs.util.rebuilt-forrest.add-tree":
return -7
- case "btrfsinspect.rebuild-nodes.rebuild.add-tree.want.key":
+ case "btrfs.util.rebuilt-forrest.add-tree.want.key":
return -6
- case "btrfsinspect.rebuild-nodes.rebuild.add-tree.want.reason":
+ case "btrfs.util.rebuilt-forrest.add-tree.want.reason":
return -5
- case "btrfsinspect.rebuild-nodes.rebuild.add-root":
+ case "btrfs.util.rebuilt-tree.add-root":
return -4
- case "btrfsinspect.rebuild-nodes.rebuild.index-inc-items":
+ case "btrfs.util.rebuilt-tree.index-inc-items":
return -3
- case "btrfsinspect.rebuild-nodes.rebuild.index-exc-items":
+ case "btrfs.util.rebuilt-tree.index-exc-items":
return -2
- case "btrfsinspect.rebuild-nodes.rebuild.index-nodes":
+ case "btrfs.util.rebuilt-tree.index-nodes":
return -1
// other ///////////////////////////////////////////////////////////////
@@ -398,27 +400,37 @@ func writeField(w io.Writer, key string, val any) {
case strings.HasSuffix(name, ".pass"):
fmt.Fprintf(w, "/pass-%s", valStr)
return
- case strings.HasSuffix(name, ".substep") && name != "btrfsinspect.rebuild-nodes.rebuild.add-tree.substep":
+ case strings.HasSuffix(name, ".substep") && name != "btrfs.util.rebuilt-forrest.add-tree.substep":
fmt.Fprintf(w, "/%s", valStr)
return
- case strings.HasPrefix(name, "btrfsinspect."):
- name = strings.TrimPrefix(name, "btrfsinspect.")
+ case strings.HasPrefix(name, "btrfs."):
+ name = strings.TrimPrefix(name, "btrfs.")
switch {
- case strings.HasPrefix(name, "scandevices."):
- name = strings.TrimPrefix(name, "scandevices.")
- case strings.HasPrefix(name, "rebuild-mappings."):
- name = strings.TrimPrefix(name, "rebuild-mappings.")
- case strings.HasPrefix(name, "rebuild-nodes."):
- name = strings.TrimPrefix(name, "rebuild-nodes.")
+ case strings.HasPrefix(name, "inspect."):
+ name = strings.TrimPrefix(name, "inspect.")
switch {
- case strings.HasPrefix(name, "read."):
- name = strings.TrimPrefix(name, "read.")
- case strings.HasPrefix(name, "rebuild."):
- name = strings.TrimPrefix(name, "rebuild.")
+ case strings.HasPrefix(name, "rebuild-mappings."):
+ name = strings.TrimPrefix(name, "rebuild-mappings.")
+ switch {
+ case strings.HasPrefix(name, "scan."):
+ name = strings.TrimPrefix(name, "scan.")
+ case strings.HasPrefix(name, "process."):
+ name = strings.TrimPrefix(name, "process.")
+ }
+ case strings.HasPrefix(name, "rebuild-trees."):
+ name = strings.TrimPrefix(name, "rebuild-trees.")
+ switch {
+ case strings.HasPrefix(name, "read."):
+ name = strings.TrimPrefix(name, "read.")
+ case strings.HasPrefix(name, "rebuild."):
+ name = strings.TrimPrefix(name, "rebuild.")
+ }
}
+ case strings.HasPrefix(name, "util.rebuilt-forrest."):
+ name = strings.TrimPrefix(name, "util.rebuilt-forrest.")
+ case strings.HasPrefix(name, "util.rebuilt-tree."):
+ name = strings.TrimPrefix(name, "util.rebuilt-tree.")
}
- case strings.HasPrefix(name, "btrfs."):
- name = strings.TrimPrefix(name, "btrfs.")
}
fmt.Fprintf(w, " %s=%s", name, valStr)