diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-13 18:52:51 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-03-15 09:28:45 -0600 |
commit | 0733161bf46a279f11e20f9ffd34e0136c13a884 (patch) | |
tree | 3d70a7f5705ab5ccaf7daf296629ed8d300352ae | |
parent | cd1a18b54316da20482f3d1765319d69fcbd852a (diff) |
btrfs: io3_btree.go: De-nest populateTreeUUIDs
-rw-r--r-- | lib/btrfs/io3_btree.go | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/btrfs/io3_btree.go b/lib/btrfs/io3_btree.go index 426e4a1..db4e42c 100644 --- a/lib/btrfs/io3_btree.go +++ b/lib/btrfs/io3_btree.go @@ -28,28 +28,29 @@ var _ btrfstree.NodeSource = (*FS)(nil) // btrfstree.NodeFile ////////////////////////////////////////////////////////// func (fs *FS) populateTreeUUIDs(ctx context.Context) { - if fs.cacheObjID2UUID == nil || fs.cacheUUID2ObjID == nil || fs.cacheTreeParent == nil { - fs.cacheObjID2UUID = make(map[btrfsprim.ObjID]btrfsprim.UUID) - fs.cacheUUID2ObjID = make(map[btrfsprim.UUID]btrfsprim.ObjID) - fs.cacheTreeParent = make(map[btrfsprim.ObjID]btrfsprim.UUID) - fs.TreeWalk(ctx, btrfsprim.ROOT_TREE_OBJECTID, - func(err *btrfstree.TreeError) { - // do nothing - }, - btrfstree.TreeWalkHandler{ - Item: func(_ btrfstree.TreePath, item btrfstree.Item) error { - itemBody, ok := item.Body.(*btrfsitem.Root) - if !ok { - return nil - } - fs.cacheObjID2UUID[item.Key.ObjectID] = itemBody.UUID - fs.cacheTreeParent[item.Key.ObjectID] = itemBody.ParentUUID - fs.cacheUUID2ObjID[itemBody.UUID] = item.Key.ObjectID + if fs.cacheObjID2UUID != nil && fs.cacheUUID2ObjID != nil && fs.cacheTreeParent != nil { + return + } + fs.cacheObjID2UUID = make(map[btrfsprim.ObjID]btrfsprim.UUID) + fs.cacheUUID2ObjID = make(map[btrfsprim.UUID]btrfsprim.ObjID) + fs.cacheTreeParent = make(map[btrfsprim.ObjID]btrfsprim.UUID) + fs.TreeWalk(ctx, btrfsprim.ROOT_TREE_OBJECTID, + func(err *btrfstree.TreeError) { + // do nothing + }, + btrfstree.TreeWalkHandler{ + Item: func(_ btrfstree.TreePath, item btrfstree.Item) error { + itemBody, ok := item.Body.(*btrfsitem.Root) + if !ok { return nil - }, + } + fs.cacheObjID2UUID[item.Key.ObjectID] = itemBody.UUID + fs.cacheTreeParent[item.Key.ObjectID] = itemBody.ParentUUID + fs.cacheUUID2ObjID[itemBody.UUID] = item.Key.ObjectID + return nil }, - ) - } + }, + ) } // ParentTree implements btrfstree.NodeFile. |