From patchwork Thu Jun 26 02:53:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 4425511 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BAAF19F2C8 for ; Thu, 26 Jun 2014 02:58:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC88C20381 for ; Thu, 26 Jun 2014 02:58:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABDE320379 for ; Thu, 26 Jun 2014 02:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756779AbaFZC6b (ORCPT ); Wed, 25 Jun 2014 22:58:31 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:6366 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753169AbaFZC6a (ORCPT ); Wed, 25 Jun 2014 22:58:30 -0400 X-IronPort-AV: E=Sophos;i="5.00,779,1396972800"; d="scan'208";a="32451594" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jun 2014 10:55:47 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5Q2wQoc027087 for ; Thu, 26 Jun 2014 10:58:27 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 26 Jun 2014 10:58:36 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH 1/6] btrfs-progs: fix btrfs-image old_restore fsck failure Date: Thu, 26 Jun 2014 10:53:01 +0800 Message-ID: <1403751186-31559-1-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. --- btrfs-image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index 02ae5d6..c90bca8 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -1668,7 +1668,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); @@ -2282,7 +2282,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;