From 72ced9950a37f217a6f2377d7c557332185c413b Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Thu, 26 Jun 2014 10:53:01 +0800 Subject: [PATCH] btrfs-progs: fix btrfs-image old_restore fsck failure Steps to reproduce: # mkfs.btrfs -f # btrfs-image # btrfs-image -r -o # btrfs check 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 d6f7e3da0dae7b60cb7565f8a47c3b9045c52d1d 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 ef2a8889ef813ba77061f6a92f4954d047a78932 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 Signed-off-by: David Sterba --- btrfs-image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index 2bf634bf..c1af019d 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -1686,7 +1686,7 @@ static void *restore_worker(void *data) if (!mdres->fixup_offset) { while (size) { u64 chunk_size = size; - if (!mdres->multi_devices) + if (!mdres->multi_devices && !mdres->old_restore) bytenr = logical_to_physical(mdres, async->start + offset, &chunk_size); @@ -2300,7 +2300,7 @@ static int __restore_metadump(const char *input, FILE *out, int old_restore, goto failed_cluster; } - if (!multi_devices) { + if (!multi_devices && !old_restore) { ret = build_chunk_tree(&mdrestore, cluster); if (ret) goto out;