diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-30 21:39:00 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-08-30 21:39:54 -0600 |
commit | a9d6b935eef8124efbcfd2c9569fbccd932051de (patch) | |
tree | 24b9681825a6dcc40643f7d3d081c21316ee585e /lib/btrfs/btrfstree/path.go | |
parent | 4a52c625fdf68a8693d5b3c6eb80e7faf822cb15 (diff) |
Change how btrfstree.TreePath generations work
Diffstat (limited to 'lib/btrfs/btrfstree/path.go')
-rw-r--r-- | lib/btrfs/btrfstree/path.go | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/lib/btrfs/btrfstree/path.go b/lib/btrfs/btrfstree/path.go index 4a4d66e..212b5df 100644 --- a/lib/btrfs/btrfstree/path.go +++ b/lib/btrfs/btrfstree/path.go @@ -27,53 +27,48 @@ import ( // // [superblock: tree=B, lvl=3, gen=6] // | -// | <------------------------------------------ pathElem={from_tree:B, from_gen=6, from_idx=-1, -// | to_addr:0x01, to_lvl=3} +// | <------------------------------------------ pathElem={from_tree:B, from_idx=-1, +// | to_addr:0x01, to_gen=6, to_lvl=3} // +[0x01]-------------+ // | lvl=3 gen=6 own=B | // +-+-+-+-+-+-+-+-+-+-+ // |0|1|2|3|4|5|6|7|8|9| // +-+-+-+-+-+-+-+-+-+-+ // | -// | <------------------------------ pathElem:{from_tree:B, from_gen:6, from_idx:7, -// | to_addr:0x02, to_lvl:2} +// | <------------------------------ pathElem:{from_tree:B, from_idx:7, +// | to_addr:0x02, to_gen:5, to_lvl:2} // +[0x02]--------------+ // | lvl=2 gen=5 own=B | // +-+-+-+-+-+-+-+-+-+-+ // |0|1|2|3|4|5|6|7|8|9| // +-+-+-+-+-+-+-+-+-+-+ // | -// | <-------------------- pathElem={from_tree:B, from_gen:5, from_idx:6, -// | to_addr:0x03, to_lvl:1} +// | <-------------------- pathElem={from_tree:B, from_idx:6, +// | to_addr:0x03, to_gen:5, to_lvl:1} // +[0x03]-------------+ // | lvl=1 gen=5 own=A | // +-+-+-+-+-+-+-+-+-+-+ // |0|1|2|3|4|5|6|7|8|9| // +-+-+-+-+-+-+-+-+-+-+ // | -// | <---------------- pathElem={from_tree:A, from_gen:5, from_idx:3, -// | to_addr:0x04, to_lvl:0} +// | <---------------- pathElem={from_tree:A, from_idx:3, +// | to_addr:0x04, to_gen:2, lvl:0} // +[0x04]-------------+ // | lvl=0 gen=2 own=A | // +-+-+-+-+-+-+-+-+-+-+ // |0|1|2|3|4|5|6|7|8|9| // +-+-+-+-+-+-+-+-+-+-+ // | -// | <--------------- pathElem={from_tree:A, from_gen:2, from_idx:1, -// | to_addr:0, to_lvl:0} +// | <--------------- pathElem={from_tree:A, from_idx:1, +// | to_addr:0, to_gen: 0, to_lvl:0} // [item] type TreePath []TreePathElem -// A TreePathElem essentially represents a KeyPointer. If there is an -// error looking up the tree root, everything but FromTree is zero. +// A TreePathElem essentially represents a KeyPointer. type TreePathElem struct { // FromTree is the owning tree ID of the parent node; or the // well-known tree ID if this is the root. FromTree btrfsprim.ObjID - // FromGeneration is the generation of the parent node the - // parent node; or generation stored in the superblock if this - // is the root. - FromGeneration btrfsprim.Generation // FromItemIdx is the index of this KeyPointer in the parent // Node; or -1 if this is the root and there is no KeyPointer. FromItemIdx int @@ -82,7 +77,11 @@ type TreePathElem struct { // points at, or 0 if this is a leaf item and nothing is being // pointed at. ToNodeAddr btrfsvol.LogicalAddr - // ToNodeLevel is the expected or actual level of the node at + // ToNodeGeneration is the expected generation of the node at + // ToNodeAddr, or 0 if this is a leaf item and nothing is + // being pointed at. + ToNodeGeneration btrfsprim.Generation + // ToNodeLevel is the expected level of the node at // ToNodeAddr, or 0 if this is a leaf item and nothing is // being pointed at. ToNodeLevel uint8 @@ -98,7 +97,7 @@ func (path TreePath) String() string { } else { var ret strings.Builder fmt.Fprintf(&ret, "%s->", path[0].FromTree.Format(btrfsitem.ROOT_ITEM_KEY)) - if len(path) == 1 && path[0] == (TreePathElem{FromTree: path[0].FromTree}) { + if len(path) == 1 && path[0] == (TreePathElem{FromTree: path[0].FromTree, FromItemIdx: -1}) { ret.WriteString("(empty-path)") } else { path[0].writeNodeTo(&ret) |