[PATCH 0/3] btrfs-progs: error messages enhancement for bad tree blocks

Qu Wenruo
2021-09-02T13:08:49Z

When handling a corrupted btrfs image, there are tons of meaningless
error messages from btrfs-check:

incorrect offsets 8492 3707786077

Above error message is meaningless, it doesn't contain which tree block
is causing the problem, just some random expected values with corrupted
values.

On the other hand, btrfs kernel tree-checker has way better error
messages, and even more checks than the counterpart in btrfs-progs.

So let's just backport the superior tree-checker code to btrfs-progs,
with some btrfs-progs specific (but minor) modifications.

Now the error message would look more sane (although a little too long):

corrupt leaf: root=2 block=72164753408 slot=109, unexpected item end, have 3707786077 expect 8492

Qu Wenruo (3):
btrfs-progs: use btrfs_key for btrfs_check_node() and
btrfs_check_leaf()
btrfs-progs: backport btrfs_check_leaf() from kernel
btrfs-progs: backport btrfs_check_node() from kernel

check/main.c | 9 +-
check/mode-original.h | 2 +-
kernel-shared/ctree.c | 246 ++++++++++++++++++++++++++----------------
kernel-shared/ctree.h | 5 +-
4 files changed, 163 insertions(+), 99 deletions(-)

--
2.33.0