btrfs-progs: rebuild missing block group during chunk recovery if possible
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 30 Oct 2014 02:54:03 +0000 (10:54 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 4 Dec 2014 15:48:13 +0000 (16:48 +0100)
commit0ffacad2906cdb8f62fb56565632160a1a82ad14
tree7534854b9e8a2b820b1591c26e41410cb8b1e28e
parente7c4e700ffa656af4b221a2068b02b391b0ed817
btrfs-progs: rebuild missing block group during chunk recovery if possible

Before the patch, chunk will be considered bad if the corresponding
block group is missing, even the only uncertain data is the 'used'
member of the block group.

This patch will try to recalculate the 'used' value of the block group
and rebuild it.
So even only chunk item and dev extent item is found, the chunk can be
recovered.
Although if extent tree is damanged and needed extent item can't be
read, the block group's 'used' value will be the block group length, to
prevent any later write/block reserve damaging the block group.
In that case, we will prompt user and recommend them to use
'--init-extent-tree' to rebuild extent tree if possible.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfsck.h
chunk-recover.c
cmds-check.c