summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-12-18 00:34:06 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2022-12-20 20:59:35 -0700
commit7c0e009092f593ca0990a50de8db3f81c112e58e (patch)
treecb54d2a34debc737e417dd8a6c1772610530c38e /lib/btrfsprogs/btrfsinspect
parent8ff81c1ed6a50179166ffc4cfb60bef85394265e (diff)
rebuildnodes: Reduce scope of the orphans set
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/orphans.go7
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go4
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/orphans.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/orphans.go
index 51313a9..0ecf852 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/orphans.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/orphans.go
@@ -83,13 +83,12 @@ func (s readStats) String() string {
}
func indexOrphans(ctx context.Context, fs diskio.File[btrfsvol.LogicalAddr], sb btrfstree.Superblock, graph graph.Graph) (
- orphans containers.Set[btrfsvol.LogicalAddr],
leaf2orphans map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr],
key2leaf *containers.SortedMap[keyAndTree, btrfsvol.LogicalAddr],
err error,
) {
dlog.Info(ctx, "... counting orphans")
- orphans = make(containers.Set[btrfsvol.LogicalAddr])
+ orphans := make(containers.Set[btrfsvol.LogicalAddr])
for node := range graph.Nodes {
if len(graph.EdgesTo[node]) == 0 {
orphans.Insert(node)
@@ -145,7 +144,7 @@ func indexOrphans(ctx context.Context, fs diskio.File[btrfsvol.LogicalAddr], sb
Level: containers.Optional[uint8]{OK: true, Val: 0},
})
if err != nil {
- return nil, nil, nil, err
+ return nil, nil, err
}
for _, item := range nodeRef.Data.BodyLeaf {
@@ -162,5 +161,5 @@ func indexOrphans(ctx context.Context, fs diskio.File[btrfsvol.LogicalAddr], sb
}
readProgressWriter.Done()
- return orphans, leaf2orphans, key2leaf, nil
+ return leaf2orphans, key2leaf, nil
}
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
index ef50653..d197bf8 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
@@ -37,7 +37,6 @@ type Rebuilder struct {
graph graph.Graph
uuidMap uuidmap.UUIDMap
csums containers.RBTree[containers.NativeOrdered[btrfsvol.LogicalAddr], btrfsinspect.SysExtentCSum]
- orphans containers.Set[btrfsvol.LogicalAddr]
leaf2orphans map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr]
key2leaf containers.SortedMap[keyAndTree, btrfsvol.LogicalAddr]
@@ -65,7 +64,7 @@ func RebuildNodes(ctx context.Context, fs *btrfs.FS, nodeScanResults btrfsinspec
}
dlog.Info(ctx, "Indexing orphans...")
- orphans, leaf2orphans, key2leaf, err := indexOrphans(ctx, fs, *sb, *scanData.nodeGraph)
+ leaf2orphans, key2leaf, err := indexOrphans(ctx, fs, *sb, *scanData.nodeGraph)
if err != nil {
return nil, err
}
@@ -79,7 +78,6 @@ func RebuildNodes(ctx context.Context, fs *btrfs.FS, nodeScanResults btrfsinspec
graph: *scanData.nodeGraph,
uuidMap: *scanData.uuidMap,
csums: *csums,
- orphans: orphans,
leaf2orphans: leaf2orphans,
key2leaf: *key2leaf,