From e92796fed05143239733d3feec0231a69af2f617 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 Mar 2023 17:09:41 -0600 Subject: Update log field names to reflect new file/package names --- cmd/btrfs-rec/inspect/rebuildmappings/process.go | 14 +++++----- .../rebuildmappings/process_matchsums_fuzzy.go | 4 +-- cmd/btrfs-rec/inspect/rebuildmappings/scan.go | 2 +- cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go | 30 +++++++++++----------- .../inspect/rebuildtrees/rebuild_wanttyp.go | 4 +-- cmd/btrfs-rec/inspect/rebuildtrees/scan.go | 3 ++- 6 files changed, 29 insertions(+), 28 deletions(-) (limited to 'cmd/btrfs-rec') diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process.go b/cmd/btrfs-rec/inspect/rebuildmappings/process.go index 4ef4dac..7ce3748 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process.go @@ -54,7 +54,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR dlog.Infof(ctx, "plan: 6/6 search for block groups in checksum map (fuzzy)") _ctx := ctx - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "1/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "1/6") dlog.Infof(_ctx, "1/6: Processing %d chunks...", numChunks) for _, devID := range devIDs { devResults := scanResults[devID] @@ -68,7 +68,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR } dlog.Info(_ctx, "... done processing chunks") - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "2/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "2/6") dlog.Infof(_ctx, "2/6: Processing %d device extents...", numDevExts) for _, devID := range devIDs { devResults := scanResults[devID] @@ -84,7 +84,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR // too much. (Because nodes are numerous and small, while the // others are few and large; so it is likely that many of the // nodes will be subsumed by other things.) - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "3/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "3/6") dlog.Infof(_ctx, "3/6: Processing %d nodes...", numNodes) for _, devID := range devIDs { devResults := scanResults[devID] @@ -109,7 +109,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR // Use block groups to add missing flags (and as a hint to // combine node entries). - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "4/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "4/6") dlog.Infof(_ctx, "4/6: Processing %d block groups...", numBlockGroups) // First dedup them, because they change for allocations and // CoW means that they'll bounce around a lot, so you likely @@ -157,7 +157,7 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR // The fuzzy-search is only fast because the exact-search is so good at getting `physicalBlocks` down. // Empirically: if I remove the exact-search step, then the fuzzy-match step is more than an order of magnitude // slower. - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "5/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "5/6") dlog.Infof(_ctx, "5/6: Searching for %d block groups in checksum map (exact)...", len(bgs)) physicalSums := ExtractPhysicalSums(scanResults) logicalSums := ExtractLogicalSums(ctx, scanResults) @@ -166,14 +166,14 @@ func RebuildMappings(ctx context.Context, fs *btrfs.FS, scanResults ScanDevicesR } dlog.Info(ctx, "... done searching for exact block groups") - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "6/6") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "6/6") dlog.Infof(_ctx, "6/6: Searching for %d block groups in checksum map (fuzzy)...", len(bgs)) if err := matchBlockGroupSumsFuzzy(ctx, fs, bgs, physicalSums, logicalSums); err != nil { return err } dlog.Info(_ctx, "... done searching for fuzzy block groups") - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.step", "report") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.step", "report") dlog.Info(_ctx, "report:") unmappedPhysicalRegions := ListUnmappedPhysicalRegions(fs) diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go index d6ea338..00f367f 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/process_matchsums_fuzzy.go @@ -45,7 +45,7 @@ func matchBlockGroupSumsFuzzy(ctx context.Context, ) error { _ctx := ctx - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.substep", "indexing") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.substep", "indexing") dlog.Info(ctx, "Indexing physical regions...") // O(m) regions := ListUnmappedPhysicalRegions(fs) physicalIndex := make(map[btrfssum.ShortSum][]btrfsvol.QualifiedPhysicalAddr) @@ -62,7 +62,7 @@ func matchBlockGroupSumsFuzzy(ctx context.Context, } dlog.Info(ctx, "... done indexing") - ctx = dlog.WithField(_ctx, "btrfsinspect.rebuild-mappings.substep", "searching") + ctx = dlog.WithField(_ctx, "btrfs.inspect.rebuild-mappings.process.substep", "searching") dlog.Info(ctx, "Searching...") numBlockgroups := len(blockgroups) for i, bgLAddr := range maps.SortedKeys(blockgroups) { diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go index b67beaf..2128a48 100644 --- a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go @@ -110,7 +110,7 @@ var sbSize = btrfsvol.PhysicalAddr(binstruct.StaticSize(btrfstree.Superblock{})) // ScanOneDevice mostly mimics btrfs-progs // cmds/rescue-chunk-recover.c:scan_one_device(). func ScanOneDevice(ctx context.Context, dev *btrfs.Device, sb btrfstree.Superblock) (ScanOneDeviceResult, error) { - ctx = dlog.WithField(ctx, "btrfsinspect.scandevices.dev", dev.Name()) + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-mappings.scan.dev", dev.Name()) result := ScanOneDeviceResult{ FoundNodes: make(map[btrfsvol.LogicalAddr][]btrfsvol.PhysicalAddr), diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go index 565cb06..bbfcdde 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild.go @@ -75,7 +75,7 @@ type Rebuilder interface { } func NewRebuilder(ctx context.Context, fs *btrfs.FS, nodeScanResults rebuildmappings.ScanDevicesResult) (Rebuilder, error) { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.step", "read-fs-data") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.step", "read-fs-data") sb, nodeGraph, keyIO, err := ScanDevices(ctx, fs, nodeScanResults) // ScanDevices does its own logging if err != nil { return nil, err @@ -95,7 +95,7 @@ func (o *rebuilder) ListRoots(ctx context.Context) map[btrfsprim.ObjID]container } func (o *rebuilder) Rebuild(ctx context.Context) error { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.step", "rebuild") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.step", "rebuild") // Initialize o.retryItemQueue = make(map[btrfsprim.ObjID]containers.Set[keyAndTree]) @@ -113,7 +113,7 @@ func (o *rebuilder) Rebuild(ctx context.Context) error { // Run for passNum := 0; len(o.treeQueue) > 0 || len(o.addedItemQueue) > 0 || len(o.settledItemQueue) > 0 || len(o.augmentQueue) > 0; passNum++ { - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.pass", passNum) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.pass", passNum) // Crawl trees (Drain o.treeQueue, fill o.addedItemQueue). if err := o.processTreeQueue(ctx); err != nil { @@ -146,7 +146,7 @@ func (o *rebuilder) Rebuild(ctx context.Context) error { // processTreeQueue drains o.treeQueue, filling o.addedItemQueue. func (o *rebuilder) processTreeQueue(ctx context.Context) error { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep", "collect-items") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep", "collect-items") queue := maps.SortedKeys(o.treeQueue) o.treeQueue = make(containers.Set[btrfsprim.ObjID]) @@ -180,7 +180,7 @@ func (s settleItemStats) String() string { // processAddedItemQueue drains o.addedItemQueue, filling o.augmentQueue and o.settledItemQueue. func (o *rebuilder) processAddedItemQueue(ctx context.Context) error { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep", "settle-items") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep", "settle-items") queue := maps.Keys(o.addedItemQueue) o.addedItemQueue = make(containers.Set[keyAndTree]) @@ -191,13 +191,13 @@ func (o *rebuilder) processAddedItemQueue(ctx context.Context) error { var progress settleItemStats progress.D = len(queue) progressWriter := textui.NewProgress[settleItemStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second)) - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep.progress", &progress) + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep.progress", &progress) for i, key := range queue { progress.N = i progressWriter.Set(progress) - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.settle.item", key) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.settle.item", key) tree := o.rebuilt.Tree(ctx, key.TreeID) incPtr, ok := tree.Items(ctx).Load(key.Key) if !ok { @@ -239,7 +239,7 @@ func (s processItemStats) String() string { // processSettledItemQueue drains o.settledItemQueue, filling o.augmentQueue and o.treeQueue. func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep", "process-items") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep", "process-items") queue := maps.Keys(o.settledItemQueue) o.settledItemQueue = make(containers.Set[keyAndTree]) @@ -250,7 +250,7 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { var progress processItemStats progress.D = len(queue) progressWriter := textui.NewProgress[processItemStats](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second)) - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep.progress", &progress) + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep.progress", &progress) type keyAndBody struct { keyAndTree @@ -264,7 +264,7 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { if err := ctx.Err(); err != nil { return err } - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.process.item", key) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.process.item", key) item := keyAndBody{ keyAndTree: key, Body: o.rebuilt.Tree(ctx, key.TreeID).ReadItem(ctx, key.Key), @@ -280,7 +280,7 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { defer progressWriter.Done() o.curKey.Key.OK = true for item := range itemChan { - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.process.item", item.keyAndTree) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.process.item", item.keyAndTree) o.curKey.TreeID = item.TreeID o.curKey.Key.Val = item.Key btrfscheck.HandleItem(o, ctx, item.TreeID, btrfstree.Item{ @@ -304,7 +304,7 @@ func (o *rebuilder) processSettledItemQueue(ctx context.Context) error { // processAugmentQueue drains o.augmentQueue (and maybe o.retryItemQueue), filling o.addedItemQueue. func (o *rebuilder) processAugmentQueue(ctx context.Context) error { - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep", "apply-augments") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep", "apply-augments") resolvedAugments := make(map[btrfsprim.ObjID]containers.Set[btrfsvol.LogicalAddr], len(o.augmentQueue)) var progress textui.Portion[int] @@ -312,7 +312,7 @@ func (o *rebuilder) processAugmentQueue(ctx context.Context) error { if err := ctx.Err(); err != nil { return err } - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.augment.tree", treeID) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.augment.tree", treeID) resolvedAugments[treeID] = o.resolveTreeAugments(ctx, treeID) progress.D += len(resolvedAugments[treeID]) } @@ -322,9 +322,9 @@ func (o *rebuilder) processAugmentQueue(ctx context.Context) error { runtime.GC() progressWriter := textui.NewProgress[textui.Portion[int]](ctx, dlog.LogLevelInfo, textui.Tunable(1*time.Second)) - ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.substep.progress", &progress) + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.substep.progress", &progress) for _, treeID := range maps.SortedKeys(resolvedAugments) { - ctx := dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.augment.tree", treeID) + ctx := dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.rebuild.augment.tree", treeID) for _, nodeAddr := range maps.SortedKeys(resolvedAugments[treeID]) { if err := ctx.Err(); err != nil { progressWriter.Set(progress) diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_wanttyp.go b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_wanttyp.go index fa1ba98..a517579 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_wanttyp.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/rebuild_wanttyp.go @@ -96,8 +96,8 @@ func (o WantWithTree) String() string { } const ( - logFieldItemWant = "btrfsinspect.rebuild-nodes.rebuild.want" - logFieldTreeWant = "btrfsinspect.rebuild-nodes.rebuild.add-tree.want" + logFieldItemWant = "btrfs.inspect.rebuild-trees.rebuild.want" + logFieldTreeWant = "btrfs.util.rebuilt-forrest.add-tree.want" ) func withWant(ctx context.Context, logField, reason string, wantKey WantWithTree) context.Context { diff --git a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go index 03261e0..2995a2e 100644 --- a/cmd/btrfs-rec/inspect/rebuildtrees/scan.go +++ b/cmd/btrfs-rec/inspect/rebuildtrees/scan.go @@ -32,7 +32,7 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, scanResults rebuildmappings. var stats textui.Portion[int] stats.D = countNodes(scanResults) progressWriter := textui.NewProgress[textui.Portion[int]]( - dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.read.substep", "read-nodes"), + dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.read.substep", "read-nodes"), dlog.LogLevelInfo, textui.Tunable(1*time.Second)) nodeGraph := btrfsutil.NewGraph(*sb) @@ -67,6 +67,7 @@ func ScanDevices(ctx context.Context, fs *btrfs.FS, scanResults rebuildmappings. progressWriter.Done() dlog.Info(ctx, "... done reading node data") + ctx = dlog.WithField(ctx, "btrfs.inspect.rebuild-trees.read.substep", "check") if err := nodeGraph.FinalCheck(ctx, fs, *sb); err != nil { return btrfstree.Superblock{}, btrfsutil.Graph{}, nil, err } -- cgit v1.2.3-2-g168b