diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-09 16:43:39 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-30 10:04:50 -0600 |
commit | 6f1914f5db33a0d4431069eb9378cac68daf8cc0 (patch) | |
tree | f92fd945ea2393431c01a1bd49ac16264673d467 /lib/btrfs/io3_btree.go | |
parent | d0b7bc25341c936e96a64a540824f77ed79878ce (diff) |
btrfstree: Rethink 'Path' yet again
Diffstat (limited to 'lib/btrfs/io3_btree.go')
-rw-r--r-- | lib/btrfs/io3_btree.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index 8aa485f..030ea41 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -8,7 +8,6 @@ import ( "context" "fmt" - "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsitem" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsprim" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfstree" "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" @@ -18,68 +17,6 @@ import ( // This file is ordered from low-level to high-level. -// btrfstree.NodeFile ////////////////////////////////////////////////////////// - -type treeInfo struct { - UUID btrfsprim.UUID - ParentUUID btrfsprim.UUID - ParentGen btrfsprim.Generation -} - -func (fs *FS) populateTreeUUIDs(ctx context.Context) { - if fs.cacheObjID2All != nil && fs.cacheUUID2ObjID != nil { - return - } - fs.cacheObjID2All = make(map[btrfsprim.ObjID]treeInfo) - fs.cacheUUID2ObjID = make(map[btrfsprim.UUID]btrfsprim.ObjID) - fs.TreeWalk(ctx, btrfsprim.ROOT_TREE_OBJECTID, - func(err *btrfstree.TreeError) { - // do nothing - }, - btrfstree.TreeWalkHandler{ - Item: func(_ btrfstree.Path, item btrfstree.Item) { - itemBody, ok := item.Body.(*btrfsitem.Root) - if !ok { - return - } - fs.cacheObjID2All[item.Key.ObjectID] = treeInfo{ - UUID: itemBody.UUID, - ParentUUID: itemBody.ParentUUID, - ParentGen: btrfsprim.Generation(item.Key.Offset), - } - fs.cacheUUID2ObjID[itemBody.UUID] = item.Key.ObjectID - }, - }, - ) -} - -// ParentTree implements btrfstree.NodeFile. -func (fs *FS) ParentTree(tree btrfsprim.ObjID) (btrfsprim.ObjID, btrfsprim.Generation, bool) { - if tree < btrfsprim.FIRST_FREE_OBJECTID || tree > btrfsprim.LAST_FREE_OBJECTID { - // no parent - return 0, 0, true - } - fs.populateTreeUUIDs(context.TODO()) - - all, ok := fs.cacheObjID2All[tree] - if !ok { - // could not look up parent info - return 0, 0, false - } - if all.ParentUUID == (btrfsprim.UUID{}) { - // no parent - return 0, 0, true - } - parentObjID, ok := fs.cacheUUID2ObjID[all.ParentUUID] - if !ok { - // could not look up parent info - return 0, 0, false - } - return parentObjID, all.ParentGen, true -} - -var _ btrfstree.NodeFile = (*FS)(nil) - // btrfstree.NodeSource //////////////////////////////////////////////////////// type nodeCacheEntry struct { |