btrfs-progs/check
Qu Wenruo 1a8f283c97 btrfs-progs: check: orig: reject bad metadata backref with invalid level
[BUG]
There is a bug report that kernel tree-checker rejected an invalid
metadata item:

 corrupt leaf: block=934474399744 slot=68 extent bytenr=425173254144 len=16384 invalid tree level, have 33554432 expect [0, 7]

But original mode btrfs-check reports nothing wrong.
(lowmem mode will just crash, and fixed in previous patch).

[CAUSE]
For original mode it doesn't really check tree level, thus didn't find
the problem.

[FIX]
I don't have a good idea to completely make original mode to verify the
level in backref and in the tree block (while lowmem does that).

But at least we can detect obviously corrupted level just like kernel.

Now original mode will detect such problem:

 ...
 [2/7] checking extents
 ERROR: tree block 30457856 has bad backref level, has 256 expect [0, 7]
 ref mismatch on [30457856 16384] extent item 0, found 1
 tree backref 30457856 root 5 not found in extent tree
 backpointer mismatch on [30457856 16384]
 ERROR: errors found in extent allocation tree or chunk allocation
 [3/7] checking free space tree
 ...

Reported-by: Stickstoff <stickstoff@posteo.de>
Link: https://lore.kernel.org/linux-btrfs/6ed4cd5a-7430-f326-4056-25ae7eb44416@posteo.de/
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-02-01 18:42:01 +01:00
..
btrfsck.h btrfs-progs: libbtrfs: remove unneeded BTRFS_FLAT_INCLUDES protections 2021-10-08 20:47:03 +02:00
common.h btrfs-progs: check: detect and fix invalid used for block groups 2021-08-25 15:38:54 +02:00
main.c btrfs-progs: check: orig: reject bad metadata backref with invalid level 2022-02-01 18:42:01 +01:00
mode-common.c btrfs-progs: check: handle csum generation properly for --init-csum-tree --init-extent-tree 2022-02-01 18:41:16 +01:00
mode-common.h btrfs-progs: check: move csum tree population into mode-common.[ch] 2022-02-01 18:41:13 +01:00
mode-lowmem.c btrfs-progs: check: lowmem: fix crash when METADATA_ITEM has invalid level 2022-02-01 18:41:58 +01:00
mode-lowmem.h btrfs-progs: check btrfs_super_used in lowmem check 2021-08-25 15:38:54 +02:00
mode-original.h btrfs-progs: use btrfs_key for btrfs_check_node() and btrfs_check_leaf() 2021-09-07 13:58:44 +02:00
qgroup-verify.c btrfs-progs: stop accessing ->extent_root directly 2021-11-30 18:56:54 +01:00
qgroup-verify.h btrfs-progs: move ctree.c to kernel-shared/ 2020-08-31 17:01:05 +02:00