Btrfs-progs: make image restore with the original device offsets
authorJosef Bacik <jbacik@fusionio.com>
Wed, 8 May 2013 15:40:36 +0000 (11:40 -0400)
committerChris Mason <chris.mason@fusionio.com>
Wed, 19 Jun 2013 17:52:25 +0000 (13:52 -0400)
commitef2a8889ef813ba77061f6a92f4954d047a78932
tree4ca42385e930e550ceae1523633f74f19686a1e6
parent10f1af0fe7de5a0310657993c7c21a1d78087e56
Btrfs-progs: make image restore with the original device offsets

I noticed a slight problem with btrfs-image, since it was building a chunk tree
by setting the physical offset of the stripes to the same as the logical offset
it created this problem where the super block was now mapped into the file
system differently than it was before.  This isn't a huge deal except that we
also carry along the free space cache with us, which is setup with the idea that
super at physical X is at logical Y.  So this would make the free space checker
in fsck freak out because it would see that the cache says that the super block
is free space, and that the area where it thought the super block was located is
in fact used.  In the mount case we'd end up overwriting real metadata with
backup super blocks.  So we need to maintain the physical offsets in our
stripes.  This is a huge pain because we store the logical bytenrs of all of our
metadata.  This patch scans the entire image looking for chunk tree blocks and
builds an in memory chunk tree so we can write logical blocks to their physical
offsets.  With this patch we no longer have the problems I described above.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-image.c