summaryrefslogtreecommitdiff
path: root/pkg/btrfs/io3_btree.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-07 02:51:57 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 00:16:01 -0600
commit22c32850798c264b6a20539b9cd1699228368ce9 (patch)
treeeea4fe596bc584cba96245d8bfbe92503d1a4c61 /pkg/btrfs/io3_btree.go
parentfa98ff69f24545e1836201c30ab43cc2527c52e3 (diff)
write btrfs-clear-bad-nodes
Diffstat (limited to 'pkg/btrfs/io3_btree.go')
-rw-r--r--pkg/btrfs/io3_btree.go44
1 files changed, 42 insertions, 2 deletions
diff --git a/pkg/btrfs/io3_btree.go b/pkg/btrfs/io3_btree.go
index 01da746..3c1535b 100644
--- a/pkg/btrfs/io3_btree.go
+++ b/pkg/btrfs/io3_btree.go
@@ -19,9 +19,49 @@ import (
// - For .Item() callbacks, the last element will always have a
// NodeAddr of 0.
//
-// ex:
+// For example, given the tree structure
//
-// {-1, 0x01, 3}→{9, 0x02, 2}→{9, 0x03, 1}→{9, 0x04, 0}→{9, 0, 0}
+// [superblock]
+// |
+// | <------------------------------------------ pathElem={idx:-1, addr:0x01, lvl:3}
+// |
+// +[0x01]-----------+
+// | lvl=3 |
+// +-+-+-+-+-+-+-+-+-+
+// |1|2|3|4|5|6|7|8|9|
+// +---+---+---+---+-+
+// |
+// | <------------------------------ pathElem={idx:8, addr:0x02, lvl:2}
+// |
+// +[0x02]-----------+
+// | lvl=2 |
+// +-+-+-+-+-+-+-+-+-+
+// |1|2|3|4|5|6|7|8|9|
+// +---+---+---+---+-+
+// |
+// | <-------------------- pathElem={idx:7, addr:0x03, lvl:1}
+// |
+// +[0x03]-----------+
+// | lvl=1 |
+// +-+-+-+-+-+-+-+-+-+
+// |1|2|3|4|5|6|7|8|9|
+// +---+---+---+---+-+
+// |
+// | <---------------- pathElem={idx:4, addr:0x04, lvl:0}
+// |
+// +[0x04]-----------+
+// | lvl=0 |
+// +-+-+-+-+-+-+-+-+-+
+// |1|2|3|4|5|6|7|8|9|
+// +---+---+---+---+-+
+// |
+// | <--------------- pathElem={idx:5, addr:0, lvl:0}
+// |
+// [item]
+//
+// the path would be
+//
+// {-1, 0x01, 3}→{8, 0x02, 2}→{7, 0x03, 1}→{4, 0x04, 0}→{2, 0, 0}
type TreePath []TreePathElem
// A TreePathElem essentially represents a KeyPointer.