[check] set metadata extent size of tree block extents
diff mbox

Message ID orpov8pn1x.fsf@livre.home
State New
Headers show

Commit Message

Alexandre Oliva March 5, 2016, 10:39 p.m. UTC
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).

Signed-off-by: Alexandre Oliva <oliva@gnu.org>
---
 cmds-check.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/cmds-check.c b/cmds-check.c
index 0165fba..e563354 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -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,