btrfs-progs: add chunk-recover raid0/5/6 data stripes rebuild routine
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 28 Nov 2013 05:32:51 +0000 (13:32 +0800)
committerChris Mason <clm@fb.com>
Fri, 31 Jan 2014 16:22:09 +0000 (08:22 -0800)
commit4989dc82d189494052fed6869b23fb14bd898628
tree69406153314f22cc8639fe099d7625d9fe07cd0e
parent7af8e4ee2ad1ffee55be45206515038a3c581c65
btrfs-progs: add chunk-recover raid0/5/6 data stripes rebuild routine

Decide the raid0/5/6 data stripes' order using checksums.
For one chunk, fetch each 64k logical stripe
1. search its checksum in the csum tree
2. read the physical stripe data on each device
3. calc the data checksums
4. if one checksum matches the value from the csum tree,
   then the logical stripe resides in that device,
   the stripe order index can be calculated.
5. if more than one checksums match,
   then use the successive csum in the tree to compare again.
6. if equal stripes are encountered, just fetch next stripe.
7. if some devices' order are still not decided, then they
   can not be recovered.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
chunk-recover.c