btrfs-progs: image: fix invalid size check for extent items

While trying to run down a corruption problem I needed to use
btrfs-image to generate known good states in between tests.  At some
point this started failing with

  either extent tree is corrupted or deprecated extent ref format

This is because the fs had an extent item that was large enough that it
no longer had inline extent references, they were all keyed extent
references.  The check is bogus, we can have extent items that are >=
the extent item size, not just > than the extent item size.  Fix the
check so that we can generate metadata dumps properly.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2020-11-19 16:14:20 -05:00 committed by David Sterba
parent 9cc9c9ab32
commit 0c6e59e0b2
1 changed files with 1 additions and 1 deletions

View File

@ -933,7 +933,7 @@ static int copy_from_extent_tree(struct metadump_struct *metadump,
break;
}
if (btrfs_item_size_nr(leaf, path->slots[0]) > sizeof(*ei)) {
if (btrfs_item_size_nr(leaf, path->slots[0]) >= sizeof(*ei)) {
ei = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_extent_item);
if (btrfs_extent_flags(leaf, ei) &