Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp352977imi; Thu, 21 Jul 2022 02:09:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uryqQPllVuPwHmOxaDDBV7J4zuF7Pci8D0pDsKC2YqEPycKk7s8O0k31HWkpyfK4HEnXrC X-Received: by 2002:a17:906:6c82:b0:709:f868:97f6 with SMTP id s2-20020a1709066c8200b00709f86897f6mr38731511ejr.555.1658394553768; Thu, 21 Jul 2022 02:09:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658394553; cv=pass; d=google.com; s=arc-20160816; b=HTk3si6sjTjFTnoArbMqG282YIzfghCt5Ej6a5JgYZdqDGA8yEYvZ8KTJk2JexjWW1 lq4U+80Pu7SX1KJLDjhyyzLNBMARYmihlMLVMphigldveJSGi5jgeXgKnlLckTZ0NnSa Km8pZj3Qm7vMAJ/NMj5GH4qke6jPQB6nVyI9azxMIkZKnr8eoBuDLNEzdxPT15SKdW+w /afF/Eld47RTGgkafleR+VorJoNvPp6s7ezSPer1lEoicbEp90E6l2+JDYd4IHM+Nzbg b77WZdvqC+9GpVuRb+CGVqTHf2xy9yuKl3swFzjvLVosOWbBqvI9vqCTeDRThPjuFVwc RxKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :domainkey-signature; bh=CE1Xk4p5RR17p5R3WbIoxrG3xk/BTEPCABwgd4UK3no=; b=zBsgnu9ShzZmZiH/vcUo+r2UT3A1VNR2SYubcoH4XRxKUxiLiPKiey5PK8r5Y0EjD6 LCGSVih1Gg5aauFzNy36kRckPIAu/D3CE5pUychRLsNmCpZ5+PFtBt8q+rGN+oNcSP0a NWBpK0A5IAW71RHpZYV629AGZiC/OusOTg77CchK7AHG2G5LHfNZb5wIvpVovyj/Pn+o LbaB2V/vekjUXhzG0zYpLk47K9YuoL93dfarFV9lneZ7CBa2Pwu7kNn5VJObnKxH61/t g8qBT4q8edRTvK70aPP0h2r56UrKaNtVVqZ0YGYIp9NkxEkgTlN/i5ScexwmYCfiksQb GfPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=dOtXi33j; arc=pass (i=1 spf=pass spfdomain=zoho.com dkim=pass dkdomain=zoho.com dmarc=pass fromdomain=zoho.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gg12-20020a170906e28c00b00722eb684a60si1518573ejb.979.2022.07.21.02.08.48; Thu, 21 Jul 2022 02:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=dOtXi33j; arc=pass (i=1 spf=pass spfdomain=zoho.com dkim=pass dkdomain=zoho.com dmarc=pass fromdomain=zoho.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232372AbiGUIhF (ORCPT + 99 others); Thu, 21 Jul 2022 04:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232361AbiGUIhA (ORCPT ); Thu, 21 Jul 2022 04:37:00 -0400 Received: from sender4-pp-o93.zoho.com (sender4-pp-o93.zoho.com [136.143.188.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4902628729; Thu, 21 Jul 2022 01:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658392612; cv=none; d=zohomail.com; s=zohoarc; b=RZuvCtiU4fKZaz+xbff2VIqiPdkTLtN41r0+W1V6BWSCLkwfC1qk3Usks/cEEVsCnVK575F1BlJ8WPrVDkTq9V5WanBsEwrd0FI2pQInHfg7rqvw2wyG//gDCOpDmPfyS2F2P6rawD8rVHnk4ZmQYYGyMIvBdIEs4BO5rr6sHug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658392612; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=CE1Xk4p5RR17p5R3WbIoxrG3xk/BTEPCABwgd4UK3no=; b=SyVBugycFOPlhHgOb3X8UpvAYyE2bj2H63RV+qBJNms194PEQZy5QjR28oNZAYh3HRLiI01MmtNGvyJOJIC4PcmGdlR3I9GQhR0fXYmXWmZPjEoGCUXSBku24gVWkycIiW2ZWn+Q4C6D27t/nbqmQhOtpF3mSH/Wac7vUTGii7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=hmsjwzb@zoho.com; dmarc=pass header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:mime-version; b=euHo0Fc7Jdb32iFSTPOuhv/F3vJlDCbjE2r6dDD4CJOEgQO/VqkocQTs0FZt1uuhf9SJB+zxu/MU TPa+K+zsAbF/b/zbxRmkzNDkkBlRc5utFZa9wubsQjwfTrjtb6Iz DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1658392612; s=zm2022; d=zoho.com; i=hmsjwzb@zoho.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=CE1Xk4p5RR17p5R3WbIoxrG3xk/BTEPCABwgd4UK3no=; b=dOtXi33j/Fen5kR5h8r8QMuE5Ojya4cxcYL294zk5+asVzMwRQCxEHB2tQJPcWT5 FqZlj/ghXKfdxaEehZBfowa8KtZHCBfZcbh5k2UYIjmzL47pLUSCvtKiBdPsPs2rdK/ YepmBB1q5ar1VJ5npKuJGJjgQE7SGwXR7mF/OIA4= Received: from localhost.localdomain (58.247.201.70 [58.247.201.70]) by mx.zohomail.com with SMTPS id 1658392610284663.8069833515924; Thu, 21 Jul 2022 01:36:50 -0700 (PDT) From: "Flint.Wang" To: anand.jain@oracle.com Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH]btrfs: Fix fstest case btrfs/219 Date: Thu, 21 Jul 2022 16:36:08 +0800 Message-Id: <20220721083609.5695-1-hmsjwzb@zoho.com> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, fstest btrfs/291 failed. [How to reproduce] mkdir -p /mnt/test/219.mnt xfs_io -f -c "truncate 256m" /mnt/test/219.img1 mkfs.btrfs /mnt/test/219.img1 cp /mnt/test/219.img1 /mnt/test/219.img2 mount -o loop /mnt/test/219.img1 /mnt/test/219.mnt umount /mnt/test/219.mnt losetup -f --show /mnt/test/219.img1 dev mount /dev/loop0 /mnt/test/219.mnt umount /mnt/test/219.mnt mount -o loop /mnt/test/219.img2 /mnt/test/219.mnt [Root cause] if (fs_devices->opened && found_transid < device->generation) { /* * That is if the FS is _not_ mounted and if you * are here, that means there is more than one * disk with same uuid and devid.We keep the one * with larger generation number or the last-in if * generation are equal. */ mutex_unlock(&fs_devices->device_list_mutex); return ERR_PTR(-EEXIST); } [Personal opinion] User might back up a block device to another. I think it is improper to forbid user from mounting it. Signed-off-by: Flint.Wang --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6aa6bc769569a..76af32032ac85 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -900,7 +900,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, * tracking a problem where systems fail mount by subvolume id * when we reject replacement on a mounted FS. */ - if (!fs_devices->opened && found_transid < device->generation) { + if (fs_devices->opened && found_transid < device->generation) { /* * That is if the FS is _not_ mounted and if you * are here, that means there is more than one -- 2.37.0