Skip to contentSkip to conversation

set metadata extent size of tree block extents

check Alexandre Oliva 1 participant 1 message Mar 5, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

When scanning extents, we didn't set num_bytes when visiting a tree block extent. On the corrupted filesystem I was trying to fix, this caused an extent to have its size guessed as zero, so we'd compute end as start-1, which caused us to hit insert_state's BUG_ON(end<start).

---
 cmds-check.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmds-check.c +3 -2
index 0165fba..e563354 100644
@@ -5208,9 +5208,10 @@ static int process_extent_item(struct btrfs_root *root,
 
 	ei = btrfs_item_ptr(eb, slot, struct btrfs_extent_item);
 	refs = btrfs_extent_refs(eb, ei);
-	if (btrfs_extent_flags(eb, ei) & BTRFS_EXTENT_FLAG_TREE_BLOCK)
+	if (btrfs_extent_flags(eb, ei) & BTRFS_EXTENT_FLAG_TREE_BLOCK) {
 		metadata = 1;
-	else
+		num_bytes = root->leafsize;
+	} else
 		metadata = 0;
 
 	add_extent_rec(extent_cache, NULL, 0, key.objectid, num_bytes,
Signature · 4 lines
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer