btrfs-progs: check/original: don't reset extent generation for check_block

In check_block(), we unconditionally reset extent_record::generation.

This is in fact correct, but this makes original mode fail to detect bad
extent item generation.

So change to behavior to set the generation if and only if the tree
block generation is higher.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2020-08-11 19:44:49 +08:00 committed by David Sterba
parent 289e87d9f8
commit b858e3b5c2
1 changed files with 2 additions and 1 deletions

View File

@ -4455,7 +4455,8 @@ static int check_block(struct btrfs_root *root,
if (!cache) if (!cache)
return 1; return 1;
rec = container_of(cache, struct extent_record, cache); rec = container_of(cache, struct extent_record, cache);
rec->generation = btrfs_header_generation(buf); if (rec->generation < btrfs_header_generation(buf))
rec->generation = btrfs_header_generation(buf);
level = btrfs_header_level(buf); level = btrfs_header_level(buf);
if (btrfs_header_nritems(buf) > 0) { if (btrfs_header_nritems(buf) > 0) {