btrfs-progs: check: change the way lowmem mode traverses metadata
authorSu Yue <suy.fnst@cn.fujitsu.com>
Fri, 1 Sep 2017 06:12:37 +0000 (14:12 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 Oct 2017 18:33:00 +0000 (20:33 +0200)
commit723427d7e6b7d0f7640524291983bc06a89bcd4e
treec67a7332f8c51cbcaba577dc5417a24d16ed50f2
parenteca65a8977aba6f02dad820a88aacbb9120421ca
btrfs-progs: check: change the way lowmem mode traverses metadata

This patch is a preparation for extent-tree repair in lowmem mode.
In the lowmem mode, checking tree blocks of various trees is recursive.
But during repair, adding or deleting item(s) may modify upper nodes
which will cause the repair to be complicated and dangerous.

Before this patch:
One problem of lowmem check is that it only checks the lowest node's
backref in check_tree_block_ref.
This way ensures checked tree blocks are valid and avoids to traverse
all trees for performance reasons.
However, there is one shortcoming that it can not detect backref mistake
if one extent whose owner == offset but lacks the other backref(s).

In check, correctness is more important than speed.
If errors can not be detected, repair is impossible.

Changes in the patch:
check_chunks_and_extents now has to check *ALL* trees so lowmem check
will behave like original mode.
Changing the way of traversal to be same as fs tree which calls
walk_down_tree_v2() and walk_up_tree_v2() is easy for further
repair.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ heavy coding style fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-check.c