summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go4
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go10
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go8
3 files changed, 11 insertions, 11 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
index 26fa64e..ff6b1c5 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/forrest.go
@@ -64,8 +64,8 @@ type RebuiltForrest struct {
// mutable
trees containers.SyncMap[btrfsprim.ObjID, *RebuiltTree]
leafs *containers.LRUCache[btrfsprim.ObjID, map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr]]
- allItems *containers.LRUCache[btrfsprim.ObjID, *itemIndex]
incItems *containers.LRUCache[btrfsprim.ObjID, *itemIndex]
+ excItems *containers.LRUCache[btrfsprim.ObjID, *itemIndex]
}
// NewRebuiltForrest returns a new RebuiltForrest instance. All of
@@ -86,8 +86,8 @@ func NewRebuiltForrest(
cbLookupUUID: cbLookupUUID,
leafs: containers.NewLRUCache[btrfsprim.ObjID, map[btrfsvol.LogicalAddr]containers.Set[btrfsvol.LogicalAddr]](textui.Tunable(8)),
- allItems: containers.NewLRUCache[btrfsprim.ObjID, *itemIndex](textui.Tunable(8)),
incItems: containers.NewLRUCache[btrfsprim.ObjID, *itemIndex](textui.Tunable(8)),
+ excItems: containers.NewLRUCache[btrfsprim.ObjID, *itemIndex](textui.Tunable(8)),
}
}
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
index a25825a..65f76b2 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/btrees/tree.go
@@ -40,8 +40,8 @@ type RebuiltTree struct {
// evicted.
//
// 1. tree.leafToRoots() = tree.forrest.leafs.Load(tree.ID)
- // 2. tree.PotentialItems() = tree.forrest.allItems.Load(tree.ID)
- // 3. tree.Items() = tree.forrest.incItems.Load(tree.ID)
+ // 2. tree.Items() = tree.forrest.incItems.Load(tree.ID)
+ // 3. tree.PotentialItems() = tree.forrest.excItems.Load(tree.ID)
}
// LRU member 1: .leafToRoots() ////////////////////////////////////////////////////////////////////////////////////////
@@ -149,9 +149,9 @@ func (tree *RebuiltTree) Items(ctx context.Context) *containers.SortedMap[btrfsp
// RebuiltTree's internal map!
func (tree *RebuiltTree) PotentialItems(ctx context.Context) *containers.SortedMap[btrfsprim.Key, keyio.ItemPtr] {
ctx = dlog.WithField(ctx, "btrfsinspect.rebuild-nodes.rebuild.index-all-items", fmt.Sprintf("tree=%v", tree.ID))
- return tree.items(ctx, tree.forrest.allItems,
- func(_ containers.Set[btrfsvol.LogicalAddr]) bool {
- return true
+ return tree.items(ctx, tree.forrest.excItems,
+ func(roots containers.Set[btrfsvol.LogicalAddr]) bool {
+ return !tree.Roots.HasAny(roots)
})
}
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
index fbbda26..4709db2 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/rebuild.go
@@ -723,8 +723,8 @@ func (o *rebuilder) _wantRange(
return
}
- sizeFn := func(key btrfsprim.Key) (uint64, error) {
- ptr, ok := o.rebuilt.Tree(ctx, treeID).PotentialItems(ctx).Load(key)
+ sizeFn := func(items *containers.SortedMap[btrfsprim.Key, keyio.ItemPtr], key btrfsprim.Key) (uint64, error) {
+ ptr, ok := items.Load(key)
if !ok {
panic(fmt.Errorf("should not happen: could not load key: %v", keyAndTree{TreeID: treeID, Key: key}))
}
@@ -776,7 +776,7 @@ func (o *rebuilder) _wantRange(
}
},
func(runKey btrfsprim.Key, _ keyio.ItemPtr) bool {
- runSize, err := sizeFn(runKey)
+ runSize, err := sizeFn(o.rebuilt.Tree(ctx, treeID).PotentialItems(ctx), runKey)
if err != nil {
o.fsErr(ctx, fmt.Errorf("get size: %v: %w", keyAndTree{TreeID: treeID, Key: runKey}, err))
return true
@@ -848,7 +848,7 @@ func (o *rebuilder) _wantRange(
}
},
func(k btrfsprim.Key, v keyio.ItemPtr) bool {
- runSize, err := sizeFn(k)
+ runSize, err := sizeFn(o.rebuilt.Tree(ctx, treeID).PotentialItems(ctx), k)
if err != nil {
o.fsErr(ctx, fmt.Errorf("get size: %v: %w", keyAndTree{TreeID: treeID, Key: k}, err))
return true