btrfs-progs: fix btrfs-image old_restore fsck failure

Steps to reproduce:
	# mkfs.btrfs -f <dev1>
	# btrfs-image <dev1> <image_file>
	# btrfs-image -r -o <image_file> <dev2>
	# btrfs check <dev2>

btrfs check output:
	: read block failed check_tree_block
	: Couldn't read tree root
	: Couldn't open file system

The btrfs-image should not mess with the chunk tree under the old_restore way.

The new restore way was introduced by:
	commit d6f7e3da0d
	Btrfs-progs: make btrfs-image restore with a valid chunk tree V2
	...
And the following commit enhanced the new restore on the valid chunk tree
building stuff:
	commit ef2a8889ef
	Btrfs-progs: make image restore with the original device offsets
	...

But the second commit should not effect the old_restore way since the
old_restore way doesn't try to build a valid chunk tree at all.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Gui Hecheng 2014-06-26 10:53:01 +08:00 committed by David Sterba
parent 99ac0d5732
commit 72ced9950a
1 changed files with 2 additions and 2 deletions

View File

@ -1686,7 +1686,7 @@ static void *restore_worker(void *data)
if (!mdres->fixup_offset) { if (!mdres->fixup_offset) {
while (size) { while (size) {
u64 chunk_size = size; u64 chunk_size = size;
if (!mdres->multi_devices) if (!mdres->multi_devices && !mdres->old_restore)
bytenr = logical_to_physical(mdres, bytenr = logical_to_physical(mdres,
async->start + offset, async->start + offset,
&chunk_size); &chunk_size);
@ -2300,7 +2300,7 @@ static int __restore_metadump(const char *input, FILE *out, int old_restore,
goto failed_cluster; goto failed_cluster;
} }
if (!multi_devices) { if (!multi_devices && !old_restore) {
ret = build_chunk_tree(&mdrestore, cluster); ret = build_chunk_tree(&mdrestore, cluster);
if (ret) if (ret)
goto out; goto out;