summaryrefslogtreecommitdiff
path: root/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-02 17:29:44 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-02 17:29:44 -0700
commitabff94282174a8f14aec482d2e4992de5915c837 (patch)
tree90113b4c4dac91ea5ad6f4342b45a9b9b2988007 /lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
parent2098ac287002f090a02baf82fd5dda1bc3753e25 (diff)
parent301a28a093372f1182253d021659425070ae8747 (diff)
Merge branch 'lukeshu/rebuild-nodes-take6'
Diffstat (limited to 'lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go')
-rw-r--r--lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
index 9e3b144..04df2b6 100644
--- a/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
+++ b/lib/btrfsprogs/btrfsinspect/rebuildnodes/keyio/keyio.go
@@ -7,6 +7,7 @@ package keyio
import (
"context"
"fmt"
+ "sync"
"github.com/datawire/dlib/dlog"
@@ -48,6 +49,7 @@ type Handle struct {
Names map[ItemPtr][]byte // DIR_INDEX
Sizes map[ItemPtr]SizeAndErr // EXTENT_CSUM and EXTENT_DATA
+ mu sync.Mutex
cache containers.ARCache[btrfsvol.LogicalAddr, *diskio.Ref[btrfsvol.LogicalAddr, btrfstree.Node]]
}
@@ -153,6 +155,8 @@ func (o *Handle) readNode(ctx context.Context, laddr btrfsvol.LogicalAddr) *disk
}
func (o *Handle) ReadItem(ctx context.Context, ptr ItemPtr) btrfsitem.Item {
+ o.mu.Lock()
+ defer o.mu.Unlock()
if o.graph.Nodes[ptr.Node].Level != 0 {
panic(fmt.Errorf("should not happen: keyio.Handle.ReadItem called for non-leaf node@%v", ptr.Node))
}
@@ -164,5 +168,5 @@ func (o *Handle) ReadItem(ctx context.Context, ptr ItemPtr) btrfsitem.Item {
panic(fmt.Errorf("should not happen: keyio.Handle.ReadItem called for out-of-bounds item index: index=%v len=%v",
ptr.Idx, len(items)))
}
- return items[ptr.Idx].Body
+ return items[ptr.Idx].Body.CloneItem()
}