From patchwork Wed Aug 2 23:29:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338923 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 51748C00528 for ; Wed, 2 Aug 2023 23:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231591AbjHBXaR (ORCPT ); Wed, 2 Aug 2023 19:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbjHBXaL (ORCPT ); Wed, 2 Aug 2023 19:30:11 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3BE830D7 for ; Wed, 2 Aug 2023 16:30:06 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiBwc024972 for ; Wed, 2 Aug 2023 23:30:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=o1fIyC+wjWJyDATEsOJy+iLRD+G4RkafQ+cYZga4/mc=; b=TTYYHKza1B0nuPo1qEOyHrRlcx1UwAlxuWDhWOsGj0Q2jQaz//SlFU3/QtTiJRU6PgP/ sXqaxI9l3r5JL/KjhoEbFzt8VtUpUJv/U/AOZhASBrVh/KR/kZmwvN2sAqVE5Otdtada SF0Z96nAtHc7dja25y/9uz1W+gipPoSt8GXKXI5GsUuVaqA4y6F89Uzg/4iGqvyfGfz7 ib8khJxk2aurjgL2GDSgagFiz20Vdmi71+gcelbRYNktrEz73vZSIGrlw4e1xPlnLKq8 q/OSrOwxtX7erGOeORnnJDld3RB80eGujuE0ijayDH8wVU+DQ1qVKUXxo3BU58qpXd0d zA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4s6e8dcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:05 +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 372N5RA7020534 for ; Wed, 2 Aug 2023 23:30:04 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s78tucd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljE3EpApKVx3z3gNSXWQ6wMYEX+a30L8QIugjkrW+oz2XJ7F103MhfstQwZVZ/zP9Z8Jv5biKNoUE5FGdUyVa3Nm0QYSkKE6tWhhsMsnLP4wSahJ3kZWLC05y2Rz0aCX/HJ0YBwv6qbinTjWBwYM2eZ6u6bqbvtO2iEj9gBYH1QSWenaKIeRiIAv3raSyOIYOHf6Aby0OR9OPNvO9AlLgFrsrwVOuRT3H5J/yYIutzjYMyj2B+wXoO5xutGoZ1gi5x2A+H8RN0aw+AxIVtIHLr20cyajH87qJ2NmrR4BupecBLY72zbB33UsZawDWxoCXK9o7963NSrVSffuEXRl8w== 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=o1fIyC+wjWJyDATEsOJy+iLRD+G4RkafQ+cYZga4/mc=; b=bgq8BlmFcHFvZvVSolvlyb2dMgDEHNAo69II5e3zB89H62DRNGfY05LuYJLxOqCEDNlOSLAX6xtvCepmVeIlePb4fDZyQG1XSvOWUH1h8na5qyLRJ19TGJdzIpgM/3YczmDgOU4IkTengDu4HrHk4r2baVYfdtBCx4cvf2xkuzszJm13U6ODwsyrblPjXcUQJubpQ50UjM1jazUpPRAT92jFA2EkEJ7OmBUldUY6pzPox6UL3qIQTN6fY93jx5Up7w9qS4aL8H2xsmBL2MxbFpdN/vljx4s+L+UxY7kuAg1eiGb+LEhfJhQInt8xAgiDPdmDSq30plVZC8lL3w62EQ== 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=o1fIyC+wjWJyDATEsOJy+iLRD+G4RkafQ+cYZga4/mc=; b=t26nfMqamGBR9wXofGEKHqbI27x9UD0nlhw8s24+jZkST8Kxe+Yh3crvCDdXxIl5DIKWm3hyGDGZZDxjdLY4nSAyFdtYARjs5g0K35ft9qgHiflXGOTZSAudduaYHM4aDku9oZ6Y5TBRkmAo/QV53pqA/zfuuxGq3cvmRVsv6lc= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:02 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:02 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 01/10 v2] btrfs-progs: dump-super print actual metadata_uuid value Date: Thu, 3 Aug 2023 07:29:37 +0800 Message-Id: <53c1111fcc49df5f0563839146260c8f0950b071.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SG3P274CA0007.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::19) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 90836723-a483-4881-9baa-08db93b06500 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uOlZOPum8WsAy9cne5/CFU4JnY3gBPzs0CymnVF7VV+jHYFC6ymkI/2vmkJQCEhorVc0QLxuZ7wPep8Ar7LMPdPlZWYRsZmONmukK6zDZ7X37uWZrQgH80PXa729ZogVdrZiMJz2zZSUkIfFcP1wGeXkvtqdgXQQiSX+5bOFQsMSr18q1Uc88A546gGRaHS2qfENHkzj46lctjY7GZtCc3YAkspAQnuk1LRfSJCky8eUvz9+72EiW8yZwcjg74xq0yuO35dd9HuOR5BVadPijrrhFrZ9vnmeWRRHJ6HZPnqFNjW/u2PgXHnCXzJXNTxTJFOGrN35T3WJ0PmXLr39l340m3pqBXNuqveJsCQOqDXLfZJ8Sbi1VJH18o6l+30roHhzyhHXS0PAJRfBNzODJ5b7ROjwV8+SJuBy7OdafiAUoOERHgmHOkGYqsjxMH20SAZzY8ijAZueBhjeqiK7ybQU2VzgfNTvDBru37M8GCsjpoI64gRh8nt+DKJdvga3mX1TeEHe4Qc4yKHm8CFI/UqN6k3QwUF5eoTCwGvuBMJY7KgsyB97TwVMXF7Ax8hz 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SXX9VyszXdO018bIZ+ghhm4WMUJMYd7niGAlCUBQtQRaO3O+umKQkCBnYlHg4YsBtEdkg5Mp2dRWnhAdP2FGWYusGE+U8iwwl+TZYtH1f4fXgEH85wZaBK5zJQ938URlW66iIZ64WH+N+qnBIhLuREJxsysp/Cg7m4+Z0hsREThtU8KjtbHk7L04bUsjV2d8mxQ4tf24O/fccY+WRnQEt+ljwHWjvQDu1BrR/D3ZI0PP3ZzCx10cFIhvmcELh30J4OKz9yb45/yeGKx/WJFmAylNoU+S0DNXGziJs/xY2x5Rxxsh0qAQdA76Be+L+dZ2RMzAO1Bw/Kc48Ve/QNe2NfQlgnTKdKFiijt6y5j5oSeUPOs6I3VACL0Mqj/zZLSvMr4stfIP3v03x1PkYM7zyQUpnYNiWbY9nvL9B6m9CSc1sog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OfCdquAkV61WSRl2mf+7OfpwXh77ere6lisHu4AgH0YTswWaKF3+Ph0b3BHT4B5wcHlNStAJ/BL3xWBq7rRT X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: B4C7jLaEn3drCX3RI3CM6uqS95GuULt1uTc/3LiMFGlAX7afysLa2Z9u5s+0uKouAmxM65K0gSUdd/wosn02wIgdWKFUhJeyjznybn5Vf0dSBoE0zNGlDThTzt6GiraOXbA9LqA/diFqZXB5e4wcuEPnKv0WJekYp3PjQudX6XOfhXUWsacJjLfsMISwSdsC/Q0Q1/UAmePx50rBl99y/tryhkB5s3zOpUcMV9MlRWVicXYVCbXKt1s98ZIMqpj5fgLF5EOrFfDsEEXO87xdbCNEH521VC5ixcD89wVtbSdrXYvqP/M2HQVpVJTbxE651YyjEcwFSSqw+Uljxw84jXPFbrNzHNfv/Q9qYJcSuL+IKES3M1KklckTWie0zyJcyhuwVQc+JErniKhROp2k/kjK9b8v/P5T9bYV/R3i/0zVKC+Y3aPnhjt3yB86RZQeutJO5P3GGdGtY9S5nXYG8oI8NiN6R5ahpcGrEoO2LdzgtrG0S3JbEqYXzJFRNAzIz+AmaD5yFCWVh1v6uQUdQfAd7zKl1hRlI+fmhP7PTpwYACcMUSAgYLAzSD693v7xCSAztnRZKz/49MDYWUGkPOYnWmTFXXASphZz4zJ7+DRXX9xmO0FZfbKrsZjhQb2zX+ok5v/mA7xCE3x9XMlbKBeoxc+dFsslkYLa5RVhiSCzrhT1bly3YuZS++U8v6OzjGiSO05MgJBL11Rm43eMmQ62Ip/IFfYj/W+XwF9LH246x7sVAx6XFXyUZC6TnDVkiaH80qntLCWdzvBbh+4/mw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90836723-a483-4881-9baa-08db93b06500 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:02.3153 (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: Nl8BqdBIUhY25F03yIpcMqMPVBU1E4N3rmGDsXwebSJEge1cOsHoKK9ixoRS86JP94iD4nd6MwV9SCHHVLhfDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: p9MYc-zNg0vtFTnzZI_g1hGKkGfAsi8- X-Proofpoint-ORIG-GUID: p9MYc-zNg0vtFTnzZI_g1hGKkGfAsi8- Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The function btrfs_print_superblock() prints all members of the superblock as they are, except for the superblock::metadata_uuid. If the METADATA_UUID flag is unset, it prints the fsid instead of zero as in the superblock::metadata_uuid. Perhaps this was done because to match with the kernel btrfs_fs_devices::metadata_uuid value as it also sets fsid if METADATA_UUID flag is unset. However, the actual superblock::metadata_uuid is always zero if the METADATA_UUID flag is unset. Just to mention the kernel does not alter the superblock::metadata_uuid value any time. The dump-super printing fsid instead of zero, is confusing because we generally expect dump_super to print the superblock value in the raw formet without modification. Fix this by printing the actual metadata_uuid value instead of fsid. Signed-off-by: Anand Jain --- kernel-shared/print-tree.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index f97148c47b5a..1c398c3dacab 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -2006,12 +2006,8 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full) uuid_unparse(sb->fsid, buf); printf("fsid\t\t\t%s\n", buf); - if (metadata_uuid_present) { - uuid_unparse(sb->metadata_uuid, buf); - printf("metadata_uuid\t\t%s\n", buf); - } else { - printf("metadata_uuid\t\t%s\n", buf); - } + uuid_unparse(sb->metadata_uuid, buf); + printf("metadata_uuid\t\t%s\n", buf); printf("label\t\t\t"); s = sb->label; From patchwork Wed Aug 2 23:29:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338924 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 E1B15C001DE for ; Wed, 2 Aug 2023 23:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232622AbjHBXaS (ORCPT ); Wed, 2 Aug 2023 19:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbjHBXaN (ORCPT ); Wed, 2 Aug 2023 19:30:13 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B8E2685 for ; Wed, 2 Aug 2023 16:30:12 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiNQe003683 for ; Wed, 2 Aug 2023 23:30:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Vl5B1Onc+xHpBkwht5UqtV11tAOpa5zbI7H9INHhedk=; b=qSPwhl4i1hD7d/DS88HNaSYjurRZDdKqW1SQt+gETgh9A6/JNacrV1Vs22NH0xWlGxm8 xiI1wdg8YZtMAm+ycEAbXgidEcsogM0YIUt2WasEDbtMdJjxzCbNV1seQEootuBbRdHV tw514rJENKRpE4by9ks3gaz6UneV9VBU8kIXFRSkgoWxE4yXlNDk0sWp7JhQwa2CUSE2 6yMJf330yuzNgLP9rHmPodNieWib/SNpCAOczA+wdVWnInRQaQ2Y58ThVgcyrvs6Vcub 6hC453Jn5u041C5j2nYTi0IDSX3vHfXa+SPHZDw+dpEfPMuzTZcAY6trMetDDzLGaD6+ wA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4uav0egh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:11 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372MJ45F003887 for ; Wed, 2 Aug 2023 23:30:10 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7emefg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQJdml3r/eCei/+GHVPYMtjZaenpFbhAdtzGxnEDxIeaFXTvqJd8dToBW83mDM3AXe5DRuwOrOaiDJeQF1u3HR9b3fQz5jNW9tc8D+KLk0PWIajy43b46jA19R7yrRJOH9dWUQi7pKX0CL/SsBA/DUnqiU7EnVSlyEsYIEFOAEdh0pLXoraxyJ90mPgsmrEllXmH0pCvGqC6IUJxT2gYaOCBvpTjOjskxHzAveYdNZUUsGX7zut4AQczEeWJrNylALn0YIahe5hrUGbWWXt8vf4vBeJHTBrg7nOVvAbj0QvSV+VxMzmee8crqX6IlzBBeMf47vjNd22n91P8FWhWVQ== 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=Vl5B1Onc+xHpBkwht5UqtV11tAOpa5zbI7H9INHhedk=; b=aiWxlk0tzkN9j1qq3436bjsQKvmCa4gBeNzh592PEo3WNzNpDxmdDqSLPZkgQe6t8NaEYPpyBvD4bKOW6dGrV4hawFQrRr46TRNDgL6fcxI42CxdEh9bE0t6QRhcPBR5QWGGtq9RHeEolEBuvaDEto6IczoAQTya1vYm8Ifx6T7qmkYbcEwlwgzgMsseZvxun+UW7xkpNDWj2YUi6q2K2IJxms7BM3/iO/ceIHHP7dg3OeaEVvgdCpIUPy/XkqrN1aKFWrhbAhoiQEORXr7f4/xn9a++Mx37T91xxazm4mz8GxIxKAooX5TkE5NiK0zN+UgmcG00+NMvV7uZ7Z84hA== 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=Vl5B1Onc+xHpBkwht5UqtV11tAOpa5zbI7H9INHhedk=; b=F3H1pCwdKJrqPv+LihMmOogFm6239pAwuluG8zLTtqVW6K9jcZE35eqAaJaIvx7wpcmjIAhybQzovRQzC844UGJlXOqdQ7mMYAp6K7jp2Y9UxJckydfck+WgqnN+rPEAyWahN71Hfp1rXj1xB7SYdwcqRNI4eRRW59IWK3Q8Gqg= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:08 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:08 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 02/10] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Date: Thu, 3 Aug 2023 07:29:38 +0800 Message-Id: <9a4daea1034aa907ed8f810066e29770b782ef82.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR02CA0052.apcprd02.prod.outlook.com (2603:1096:4:196::18) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 2334d958-ecb8-477f-7acd-08db93b068bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r776mDomlAOERCCrUXi00dv+YInYLeu5VF2QAc0LOoVxM5NI50CgbCPJCwyRmJqXo60gYKPC8KgeK+KmAhRhGIYJ9e2sIw1UPow1/IGpcgvEQx3YONU+eemjx0GoG/BoCz7DlufY7hQJczVa8PW0HBdUJeKRkByeDZ5HGJt1OpYcxu8+0yrOvHDxK7scDp4RCb7cP6HHYRZbwb8+NenfM4djMWvtqKEMgU5JXfiMj4tyYNsrAo2cyQzEu/m53KVbPb1BLs/F/lmqcK6X0XIXmquuaBU3i1X8ZyLKeMnHmAmg5ViYQRKC9pD/C8U+bpFthzpkio1IY50nLdvdqSyzLgD+OdOcjtoFdXsLHQXfdQlyoqzlIjqTh6BBV0rpcXl89XNsIRSy7j9sq4/DMRHynrlVTXjMzm+Vg2xnIAA8C6c3w+TKD8ZxPH416vPnlVL0b+9gr21SjCUm0qvfA52JazfwsNYzpkqd3ovaV+uWI+o7Ky08yNFCPXp7/HqJK2dsHnlivYxiw1VUba52sm1bi7u0C39gVHMkx8dpsgnlqPdfHT7u8cmVXXY88jHExNhz 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jIB2kQIn97eHGkNe1SX0YwXYay3aXnoVnDeTWVud0MBhKEssrDRhLsz4UkYqQNxVT38YDFo7zSRoHcItYOpw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06O2B0+vvE7ea3euCyP5vjb9Qck2019ccZeiU8XmFE9PeGWuyd3ADIk8O2LLeYpN4ORw2dhPpLkOQ14uWBZNZQLlgdsaWhy0RyTi+ueQIDPcsOU8TD3ouPRFpQ6rDFWXMhdMHyWA2KC+//GhewZUC+zRanm2N6fk7+z9pnW4ywxxF6axyEzciMiNYFDkFkbwIwgmgVpvchT72JE0B/JsSeoWO7Fg+EypA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2334d958-ecb8-477f-7acd-08db93b068bc X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:08.4959 (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: yrB6EgA0yN5Sg4vmXYjSKm3WDGMiyruF/K0jIzHZynHK+MQLCY9SYcP/9MqlYEyx4asYOhT3lGr7U16IQeFXYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-ORIG-GUID: nv3R1NmbvnWmckkT1mES_t05JJJWLvhg X-Proofpoint-GUID: nv3R1NmbvnWmckkT1mES_t05JJJWLvhg Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Commit btrfs-progs: dump-super print actual metadata_uuid value fixed the value of the super_block::metadata_uuid to be printed as it is, without tweaking it depending on the METADATA_UUID flag. Apply similar counter tweak in the common helper functions used to read the metadata_uuid so that test-cases still be successful. Signed-off-by: Anand Jain --- tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh index 88e468d96748..ab1e24637d1a 100755 --- a/tests/misc-tests/034-metadata-uuid/test.sh +++ b/tests/misc-tests/034-metadata-uuid/test.sh @@ -15,6 +15,19 @@ if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then _not_run "METADATA_UUID feature not supported" fi +has_metadata_uuid_flag() { + local dev="$1" + + run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ + dump-super "$dev" | egrep -q METADATA_UUID + + if [ $? -eq 0 ]; then + echo true + else + echo false + fi +} + read_fsid() { local dev="$1" @@ -24,9 +37,14 @@ read_fsid() { read_metadata_uuid() { local dev="$1" - - echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ - dump-super "$dev" | awk '/metadata_uuid/ {print $2}') + local flag=$(has_metadata_uuid_flag $dev) + + if [ "$flag" == "true" ]; then + echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \ + dump-super "$dev" | awk '/metadata_uuid/ {print $2}') + else + read_fsid $dev + fi } check_btrfstune() { From patchwork Wed Aug 2 23:29:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338925 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 BC65AC001DE for ; Wed, 2 Aug 2023 23:30:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbjHBXa0 (ORCPT ); Wed, 2 Aug 2023 19:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjHBXaY (ORCPT ); Wed, 2 Aug 2023 19:30:24 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DED2685 for ; Wed, 2 Aug 2023 16:30:23 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiHME010904 for ; Wed, 2 Aug 2023 23:30:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Hy5iAWU22itvtr7AoxGKVrYOugRxEPXcsjGk9NcVM4Q=; b=PoHpOABYc96LQJp0BJQ5LVubz00fZ8BOMFijAiQDLFQofT8DlSX6aepsqKOHO2x1sLM+ kJC4LBYA+f5SzMFotUFppU90hXUF0XQBWR0q4HGNXE42Gmf8cm6gkYLrD8Q6xixeWbOb zEfOEPndyvwLUL3FoFj5AeJ2A4enS0kU8dMAVW5zPZuQg4XvQhnetAXIlkI+2lFaq515 /zZLyf3dYXGUjDguf3Q1mzk9B35wmBOGPvkr+Zhoqx2BCD/vyRI5w0Mnh4sikAcD4I+h 3Z0CXGGgubEQ98Tk4lKfGmM6NAQlpPyM0q9AsUrx5sJUF7HPUl/AqM+xnlxHruRwMZc/ Gw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4tcu0csr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:22 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372N070a003938 for ; Wed, 2 Aug 2023 23:30:22 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7ememr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SXo184KYBHxUwASF45hEdWWUO011FHW9Zu8TktTD8YZmiMgfwUIiOy1nzCtno/7nHEbo0BdiYMJHKnqJHjZNDEJVECc0sMdukxkEKn9St9bNVWPjTVuBlxiHcyh87Oc6DnOBfewkP6SkcxRuk0Qbsuc1nVw5ukiV8PB1Jiy0hTM6+ilqlf49PGWszqtNOtEkxYoQFZ6LYH9JSeZkneSMGe4KQHl3w9xsK32rYLYlrurvKE7XvzBweDXf8+7vucvN7Ax9DvJHKu69nezLXbLnnod1AVSwhx+1AZrwUTRLjUe0r3odurf4wQ9ah/v41vDl2JpXLW4bRS8evXHKfgQiwg== 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=Hy5iAWU22itvtr7AoxGKVrYOugRxEPXcsjGk9NcVM4Q=; b=Ud1PsjZO/nS5xKyUrmu697T+RRXXUsy4AGFrg22Ulne4dTt9PYqcp1nA5KRuu0KwBp+ov1PKAqZw+EqnW6ttQRNcnwIS2Qo19ZiuvAKeqSqkigqFFOk10ufktzRNgSZOuHnbpmFYllvTZUXITuGRGwcz85tXp+f5SKdbZ6//FCf8hEQbpwazrsqIEfBRwPHMjq41uahNyzotSuqH2TEeTPdsVbx7StZnlUtewBIdNNn68RH5cc85fSFsRBEKKom/JLydiPTUnTQ7+n2PhJ8on8znQdolHDuEuLNfMecLzsl0mi+EzZL8RXGmEFjLjk1OsJiySnNVJuAbxlToDGs7wg== 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=Hy5iAWU22itvtr7AoxGKVrYOugRxEPXcsjGk9NcVM4Q=; b=CPm7RBpRbfUpuEE65Ay2tvAlqFuElvt/scXXPphOzGy7G/bGgacQ7VtnKOUhVBf7BuDmjYupdVN5WMBc9y0EWhXj2Dhp32wpvg922KPb2nII0n8VCtcnI5Kjs2wosHaEVgZKgJtSSM4EsTL9kbrnwbJjpZg9nZNRuvaYkuhSjz4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:15 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:15 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 03/10] btrfs-progs: fix duplicate missing device Date: Thu, 3 Aug 2023 07:29:39 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR04CA0003.apcprd04.prod.outlook.com (2603:1096:4:197::23) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: ce22c1c2-e200-492e-eee4-08db93b06cd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7z6xvsmSK8LgwndXEsTsL06T5l/fBmYFNAA/FGMyYAFMr0rE8qBlfbCRaYYIO9UvO1bybrFfO3n0JmsebhqUtWDCvIIE/E1Xywgpw1GnP2/BbsfDbWLCMSX67XO2t9BBcVLoX85Co/w3duHE5ByG0qRTrikGDBWHR630BN6ufmm0JcOuH2QtOMIL3ycPipyPE/wgingL47biWu/h4XAy+jYvRQ/k1RiFtSQO+O8E5KRmn0EGryxzwWmYosI7PEP6pBuogXyiRsn/ZmKC/zCOfCFX9myayXY0LOlQ7/UZVIvVNpGozKl7jbPlXbUum97Z4RXD9PJdf092Acd5nK0YEcPe3pFIeHeJfsLrOXgQN6DGjIn/hoAYd2iVz9BfYMtK1bpQNINZ7F1Fno9/VxYkjGaEalj9bbLZO5tF1HT672p0aKqgit9y91ZqNuTHuk6mprKQlqYFKXyZFu/sFGfM8onRvnkbDKYuTti1/pchUijmnl9eojdks0mlDuGWcLoM9tYOa6/zbO8TbE5J+NSHGP1UEKcthSm5v6C9e7nReYYHb8UGFZsg00EmMZp14+H1 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PvBcfk02mCWnM/wN9nuJ03xJ4p22zRY81wNktFZ8LsM7ARKm4o17/ETMezOu8BXDn16jASVTY4UpR4icUDZMecozGNPdf2Q0IUGmdpU8+JcIKiOAGY8WpFTTIezfBwS6RuNxG/4e3YJIJnWyzTC0gI8qAieNwt1/CVOvz9yhXHL1sQkSQEfaoBm70uF9yBBGSqLhHLL86eIAXipKkdwG2ISt+pweGVHgz8VJ3utwgRQBNQJbDK2lyd7TVsGxM5KHdn/ZWYfXkntAAjrknpj/EA6PMOEGh2pWhDJVw14EQqX95nnYE26iiCD1Kd834oJvJAOUlD4kNGgkH4hQPX5Xoy21pP4VPvTSdwyhIruI8ZGuywAEY3i1CXheGCHjEMOLUG3WXhblCCMf8hL0YVYSuP7ka0cWWE8BqOMdRgYJx1I3tvTVUiTPXtLqAa1OOjYEbuxCzv7gaZvIqk9omCPTz5mfYwKBKR2QZdLgT1Jm9fQHBMqHo1egfdHGWCe5eaZqZ3CJqarETr9FGmK4JHOSj7y7cs/S0LxOnAv8SiDTRvyr94hZSjCr5cJmKCJT4biHnf/DThlAiSxYkQS8lFzH9ho5OrW6ed9sLx/F1CIAEVPkl0M7UX24b8JWRLpXbcWOkYWGBPF7mDvZ/H5C5Jofr4sgYShP3ucipX/0x5cTbclQWJ1np9o51l9FrR2hsf8icBEWFA5xEqb4WU+CHeEPHNaR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KkDuQ2MPWWj9IHGPt4+D2es9/jPfXQhzQBZFnmjFNBE1mwJVflrO5eSgDm6fbm4UMCCSCWG+pDUXsHhTUf4JBQgE/fJUuizfoBMTVDmFTug9bHTkaCwu2hbzK6DS6fYWu09/pPgrG4ud1OmkMCf9LAkCk9eYW0joWT2ZhxKemyKthAf2mF/6gb+yG2/jVpL8T2PuGX3THzd3q8DYlD857ezE1jnZhrOmmB+y17tZjiRMpLvUU70N5VKbT0bK33MnljRjgxb32DKSlmRoOFYSeafJOlCRCEbFTsZKrecxXN9mJwiLR1Htqdtlo+WKkSqdysCP5PTHDleqnGJHNQdX9NIsa4o5KDWt/FHELsvdCVpvn18yqT4hGDjJeL31g/XtGdGwOB14xBELQRFatpX0UND+kSQy4YJg9n4eDs9b0L5HqyCU1bhBKduSl/6tCKXcnjl+SFKv5D4oLoDEAnlOGVbI8mt1PqP2eclvI49cTYyHvjT0RvxnZ65VPC1ztr3dC/QduH+nSfvDJYtVIhZoiZBBVzT0jr6VGkwxNxwUG7S+BfFt1JiSBqhRLIirtC6+7rhNJeZ7kV/aE3XhuJ+SBDWlIWflZqiVdWiMretYXwHuTVB6/ZGxGc7BvwCLk5uuSWMs2/hXwNjepds99wsCqUw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce22c1c2-e200-492e-eee4-08db93b06cd2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:15.5448 (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: QLdHrWY27aLAfKuXMstxecS9zR7uCc4NXyiErsNh6tq8L9ZH5l8+DznBNQ6oDFF2DRMmBD9qT78reZ64YNHsfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: eNmZhEafU0pv2oQd-hxdGQjlJEAKk_qK X-Proofpoint-ORIG-GUID: eNmZhEafU0pv2oQd-hxdGQjlJEAKk_qK Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_read_sys_array() adds a missing device with its devid only. So, any subsequent btrfs_find_device(..devid, uuid) call in the open_ctree_fd() still fails resulting in addition of duplicate struct btrfs_device to the list, as shown below. open_ctree_fd() :: btrfs_setup_chunk_tree_and_device_map() btrfs_read_sys_array() read_one_chunk() btrfs_find_device() fill_missing_device() <--- dev_uuid wasn't updated list_add() btrfs_read_chunk_tree read_one_dev() btrfs_find_device(..,devid, dev_uuid,..); <-- fails list_add fill_device_from_item(leaf, dev_item, device); This ends up having two btrfs_device for the same missing devid. For example: (btrfstune is compiled with a boilerplate code to dump the device list, as in the mailing list). Before: There are two device with devid 1. $ btrfstune -m ./disk4.raw warning, device 1 is missing [fsid: 95bbc163-671a-4a0a-bd34-03a65e4b338c] size: 120 metadata_uuid: 95bbc163-671a-4a0a-bd34-03a65e4b338c fs_devs_addr: 0xdb64e0 total_rw_bytes: 1048576000 [[UUID: 703a4cac-bca0-47e4-98f6-55e530800172]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0xdb69a0 device: (null) devid: 1 generation: 0 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 [[UUID: 00000000-0000-0000-0000-000000000000]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0xdb3060 device: (null) devid: 1 generation: 0 total_bytes: 0 bytes_used: 0 type: 0 io_align: 0 io_width: 0 sector_size: 0 [[UUID: 1db7564f-e53b-46ff-8a33-a8b2d00d86d1]] sb_flags: 0x1000000001 sb_incompact_flags: 0x141 dev_addr: 0xdb6e90 device: /tdev/disk4.raw devid: 2 generation: 6 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 Fix this issue by adding the UUID to the missing device created in fill_missing_device(). After: $ btrfstune -m /tdev/disk4.raw warning, device 1 is missing [fsid: 95bbc163-671a-4a0a-bd34-03a65e4b338c] size: 120 metadata_uuid: 95bbc163-671a-4a0a-bd34-03a65e4b338c fs_devs_addr: 0x161f380 total_rw_bytes: 1048576000 [[UUID: 703a4cac-bca0-47e4-98f6-55e530800172]] sb_flags: 0x0 sb_incompact_flags: 0x0 dev_addr: 0x161c060 device: (null) devid: 1 generation: 0 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 [[UUID: 1db7564f-e53b-46ff-8a33-a8b2d00d86d1]] sb_flags: 0x1000000001 sb_incompact_flags: 0x141 dev_addr: 0x161fe90 device: /tdev/disk4.raw devid: 2 generation: 6 total_bytes: 524288000 bytes_used: 127926272 type: 0 io_align: 4096 io_width: 4096 sector_size: 4096 Signed-off-by: Anand Jain --- v2: Update change log kernel-shared/volumes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 81abda3f7d1c..92282524867d 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -2077,12 +2077,13 @@ int btrfs_chunk_readonly(struct btrfs_fs_info *fs_info, u64 chunk_offset) return readonly; } -static struct btrfs_device *fill_missing_device(u64 devid) +static struct btrfs_device *fill_missing_device(u64 devid, u8 *uuid) { struct btrfs_device *device; device = kzalloc(sizeof(*device), GFP_NOFS); device->devid = devid; + memcpy(device->uuid, uuid, BTRFS_UUID_SIZE); device->fd = -1; return device; } @@ -2150,7 +2151,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key, map->stripes[i].dev = btrfs_find_device(fs_info, devid, uuid, NULL); if (!map->stripes[i].dev) { - map->stripes[i].dev = fill_missing_device(devid); + map->stripes[i].dev = fill_missing_device(devid, uuid); printf("warning, device %llu is missing\n", (unsigned long long)devid); list_add(&map->stripes[i].dev->dev_list, From patchwork Wed Aug 2 23:29:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338926 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 3FB0BC001DE for ; Wed, 2 Aug 2023 23:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbjHBXaa (ORCPT ); Wed, 2 Aug 2023 19:30:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjHBXa2 (ORCPT ); Wed, 2 Aug 2023 19:30:28 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD19E26B5 for ; Wed, 2 Aug 2023 16:30:26 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiQaS002262 for ; Wed, 2 Aug 2023 23:30:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Ox2af2lQ8vFbNKP0HdTY/k8AQO0K6c0cJGlo7nAkpSU=; b=bydLKXy0E/NPkI4LH3k/F1HeCURb7SQzi8ndVxdymLdx1VziPYxUWiJ/CmisOX6nGxxs HcbvwR7uSsKng915wTzm1XCgFttWa7dBIU4qQhdl9Eg0ED3ggTFIMkYBUYcSkkBR4r1/ MSHstVc8VQ5aL6Tz0WO1djchtvSE6SYhDRCQtJ8B3CFNV5KqSAqtK7U4Mc4DvuiZZmKA Rqrg9YsU1ZizbjmZbspmGCNjHijlIhWiTqvnf+FKODRVts1RkZKWsI9zSTTDFpLTSWvU dezUkzTdKQRZVA98v3gstdWE1zZce3mf26BiXOVsA7uMDmzlquULBOn86+V8kMvbamnw pA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4sc2ggfn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:26 +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 372N1FV6025102 for ; Wed, 2 Aug 2023 23:30:24 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2044.outbound.protection.outlook.com [104.47.57.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7f4t1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMTaMutZULaSSnlHpitZEeh9ihsxV8sV/e8R0Cgy4+qGohOHh/WLs5+dQuYFR/BrnbE7czRM1WnijJQTQo8FLPeRDwlQPr0jaIIIXhhWlqlpSCXlnfrlNy0tgBlmBdKlOE6BYc01v33s9pMpzD/ZcDJoW0oQcAUzbZz64zqhx9r5+HACDjeh0LBk0vN+Vc4V8T822gSaDDVNyDFeNAjW4Sm50feZtzFtMKDdB1hksrcunIOcDVTX9feKph4HIe60ONvZkTuDi67eAhcU5vNam2KKTPzovbI0MPEx+zWruNUg6yxtsEn5ciuzdnWmTPVMIlYsi44tweD3CBwKm33p8g== 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=Ox2af2lQ8vFbNKP0HdTY/k8AQO0K6c0cJGlo7nAkpSU=; b=gRdxilgqon2TJg4C+KnSktbE9A5OZ1lUSdiwbtpKU4RPU6BFD3pLepJWriIQPVNnIs0dZkejtWhUmTqMsP6+RcCFkZwggh7nqAxSDQ0/EsKWGBvtyP6P0Svqshq0MOjpEY7Dk0CZlhKEiJxEz0nH+7oczSro+H29sOi6hcxrUrBLhrMWsPq/ifgPglZjwzmB9CFETqD608s1smZ9FL3FqDMZbAdk9XK2gohGJvqBhL95+nXRu5xwKnxqX/nF0fLvNXTPim48PEfkurJ+xsxo0RPQSoT6ajO62CMuXqJHyWvkwipX1aJQOy1XXOEZ/awXK2g30icFZDiAAzi1A7bKXA== 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=Ox2af2lQ8vFbNKP0HdTY/k8AQO0K6c0cJGlo7nAkpSU=; b=u8JnFauNnmqeUtM+K0pP2tGfcVdY01k1oU1QZI2VomNx/bE5Wgc7UeABT9Yqv35xQd7rxAsDHc/nTApWthoGV67BmWIuVhU42nVvq5Hg0lkX8V6hv+LTzBBpIqly+Wtoee+vNBLAb/gueTEh1tNTzQfqqdQ74sUYR3hrDZsI1Go= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:23 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:23 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 04/10] btrfs-progs: track missing device counter Date: Thu, 3 Aug 2023 07:29:40 +0800 Message-Id: <644a524e8929ed4cd749b0b35ac0567271a861e2.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::14) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: a617b27f-f62e-45f1-f4bb-08db93b07162 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vYiWbB2FbBKsPMUyZLs6JAtrffUFV0RV38TVNINRHzmqiuYbzpOJnTq+P4VJE59aupmcjj5Lt+JGfT+ZTJ3fXvdpItKTkF0FXfqE41dt8v6CE+/ehtLtbK0+VfgDOefrLCB68TtFJo3faSXxfvVb5AW/r19eaE0kSOzhT1msPyLp65LqU8sijFWnsdHCi3HSMunEkjqJpVZyIteSV8iNpxmPsmwhYJvrVOlI1Slg8M/I7IRSuu526VKwPV5K1wLVjXoBSwiKNixuRBNhlC/EZ+gHBe9NOkTgqo71mv4lnVqV3J6BKcn5RkppPB/avizRnQpLDcUzmlhBvmn0aXcJzLBlGA5bK82+2V8lgE4Hm2CgvMD65Dwnwbp5B2t+eOb0seMMiZ2dpiMQAfTfqXtwaHGi2OwI3XXHsrU+Z8FSMXV4AyEK1Iy4j+O5xcUZ/lPq1AcMllapcaMAR94WkAM+zntT4rEV/eKr4yBqudzPo5ZuXKZwoXP1wo9Gkv2gqSdfmjdJamqk11cdkXMPKTLAYjjM5WJODA4PjK+eDNBP3EUaFuiM13D70Q/EZkLDgyif 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /SkcniXGJHO4LoVrqN2Ea7OclbFGZ4H1Goq7z4ZE4PAVBorLg9MDfWs9GV9gy6ejo874i8fch7WdjtfzwqRYWkhytnGVmBhtl89DNG2qdJTkZ1oTl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/NyiRcn1cfy4Y4tqiE+YUKdOZkRH4qglRK9E4beHDx39B3o5Z3b32jzls1aJYM4aPhUcZQjI5QAPbmU37Lkvc75s0Uwf1hKCnMlWpTkFuX2a2b989GhZwzWr+Acu88TIJhGWSAcqgsSjbwP85Tx1xWjnroLtRzL3E/J0SeJEEb7QX8rAPht56+39cT0aqK1D51YJVvpMHJzdpg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a617b27f-f62e-45f1-f4bb-08db93b07162 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:23.0107 (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: oXFcxgoYq1wSN8X/fh8HC+UQOrNQT90R7mvmiVaj7w00AMiqPXjEK26HhC4u8WmKX0y+8AfnhVcAaZaZTwIIjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-ORIG-GUID: K2shaun-w_NxL7pfWxSGZjGnyJln9_JW X-Proofpoint-GUID: K2shaun-w_NxL7pfWxSGZjGnyJln9_JW Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Maintain the btrfs_fs_devices::missing counter to track the number of missing devices. Signed-off-by: Anand Jain --- v2: Maintains parity with the kernel. kernel-shared/volumes.c | 2 ++ kernel-shared/volumes.h | 1 + 2 files changed, 3 insertions(+) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 92282524867d..54ef553e8230 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -2156,6 +2156,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key, (unsigned long long)devid); list_add(&map->stripes[i].dev->dev_list, &fs_info->fs_devices->devices); + fs_info->fs_devices->missing_devices++; } } @@ -2258,6 +2259,7 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, device->fd = -1; list_add(&device->dev_list, &fs_info->fs_devices->devices); + fs_info->fs_devices->missing_devices++; } fill_device_from_item(leaf, dev_item, device); diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index ab5ac40269bb..24b52c86562d 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -88,6 +88,7 @@ struct btrfs_fs_devices { u64 latest_trans; u64 lowest_devid; + u64 missing_devices; u64 total_rw_bytes; int latest_bdev; From patchwork Wed Aug 2 23:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338927 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 6B142C001DE for ; Wed, 2 Aug 2023 23:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230248AbjHBXag (ORCPT ); Wed, 2 Aug 2023 19:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbjHBXad (ORCPT ); Wed, 2 Aug 2023 19:30:33 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5503926A2 for ; Wed, 2 Aug 2023 16:30:32 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiMeE003655 for ; Wed, 2 Aug 2023 23:30:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=4Pwu99+kaMez8uMc6xA6npMNVrqYg0EqAMmV2xMfBvA=; b=mefzTh6zPuk/M1p9Fv7L3Nv7/wLOoR0klTJFEZIXFAlboXsw2msnd/AQ3nha8TxMC29n X6G+mAPLGfWLnhQjT8lqPIbz38R15v0uJBdkAmwc7Nr8tFiQNK17g6wG0Kys0LcX8tPb oGkfNbob2e4MF0a1JK+yJJ9LXzK5xkP/XjfFAE7dngY/4EJNXQwr41YGSkPuD3j4ivvW YsL0C6Kvlf2BMluVxATyqy3666uqH/Oaw8L3m10vNn+wBNdEScCLXtldAHLL12Ca9LcU X+w/OGR2k+t3IabPGi9pyZ6co7Zc7GIjMJS3NiheyNzG2GExJlIgZNm1DSZY4FjG18OK mw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4uav0egr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:31 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372N635X006590 for ; Wed, 2 Aug 2023 23:30:30 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7f3qt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eP5UQX+zTWDKYgn9q4b5h2YBjudhJSCIU+6y5V0c74qecJSeC1hWHiS2LB45jRZTSms5EaVJzMBuqJ1iS5R3eUhcukI04fzWanKhKfylIaEeRPZUnluRGpHeUu3FdQ0A5fqDvikHlXj8EPkrcmTLAAvyWQUeTSVx5EI18Ymbvm2rXRaOU6wsQwbTEgh4ksh/yE7DMdC1LDP5O7+/E65yPPmpdIVWShjE6WJU2KC8bzViJ/9jVGKI+J4hTK7K3inb+s+i249CLzdKWK7Idbwbq9vK48gw+63RzqQpNb8Y7cblBoM+tUP5pRfT0oS61eS3JhwLUIERSBxlkwxDVpcNzg== 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=4Pwu99+kaMez8uMc6xA6npMNVrqYg0EqAMmV2xMfBvA=; b=TDNl7q3sYEdeF/VV6ECrfn9lv8es/XzlAr6B4MfsRkn0ZC9tEokSFSD6oI3AIwfxuptcx5A6JELdx2OgD2Fuw/i32G/33hA/pF2UTnsYHosQBTRVY/J142RaIzhSuRLaixVPucMj2wYRQ4JGrwD6adVShws/Zq9cVXdn+hTNnSJlcINLoDwihjfHXJMm9/r9SSCC/2qP+Zeni384Ta5JJSzLQ7F2WX5j4tqA+U/SHFWDqqBvCVdVvtfat/jh/wyQZ7amU1ADo2/YTw4UMDOQmyww01DDDIEfr6Q6TYCsShSPZoSt7I9tMYuU3EQPvH4qZOhLf2omlZb2Bgyzy/oTzA== 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=4Pwu99+kaMez8uMc6xA6npMNVrqYg0EqAMmV2xMfBvA=; b=AW0vcW37vTzItS25ZeZtwCc+lgAG5CRaTix7ts7JW0zRt62uMmAV7G3iJemCPQz7yLsq+QG+SmAGEKrqoxODIKMaRnKlpk1CwuAu5E3xL25mv2X5uW8tYBJrTNZSOaxWgAtEYW9j66CL9J6kNfY5jSl+vd+Tvu/CHPMNImRKQGQ= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:29 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:29 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 05/10] btrfs-progs: tune: check for missing device Date: Thu, 3 Aug 2023 07:29:41 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a35dfa6-9ec9-484c-4df3-08db93b074f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 89ZE6jVJraUVYe1H4rBsC56KVD002NqL5J/ii+oXe74OLggGf4kC0VZudVX1FsLmKPUTRgn5WotiyN6KVs2dK0dql1xE9BTAouivipcJL+8Gkw7RbXiyBXc59dN8hqx3OCaWHu0jQiQZ8BZWNNQeICL7nZoOd60fClvbMNEFUhh/Nxz/9UM0UiJZ3znJvOxhAsNyPC2BXMaiL2OwVb0V50LrAHAggbma5EL3P+ZAU4Lssn5lspuDkA4NmNIIDJBPftLpaI+NB2ECDTXajDq4ICpXlWb6Yd7LmIOiMJ1HOW3/nJIqrkaIo+i08PK/RbycBMBLpP/1c15jX2Jao0po2lQtKQfDa2CzrZmDAhl6xw4P5kLYSl16WXFaWDXR1t13huZCmIs/AC7Tu0xcPEBZkTkNybBZ0l2iHrN4FZ1aNNuZUkVgA0Q3jQfqEcJ1xp7QPFCh8CRrTEsOlnGGyWeE9R2nTxaFEJ+oktvaKi3WOSO8TsBwrE8quSV9Ic6Xh+37GKIK8mmDFXtutu1wK/iiDQg3sC+BOelhM09+30ll9gTHJBpDEgWPSNLQ1RpIUlFb 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LdpZAQt8z2GpbR8pmU56Rhsm5aAxrIqCOZ8yihHRtiqMgpp2tqKaJI6GAw2V3eAQp/PfFQMNt0iyyq/9AYN1K0OqOXlId2TqILVUUIOlw+P3rLYyU2eYmyS6O8MTUI9TFf6y/hs9Q9JnxcAruzdtQxe8o2nETeZHgpwcfKEpaEdHGai+lGQ3/ZJstmV3Qv1F2VXqADB/IzakwboLMTrFp9P1mDIaWE69Gp2nEgMbsm4qx1Al7StUgwUaICkYQG6QDQ10kINe1MOZQOwSxOheebxWvKX0sjCxhxSzZcHQgzoXH+8Hme3901ejxap5+0bgi3EK1gAZzfskL++xl89JzhArpgqthjwmZN4nDNAJOAPcQOl6RgVTbSCTKQ7ReQlFylihShxk7egykOFiJMziqrlHIwVHyZhSilOV3qtRZsVS6qSjgN7AZ9dFb+QW75zWoqB/KjG5xMZrwMAAKBaB6oCzJ6Tf726HVAGJAbYO1t2iFOsK9/hnytTll2Inr8kYcthmSkBABcLBLM9Rs/EGPKpvcY+e16EO+ujW4iJfbewGVo+N12Rf+hb8l3YY5KZ6k+4PdIKLNThXU+c7L8P1qlsEdrQEljzCu3+mafe1Y/DP7vUarz5TfWuZK/oJX4eBLo6aFnfXclMqxLNbL8WubPkYKutx/LuH7o0s9jwf+nU7Ereg/mVVt6YK3Bwis8CC83LdxZ+l84Wptupd9SBF4E1cLFck55hdlwlibE28ot4I+zWVEGSBah7JkA/rHnX+z0s7beGmnm8qyLzCDGTVMAQuD/eHPaXTp7APJ4BvIl9F1D2WpPeJxGmRoVTQpr7YRTmgziwHhDulI0yla82vT4pZr1kI36TrBZSPonJr76tWJ1g/M+pbVHnDaUSrTEuhSJ8J6nptQ8rsrkGqeuuV8uLPo8IDGZ83gJFDCp02l6SvZ9L6Ino2gwo133gsHrC0bJxasUHNchPRxvIpGBeDT62pLApfKrq4gaNet4pes6cR/KLi130eDkP4DHibLjDYVjtGgPVDWm84VhL4It04sZYacPyecXa/QYC0VS1khTVTxy7lBzFSqsB+/voYea7aThyC35ZAFEiEBw+Hqouq5bV8wFTZL/CcENbZgUKtDaHyPBh8AEETwXcteoQArD3JIzGJHvyVi2k5+a35IsZthTOJN0R46OE82bqfz1X04IqSuJg5/YokNaliIN7Z3S3LtIErR2SXjpbffvf35HpS3p0VHgXNdYlLCRjUj0gCwKlPaUJOS1cLwe79yuuIor9Eak6O2aG5KDMZ/53ynn5LP6hb7Z3enkARhLQFRhIWI9IRVW2G8ryXc7Hz8Dd5QDixnkzwtMoJFgwiA+D1MC2RNA4OUoO6os7A6eETTATBQyHQC9DjwNXU1dj87PFuCyQjUuEzHTAZb/p8oBBx8YoUzapvkg0FulYfN7V89BXlomi4L87l8O9i4lP+bbQurIAIM6H6DDtkyG4saBZwbjPAJ0lbe2Ovv+dmPiedaBMGjmWyVf296iktOIYphcN0P3okbCSlxA5L/M2TyOU/WD8Dhb30XARfQYsuTQSjl+70h9QIkwsax+dFKfxhvN2BbJ6S X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nBjC1Iw9drTgcOiaUK16hWp8dDWwadNd7aZu3U9oHjgpYabYfFzlfwDXMvfr7CQjmjotTGcllFWKC35M+0KQBdltvdaFcOHPoukD7p7VXDWGaejhIYA5rk7vIFYqRuRgkZ/Pnkte1iiqJKpYL20inx8LYcxWG9/EvFe0b2LoXov/QErjradofSv7PaCUk2RQnU4tvMwSrGMKbH0uF0nej1Smib7OTVgQHuuc43W+BE8KXc8yiNytoBMTvndT/mJLqEAi/mDZCeBuyt3NlU7vZ+Bj4caA3SDmQAldjtgfa59/ZolCkjnIIxriHNjFutQHp/CgP2U6BQ3oFiZNF90cohIxNwoOEw8lF42flRXY26YnYzjCfhb3/0yYGTiaVVr9pM2hUDl6mEiR6Bw8rKEfb/iKy6bm1fnUflHbh1Q+qge8kiE7GoeI37PboIbhNvOLzfQ1quMiOaopRGH7xNEp41sSO4lU4e+VDAnhtFKHipMnnr6EOr4NGStmQel97GMJKyVMa5sEHOeYdnHclLuPDW72KjeoA/JQw/66T/ZlpxRM2KwCYoHSrIAGK/5ZFjDGTytRsYgRNK0VdwvNVqX8eF61ZxP5Tq0kpT9GOfVssbTokVsTMq80s1tH9kRf45R8hCaczt3WFjXxMXNhQe30w+zpogzBcawMgFt1kYrSKuasRzH7hJK9g6fz+5FlTY8QaTS3EnEgNOgF/R64q/M8FCJK5u3l1K+JXy/h0xMJ5oe8lkqSEkJD0JSlYkyOWtGiWj5VLMhKv5JEvy/wB1pqMw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a35dfa6-9ec9-484c-4df3-08db93b074f6 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:28.9948 (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: 1mv+D9KaSOCfildDhVXd/tUU7E9UmbP84vXWHYdeMBNWiyiY9dYS0U3BhB71EMaOQGEcqpV7rrP92xmJGhXd9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-ORIG-GUID: xQp_x_-LSqTDxKkr4LG4BKRxOzbsqvVv X-Proofpoint-GUID: xQp_x_-LSqTDxKkr4LG4BKRxOzbsqvVv Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If btrfstune is executed on a filesystem that contains a missing device, the command will now fail. It is ok fail when any of the options supported by btrfstune are used. Signed-off-by: Anand Jain --- v2: adds comment tune/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tune/main.c b/tune/main.c index 73d09c34a897..8febd0d6479c 100644 --- a/tune/main.c +++ b/tune/main.c @@ -287,6 +287,23 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) return 1; } + /* + * As we increment the generation number here, it is unlikely that the + * missing device will have a higher generation number, and the kernel + * won't use its sb for any further commits, even if it is not missing + * during mount. So, we allow all operations except for -m, -M, -u, and + * -U, as these operations also change the fsid/metadata_uuid, which are + * key parameters for assembling the devices and need to be consistent + * on all the partner devices. + */ + if ((change_metadata_uuid || random_fsid || new_fsid_str) && + root->fs_info->fs_devices->missing_devices) { + error("missing %lld device(s), failing the command", + root->fs_info->fs_devices->missing_devices); + ret = 1; + goto out; + } + if (to_bg_tree) { if (to_extent_tree) { error("option --convert-to-block-group-tree conflicts with --convert-from-block-group-tree"); From patchwork Wed Aug 2 23:29:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338928 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 B107CC001DE for ; Wed, 2 Aug 2023 23:30:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbjHBXan (ORCPT ); Wed, 2 Aug 2023 19:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231269AbjHBXal (ORCPT ); Wed, 2 Aug 2023 19:30:41 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 929252695 for ; Wed, 2 Aug 2023 16:30:39 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiGDm010854 for ; Wed, 2 Aug 2023 23:30:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=ItkSvp7JVJ+uAdvNvF0f/SMbKoUJjoC9sUI/0UoCXQQ=; b=ywo1JhLOolFyptgKTxXXT3z210LWbgWa11HKq/f7AZICgP/loKFpZPzq0lrUz5zjqeh2 v2Hx8Tncm4ZSuyy6eRJ8BX0VTUtAGM441up10EN8EGYN/pNYThnbR9rLc+eIDv5lc9DP eR1bGCfp6yF/8OS5i+2aLQfqOL80UzVqt45mK48Bu93z7dRAIYOT9QNOzCTZmyG+no/V mR9tG5XwIqOPa3ZfcAUto62p3bQHpbbWMdcQwQ/4ZVASWyDbuRTjQmq/hdHBoggR9v8Y ECvEacmTUCgKN6cd3XMF83wDDY/7j9SPYVvTyVcEc3D/PzWBJ8s7LJyrCzD8dj+CZY7z hw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4tcu0ct1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:38 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372Mt1nB006697 for ; Wed, 2 Aug 2023 23:30:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s78kyru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QxK+BHAzb9ah3AOD9DlpXx3VST5+nxKEXcOzDayyviXhx+DvCnmhNkXCGFupFd7siCfd9lvNdwxuelWaefFIIbZ/X0gtxp9nCdRfBdvLpm+epHkBpo5Q1hNDwNn0MTyLUduA6//xYemqXXuXnhNz9ZgQa/fxnJ4ycyhhhaa/9tNPxxZHgEEvG/w7DMwHiTC5iVuHMyiNj6EmfpSACKqocDE8MhBnVs/9PJkq2NclUfFVf//mQM3TtgNgOk2hqIODHoLcKM8/3PDA8+6TuC/J3H6/NRLF2hcCa9pvHJ05NJtPDpniBUGP3FRcZxtJ5DDuChzZl5KvA1Rk2cNQnVsbdA== 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=ItkSvp7JVJ+uAdvNvF0f/SMbKoUJjoC9sUI/0UoCXQQ=; b=KXucOcW5W9QR4gxwk9wy0/inQYeMXreeXe7upWH8lpjzh8Z99eF7UvfVIJZJyxO+8CHbONjxdRdl792GwZ8sSronu+mTnswo//RpSJhlUrVePPT/2LnkgZ+rrAICwdpCl9xfGQL0q1M/fWZHAvM9Qqy9AsMaoCZA9WPlY5FqRuieZRekFhd4J96IrQiVZJ02okCNGEHJVFZ1Nj1yrPAa0VHopRWda4rFY72rdoiDQ2PxkvI9n/V/PSzkGM/pfVwsMjcUAkkj96VgbSTXr9W3ABBtMPFUmafjmFyQsOnoKxf12T64ebYnBzB2rkG6raINZIyJIsfTw0R34HDEUTIBWg== 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=ItkSvp7JVJ+uAdvNvF0f/SMbKoUJjoC9sUI/0UoCXQQ=; b=cCXmKvCvDU51XsMySNdGzsDJAX0UY4p/FXojxGDP7DyKo4leHY1YsraMybDhO5wrQqhXMcfDVmWzM2Me/7XKsTp2RD6gWbdZTvuceq0DfUHPFLp9GvRd3P2r/xRg9ln44SMIjg1kU8JI31L4vZgSJ7QGt3BxfTI9hWS79X1g3/M= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:35 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:35 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 06/10] btrfs-progs: track changing_fsid flag in fs_devices Date: Thu, 3 Aug 2023 07:29:42 +0800 Message-Id: <3bc9ce3332f6e69abfd73a89384400196c995da2.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2PR06CA0002.apcprd06.prod.outlook.com (2603:1096:4:186::10) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: e77a781d-65b5-4eea-1562-08db93b078dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tDTsBD/aMiaBeQLyfKDniznuJX7LguDYS6+KzRpcuO+QiHa70vKS1gjW6MlMBdkM8/zRl5aekuJXhiksb7Va3GEbuoG5Sfk8yq54HpsvCdIg9XlZe2tidEqLspKEbW61Vh7/BOap8+4dVgXuMSUM7bobNWTYhqu1//pEccP/mNvGKfSwhLe9QCvliPdp6Z+DBfBlpMnvY0NFHDKVtUTe+hodeZyPdDq1DI7jEECR3rCAr1uiM1iXdv4ma4BYorP5D4g25Igzc9oShbVVD7bBk05adJGhPSJteUhnsxw1lpmzDDUTMAK8Dcae1P1bdS9cx+vAN7DEsPRkawAsZBB0B89nsXLKmCMpwzn9vhP72dRDoHiGibbKm/JCbOqPLlWAEBAuTU7eMcyBwkyfZmivq8Z0WVG0eEdbGe9Wr/lYXuCBSHa8HvcSBMPxVoOyJjBMKdWlF9RJ5JwLSbbkx/kM3TUo4EW2HDvvn8f3k1NYrkzEiX3jaXlkKmpDaUbHDUr2VpVAk39gL/WrKSeZEwJEHy2dfijfgFiBviVqZpzgjvMGP9k3vODIgnGDQgcr4Y/H 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ImSTb8e22hDcPnjCxTto6n11Qx5yHGhJVtrDqw4XBCwi1rjZ9uEOfLR8EQG9bp2G2B2fk69OaUP7f1sJz0vcI0aS3anqpIviuTEz4s2cN5zN0fiJMmAIPYU7x0l3CSPZp7nCUORkgCi8QHvtUWcQT+BXc/+UX96tcfsQMlOIKRBmh/zdoI6YXiiG/LehZVli6TLWLFr4TigU5u8fP3vgMp8GPgmmdcwbjb9RO0U8coe81jEfTtXlGoBhh6eV8iwqPHz2Vi075lJWdPThlBdYLIqw36AOxsbm7t3TX7Faii5PGL3re6w4VTskB16GvtZbuaxaAPDU44lygWkSbI+cNw1arpEs+k+T+EbBInAhRFAPKujvZZD0aUVsk8KBXnzyJWZCOsFWoBc1gba0GHu1xyWhCYHJBqW5NUvEUpZZph7t92gqu5Qt66koQGx3/kbOR5HMBOGDLOkQCVZ/l/O/uThg1i87Jg08FBxi01l1nSOTPQ2hUv/9ry7l9gx4lzEZiJrS5QrWEyNugIB7c/XFiLxZusa9agm5T+gyn19uSB/ixw5tGh/Fin1tvC2s5vEKo+lxo+IX4ZOZTob5+SVUac9TAF5ZmYKb5GDjaEftWbHXejvde7ZH3A7r6ifXDx2cl7M6DE3Y2IxpuRitRV2EtPZdEIGR/e14joy3HqttBTOKHschewuLwn2wVepEJ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MzkWNxO3a6w0Yp7mYLUtVJ3mVb9nuFcu7u59McSaxx3jYgsd53Z8rMiDSrcK769jxBM+gR3lH7REY/X1M6tSZAPOmxvz6YXCQMUhRoh1yXfRrrsNrksnRtdnHKfK0ivfsL/JevS58GinjXAFwwVfI9Eh4VArS+J8ni6AeiD4/Cx/6+fduQmec5tCqxs6ZIVX0NbzmxPL4K+YMFfnWtjYZ2NdAECLC2jXhktq16mfMvZYzn6Adu0fGyZy7Jy6BYk93tWZl6uMWMYSsfN+NZ7kuFKpRZ+s6KpgV6MWK7ZxUucMiHXEOBtifl9UXsIsmb4FvuZ4nk7RyuHBZ9em2OkJKZmCLbNW8ApLLuZSU7Fo8ZLToM9u0w7F/oYA5pGStRtjL8vHMY5NLVtIpKULxAD7Biz1iRUHNBnGXowf7mCyrNmuh6OaUZazp8mKRv2x+uOBNVIw76wFrUD7giEMM61yCZ9ZtZ3ofK3vESNRHs38feJeUSEZG2uZXWmBJtJsW5KV81AWUoUSJfoWdb6gC0S3KHxpZTiVICAhl47dp4tLzR+04JyqmsNptI8/Mgsa1W+SuBQNRvZ9GgXgRRrFyNQZJIrEck8a9MUfLdsn1vtxp8Ghe/GLMGf+Rdz41pNpKXCAdxQ5ZbbQQkEKQH/LihaneNQQcj/pHwTCjj1Li15Qj2tWXJ8xrJ/+6DQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e77a781d-65b5-4eea-1562-08db93b078dd X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:35.5460 (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: DU/Oj5y9YIaYdM6I+n7xKfi5iw2+ms9FVIxLOFqJF5JXmC7Vk0RlRrfr9imz5QDC61XGfjcR+VQdmi8B/5V93A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: 3WFHmvkj8xnFDUnNV7ea3mSgr7t7dh_m X-Proofpoint-ORIG-GUID: 3WFHmvkj8xnFDUnNV7ea3mSgr7t7dh_m Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org To prepare for reuniting separated devices due to an incomplete fsid change task, consolidate and monitor the per device's changing_fsid flag in the struct btrfs_fs_devices. Signed-off-by: Anand Jain --- kernel-shared/volumes.c | 9 +++++++++ kernel-shared/volumes.h | 2 ++ tune/change-uuid.c | 4 +--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 54ef553e8230..375ceaa93de4 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -342,6 +342,9 @@ static int device_list_add(const char *path, u64 devid = btrfs_stack_device_id(&disk_super->dev_item); bool metadata_uuid = (btrfs_super_incompat_flags(disk_super) & BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + bool changing_fsid = (btrfs_super_flags(disk_super) & + (BTRFS_SUPER_FLAG_CHANGING_FSID | + BTRFS_SUPER_FLAG_CHANGING_FSID_V2)); if (metadata_uuid) fs_devices = find_fsid(disk_super->fsid, @@ -424,6 +427,12 @@ static int device_list_add(const char *path, device->name = name; } + /* + * If changing_fsid the fs_devices will still hold the status from + * the other devices. + */ + if (changing_fsid) + fs_devices->changing_fsid = true; if (found_transid > fs_devices->latest_trans) { fs_devices->latest_devid = devid; diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index 24b52c86562d..786add2c879d 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -99,6 +99,8 @@ struct btrfs_fs_devices { struct btrfs_fs_devices *seed; enum btrfs_chunk_allocation_policy chunk_alloc_policy; + + bool changing_fsid; }; struct btrfs_bio_stripe { diff --git a/tune/change-uuid.c b/tune/change-uuid.c index cbfc8634168b..30cfb145459f 100644 --- a/tune/change-uuid.c +++ b/tune/change-uuid.c @@ -214,10 +214,8 @@ int check_unfinished_fsid_change(struct btrfs_fs_info *fs_info, uuid_t fsid_ret, uuid_t chunk_id_ret) { struct btrfs_root *tree_root = fs_info->tree_root; - u64 flags = btrfs_super_flags(fs_info->super_copy); - if (flags & (BTRFS_SUPER_FLAG_CHANGING_FSID | - BTRFS_SUPER_FLAG_CHANGING_FSID_V2)) { + if (fs_info->fs_devices->changing_fsid) { memcpy(fsid_ret, fs_info->super_copy->fsid, BTRFS_FSID_SIZE); read_extent_buffer(tree_root->node, chunk_id_ret, btrfs_header_chunk_tree_uuid(tree_root->node), From patchwork Wed Aug 2 23:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338929 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 F3385C001DE for ; Wed, 2 Aug 2023 23:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjHBXas (ORCPT ); Wed, 2 Aug 2023 19:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231354AbjHBXaq (ORCPT ); Wed, 2 Aug 2023 19:30:46 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5B42685 for ; Wed, 2 Aug 2023 16:30:45 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiGDo010854 for ; Wed, 2 Aug 2023 23:30:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=+o0i9KbfPxCYJe3Xymr46lpr5mvX5oxAiyuCcrs+SCs=; b=FIFt+DlaYD7eSb5ARHjae3uWmsHQjPOBL3+yH0mfls5zMDoubH5yu9wQJ8WZDbJEG/3M AgwzxQnGrAsawbv/NOO+H/wsnhx1DMdR+s4gAWYomzMunh96DGvWlvB/pkdcdwDrxK0/ yaQLE0Et51MaHVjk/U7gl0XIXL36poNvRHjhf0AGBMBn1SrMISa3Je83XpqwNSEQvGXJ SutftDKR+HyVVWf4oa3Z6oq/79uo0TBsp8oGQBJg3048f1+Y/C4dXYn+oyMykaT3JtAY KE32pFOzSLBefIArcM3C4hxHpv8kBACreGw4MRFEgMTlIJS/ooqt8kLr8K/ECfJhD/tN 3Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4tcu0ct3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:44 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372MJ45f003887 for ; Wed, 2 Aug 2023 23:30:44 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7emf9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YzLW033SR1TxnJXwE333PB9L463IO+pC1puL6pnv/FRz8hKiigMVWSnlIZQVgXlP9CaV+F16vPoZPkl+QRrZyEkPYsXFK6NhjZc14SgyVcljfJkOzvDg/J4VFiS1HSQntTnelevIPpHxpDwRQYzfnPu0LCnxLt0aG1vzWb0LU2iIx3Kjh4qUCQyG6rj2W5N9uV62I2RfLwIR2Rtpv3AVHYy+C16p6ZGuyGJuqZMS2WEtCDwDgtMERO9BQ6OP/8L6Nqo2JC+HVHEMvWYaeQcULD47ayb9wpfGxAGaM+9YEHySYlwDSQdV4mlnMLEpselHDxUnAao87VvNABmGpn64aw== 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=+o0i9KbfPxCYJe3Xymr46lpr5mvX5oxAiyuCcrs+SCs=; b=C7z22BXRfmZOoCeV6+CZEVTi/tAeDV8IdzZVT1VFpLO4o5my/7ImO3NEcAaNm3Wl9vwNkZYbZOLMKPxoioRKtpftdFySaajkv2PzNMFKBIR+EWmmkO43eSedZweEGWI7R17MhYCzkfcE5Ro7vK64wQ8aZ8YtMt4dC3XC2R6n3kcqB0FiELaIZGnmS2aJ+Z4k0cAPsfcr6zj6HVsnpEWytTJq4c+CCIRCOOal2kA+7Gc8N0xv0GeQZN3yebqz9wv+4CrgKDFS51vbDh8QGHqnf0m209LB8sT+4nADXs9moPjnH/qJTjz8YKpwwp46K9S1Y4xMe4pzyUs2LQCxmvvxmg== 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=+o0i9KbfPxCYJe3Xymr46lpr5mvX5oxAiyuCcrs+SCs=; b=yT08yehC6QQHoAbUpAI1FZ8O10q78J6XDSWhBeEeCe/mKexFtP+agFaBQHSkdkVWY/71520sSXihpna9sp8MWI2DwG+w9+QWH2SU762OOqNvVAmQkRiBgeswHj1Kpg7a13y1OEupgJHM/9OD9rA/EJaNQOMnHBWM5vl2LVTUWTo= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:42 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:42 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 07/10] btrfs-progs: track num_devices per fs_devices Date: Thu, 3 Aug 2023 07:29:43 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: db0a2453-db42-4434-c4d8-08db93b07cee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UD4mFTcQJvcdLB9ojzCVjbqQUBh8j1z+TL56z0QxGsBlMcviFQYG258pK0TwckCil1fbTnIc5Jr4CGDE2UZOX+N7EUgaPsWfwR71AKZjPrlShEuXw4J9OjPsjQglHdf97t/acIlsO6SsoYtWSGEU3cpF0mtV56kGVFRnNIVrdGgF2LtT9u333YhSUiN+1yWlI+FLw+pgbcUSlcuNAhybzvOmavn9iaeWyNamhWOJXM2K5BvKDDeOIzJoCvg2TpupEVGJ3rfXSW2yyJQ0FDmNWqn4mao09WN6eJ/mtKSSkKZw/ik7F2rVvVSrBkkNw7T9LdDjVU/cpy3eYA6Q4z7FlziKbmxHjSYVG9GKKIntD+CkptYHBgGYTgdFo5tOy0HJ3AH4KNgAuOXBurFxjz8VttTbcl3rxrhJkK+ES8R2oNZmP9ESPum2Qa5Xe64VygmPLuu9XAW/Q8XusbZijqzXvx2dIdYibUVa5sPhqkAk8xKT9lcSIBAq9NR3KXk9VFU6yTr+mW71IlZ8+LJEL+mtd5fPQCfdT6sjikBbEfW3p6ydcvlHMi2AF+wQrqNSZNFg 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I9d/8sANv1A2nARgkx50K0TixiNNOmmfp5UAtSCicFRCvT4H8SGb3RzkYF66a2PoAiYODKNl5FVc9x9dxdBRu2XdDBYCzm4sYvgskfFbMlYyL3UD6PJK1nBaI7EzzjJoahY5DEv8pjC8x37JF/mQ4b0Yd7sKuW3tVCTbtWg7v4Vvxn4dPmbi1ooUKXaL8fiawzIL91ZR+dLRNGr5EApYTuFfMfEUc406XlGfqhU7itCpB6l/6vMPrbMuOi5mSWDQFc7Zlg3xLZCs8UCzypgmRm7IJaPJEfvekshm6pWHilkMesIq0RSwbhMjKWGdz1ybUYGFd5aZC7FrlQEiPQp3UA4h5+ebv/no7lGoY9Ka2+BbY7lcmmN+3hQSOOeRhn8yqQQ/ck0u30uQnbFyggQJBIahk61h0SwgCrivoxcb/YLEBXjeD8i61Tij3cfh0lJat/wOGRJaDJgMusZWDc66yFuOaov5Oq3z52M56PPw30VNDtc8ilN5uvt4HuCKQ+Ed0/L5TNxqttjbPRFcTnPu0LYPGO6xusCtneN0CSggxmx+W7lEn5ziaj+o8okbbiVlVQl45S8EYk0/0BOgUYQLgyOiFD5PBz9WHufV/eYoSTUzI7kXluR6EiPrS9mS/PfNwDq540R9ZVUN+iWvLfcaA4eXcKwkGFfJV6d/xtrM782x0790/zQZL87GvIvbXgnESrN4EFTnl+spoyGwhPQmeqvU5skLyQDBYVbjxpDWTL20AK8d1OVUSuS0k3LY2Bs0q6QglMyUrjUzcF3JivrayVCXOpV+KnG77x+RnpL9MyVgJMxJQIlltNZBpNoWHi0QwnhEYzwfwODC9rD/d5KXhM6Egyhp8EPqjUKL8iqInmDOMTEBroGKM+s02vLzAF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8yC6zKwhnm+T6BnfMbCpbiZqLCOv0IoVvqkhru4D4XSh3taxQARd/m/I6EjZ5c3pNFt3ttBg7ApDVz/S9uaoBDRs6uz3XbPDnG3YjUH48vxwqaQngjDFlxDX71seJlF6j6j395dQy0UatHtPO/yFxtSvEa3fjYzGGz9J7qDYXEOB4EDUm4KXuCFLyn+hcflVBY1zOHMIhUkzHB4Fgn7G/ZL+8UTy8YtXD8AVA3Hi4uzNpcUYYa3f29zjAO0LdWOiKcxEsM5r5qxDSgzuoyrnfxtDP7jZ10KCw2XH/556f0i8WfLgCSK7NJyzBrYGjRPev4m8YJJcd3SbUoRZpIUfo5xTHFfpRwO5UfWfFLImajG3DnadOcPsUjLuOwoQutbq/uTUJTYTiB7bKU5D8gMuJXwrU0djQMlt8FIcM18LxtLOBENdoKnPXWuDx3XkUwjnuibGdqVjlagoPDFJg+zLFFJm3Q2BEvujH34mwCuU2opMj+SlxMQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: db0a2453-db42-4434-c4d8-08db93b07cee X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:42.4301 (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: 26oCHvfUTai56/dtf/q4jtLPonKHPN+26aD/txsCxlafbpDPEVeIQ0v1LI7E+pld6kbY7NboCcw8EhNg3bsiSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: E1DaWST81YMYXfwsmjOgMDRApvWgzrWv X-Proofpoint-ORIG-GUID: E1DaWST81YMYXfwsmjOgMDRApvWgzrWv Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Similar to the kernel we need to track the number of devices scanned per fs_devices. A preparation patch to fix incomplete fsid changing. Signed-off-by: Anand Jain --- v2: Maintains parity with the kernel. kernel-shared/volumes.c | 1 + kernel-shared/volumes.h | 1 + 2 files changed, 2 insertions(+) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 375ceaa93de4..88d6c51e3e7e 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -405,6 +405,7 @@ static int device_list_add(const char *path, btrfs_stack_device_bytes_used(&disk_super->dev_item); list_add(&device->dev_list, &fs_devices->devices); device->fs_devices = fs_devices; + fs_devices->num_devices++; } else if (!device->name || strcmp(device->name, path)) { char *name; diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index 786add2c879d..fe8802a9fb38 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -88,6 +88,7 @@ struct btrfs_fs_devices { u64 latest_trans; u64 lowest_devid; + u64 num_devices; u64 missing_devices; u64 total_rw_bytes; From patchwork Wed Aug 2 23:29:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338930 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 BF1E3C001DE for ; Wed, 2 Aug 2023 23:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbjHBXa4 (ORCPT ); Wed, 2 Aug 2023 19:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbjHBXay (ORCPT ); Wed, 2 Aug 2023 19:30:54 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098E726B0 for ; Wed, 2 Aug 2023 16:30:53 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MjE0V032491 for ; Wed, 2 Aug 2023 23:30:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=zBdLO3bcnk0HYARqSZTJ3hAvhLZoVnW4hTbN+MEOXfU=; b=1MlrPpr4FCBR4nUfCFTY5MB/Gw//ZBlD5EVf+Jxptl51cte0kPvaShWREqgWEUt7kSnr wYByg9gRVapf5l1FLAaJegrU5dEnIyP6kHNscTNolvvqGa/XBYhMIhxaXFEEk3ulLi2k 76NfL9y4mOwyKpauqsruxgRKbymlygdQ+HtWzv6OApfWN71AIVIVHQLDHD/YdktepvaA in4dCFKOhtSaX95dUc7DbuBJWHT9q9SG8l68AdDRKwxz4w2lEFmP52ajIt8vMv1/xrLa rhtPaxkq1fk38neYFffpPVhFlwxko1gII9yw3T5lcK1ZjdmW4n9qrB1sl7t7Ly4nvF4P Kw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4ttd8h53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:53 +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 372N2WS0020505 for ; Wed, 2 Aug 2023 23:30:52 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s78tvmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ITyZyp2g/ywIJ54LhYA0VE/V0ssGWLUVtyKL3fD/m9PdQyy8o4zqTvljadM+UAgZxmAwM76bgbx/kZ9sgZH/iPu3V2UP00cFSxVkjdGQa2IbLnASzhmimkexC3+cEhykz8WmJ+4/RHqQMbZWpCbwDKtbN5bZPaqXOduLOD9yHNAK+xS9dLREIcj4IzRkefmBTm8BS90k6Q+tUUYy8mVxL72v0dgSn1ZDlNxsd66qA7WEY1fEy+SiFnyuF8QrE6zcM5oaz2uXqvx5jUO6CxlyyF1dkgOPdXhnBhbCtwJ5shR94OM5cP7DKIGSPrYSJUIkme/raZsUJgTd0ztO/6CpTw== 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=zBdLO3bcnk0HYARqSZTJ3hAvhLZoVnW4hTbN+MEOXfU=; b=L19DtNekO7YBtkgFj/dZXUSx8i0fu7Q9sNjxOXQFaUjdiGztmXXyfzXuhM0OMjrMODS3VIxhtyLE8qWrAn0a1hhdRQmXA7RQJyWKUT5/pX5qxoJFQ88hcYDeO+tS3Kbmg+9AlW7vh6QoDy2bPGu64iIJ+nVuHcUhdmAgnZLyNeFgp0El1WC/NQB+EcbPySwfqauPTVxQNRbnJcwjLfNHTXbYYXezk7kQtAIXznRWw4hmNwNPk9U9jnW1LznJ/mU5gKarJP5eDp7f4cX4up7HsVTXLxPZE2CAcRDpXLaAe+zC/sP2f6iy9GE+RZ0/s8rf8SJy0zhioZw3LFvIuJoX/A== 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=zBdLO3bcnk0HYARqSZTJ3hAvhLZoVnW4hTbN+MEOXfU=; b=yLQ3GXaoX6mT/MLcqthaMjvPDIEFz152f8quVDrWMQ4EhVb1LFIzzLwM96XU3d+4G7DRZSleCvHr4NNdCq/7R4GGEOXy9/zEoxHnkCPNyx5Zy3+TRN8vetSOCrzK8yoYHT9Rk3zpk8F1B44jO3KqALnp6FyP5sdL1DPvRx5LSSs= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:50 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:50 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 08/10] btrfs-progs: track total_devs in fs devices Date: Thu, 3 Aug 2023 07:29:44 +0800 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SI2P153CA0007.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::8) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: a167db3f-24b2-47dd-df90-08db93b08172 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MaGXCxLUj0c23A5Nee+p38M/Gp2mB+GstZa0YpiZw/AgnKU3SyGcYbRigeVfXzoenqbvkX009OnHCYHJ1u5ENbf/h38MISudYgsHUlDeNUX4nZKat0BvE46ujJ+HW8UhxTQtC0HjBFdyEg3Uj+hfqhAK+A3O/EKL4gDhK0e51p05Nptl8jCPLhRWGkEeuQrOXe8Q6r8X/wjX+ON5VsEOUSlAEoMkDNY8QkfW1lwhKDAifNpOJCqTJ4qqWt52eaN7GslJE/CRXqJOERFFt8hhspzBGCFU8sqxlsTwQQFrYc2s7a7nEIaCH8NZQAfHTc2wPGHAsluUjuMIR2DJ9Uhzo6OYofDXKWyR0IXgWEirdJyUdtJxPhAn4EtXPgraSGiTw0froVNn8T982paoGRUXzQknsO/MDA2Cvo+JvxzYC+fK8Hp5xK0O2SXwS5rxwpnpzSQhV1zfE9qZTIxbc/04t2Me+FDXwWcyhgrAXV24VSVNN8kQoYuUQLsOyaiOoP3ZCBvfgjcE8HfAlsq4fixKKTDuiWyJyAGweyJqhFrpp8eclCjDEZ43hV8sfogQr4cm 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TcOilQoSTnBPuICWrlI43Wr79vbnWapsAtZhbzt2eTaRlbY2L31bEVvDmZvH6Ye+rilN2iR1tpF1mgAnYi6An5sn1Ub+XGuAHecr1vMtcTo99BHjvxOlGeB8KLjQ768RFHCoX5BUHB+z6tp+UyFVjhIahE+MvLzbLfE+gIqmw8QPCQuuHeQD7RWv8suoF0tgNTv410Sp3Hu6ZReQ2t38H3Dq00c8ENtBRHeq+14VHkvMXZuTV39D8G0FGqj97V3HINjeNnBBySOBUahqpz6GdR/SWisOvMWPNKrJZmv96SUKJxq9C5mZq898mrIR4pOlSiClrOmrJJ5SMdsCKApPcGWheBOWXU4k7gl37SuLq7BFXEoGKKF1EEJn50KaGxgMS8X648Ao6OFG/LEOdNRI0gWvSf+YfUXM/uGeSgdYi7X4qicXK4NTwdoXy9V1xggsuDkvNN7psaSOx1OFLPm4gXIQDhSPCuMDdYLBUls1v6m9URWELWejmnf8pcFmhu6YtsqjpaC1gKITqetxtc9iKiWuTEAVWCp3Gl7R3U11SbOVE6D3yOUbS6jEi/oDaRUbvH2X1Gb1ySX+w1FDCmc5xEWlG1v6nK9nZr01UVnZE5eSqr7TcxAvi0tidtBdJsb+IaGpyTwt5bD0oYaR6b42MmzoFNqO2vG0nZvfANQ2Cgb2xb4+5m/VAd77MCfkf0wA67Eizc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Dhw3lwbCEsV0QaLaiVOSwKFQE3QFCq+BIxVm3LW+nuoU4gMIP2+/z4tzXl4kU9hapVD62kT+14x52TIoOEERznVLAp/liuTg+3DgSg1YsmPVD+VYIX96Crj4S2QD9AkIrM0PE62vH0Sbx2gblIaFYwXikh0qGrmjdBQnqCuumLqn+lrWmb8GLNomxaJjeWG0C497SnG2wAXJWcN4QCJJAfYpneFGgAhpzSKMjvATpirSegYubgUpc9zSZAy3hKf6XwRdLEfx0+jZcWM5vi5UcSr5us42k0WqCSteCkWUXTXTi1OdYQbVqZh8kAX321G0yDYPdiMlqqexwElASYiJWMSiWbBC0cEKxAmcT2xFfpNdJcgfL6Qm+M6+U4pfDGdGFwhq5Wv+Ul8/LBTHS/6uyN2S8cDXruY5JCu20ict0TMsbeWHdWWqX3m1dkvbIFByPxSvj7Bj6EiXGS1y+jvjw3Y5DXdyKWHKGodQu7pJ4jDuLzq6RTDO+b18sCtokALqZuI8Kd0KjB4SLGIxdbxNirQmafSK8tS6kMw/dlUygYSttyj2UEClzLXgy7H0ElTjy5ELOtw4KH53pekYP+kF4UQ046qALkfTUD4KXKZQ3E/8dDT9Wmrtw2wcGAfbqLUpDPMoKN8/FNOTeFQHGIIcvKAnGIS3c6808Ve5A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a167db3f-24b2-47dd-df90-08db93b08172 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:49.9493 (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: Fcw7Hi1Voib8RIFjXYdX7ODjrj4IMZZa+jTVSP/49ZcryahN8v38wNjBO5/hhGLMmkDWtIxvmeUatQ+O8Lh8Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: R8aZ3EAyV07RCiTnYVFO94G9GSV1sHdj X-Proofpoint-ORIG-GUID: R8aZ3EAyV07RCiTnYVFO94G9GSV1sHdj Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Similar to the kernel, introduce the btrfs_fs_devices::total_devs attribute to know the overall count of devices that are expected to be present per filesystem. Signed-off-by: Anand Jain --- v2: Maintains parity with the kernel. kernel-shared/volumes.c | 4 +++- kernel-shared/volumes.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 88d6c51e3e7e..1954bc230462 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -367,7 +367,8 @@ static int device_list_add(const char *path, BTRFS_FSID_SIZE); fs_devices->latest_devid = devid; - fs_devices->latest_trans = found_transid; + /* Below we would set this to found_transid */ + fs_devices->latest_trans = 0; fs_devices->lowest_devid = (u64)-1; fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; device = NULL; @@ -438,6 +439,7 @@ static int device_list_add(const char *path, if (found_transid > fs_devices->latest_trans) { fs_devices->latest_devid = devid; fs_devices->latest_trans = found_transid; + fs_devices->total_devices = device->total_devs; } if (fs_devices->lowest_devid > devid) { fs_devices->lowest_devid = devid; diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index fe8802a9fb38..088cb62c3c32 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -92,6 +92,7 @@ struct btrfs_fs_devices { u64 missing_devices; u64 total_rw_bytes; + u64 total_devices; int latest_bdev; int lowest_bdev; struct list_head devices; From patchwork Wed Aug 2 23:29:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338931 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 E9071C00528 for ; Wed, 2 Aug 2023 23:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232824AbjHBXbD (ORCPT ); Wed, 2 Aug 2023 19:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbjHBXbB (ORCPT ); Wed, 2 Aug 2023 19:31:01 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2CD26A2 for ; Wed, 2 Aug 2023 16:31:00 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiQaU002262 for ; Wed, 2 Aug 2023 23:30:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=kw0RkFQ/8vk+TXFXb3kcO/UIb0BkeD0BgW25fa+dyBE=; b=3dxVDPpgO2KZzyhsoPKMdtUcnGNPVV+lz0SzLThsAXuMlCxQstDf/bI9JAlgcRHmP4Dy Rjbs6FOo8cQvUgGkTuw5J+qpfQRsUHbrQoyidNNFU4mXwjh1T7Ibnpw7qVVfGPm+HI/Q pRsjUI5/Vz7g+ee4Y+D7s9mNED+2ZmosTfXDYdQ/YgGmKGTOT3/r3LiT7mpgh7rmy6AA 9iAbamyAhgGEMfaCl6CvVQ04gR07mgphc5w9HlwqcvWxCB8qbUXhF+X9wmQm/53UW0HC CN2JFm/5tw86ty1LgL4zZf33cIjwEgOHB5W7PD9jw8bnvxxGm/VDFtU5rlbVxhmg3fVK PQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4sc2ggg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:59 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 372MTca1003917 for ; Wed, 2 Aug 2023 23:30:58 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s7emfpx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:30:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aa4mdoqn9DWN7YuixWB7r4nEWlWGBWrO0WKZ+LAotkQ7WSxpldAcFel0+6AluuGldJ/wgw+MGlMHdmSsahOTnW04qSf3CbmCW3vGwgg2/H9bkK4A+mw4WAXEv4rWp51lTCPiwKc7VR8WDEwMyEBQUWHGi43YJgpwCK+yTAkUQphw1YqtoSYGvd8dWoUGw19YgP0vExOGp+lcwDY5RyLuTMnyJ+GNb+H6uBiz5Hc4WAZjhvkb0oINqqE+CYtuKIX7CZdku2Kel10sFiRjMcQI69UsA83HyPwQKauA7rv1Ag6WktTmc5e4AUpKzBC6y07wPSrBTs7beq4TLP556OdLOw== 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=kw0RkFQ/8vk+TXFXb3kcO/UIb0BkeD0BgW25fa+dyBE=; b=NrdXO31UIUbfeKZYWtvQka37uI/NdcRAP29MYaTdO3Klw8IgdsChUl2UstsBe71hED1Z8bdnQu36w6frkrvAZ1DEnvVMN7lfcEVKwLWU+e88jU96fWNDq4CYzcBT0+UKbU6vEDTwd7Oh7A/YSs08ctcDWiHSQ0ibGSD1rc+HYPyJk14AJk+bP4nsP8NeCnj7hlAfNAhdm4Uu5R9hgJArzLkcddc2CPfoqtMP8qHQFCdNoAB0jrPVoS2nE1+aWlUusCWAedtQNBTvhVxwJJ7kG9FX3niG2n0zop1NOceaAu6hWeoSoouVClPEP4q35qce6FBX+GE9G2fBHXTHA4+bhQ== 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=kw0RkFQ/8vk+TXFXb3kcO/UIb0BkeD0BgW25fa+dyBE=; b=bBje7bY45K4ZkIUFyZyQHPsJyBO1Mp365lCz1Vgc4WibT+g0f8CyoTQiQwmZdyejQ1raBZN2/DP/J/fNOyi28JOYGmZ9KR3BeEKyz94wIKNMmc/DTz7swe80fytX1Ghl6vMLSnN1InWE/XCXknzRh4vfchg+cp7YHh+oQ1Efdtc= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:30:56 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:30:56 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 09/10] btrfs-progs: track active metadata_uuid per fs_devices Date: Thu, 3 Aug 2023 07:29:45 +0800 Message-Id: <3d9fedc25a03ffd184cceda162ef13e6427dfab6.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SG3P274CA0012.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::24) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 1620d488-6217-4d1f-9224-08db93b08565 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pSV1+aZG28wvDEiGrwiZsgSAhHqTd38pMAFHrnFwsDh/pGYvfaiCZKMx18Ms4qYqpziPiGq1mh4DSydBhhyl9ubcYlZlsJHwXWPpl9VipAPRyupGyAn0auOQqux87cbxX39dfnpf4unk8JWmQdWAfw1kpqMBEwPwrDezsXqPZTX0Lab22CXY+OV0BkYsZs+/Duct0jNknow9zADpX/Pzf+yaonRpcmfQzDWhmbOg0vROc+nl0wRDLC2cXJLB2GWx2WsCYvF4peEOH1f2uh7x+dPc6EV1b8QeNw1wCTVo64vRpQj1/At3ErGGNrhSMKN52lH8AnHl/p7TJ48fa7pRhLsoGP2ZKdgcsLdVz7+secVY/ayvXYHFzTajwx8H7FXKxjeB4FwaAWvt0jR3QxLBh/VNX182ljNqa/gqgxyh1ggzBVhuflUhyvS4x/BiNtuF2mhIFMq+Y6LAnCkpwWb4m50OT82Rsb9APkItiIjZ9XiSgNu+XcR+LjiohEwZGgUGFLy0XwHbbf7Pd9sgTGAq57KEda3rE6NU9yy47aVyqfefFmCgzvYswwesqORYv6sz 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lqIQiZg6vLlAJDNLqysq1NJH55aOURCNH94NlHkJGBA+VdymOcQQpXpcn3fKO/g121bfJbIL2h65ZMWrTa+bK49L350B2X1VtyPFMfffnKEt/HgFYke96X5UvQBXut/PeHkvkWDL71oHJxSHq2R8OM78wNzCH/DT/NXydv392dI7l4i48MOb63Z5/dX6V5Z1/gQGCbKVVCEaPI91po5QA3ui4i2cHioVAHLr4wWtz39+pX1bMUqnM/LTReJvXapvXUfvEiE9xWXFH1n9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CEI91VxO1y/CguSzBz/3m2akgNMX98sirC+4+3fR7ZFucHyVsWVH9ehmLuBpgKUCsL1JE883HNLpM6sLxZvEF91TWLy9mWcYRVlluYYU+zC63qiIsteE5RZBuLVw3kNrCSIybY+KdtwvbccKn2zziKBjZfiat+FOCjeUcfi74888Of5SXLiWbvy/G9h4HoMRD01vkSJ84EVxIiXgIjAF5Xh5L8J6kQdEdb5b0AKnLvR26i X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: /IIlAHzVw3MTxwyjcVYPU/zrDaGO8JDRt/T8HSQ2Hso4wwzL9Ok6XvyKd7OH20lVEiNNGF3VVYHkJ1hxZUflLTq+DiqywfT7MmNSMcXHQC+K+CNVLyN3F/JD7xswBGM/GwC+YFuoVgdn5vOOoJ0hIYue2dnCK4pVysvFQ8junWKB5w78J5s+l1BouFnEAn21R3JCpHKEXAsIRQkGUsywHspTUUzYjEirLWRzgHU/LPaSt8fDvk+Xlx3iu72atrUdCd+Y4GcsySiopyPdFQ0UQ+qm2uhNeZG4GxNM66Lw/4I5hNNO91NDqcU4t6RpjcGrF4BMqAppxml49AFvgruVZQiOSRv1cVs/7KkWjJOUTtddWeC15qw/dFhI6Rqxgoh9gSyFT019KZLNPONfFW4IsPx4Vwpe4MQRZu5WnNKQd45DZXct+VTXjWBxf0A2B13vpyyRZiKw+0e0o8dYcDEft8WaTgGjgsVtBV5Jy862vpQGk054frWPKcKC9O6MnGu8xm4RZE/bc/MCUay5HRTXwQWnej4+lVSsd27FHH4iDfF0hYpvsgv0u9A+s9YRQFi1oK2Zz1QHx2cwQeCD4kha42I/bvyzA6C1BRas1ngmestz6dPTDUDQKMqSExSs8h9JKr3zapAxiZZvH2GlykpnBfo0CY9fmcQq45k47oF/W4m2kW/kKBYbt1XCutbEJNwsmoBvyJYI/jRSHW26fZaAXGJhlslDJX9i3TRA2WeKr+EaHEDBuieFALeZZyT5k/rteZlYrg0kbXNctsS7ALygwQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1620d488-6217-4d1f-9224-08db93b08565 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:30:56.5858 (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: JcEL+066HD/DDcdXU1iecrOWyGKWO3TyU09pL8AG+gBLlm0OTy9ffVwHgACynOVQTa6Xm99XokBLFLdd4v8PLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-ORIG-GUID: g63NxqVnjcOVTw8tTbTkMlAYrDMKHi5z X-Proofpoint-GUID: g63NxqVnjcOVTw8tTbTkMlAYrDMKHi5z Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org When the fsid does not match the metadata_uuid, the METADATA_UUID flag is set in the superblock. Changing the fsid using the btrfstune -U|-u option is not possible on a filesystem with the METADATA_UUID flag set. But we are checking the METADATA_UUID only from the super_copy, and not from the other scanned device. To fix this bug, track the metadata_uuid at the fs_devices level instead of checking it only on the specified device in the argument, and use it. Signed-off-by: Anand Jain --- kernel-shared/volumes.c | 2 ++ kernel-shared/volumes.h | 1 + tune/main.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index 1954bc230462..ea7bfc66a5e4 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -435,6 +435,8 @@ static int device_list_add(const char *path, */ if (changing_fsid) fs_devices->changing_fsid = true; + if (metadata_uuid) + fs_devices->active_metadata_uuid = true; if (found_transid > fs_devices->latest_trans) { fs_devices->latest_devid = devid; diff --git a/kernel-shared/volumes.h b/kernel-shared/volumes.h index 088cb62c3c32..23559b43e749 100644 --- a/kernel-shared/volumes.h +++ b/kernel-shared/volumes.h @@ -103,6 +103,7 @@ struct btrfs_fs_devices { enum btrfs_chunk_allocation_policy chunk_alloc_policy; bool changing_fsid; + bool active_metadata_uuid; }; struct btrfs_bio_stripe { diff --git a/tune/main.c b/tune/main.c index 8febd0d6479c..d6c01bb75261 100644 --- a/tune/main.c +++ b/tune/main.c @@ -412,7 +412,8 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) } if (random_fsid || (new_fsid_str && !change_metadata_uuid)) { - if (btrfs_fs_incompat(root->fs_info, METADATA_UUID)) { + if (btrfs_fs_incompat(root->fs_info, METADATA_UUID) || + root->fs_info->fs_devices->active_metadata_uuid) { error( "Cannot rewrite fsid while METADATA_UUID flag is active. \n" "Ensure fsid and metadata_uuid match before retrying."); From patchwork Wed Aug 2 23:29:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13338932 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 9B4D4C00528 for ; Wed, 2 Aug 2023 23:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbjHBXbJ (ORCPT ); Wed, 2 Aug 2023 19:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjHBXbI (ORCPT ); Wed, 2 Aug 2023 19:31:08 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6102D2D49 for ; Wed, 2 Aug 2023 16:31:06 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 372MiAmT024947 for ; Wed, 2 Aug 2023 23:31:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=XLaP9aAyX4ILfVTZ0oY5MhkqI/nwH84NYbbUYU++yY8=; b=qz0K/mjuFTaNsrfpxrfqtX9kGA2mLy0LsqUDNsEDTl9qczVgTUNMZuohJ80pir/FnlnW MCcwhqQhwUsoR/dBUDjrsHvXFEEFRI9nh/MHvQoz2PzF759pOJbzGyOajxu+ihrvj/S/ dooXA8V67tZL02eV9QYkqVVrA34GaDRbi43VX63yjY/grY4wIGHGjA0IU3SbbjusVSTT 8bUACWHBbGXZSD0FopNFDMYVlEcG/5fZ6RXTRxlmmnzKu39J8rLBTz4L46noVCp7A0VQ 0DKDSlZn2mHc7tFUCZr6r1REKzHRgMa6qIoEmYiv4t/6BQjBXq4hVmoiNlYrI2unoRPN qw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s4s6e8dds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:31:05 +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 372MNfqa020585 for ; Wed, 2 Aug 2023 23:31:04 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s4s78tvvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 02 Aug 2023 23:31:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UCXpENkLYmG+5jvabrgKmNFtawDkHmi8y7GnPfFWXHXfnr9xQUfp9hJT9G8VzzqfGyt1R2OQDrUoJXrHC9acnI7vf0bbw5pwcoK+jLMX/+T4F0bO9wJavJdIQTqf1TSeh+70kDmeE75ZEb6qoO19NaMmMyXh96yc9agEri/1JQBkl6mL4sWf3DRrksOdG/kTrm+MINccS0VadE9Q9h2v2MuskwpPWd/yKwO0RiHG0rmHcjKnrEEqMUNUCZJOdsB9WnbULt/ES4KLcRc2EmXwjJ8s2Os/9VyTLiP4vWTA6X8veoLqVbsiboslt8GZXhZw6hEuvdMrYAE4VcjeLAQ+vQ== 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=XLaP9aAyX4ILfVTZ0oY5MhkqI/nwH84NYbbUYU++yY8=; b=Uxekwc+0BmEkLY1I9xr3UpvEz3r6k6Q2Bpb7Jmd8lcrB8kCuLFw6DU+C+MdlT8Sdw32XU4QVl/14vaxYCIVZlHLnJsS62TUIksNZmAZgXPj4ZWDWUWBnIW+mq9gsIu84x2qFX1ZEcUq+gBKgoeLS2jXNdm+pv5OMVxbTzRNTuqs47hoyoheAGNwZoOaqadS2ElK4AznvggM6RqQyNcLkLbS2f6siK6FCS3xuiNNAO976WTCrbS03vfiN2wuAVp2Kw5o/I4wCMvT8W85ye53iLPLxy4jXkD7Xcs7nj7OZWIdbqEsNBOaa3r2xnDZRuo9rmgU5O0upKm08iU94nElQVQ== 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=XLaP9aAyX4ILfVTZ0oY5MhkqI/nwH84NYbbUYU++yY8=; b=vbEiQbeSR2KnIriBxJexp/YdvboGazBOJzasOsCvq5A2KuiXeiQIVeWPfDWV54ja30XrSpKtuXk2cJikm8hoAYD7O1wVtGMLKWTDMJx2UB+CVPId1iU6TK5h6eLJk58cD99Zpj/cAjjRSM+fLpU2jCg8ZRBAunC171mR9gr+2Vw= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SN7PR10MB6383.namprd10.prod.outlook.com (2603:10b6:806:26d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Wed, 2 Aug 2023 23:31:02 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::b3cb:e0d9:ef96:aa56%4]) with mapi id 15.20.6631.046; Wed, 2 Aug 2023 23:31:02 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH 10/10] btrfs-progs: tune: consolidate return goto free-out Date: Thu, 3 Aug 2023 07:29:46 +0800 Message-Id: <27568376033263288027ccb60dbbc0d9f78c4744.1690985783.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: SG2PR04CA0171.apcprd04.prod.outlook.com (2603:1096:4::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_|SN7PR10MB6383:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cd8e92b-1d8c-4859-17f6-08db93b088c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o8YSlBp9tqESiDGuNPXCQGjnD9UNOojWk7BgDL/D9mooGqru1Jbhb1GuMznOswVQO6KlmC7xm2seH4G2k3j8Pcu0pauFsJSQRG/xHdvQ8v04avXCKMvuPOfll0rwjhzuNADTjIcGvZYpb+2qtts3Yueg1ZgpEyFGbCbbh3lmSn1IkqKmDuclcjZkcGbzG1Pk2gpz4W86M4W2UDxX+R+cOWuhpqcRxNsxBraPOfq9v1els8uCBqlU0jxcjCV7qvS/WReC1zUNXyzah12dPTTOaQNsMg5gIuwmBXz6nDAHMKV3fT8GrlzVf0OfhC7AtvtK5aV+y8QESD5s4Mvi2P7r1OtIR9ihqdhtJkpVoKxIn68dgI92C8VteqE2YQB1AK0nMXtrHyH8gWy1pAmXMul2gQsaI1tSEfHeLiEzRXbaLrRMgZuiZzYF0kN+UWSnY/DwVwqzAe5zF4aE2pTU/Rq6Q10ywSkrRpBx0tnHLgFD/SWR42u/t13gbhER8CM7xf8xRZKY4rYzFlq2aN8coXnKpncm6N6UCaxaOMUPnIXwT5hg0NduXAIcQX5asx3I6V+8 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:(13230028)(39860400002)(346002)(376002)(136003)(396003)(366004)(451199021)(2616005)(6506007)(26005)(186003)(83380400001)(316002)(2906002)(66946007)(6916009)(66476007)(66556008)(5660300002)(44832011)(41300700001)(8676002)(8936002)(6666004)(6486002)(6512007)(478600001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: duGQ8Is47Ex7YPpsrbvXHSgm3WiAo0mZGRfiyaZfzkOUyG7O69vNxl+4pwnRgknZDJVLN7XcURPIgbLPBQfR7pFd18ddkJDJna0b6ysvzB5YCT4ZIRIJ1z9m0v6Ij3YUhzrm7gY770kXhRZPiDNx6LDZt3tf5xpxJ0ylGwXxf5D7f0n65sTo/vQCAkusQIX6bi8wPgtuTvetqYbnve2Ptabh7rNlfsVB2oBq31H+7wwkIpTJPSHgIn9s/Raa2tPzpl6AMOQpLuFubt1I7RktpfozLRc7pEbO7kg3KrllpgmsFizUqkYkv5meVSywjxT1s5d0IVxLcg4tTQR7tSUAmfrhwrSgIyLOV3N0bGWLSqX0n/5bjotwG6FLiIKdHhvqtu4bQ47lX0rM3J7WtND+4ZVM9BhvQhptlnVwR/Xd+GvGSuglxDGEv/SxSwAxwBPV7spw75xXPOFeIJRVTsfBV0bmGZrw3atxlAWnjXDH8zUdoBRtLK7g31ZQ8L0oY/HM9vWq/EIZJoXU16MA9ykmUj9Ux82Ndp7nVaVkK/vq0ZlmROIHl4MXT6uGUhdoqR4MBUzgIdHDJvTsnqR1Zgwv7sigNb+NDFGCQ7EPcubAJBvIGsOu/FWtMMOeltd7nIRdUm+FgPeGqe11gzMLjZZWqjK7jpoyshl9DljHjsd1ax7pk90I1cZBVZXWnLOFLMQ0zAqtdNQ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T0oqVpRg+VAgda+Abedk0c513t1OwQJGjSdUr6/5tKeZMu8YS5a1iI/7nGet/+v46SOcdpyMcRaGdId1dDYvK5T8d9SlWoey5CRTNabryAHg4deWOwoCuArRFm46F6z+ujKmU/4DLZsznv2zWf6oQjPhl9munPGxhPndCmnrp/+jo18k+doyQkLdZv6dE056KSGI6YqDOnhTVUmt0azkaYg+mY/qN384lpVQw8l5UzGNfI0UULUhJPrgPs4Pkhhuz7/ODVR3xOJzyPTKY6++vHmuGfsA7kS+goGSp/DtCDckYZucDoo2gXmRoT8lGM1KnTZfUqOtMiivez5Iqk9cASeUllhzATwKDttXjnjVWF2mlSiul7aY1RAmUxEhqtMyW8Vp6c6kKj/5kxgwnWrxtLQc1zWKjy34NixMakFeJTFMAbpGo4JcqES9OiLyx9fvj4OiT1pFXI5/7nmoqbIHP2QAkt0FSP8xTCY7Z7zpDZdUbD2Of4tLPrqWu55F5QIWu+4szdX1AzVHJYY8Jw9PFsSG2eJi4BrT0BXgbj8j5kJ13I7ZWM+Z536Hf3rPoD7CFquJ5PouVXJoXbuE/8n1ZC/ZswEe68Xmi6xFzwAiTCDGWRBkjH4ZNvJl9zY325W0eyRHCKe2vGrARBM7cpVPyXrZb/gaaSdFFXOYiWRPDAXTgorhm/bqrE6kJ/kM+jVGCg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cd8e92b-1d8c-4859-17f6-08db93b088c2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 23:31:02.3787 (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: H/Tszfk2rxlJuTEK9/W2R+9lyaM+RczTJZ1PNykcgXcYHbfW6bUYbLApVlSAkF/aUVXzfigLIUBIbePH8s541Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6383 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-02_18,2023-08-01_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308020208 X-Proofpoint-GUID: gNPI-SDu0WeK65Y66LP18NGMqoRZyydh X-Proofpoint-ORIG-GUID: gNPI-SDu0WeK65Y66LP18NGMqoRZyydh Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The upcoming "--device" option requires memory to parse devices, which should be freed before returning from the main() function. As a preparation for adding the "--device" option to the "btrfstune" command, provide a consolidated error return exit from the main function with a "goto" labeled "free_out". The label "free_out" may not make sense currently, but it will when the "--device" option is added. There are several return statements within the main function, and changing all of them in the main "--device" feature patch would deviate from the actual for the feature changes. Hence, it made sense to create a preparatory patch. The return value for any failure remains the same as in the original code. Signed-off-by: Anand Jain --- tune/main.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tune/main.c b/tune/main.c index d6c01bb75261..7951fa15b59d 100644 --- a/tune/main.c +++ b/tune/main.c @@ -145,7 +145,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) bool to_fst = false; int csum_type = -1; char *new_fsid_str = NULL; - int ret; + int ret = 1; u64 super_flags = 0; int fd = -1; @@ -233,18 +233,18 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) set_argv0(argv); device = argv[optind]; if (check_argc_exact(argc - optind, 1)) - return 1; + goto free_out; if (random_fsid && new_fsid_str) { error("random fsid can't be used with specified fsid"); - return 1; + goto free_out; } if (!super_flags && !seeding_flag && !(random_fsid || new_fsid_str) && !change_metadata_uuid && csum_type == -1 && !to_bg_tree && !to_extent_tree && !to_fst) { error("at least one option should be specified"); usage(&tune_cmd, 1); - return 1; + goto free_out; } if (new_fsid_str) { @@ -253,18 +253,21 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) ret = uuid_parse(new_fsid_str, tmp); if (ret < 0) { error("could not parse UUID: %s", new_fsid_str); - return 1; + ret = 1; + goto free_out; } if (!test_uuid_unique(new_fsid_str)) { error("fsid %s is not unique", new_fsid_str); - return 1; + ret = 1; + goto free_out; } } fd = open(device, O_RDWR); if (fd < 0) { error("mount check: cannot open %s: %m", device); - return 1; + ret = 1; + goto free_out; } ret = check_mounted_where(fd, device, NULL, 0, NULL, @@ -273,18 +276,21 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[]) errno = -ret; error("could not check mount status of %s: %m", device); close(fd); - return 1; + ret = 1; + goto free_out; } else if (ret) { error("%s is mounted", device); close(fd); - return 1; + ret = 1; + goto free_out; } root = open_ctree_fd(fd, device, 0, ctree_flags); if (!root) { error("open ctree failed"); - return 1; + ret = 1; + goto free_out; } /* @@ -450,5 +456,6 @@ out: close_ctree(root); btrfs_close_all_devices(); +free_out: return ret; }