summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-12-27 01:14:34 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-05 19:48:17 -0700
commit5590315b11557aa48999d09700631ad9239ce03b (patch)
tree0a2246a0ff601a397219c478f943d05245b71ad6 /lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
parentf416f777b2c2cac095e851e6799020f91e34aed1 (diff)
rebuildnodes: Optimize: Try to avoid disk access for DIR_INDEX
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
index 24c3dcf..eb03004 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
@@ -39,6 +39,7 @@ type Handle struct {
sb btrfstree.Superblock
graph graph.Graph
+ Names map[ItemPtr][]byte
Sizes map[ItemPtr]SizeAndErr
cache *containers.LRUCache[btrfsvol.LogicalAddr, *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.Node]]
@@ -49,6 +50,7 @@ func NewHandle(file diskio.File[btrfsvol.LogicalAddr], sb btrfstree.Superblock)
rawFile: file,
sb: sb,
+ Names: make(map[ItemPtr][]byte),
Sizes: make(map[ItemPtr]SizeAndErr),
cache: containers.NewLRUCache[btrfsvol.LogicalAddr, *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.Node]](textui.Tunable(8)),
@@ -62,6 +64,10 @@ func (o *Handle) InsertNode(nodeRef *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.
Idx: i,
}
switch itemBody := item.Body.(type) {
+ case btrfsitem.DirEntry:
+ if item.Key.ItemType == btrfsprim.DIR_INDEX_KEY {
+ o.Names[ptr] = append([]byte(nil), itemBody.Name...)
+ }
case btrfsitem.ExtentCSum:
o.Sizes[ptr] = SizeAndErr{
Size: uint64(itemBody.Size()),