From patchwork Wed Sep 20 21:51:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13393474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88820C2FC09 for ; Wed, 20 Sep 2023 21:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjITVvs (ORCPT ); Wed, 20 Sep 2023 17:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjITVvr (ORCPT ); Wed, 20 Sep 2023 17:51:47 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2502CCF for ; Wed, 20 Sep 2023 14:51:41 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38KKJ0GE003965 for ; Wed, 20 Sep 2023 21:51:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=AYDhyp8rjkxVudQMDX4LVXo/NS8mTpQGggejKwONcmw=; b=z6e68ncQUrVVM0ZlhjZNzZMKYs3l8MHdsvDwxHaCBIrDY1H5FTbjGiAdXm7uADFwowMo LOh+N6//RJWbtONZKwsU6N5lKJujpkU1X8ku5m4GrSUC9dI0dZSIAAYPLKBrGqL+2SgM qEs4d2wsT371HKqDmI7WYpB2FG3il6xfhUOEWGb75/5hPvKfiC1KMwH91VsaAQ+tHkK9 tWyPDJ3NP8Xl4PkiqoCKPzPQMQW09hxiw740TC/CnpucloQ7sEjovqh4SxYTKZeOdSfO fwbz8BogwUNZJaobgUolMTedYQ1itVayOFpyrxR7UREkFZKhw3sHZ2VuoqFYk27WOkX5 Jg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t53530g6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 21:51:40 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38KLo2aT030751 for ; Wed, 20 Sep 2023 21:51:39 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t7pb78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 21:51:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VcmyNsakKEQq0iCwaVEQ3pNP/IDWbzsSK3d9sf4L9tqaa8xrvakT/6dTyBtcXWnl321kEFSXgssbwYQJhxAQJUm+EntexxY2rr8nX+hDcyOkjhdC0qDTTLvFnH6IWQX59fyV3UpAvFXWvpFcjWFiO1Tz+im0Qe94Fv6d16+PC6YUDfJeHcrXyM11/P9D89fd8rH4pjp93AVVOOUJcOVSXDZtiCL1JvIj/0SG/JIEiubM5IxlLW3S+Gq7+QGm82U6jbBKJ4ws8WQPhR6nJMbpmt69RHlnlJhlgNRBsxCOgZEGdcmNlpbNQKJzcr06V+iAby4Y3y9gYxr1Is/1lAZzPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AYDhyp8rjkxVudQMDX4LVXo/NS8mTpQGggejKwONcmw=; b=KuqcLKz/Hoi+ncLZb7raLAYWA5g+JJE9U01b5nRzcvvuovbwUZe29WUSHgxlezzE/3ycZJSox6+ah9pNMyLnYXgdu+GM9K5dCkVACFYEjDBrhEdT8uoQcJTBJwOv7jTbtvZtOPSQMnVOz9Tz3kFcg8zY+J6HQixr2UaHRan1jWpTCYUSQzyXdjOmkHXRP9uQJTdjevY/k2VzPT5so4NUpWN6X8PrPZ942Ns9FTwu16cTc8IWPHCSuZrpYjiV7hZmN5Skh6vLf67pl6k6jC8epMoV693jnaeFEkkM19Uh1ElSx1AXfo9DXodEdA4QzhgN4PjRR0jNx+YLBvzec+mFJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AYDhyp8rjkxVudQMDX4LVXo/NS8mTpQGggejKwONcmw=; b=J58gLmSMD4uq/Iem5J4leg8OPaj92QaGFDhBaZb1WIW5fxDzbqaylbI8v9J6qbbkSICSEMqYuS+j4y/MauFo78+pE2EXJyz0HS9Rzk03dHxGoaAdbX5yFYUGNqr/CFyVAdZc1vduvX0fiFYfE3YYpMVcHmjSAiMdSQeuW6Ry5cY= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM3PR10MB7927.namprd10.prod.outlook.com (2603:10b6:0:42::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Wed, 20 Sep 2023 21:51:34 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6792.024; Wed, 20 Sep 2023 21:51:34 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 1/2] btrfs: reject device with CHANGING_FSID_V2 Date: Thu, 21 Sep 2023 05:51:13 +0800 Message-Id: <83e6a50ea2040a27e0dc05a09a9213b79e8938c8.1695244296.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR06CA0249.apcprd06.prod.outlook.com (2603:1096:4:ac::33) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DM3PR10MB7927:EE_ X-MS-Office365-Filtering-Correlation-Id: 56a0caf0-8d1e-4446-3db7-08dbba23c18d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /DCKiJhQt6mRvB1FarR3QvcPfau1cMObzte9UVNIbEJEpHjPZ9nU8IC5G9AvBlomFJxNA8N8GeFc4KE/cnm9AeeHZV407jXZQVDc2sH+BVpAyd4kd05yIsyHkGjjA5jSYjXQB90YPUdbShFdf36c6Yl3Aq9Mu/4ndBUK4TOBodNyJQqdvXOA8k0evUtMhB8LaPGs84dLGrSzVtE9nmehloivxknndM1FYzb8/wFYrfl3YX4exIZq5fiiU/Axan4z54U6OA9yVWe89WybN+E0AHBiwrHYROyzsr3w7boelKrnfZFGujsbKOq3LW4euoWIoDvzyq45F31h4Ie2h3FeY0424Gd3BMeIApGmwbVOYBN9jolL8Syd7sasQz+IrVMvzvvtuAi+uvaJwxbF9ujAPTVOtPHhzeKYe3EEWd3d85ApU9cHvc+FdzubjQCiYaX8UfcNtCumhzLACtpreE+0WMybV5GAj0X29NahCl9hbHHjM5PeV7ibf1JCR4biXiGC/1eQdr2ygRYEmSN+cK7+8V4geVeVdSs35GQ01uodobPb4DXSMk+idg76XaLbFrXD X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(39860400002)(136003)(346002)(366004)(186009)(1800799009)(451199024)(86362001)(478600001)(6486002)(6666004)(6506007)(36756003)(38100700002)(2906002)(26005)(8676002)(44832011)(83380400001)(8936002)(5660300002)(2616005)(41300700001)(66556008)(4326008)(316002)(107886003)(66946007)(6916009)(6512007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CpUDNYS2Pcq622vTUBzXzWC2VF7Mm7U3pmN3YNo6pZIJZAh7qr5Me5aq67Ax+ykEiGcQUlhbVxcCmU4DpEJtNji0uFnoR0qluk7A8I8RGEMOlP5cInwic4kiS0P3Di/1EzA5OiUsspq6dYZHUueQFrlrmOkFOWVtEAdyzeKZAvf6iSh7H1d/0UZAJiFgVHFwUNd+KaQNYLdSrYASF5a0fDPz0lqRKrXx8utEADdlllABjakB6b7MdCvac9KxorUoLCiStRf6OoLwQx9/m9ydgeJLcW1irWWIDE5WuZvmc/WFutv2qamWBSbKFLbselnhfpC23RNYxsIdf6sXTvB3BOKwsqQMhH5n15YqtXgF/OLSGiFM3yMs34j2s4I/bts9w09fmeJxTIBKrtxUD4JwqztRh44ZXhXEiAlN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Mt58KfsuoHEdUbWK7p0GVbBFLibdxBbcLYOgXgmfh5UFgyWoHYeyojJkQ6nrIDJcRHclk+qarhm30PgSbGaquNLIyN8UT6 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zJJKRwLpre0LWrREjHHKoxPRF0KqUmuZ5jC/A/rwlHQcbIowaAXTG1CMEcCepV0HGaqMArlYVOKR7yKNK/Avsi2Achx9e3AgZI7vzdsNY3DQ4IZyblgWo0+ePMZje4Ul1VVTkh3Lr1AyoKTC3LwkKcRvInLDKx0UOPkuJ0kVP/KAcj2ii6BNCsKZGG57chpextZEMG2/X5gipOBcP+4N1YZjI70BUXThaHM0phsO4p2scX+POfQx7tF003vwlrWnYNdFkVE144tpfTsGpaUFH4Lz3uiTxB08gEqAkEDZvZyMgJh61OV4svYX9WxsoHINlpkgGcrfOP176StA0FMGg2cHvg/JWaoh9c8YrNm64SwcjtQnOqXpax0aWFeUPPHjqlOeFN14SJtLhsgZwM7bjCojA2sO3euYim82nLyCqYEvPmMKl7PGkf63IUebNjyM/7OfnrWGrQhBZw8J199/6XeWQEWK08lB8rYMRABpEzMiuDf7rU+pZuOcH1SpT1HF3hbOf34di/hlcTTAcf/qORMuM5nQ9Frhw4g8+4MoYOPnpbIcyaHVpcIS8PRJTX7Yr8XnoADnSM5XmE4DVtihGtiNE4rOPEshBHwKOsq6RFNg9rFhO2b/FZKyyU08dLtMLOY8HWEZ0uOl/OFDEGly3HBCkgVyE3ave6APiCeiJhv+LmP8vOBf4DY1J1ntVHI2Fa2szdT2qJXsq6bHPoKxUe+WNv/mKqBrvnu0n/vusINJBn3p1w3XAcA7o5+t5sGaZIx9SDG3O7mQqmRdK/nl+w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56a0caf0-8d1e-4446-3db7-08dbba23c18d X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 21:51:33.9821 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: otmEZamA6gMX+Es1XJ5DYsVSo3UvHZZjG3K7CImKO12z/8oZ6Ddn8s+xw8PZxCrfXfqLM3nQCTNhDRURuXfX9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR10MB7927 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_11,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200183 X-Proofpoint-ORIG-GUID: O63o-B7TXArYV9rb4S21MR1Sp7aj_tRD X-Proofpoint-GUID: O63o-B7TXArYV9rb4S21MR1Sp7aj_tRD Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The BTRFS_SUPER_FLAG_CHANGING_FSID_V2 flag indicates a transient state where the device in the userspace btrfstune -m|-M operation failed to complete changing the fsid. This flag makes the kernel to automatically determine the other partner devices to which a given device can be associated, based on the fsid, metadata_uuid and generation values. btrfstune -m|M feature is especially useful in virtual cloud setups, where compute instances (disk images) are quickly copied, fsid changed, and launched. Given numerous disk images with the same metadata_uuid but different fsid, there's no clear way a device can be correctly assembled with the proper partners when the CHANGING_FSID_V2 flag is set. So, the disk could be assembled incorrectly, as in the example below: Before this patch: Consider the following two filesystems: /dev/loop[2-3] are raw copies of /dev/loop[0-1] and the btrsftune -m operation fails. In this scenario, as the /dev/loop0's fsid change is interrupted, and the CHANGING_FSID_V2 flag is set as shown below. $ p="device|devid|^metadata_uuid|^fsid|^incom|^generation|^flags" $ btrfs inspect dump-super /dev/loop0 | egrep '$p' superblock: bytenr=65536, device=/dev/loop0 flags 0x1000000001 fsid 7d4b4b93-2b27-4432-b4e4-4be1fbccbd45 metadata_uuid bb040a9f-233a-4de2-ad84-49aa5a28059b generation 9 num_devices 2 incompat_flags 0x741 dev_item.devid 1 $ btrfs inspect dump-super /dev/loop1 | egrep '$p' superblock: bytenr=65536, device=/dev/loop1 flags 0x1 fsid 11d2af4d-1b71-45a9-83f6-f2100766939d metadata_uuid bb040a9f-233a-4de2-ad84-49aa5a28059b generation 10 num_devices 2 incompat_flags 0x741 dev_item.devid 2 $ btrfs inspect dump-super /dev/loop2 | egrep '$p' superblock: bytenr=65536, device=/dev/loop2 flags 0x1 fsid 7d4b4b93-2b27-4432-b4e4-4be1fbccbd45 metadata_uuid bb040a9f-233a-4de2-ad84-49aa5a28059b generation 8 num_devices 2 incompat_flags 0x741 dev_item.devid 1 $ btrfs inspect dump-super /dev/loop3 | egrep '$p' superblock: bytenr=65536, device=/dev/loop3 flags 0x1 fsid 7d4b4b93-2b27-4432-b4e4-4be1fbccbd45 metadata_uuid bb040a9f-233a-4de2-ad84-49aa5a28059b generation 8 num_devices 2 incompat_flags 0x741 dev_item.devid 2 It is normal that some devices aren't instantly discovered during system boot or iSCSI discovery. The controlled scan below demonstrates this. $ btrfs device scan --forget $ btrfs device scan /dev/loop0 Scanning for btrfs filesystems on '/dev/loop0' $ mount /dev/loop3 /btrfs $ btrfs filesystem show -m Label: none uuid: 7d4b4b93-2b27-4432-b4e4-4be1fbccbd45 Total devices 2 FS bytes used 144.00KiB devid 1 size 300.00MiB used 48.00MiB path /dev/loop0 devid 2 size 300.00MiB used 40.00MiB path /dev/loop3 /dev/loop0 and /dev/loop3 are incorrectly partnered. This kernel patch removes functions and code connected to the CHANGING_FSID_V2 flag. With this patch, now devices with the CHANGING_FSID_V2 flag are rejected. And its partner will fail to mount with the extra -o degraded option. Signed-off-by: Anand Jain --- Moreover, a btrfs-progs patch (below) has eliminated the use of the CHANGING_FSID_V2 flag entirely: [PATCH] btrfs-progs: btrfstune -m|M remove 2-stage commit And we solve the compatability concerns as below: New-kernel new-progs - has no CHANGING_FSID_V2 flag. Old-kernel new-progs - has no CHANGING_FSID_V2 flag, kernel code unused. Old-kernel old-progs - bug may occur. New-kernel old-progs - Should use host with the newer btrfs-progs to fix. For legacy systems to help fix such a condition in the userspace instead we have the below patchset which ports of kernel's CHANGING_FSID_V2 code. [PATCH 0/4 v4] btrfs-progs: recover from failed metadata_uuid port kernel And if it couldn't fix in some cases, users can use manually reunite, with the patchset: [PATCH 00/10] btrfs-progs: check and tune: add device and noscan options fs/btrfs/disk-io.c | 10 ---------- fs/btrfs/volumes.c | 7 +++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index dc577b3c53f6..95746ddf7dc3 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3173,7 +3173,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device u32 nodesize; u32 stripesize; u64 generation; - u64 features; u16 csum_type; struct btrfs_super_block *disk_super; struct btrfs_fs_info *fs_info = btrfs_sb(sb); @@ -3255,15 +3254,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device disk_super = fs_info->super_copy; - - features = btrfs_super_flags(disk_super); - if (features & BTRFS_SUPER_FLAG_CHANGING_FSID_V2) { - features &= ~BTRFS_SUPER_FLAG_CHANGING_FSID_V2; - btrfs_set_super_flags(disk_super, features); - btrfs_info(fs_info, - "found metadata UUID change in progress flag, clearing"); - } - memcpy(fs_info->super_for_commit, fs_info->super_copy, sizeof(*fs_info->super_for_commit)); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index bc8d46cbc7c5..c845c60ec207 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -791,6 +791,13 @@ static noinline struct btrfs_device *device_list_add(const char *path, bool fsid_change_in_progress = (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_CHANGING_FSID_V2); + if (fsid_change_in_progress) { + btrfs_err(NULL, +"device %s has incomplete FSID changes please use btrfstune to complete", + path); + return ERR_PTR(-EINVAL); + } + error = lookup_bdev(path, &path_devt); if (error) { btrfs_err(NULL, "failed to lookup block device for path %s: %d", From patchwork Wed Sep 20 21:51:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13393475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17BD4C2FC09 for ; Wed, 20 Sep 2023 21:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229567AbjITVv4 (ORCPT ); Wed, 20 Sep 2023 17:51:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjITVvz (ORCPT ); Wed, 20 Sep 2023 17:51:55 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39AD1C9 for ; Wed, 20 Sep 2023 14:51:49 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38KKJdsr007884 for ; Wed, 20 Sep 2023 21:51:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=5F78KBT/PF0US2pGxo53oobZAueRkf8IvRdTGJeq3vI=; b=b83WnMZZ9Hk7BapttUX0vcYNEWJOhsdrfi7FQBGnmmUp8zVOszdLUlSAMJ9xhw4evYYY 9RidOp3mBMA+6OnO+ZHhgJIOS+TLi7xOkO2ZtgVBOGFo187Ox9R7QE80Z9oLJ0Bi5Qny HKQN7sxlm2Dj56oEWqHtmyw4fTSFfsZJSF/5oYYgfpjXjsE9uFZyi3rnYj93zUFU0Jc1 3Joj2tp5Wj9r4er3zWcMTJq0Jmwc84Fzx49zmswTrUK+5s0yaXAO/zTnw8iKuHt7sytc ecQYHVoGcOZ9cUdav2Gk72W4hxiJGqneMoGFSpvOlx3LuHjjI786a/glAI6+0Rp/IK6M ZQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t539crjc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 21:51:48 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38KLa84b015876 for ; Wed, 20 Sep 2023 21:51:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t52t7ek3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 20 Sep 2023 21:51:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hil/pEa/ZYOv8C0nUtHIU9ngrbK610STflMGlAcNxnVrDO5+cC6cllHUYWU8vXYoL39yeiD4+BjK6mljgO6RWb0/SPJAKCui3YTs1FJNERfKzoOUzpRfX9sGBYU0RdNAA6Vd5YlL3Mq1qcjwy9TtuGEwGtAmxVtPUVBZURofalQPVYkNikvQr/EbkMQ75dbCRhbMR8vzd07ZCbRiUYOz3zSkiw83uQqPSrZ7linA9lQ0P7APjQzI68W1iDTcXVqP2Ka5CHFlV8lGr/eRX0U4DM6lBxaq87qeW8fu7K0JJtxQr4O9vXlkdmdVd/6DmqurjpayymcZ5kq5sZ2efjY+Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5F78KBT/PF0US2pGxo53oobZAueRkf8IvRdTGJeq3vI=; b=FymuYWXg8az4rH5dMitsCzdPUjsAtHtYvv//CCjgrIlrWMQN039jmGai9FWwjYfQw//xj/9zuci+y3Tv1YHueJcYm3kewh12I/IMp8GHdW4MNx/jnmGHk2zdC6IVXMWWN3sIeuXDP0T5XeanCNEJuygtMm91iMNhHCzqNfV1KMAHm+B8HWGWaGHImID5Lj6oDh5Abqt5BzXTjCDjOTCT43/iWxcyw1RJnsevixXXEVSjUkpia6OCYP5rJ6K+xdvsUTdJS86Np1bSX/1K82YwSooaoHfYzYSGna9YB4n4Md09j5pHYHu2ZlMR7xRXHMa07W3yunNVLEuiqjxa/BZeQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5F78KBT/PF0US2pGxo53oobZAueRkf8IvRdTGJeq3vI=; b=vbWYZfIMhE6OrllVnXel/c6XkD8swncSts4A0LYHtYkDIYKTYWF37Gi68hfewl7qY1IYB9gO93ka7B1sWxs2Bxzo1PviMhqwKchDrJxIMsCY5qZT6AaVMy3kK5PhzaVjnZtVIIjJ9p441D70odphyH9LQCmdiDQdttzm6hdxysY= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM3PR10MB7927.namprd10.prod.outlook.com (2603:10b6:0:42::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Wed, 20 Sep 2023 21:51:42 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::2bbc:60da:ba6c:f685%2]) with mapi id 15.20.6792.024; Wed, 20 Sep 2023 21:51:42 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: Anand Jain Subject: [PATCH 2/2] btrfs: remove unused code related to the CHANGING_FSID_V2 flag Date: Thu, 21 Sep 2023 05:51:14 +0800 Message-Id: <0f62955f15e60f493014592e8cf0dc6427e2bc1b.1695244296.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR01CA0142.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::22) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|DM3PR10MB7927:EE_ X-MS-Office365-Filtering-Correlation-Id: b9f7c25a-1f87-4469-10c6-08dbba23c692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a+yZ2NSRgq2cDY/2B2CfSkxjoCABAqQQgXZpdz2OO9aFYrW3i+Vc793qDGsDXRtD6UZCRpTm8+s5Ubv3AGSTB/h+ZTuXqiC8RaiJwflBdPlMt1887CzUWaLw//DXL5MLXiRs4E+fxS2/sV068NhIHy4/CeqVySy6bzzbiSyrHk76RcY1Ybra9RYvxSI8gei6xpfQWdyz1D/+Tyz9DnHyFKP4bL5dl3eImFrKV9moz1dUSFTgM463PBnYpGthjBcXnx1WMnh51IzY9caeov4xtLTelNhFvcFiXbUbDIiKFg1P8/3AXMIHm7KP4Apoq/S1LQGpFBjZj+D5PYoq5et00ZSTQKgrGHFfcHb7PxAYOCFT7AetmXcYm5S4nPord+0K/MjkBWiCsRIZYSYRmtPDL9f7YbdS09pugc6WKpwDc3YSpJiiEqs921Lq3Z7RXcsvBVP64pRTv8MWEC05Zam0fzHEG7fEgdSjJ5DR79S5zBE8JVXQuaYx50KfV9tp75NLXh58HMDOqFHIocseiybgwlCwEFPS+7GZ/+KfgDuEL7bNSDXy7LtWN08S1UMZUNTu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(39860400002)(136003)(346002)(366004)(186009)(1800799009)(451199024)(86362001)(478600001)(6486002)(6666004)(6506007)(36756003)(38100700002)(2906002)(26005)(8676002)(44832011)(83380400001)(8936002)(5660300002)(2616005)(41300700001)(66556008)(4326008)(316002)(107886003)(66946007)(6916009)(6512007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /6cDF5zFTn35Q7Klm0Hi9F39WuI0FoBi90YZAbT+/LgH7KVFR3aKdZWkHr/zmOAFQiZOHeCL+5EYKC2mF7nNze49tG16cCuxEOlS1XSx3arM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CCh10NVHtcd+zFK8FQcI6ebBIoh7vHqaHFSzBClqUcEs76Cw4WzzKVhIWf8w/dY43v0hm8EIM2IqGb6dfgUPFOg5dGLQi50oa9Cs9fX42C7X+odZGok8XDaA+1TXivLx9D6INIAnr60xJvzcUUoKYkf4TMQP18evSM67lEhCcj5hzeUWOFT1oFYKfqxy6vg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9f7c25a-1f87-4469-10c6-08dbba23c692 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 21:51:42.2395 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o2FlKCTLoq9L0+GA5HLd1JZANbjbbfS1vNtz8etjeV8xu3NUfV0SILcBBY9/ayuA0rJPJwbsDnKS0IgiZ9ZH+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR10MB7927 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_11,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309200183 X-Proofpoint-ORIG-GUID: qYnh31UeTsq3BThOaCA3wNs3KxlBzII8 X-Proofpoint-GUID: qYnh31UeTsq3BThOaCA3wNs3KxlBzII8 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The commit ("btrfs: reject devices with CHANGING_FSID_V2") has stopped the assembly of devices with the CHANGING_FSID_V2 flag in the kernel. Remove the related unused code. Signed-off-by: Anand Jain --- fs/btrfs/volumes.c | 161 ++------------------------------------------- fs/btrfs/volumes.h | 1 - 2 files changed, 7 insertions(+), 155 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c845c60ec207..8ebd1427a6f3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -455,58 +455,6 @@ static noinline struct btrfs_fs_devices *find_fsid( return NULL; } -/* - * First check if the metadata_uuid is different from the fsid in the given - * fs_devices. Then check if the given fsid is the same as the metadata_uuid - * in the fs_devices. If it is, return true; otherwise, return false. - */ -static inline bool check_fsid_changed(const struct btrfs_fs_devices *fs_devices, - const u8 *fsid) -{ - return memcmp(fs_devices->fsid, fs_devices->metadata_uuid, - BTRFS_FSID_SIZE) != 0 && - memcmp(fs_devices->metadata_uuid, fsid, BTRFS_FSID_SIZE) == 0; -} - -static struct btrfs_fs_devices *find_fsid_with_metadata_uuid( - struct btrfs_super_block *disk_super) -{ - - struct btrfs_fs_devices *fs_devices; - - /* - * Handle scanned device having completed its fsid change but - * belonging to a fs_devices that was created by first scanning - * a device which didn't have its fsid/metadata_uuid changed - * at all and the CHANGING_FSID_V2 flag set. - */ - list_for_each_entry(fs_devices, &fs_uuids, fs_list) { - if (!fs_devices->fsid_change) - continue; - - if (match_fsid_fs_devices(fs_devices, disk_super->metadata_uuid, - fs_devices->fsid)) - return fs_devices; - } - - /* - * Handle scanned device having completed its fsid change but - * belonging to a fs_devices that was created by a device that - * has an outdated pair of fsid/metadata_uuid and - * CHANGING_FSID_V2 flag set. - */ - list_for_each_entry(fs_devices, &fs_uuids, fs_list) { - if (!fs_devices->fsid_change) - continue; - - if (check_fsid_changed(fs_devices, disk_super->metadata_uuid)) - return fs_devices; - } - - return find_fsid(disk_super->fsid, disk_super->metadata_uuid); -} - - static int btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, int flush, struct block_device **bdev, @@ -690,84 +638,6 @@ u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb) return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } -/* - * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices - * being created with a disk that has already completed its fsid change. Such - * disk can belong to an fs which has its FSID changed or to one which doesn't. - * Handle both cases here. - */ -static struct btrfs_fs_devices *find_fsid_inprogress( - struct btrfs_super_block *disk_super) -{ - struct btrfs_fs_devices *fs_devices; - - list_for_each_entry(fs_devices, &fs_uuids, fs_list) { - if (fs_devices->fsid_change) - continue; - - if (check_fsid_changed(fs_devices, disk_super->fsid)) - return fs_devices; - } - - return find_fsid(disk_super->fsid, NULL); -} - -static struct btrfs_fs_devices *find_fsid_changed( - struct btrfs_super_block *disk_super) -{ - struct btrfs_fs_devices *fs_devices; - - /* - * Handles the case where scanned device is part of an fs that had - * multiple successful changes of FSID but currently device didn't - * observe it. Meaning our fsid will be different than theirs. We need - * to handle two subcases : - * 1 - The fs still continues to have different METADATA/FSID uuids. - * 2 - The fs is switched back to its original FSID (METADATA/FSID - * are equal). - */ - list_for_each_entry(fs_devices, &fs_uuids, fs_list) { - /* Changed UUIDs */ - if (check_fsid_changed(fs_devices, disk_super->metadata_uuid) && - memcmp(fs_devices->fsid, disk_super->fsid, - BTRFS_FSID_SIZE) != 0) - return fs_devices; - - /* Unchanged UUIDs */ - if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, - BTRFS_FSID_SIZE) == 0 && - memcmp(fs_devices->fsid, disk_super->metadata_uuid, - BTRFS_FSID_SIZE) == 0) - return fs_devices; - } - - return NULL; -} - -static struct btrfs_fs_devices *find_fsid_reverted_metadata( - struct btrfs_super_block *disk_super) -{ - struct btrfs_fs_devices *fs_devices; - - /* - * Handle the case where the scanned device is part of an fs whose last - * metadata UUID change reverted it to the original FSID. At the same - * time fs_devices was first created by another constituent device - * which didn't fully observe the operation. This results in an - * btrfs_fs_devices created with metadata/fsid different AND - * btrfs_fs_devices::fsid_change set AND the metadata_uuid of the - * fs_devices equal to the FSID of the disk. - */ - list_for_each_entry(fs_devices, &fs_uuids, fs_list) { - if (!fs_devices->fsid_change) - continue; - - if (check_fsid_changed(fs_devices, disk_super->fsid)) - return fs_devices; - } - - return NULL; -} /* * Add new device to list of registered devices * @@ -788,10 +658,9 @@ static noinline struct btrfs_device *device_list_add(const char *path, int error; bool has_metadata_uuid = (btrfs_super_incompat_flags(disk_super) & BTRFS_FEATURE_INCOMPAT_METADATA_UUID); - bool fsid_change_in_progress = (btrfs_super_flags(disk_super) & - BTRFS_SUPER_FLAG_CHANGING_FSID_V2); - if (fsid_change_in_progress) { + if (btrfs_super_flags(disk_super) & + BTRFS_SUPER_FLAG_CHANGING_FSID_V2) { btrfs_err(NULL, "device %s has incomplete FSID changes please use btrfstune to complete", path); @@ -805,20 +674,13 @@ static noinline struct btrfs_device *device_list_add(const char *path, return ERR_PTR(error); } - if (fsid_change_in_progress) { - if (!has_metadata_uuid) - fs_devices = find_fsid_inprogress(disk_super); - else - fs_devices = find_fsid_changed(disk_super); - } else if (has_metadata_uuid) { - fs_devices = find_fsid_with_metadata_uuid(disk_super); + if (has_metadata_uuid) { + fs_devices = find_fsid(disk_super->fsid, + disk_super->metadata_uuid); } else { - fs_devices = find_fsid_reverted_metadata(disk_super); - if (!fs_devices) - fs_devices = find_fsid(disk_super->fsid, NULL); + fs_devices = find_fsid(disk_super->fsid, NULL); } - if (!fs_devices) { fs_devices = alloc_fs_devices(disk_super->fsid); if (has_metadata_uuid) @@ -828,8 +690,6 @@ static noinline struct btrfs_device *device_list_add(const char *path, if (IS_ERR(fs_devices)) return ERR_CAST(fs_devices); - fs_devices->fsid_change = fsid_change_in_progress; - mutex_lock(&fs_devices->device_list_mutex); list_add(&fs_devices->fs_list, &fs_uuids); @@ -843,18 +703,11 @@ static noinline struct btrfs_device *device_list_add(const char *path, mutex_lock(&fs_devices->device_list_mutex); device = btrfs_find_device(fs_devices, &args); - /* - * If this disk has been pulled into an fs devices created by - * a device which had the CHANGING_FSID_V2 flag then replace the - * metadata_uuid/fsid values of the fs_devices. - */ - if (fs_devices->fsid_change && - found_transid > fs_devices->latest_generation) { + if (found_transid > fs_devices->latest_generation) { memcpy(fs_devices->fsid, disk_super->fsid, BTRFS_FSID_SIZE); memcpy(fs_devices->metadata_uuid, btrfs_sb_fsid_ptr(disk_super), BTRFS_FSID_SIZE); - fs_devices->fsid_change = false; } } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index a0e76bb20140..e485e6a3e52c 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -362,7 +362,6 @@ struct btrfs_fs_devices { bool rotating; /* Devices support TRIM/discard commands. */ bool discardable; - bool fsid_change; /* The filesystem is a seed filesystem. */ bool seeding;