summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go11
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go7
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
index 1d3b693..4f4e05d 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
@@ -112,7 +112,7 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
defer func() {
if !ok {
// Store a negative cache of this. tree.AddRoot() for the ROOT or UUID
- // trees will invalidate the negative cache.
+ // trees will call .flushNegativeCache().
ts.trees.Store(treeID, nil)
}
}()
@@ -177,6 +177,15 @@ func (ts *RebuiltForrest) addTree(ctx context.Context, treeID btrfsprim.ObjID, s
return true
}
+func (ts *RebuiltForrest) flushNegativeCache() {
+ ts.trees.Range(func(treeID btrfsprim.ObjID, tree *RebuiltTree) bool {
+ if tree == nil {
+ ts.trees.Delete(treeID)
+ }
+ return true
+ })
+}
+
// ListRoots returns a listing of all initialized trees and their root
// nodes.
//
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
index b13bb98..d64d7d2 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
@@ -303,12 +303,7 @@ func (tree *RebuiltTree) AddRoot(ctx context.Context, rootNode btrfsvol.LogicalA
tree.forrest.excItems.Delete(tree.ID) // force re-gen
if (tree.ID == btrfsprim.ROOT_TREE_OBJECTID || tree.ID == btrfsprim.UUID_TREE_OBJECTID) && stats.AddedItems > 0 {
- tree.forrest.trees.Range(func(otherTreeID btrfsprim.ObjID, otherTree *RebuiltTree) bool {
- if otherTree == nil {
- tree.forrest.trees.Delete(otherTreeID)
- }
- return true
- })
+ tree.forrest.flushNegativeCache()
}
}