summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-10-06 19:04:20 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-10-06 19:04:20 -0600
commitceff7fa1fce0d6810c42ef6d57dcc2316e63c84b (patch)
treecca3d3350eea2ac393134e3c2cff33c0358b5c33
parent443bad3651a5f027cc97ebac4fc86cf86820d3c7 (diff)
fix bug with subvolume lookup
-rw-r--r--lib/btrfs/btrfstree/root.go24
-rw-r--r--lib/btrfs/io4_fs.go6
2 files changed, 15 insertions, 15 deletions
diff --git a/lib/btrfs/btrfstree/root.go b/lib/btrfs/btrfstree/root.go
index a233ef0..12df0b2 100644
--- a/lib/btrfs/btrfstree/root.go
+++ b/lib/btrfs/btrfstree/root.go
@@ -21,6 +21,19 @@ type TreeRoot struct {
Generation btrfsprim.Generation
}
+func RootItemSearchFn(treeID btrfsprim.ObjID) func(btrfsprim.Key, uint32) int {
+ return func(key btrfsprim.Key, _ uint32) int {
+ if key.ObjectID == treeID && key.ItemType == btrfsitem.ROOT_ITEM_KEY {
+ return 0
+ }
+ return btrfsprim.Key{
+ ObjectID: treeID,
+ ItemType: btrfsitem.ROOT_ITEM_KEY,
+ Offset: 0,
+ }.Cmp(key)
+ }
+}
+
// LookupTreeRoot is a utility function to help with implementing the 'Trees'
// interface.
func LookupTreeRoot(fs TreeOperator, sb Superblock, treeID btrfsprim.ObjID) (*TreeRoot, error) {
@@ -54,16 +67,7 @@ func LookupTreeRoot(fs TreeOperator, sb Superblock, treeID btrfsprim.ObjID) (*Tr
Generation: sb.BlockGroupRootGeneration,
}, nil
default:
- rootItem, err := fs.TreeSearch(btrfsprim.ROOT_TREE_OBJECTID, func(key btrfsprim.Key, _ uint32) int {
- if key.ObjectID == treeID && key.ItemType == btrfsitem.ROOT_ITEM_KEY {
- return 0
- }
- return btrfsprim.Key{
- ObjectID: treeID,
- ItemType: btrfsitem.ROOT_ITEM_KEY,
- Offset: 0,
- }.Cmp(key)
- })
+ rootItem, err := fs.TreeSearch(btrfsprim.ROOT_TREE_OBJECTID, RootItemSearchFn(treeID))
if err != nil {
return nil, err
}
diff --git a/lib/btrfs/io4_fs.go b/lib/btrfs/io4_fs.go
index 29f481c..9391820 100644
--- a/lib/btrfs/io4_fs.go
+++ b/lib/btrfs/io4_fs.go
@@ -80,11 +80,7 @@ type Subvolume struct {
func (sv *Subvolume) init() {
sv.rootOnce.Do(func() {
- root, err := sv.FS.TreeLookup(btrfsprim.ROOT_TREE_OBJECTID, btrfsprim.Key{
- ObjectID: sv.TreeID,
- ItemType: btrfsitem.ROOT_ITEM_KEY,
- Offset: 0,
- })
+ root, err := sv.FS.TreeSearch(btrfsprim.ROOT_TREE_OBJECTID, btrfstree.RootItemSearchFn(sv.TreeID))
if err != nil {
sv.rootErr = err
return