summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-03-22 21:28:59 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2023-03-23 18:35:19 -0600
commit5520c20c493d52d83288bc2e321117006e38fd1a (patch)
tree7018dad5481473878808a3159381deca74150b7b
parentbbabc9ab42accbd37072735419cc0552dc8917ee (diff)
btrfsutil: RebuiltTree: Allow nodes with .Gen == .ParentGen
-rw-r--r--lib/btrfs/btrfsitem/item_root.go5
-rw-r--r--lib/btrfsutil/rebuilt_tree.go2
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/btrfs/btrfsitem/item_root.go b/lib/btrfs/btrfsitem/item_root.go
index 4ffad9a..8bdc3df 100644
--- a/lib/btrfs/btrfsitem/item_root.go
+++ b/lib/btrfs/btrfsitem/item_root.go
@@ -22,6 +22,11 @@ import (
// key.offset = one of:
// - 0 if objectid is one of the BTRFS_*_TREE_OBJECTID defines or a non-snapshot volume; or
// - transaction_id of when this snapshot was created
+//
+// This tree might contain nodes with node.Head.Owner set to the
+// root.ParentUUID tree, *if* the node.Head.Generation is
+// less-than-or-equal-to the root's key.offset. The "or-equal-to"
+// part of that might be surprising, which is why I called it out.
type Root struct { // trivial ROOT_ITEM=132
Inode Inode `bin:"off=0x000, siz=0xa0"` // ???
Generation btrfsprim.Generation `bin:"off=0x0a0, siz=0x08"`
diff --git a/lib/btrfsutil/rebuilt_tree.go b/lib/btrfsutil/rebuilt_tree.go
index 3fff9b2..96d5a75 100644
--- a/lib/btrfsutil/rebuilt_tree.go
+++ b/lib/btrfsutil/rebuilt_tree.go
@@ -122,7 +122,7 @@ func (tree *RebuiltTree) isOwnerOK(owner btrfsprim.ObjID, gen btrfsprim.Generati
if owner == tree.ID {
return true
}
- if tree.Parent == nil || gen >= tree.ParentGen {
+ if tree.Parent == nil || gen > tree.ParentGen {
return false
}
tree = tree.Parent