From patchwork Fri May 15 06:36:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 6411681 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 0E9DFC0432 for ; Fri, 15 May 2015 06:38:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 337A120390 for ; Fri, 15 May 2015 06:38:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 528342038F for ; Fri, 15 May 2015 06:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754171AbbEOGih (ORCPT ); Fri, 15 May 2015 02:38:37 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:48596 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753482AbbEOGig (ORCPT ); Fri, 15 May 2015 02:38:36 -0400 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="92200024" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 May 2015 14:34:39 +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 t4F6bD0j003933; Fri, 15 May 2015 14:37:13 +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; Fri, 15 May 2015 14:38:35 +0800 From: Qu Wenruo To: CC: Subject: [PATCH] btrfs-progs: Fix a bug which makes unfinished fsid change unrecoverable. Date: Fri, 15 May 2015 14:36:35 +0800 Message-ID: <1431671795-30516-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.4.0 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 bug is found by making break point after change_fsid_prepare() and then kill the unfinished change, then try to restore the unfinished fsid change. If fsid change is canceled, open_ctree will still fail even with IGNORE_FSID_MIMATCH open ctree flag, since it can't find device with mismatched fsid, making it unable to restoring. Now add ignore_fsid_mismatch judgment in btrfs_find_device() to fix the bug and allow later restore to work as expected. Signed-off-by: Qu Wenruo --- volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/volumes.c b/volumes.c index 14ce33e..f7462c5 100644 --- a/volumes.c +++ b/volumes.c @@ -1510,7 +1510,8 @@ struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid, cur_devices = root->fs_info->fs_devices; while (cur_devices) { if (!fsid || - !memcmp(cur_devices->fsid, fsid, BTRFS_UUID_SIZE)) { + (!memcmp(cur_devices->fsid, fsid, BTRFS_UUID_SIZE) || + root->fs_info->ignore_fsid_mismatch)) { device = __find_device(&cur_devices->devices, devid, uuid); if (device)