diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-02 20:11:38 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-04 14:08:38 -0600 |
commit | fe3b3fdcace149b3514df716ea5de363a0c2e0cb (patch) | |
tree | d4f159467860fbc54063f75915261a1623ff4269 | |
parent | 3e35c0eb69b0fdae195d8fa372a026977acba737 (diff) |
btrfsutil: RebuiltTree: Have .items() take a bool instead of a func
-rw-r--r-- | lib/btrfsutil/rebuilt_tree.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go index 61bbb5e..836873e 100644 --- a/lib/btrfsutil/rebuilt_tree.go +++ b/lib/btrfsutil/rebuilt_tree.go @@ -173,15 +173,12 @@ func (tree *RebuiltTree) RebuiltReleasePotentialItems() { func (tree *RebuiltTree) uncachedIncItems(ctx context.Context) containers.SortedMap[btrfsprim.Key, ItemPtr] { ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.index-inc-items", fmt.Sprintf("tree=%v", tree.ID)) - return tree.items(ctx, tree.Roots.HasAny) + return tree.items(ctx, true) } func (tree *RebuiltTree) uncachedExcItems(ctx context.Context) containers.SortedMap[btrfsprim.Key, ItemPtr] { ctx = dlog.WithField(ctx, "btrfs.util.rebuilt-tree.index-exc-items", fmt.Sprintf("tree=%v", tree.ID)) - return tree.items(ctx, - func(roots containers.Set[btrfsvol.LogicalAddr]) bool { - return !tree.Roots.HasAny(roots) - }) + return tree.items(ctx, false) } type itemIndex = containers.SortedMap[btrfsprim.Key, ItemPtr] @@ -197,13 +194,13 @@ func (s itemStats) String() string { s.Leafs, s.NumItems, s.NumDups) } -func (tree *RebuiltTree) items(ctx context.Context, leafFn func(roots containers.Set[btrfsvol.LogicalAddr]) bool) containers.SortedMap[btrfsprim.Key, ItemPtr] { +func (tree *RebuiltTree) items(ctx context.Context, inc bool) containers.SortedMap[btrfsprim.Key, ItemPtr] { tree.mu.RLock() defer tree.mu.RUnlock() var leafs []btrfsvol.LogicalAddr for leaf, roots := range tree.acquireLeafToRoots(ctx) { - if leafFn(roots) { + if tree.Roots.HasAny(roots) == inc { leafs = append(leafs, leaf) } } |