diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-29 21:07:25 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-30 21:29:18 -0600 |
commit | c8c3f8b5f1b7a7f61c4fc1dda99062cedff66841 (patch) | |
tree | 806faad9a1e87b31c18a9b108f8260a4e9a2c0a0 /lib/btrfsprogs/btrfsinspect/rebuildnodes | |
parent | 66a0058a5c2921b5c4e35732011d32810a9d2f7a (diff) |
wip
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes')
3 files changed, 17 insertions, 4 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuildnodes.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuildnodes.go index e5ae5e4..c02600d 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuildnodes.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuildnodes.go @@ -35,12 +35,10 @@ func RebuildNodes(ctx context.Context, fs *btrfs.FS, nodeScanResults btrfsinspec uuidMap: uuidMap, } - dlog.Info(ctx, "Identifying lost+found nodes...") foundRoots, err := lostAndFoundNodes(ctx, nfs, nodeScanResults) if err != nil { return nil, err } - dlog.Infof(ctx, "... identified %d lost+found nodes", len(foundRoots)) dlog.Info(ctx, "Initializing nodes to re-build...") rebuiltNodes, err := reInitBrokenNodes(ctx, nfs, nodeScanResults, foundRoots) diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go index ba090fb..b29c201 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s1_uuidmap.go @@ -99,7 +99,10 @@ func buildUUIDMap(ctx context.Context, fs *btrfs.FS, scanResults btrfsinspect.Sc progress() } } - progress() + + if done != total { + panic("should not happen") + } missing := make(map[btrfsprim.ObjID]struct{}) for treeID := range seenTreeIDs { diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s2_lostandfound.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s2_lostandfound.go index 8da8588..2448033 100644 --- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/s2_lostandfound.go +++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/s2_lostandfound.go @@ -19,7 +19,11 @@ import ( "git.lukeshu.com/btrfs-progs-ng/lib/diskio" ) +// lostAndFoundNodes returns the set of nodes don't have another node +// claiming it as a child. func lostAndFoundNodes(ctx context.Context, fs _FS, nodeScanResults btrfsinspect.ScanDevicesResult) (map[btrfsvol.LogicalAddr]struct{}, error) { + dlog.Info(ctx, "Identifying lost+found nodes...") + lastPct := -1 total := countNodes(nodeScanResults) progress := func(done int) { @@ -62,6 +66,9 @@ func lostAndFoundNodes(ctx context.Context, fs _FS, nodeScanResults btrfsinspect } } } + if len(attachedNodes)+len(orphanedNodes) != total { + panic("should not happen") + } dlog.Infof(ctx, "... (finished processing %v attached nodes, proceeding to process %v lost nodes, for a total of %v)", len(attachedNodes), len(orphanedNodes), len(attachedNodes)+len(orphanedNodes)) @@ -73,7 +80,7 @@ func lostAndFoundNodes(ctx context.Context, fs _FS, nodeScanResults btrfsinspect orphanedRoots[node] = struct{}{} } done := len(attachedNodes) - for potentialRoot := range orphanedRoots { + for potentialRoot := range orphanedNodes { done++ progress(done) if orphanedNodes[potentialRoot] > 1 { @@ -101,5 +108,10 @@ func lostAndFoundNodes(ctx context.Context, fs _FS, nodeScanResults btrfsinspect ) } + if done != total { + panic("should not happen") + } + + dlog.Infof(ctx, "... identified %d lost+found nodes", len(orphanedRoots)) return orphanedRoots, nil } |