From patchwork Tue May 5 06:16:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 6335601 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C51A1BEEE5 for ; Tue, 5 May 2015 06:19:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1A75202EB for ; Tue, 5 May 2015 06:18:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA5DA202E9 for ; Tue, 5 May 2015 06:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756070AbbEEGSw (ORCPT ); Tue, 5 May 2015 02:18:52 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:57443 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752624AbbEEGSv (ORCPT ); Tue, 5 May 2015 02:18:51 -0400 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="91655055" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 05 May 2015 14:14:55 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t456HVSd008341 for ; Tue, 5 May 2015 14:17:31 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 5 May 2015 14:18:52 +0800 From: Qu Wenruo To: Subject: [PATCH 1/8] btrfs-progs: Allow open_ctree to ignore fsid mismatch. Date: Tue, 5 May 2015 14:16:39 +0800 Message-ID: <1430806606-3226-2-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.3.7 In-Reply-To: <1430806606-3226-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1430806606-3226-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] 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 This feature is used for later UUID change function. Signed-off-by: Qu Wenruo --- ctree.h | 1 + disk-io.c | 5 ++++- disk-io.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ctree.h b/ctree.h index 10dc838..45fef3d 100644 --- a/ctree.h +++ b/ctree.h @@ -1010,6 +1010,7 @@ struct btrfs_fs_info { unsigned int is_chunk_recover:1; unsigned int quota_enabled:1; unsigned int suppress_check_block_errors:1; + unsigned int ignore_fsid:1; int (*free_extent_hook)(struct btrfs_trans_handle *trans, struct btrfs_root *root, diff --git a/disk-io.c b/disk-io.c index c1cf146..8a91345 100644 --- a/disk-io.c +++ b/disk-io.c @@ -49,7 +49,8 @@ static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf) fs_devices = root->fs_info->fs_devices; while (fs_devices) { - if (!memcmp_extent_buffer(buf, fs_devices->fsid, + if (root->fs_info->ignore_fsid || + !memcmp_extent_buffer(buf, fs_devices->fsid, btrfs_header_fsid(), BTRFS_FSID_SIZE)) { ret = 0; @@ -1149,6 +1150,8 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path, fs_info->on_restoring = 1; if (flags & OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS) fs_info->suppress_check_block_errors = 1; + if (flags & OPEN_CTREE_IGNORE_FSID) + fs_info->ignore_fsid = 1; ret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr, (flags & OPEN_CTREE_RECOVER_SUPER), diff --git a/disk-io.h b/disk-io.h index 4caebeb..83cbe47 100644 --- a/disk-io.h +++ b/disk-io.h @@ -49,6 +49,9 @@ enum btrfs_open_ctree_flags { * tree bits. * Like split PARTIAL into SKIP_CSUM/SKIP_EXTENT */ + + /* Currently, no codes check chunk_tree_uuid, so only ignore fsid */ + OPEN_CTREE_IGNORE_FSID = (1 << 10) }; static inline u64 btrfs_sb_offset(int mirror)