From patchwork Tue Jun 6 09:27:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268777 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 77124C7EE24 for ; Tue, 6 Jun 2023 09:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjFFJ2p (ORCPT ); Tue, 6 Jun 2023 05:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237466AbjFFJ2n (ORCPT ); Tue, 6 Jun 2023 05:28:43 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 675EE126 for ; Tue, 6 Jun 2023 02:28:38 -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 3562qVQQ013978; Tue, 6 Jun 2023 09:28:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=TJUeNc7CXMpsd+WQUG8PSOUrgRNu8bhCIU0os6UdGgLXKtIUAfMbNGWatW82XCQ8wIJF 4fI/stvsEVIhP6teHLEfNuct+fxtUWAJKwqMFCiSwkR0r/t7lT0q21wmsIYYQOVpm/7o jtQUx8/jEY0jMPPpxamVAS2ZPdz8cVnb39DZCOCgz9xkI7VycNh2+BggcFJnJwHpr2a7 2a/YHTXP2Q99AK2YFYtkyfSUVzvJN32UbEDu/obpft4gVZqg0Slq30aSEmxFb+rUiY3h Fgfitjr7PFz3nQn1pOR0t2FHdqM0e/WU/mLaTKD5cUxjMlZ2sCLZyexbz+Xo57g06gJU rw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2n4vmb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:35 +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 3569DBXO024065; Tue, 6 Jun 2023 09:28:34 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2173.outbound.protection.outlook.com [104.47.73.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvbu2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9sDA0pg/K5xPC+GswmpKpd54yrIH08u5XEP60T3bxtVrihmOJCzbixHhBxSpxATxuiRQCdRaLKnm3xaFFI2LHUchtiLuYh2gXcplTmANFVhZ6y2LL6PBt6gmJoIY18BTwmhRKOOHiL2CZ1FZKXgW34yUDMXXeDcgIVI4jJ/bvm1FiLyKZ6DXu600kx6V17SvibQ7JmkkDR3RCqGVSWZa7wPrTBJ5fFaNqLSuNEwNxujWBO73TlaSuJ/g1kJ/tn4sQ32CfyUjYkkBDo/icHfLehMegGpYpblHoW1VoV6fc5Gr+XzyKtgmHo/1CjDO1UKYzObc1oJiLW4TV9GT0z0Mg== 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=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=bSSfAMl3B+oXTk4Cv+2aQ02bv2ARGwZXpfxr9yKaSHCGySIKmSnjKh+6svMjfcfy3uI1dSM3bHUpu5CseJvsAUybc+qGq1bU26kwazRadMxd8GS+UiAv1rHRLZ/BbD6ZMYSs/1BCfchiqTqDkGrrs+e9qYplxIodql8Tq5Z08N2HIgD9D35gqB3fcBZp8b1T9f7ezKWkQQHwOiHbY23m3tjQmuayToGJ8U77tTIULmw3cnW+fi965fiHQJGlEFwxiX8SqYIp7jt03jNfH58O4Pfnjv8dZXLGr8AaK89nn6tHWOTqTL/xqhxZ7Q/EsguUCEP4gbJ50SH71ZBues04Jg== 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=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=ZLRMyUppdp3ooCAord31lRanat/0Y4nBjHZubRHlo1DKdkj8uhJd5B1HqqInq1zsJ6V0cfJe134SNneodDIBy3UvG+fRLjCbXCpU7xzilKISQ4aIpegnXabVgh+HMfvQXTZ2QJLKQvW+TyUBxEJQ+ucggEf9/XYzn0SNZ6t/5a4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SJ0PR10MB4781.namprd10.prod.outlook.com (2603:10b6:a03:2d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:28:30 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:28:29 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 01/23] metadump: Use boolean values true/false instead of 1/0 Date: Tue, 6 Jun 2023 14:57:44 +0530 Message-Id: <20230606092806.1604491-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR06CA0006.apcprd06.prod.outlook.com (2603:1096:4:186::19) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SJ0PR10MB4781:EE_ X-MS-Office365-Filtering-Correlation-Id: 061a5f94-3b94-4c57-4be9-08db66706397 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DXmKYkDViqARVd27jJdWwOjQHqni7NrCdeNXfnmiBnX4SXpADV69qEc2xhsUrDMj2141zSV3r1YvKNJlDizi8jNz5F5sOF6WlWlS5p0cA/iv6AG+UVUSwZp2Z04UD1rOHeJQofVeBfaHWJwDf3Lz7dFvBFTFHA+qm/QwmMRlwO+wpq7nS2gZqoYDoKNuYdVFlXEOMRhQAbKwVaWX2FYp7cdVzZ22jyf8oXzXCapWWE6uEezCdRa9YIQ9MAtnhp910lDQNBUJmqE4wYtVgHJSPWgYr8gk4W2BOLNfjJMuALcBqcr4BbfWJBiX577VUBeYf+U9aQnr7nBO6s/nkeOySvFZAVs1WwyUCaI0X5JSYwI6VXEN+iqn8Om67yenVgoQvDTbCXit9WB273gXFtTIZMfw25J/fgMcC24FaajcKDrTn98dy8Xn7WpksHydaZbpDrho+tsHMvc7X39toBzFBgIJXCM9ejovEeG0A4JrO6B9Jsk+o9cHYE/PEt7WkunopvULbRJnjGVlMf+ylWR+iK97FMTl0+BIUDXHaaa3TPWPitxwBgq8K/s7gg7HT5PZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199021)(5660300002)(8676002)(8936002)(66556008)(66476007)(66946007)(4326008)(6916009)(316002)(41300700001)(2906002)(478600001)(38100700002)(6506007)(1076003)(26005)(6512007)(86362001)(36756003)(6486002)(2616005)(186003)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vePtjTm1fVzb8mpl9akwNa7ZwcOq8Efz3zhof4bB+biXkfyzG1+XYllFxIoYUJ5hL8Rt6EY87oy4ndk5Mu1URBAWCQ33LfTNbsjrfxSRyxEoh1R7/JuJI/asRy7wtbUHsOtMZFsGbJvLIEl/6ITRJ/9EaIJC9BEcT/8lix8tr9LEMfnqzgMgA/rhVW4VqZX1Pj/zIQeDc+1HttRueMsmAY7xUZAkRrRinOQVTfGODLrNOnTxHkUPLO7do6kQGm2FbBxjZUbvJ4AkCc65a+fJyXaGEeX01s/NBtqzPhBy49W/lXPwTbJ1ZcDvseS5il/qWlV+oy5cC0yjbyZrFmo+GNTmyvnC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+vskleFdpenVvvDKxI3R4XyzJiIviHD0XvqvefVav92VQChY4LvWDz6wNE0s+hTlkGdabhdjWD4xTsVra3NUKr5JSJszH4uu8PZzSR5TICcLlYi9hSZctAYUtWyNNNO2NHiRbhdbCH92O80GHxphdoeVaDqoULeLAbN5hqg3MLM/to/1q X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Te8Ne0zmOPnKyqqP4dQCXdncMWoA0h1dBgBqB7JJHFR15qnXhEw/3POq/B94WCQwy5GGgHpJd052QFDp8vVY1E0X6zTQLK5sR3M8nTrzLPHJyHGQlEL+kROCS23Q3Uvuz7GZv7yQQwXmm3M65dIvGNrZ23D9vERenGcw/vRsYyULKYU2bbTpKDgtjs6Z0dgyTX3t9XKcuc9L7Q9MBmNE1QuwpDzfjDZnXYxz7SCtQ9UeX4GvdkqEpDSTn54jKHTIO3pHaSNlt1aNOdsuNCRFTC2YAi/FhvcS3G8VmwexgwaL5pni2YyHFRdZBKZXY5A9fHVoY6VCpuIQujgszt9k9Ywt6xPq8awA9l2d2d0JqB3ym5UljABz8qMDEc8T9uSHkd6Fs2P1AS2QWgEbIXcGAPGtTCGmcjJArBRQMtwn0cxhC7i4oEqiOygXlWvfs2/KEsJBzjdcE+gNIM9y/CI+pKNXJT59vd74Z3vXF6W6v4bPZa4uur+lAm9tV23U/3QbKFwD9c0MEm/O+dHmyYjdOGeXDO6fbLS/5215avC0S6yO0A1chJ8yBpmCrvSY+3950+8ydaKNQhorcXTaQDXVJ+/lTVuBFUXHK3nJiopCrYxAye2wmXPp/xMHX/flStwCSBT3A7FtwAmDVfvnE4brhlDM2+7b0uHMvTQ5A1cHK2dNF5eamgDbCG8OOJOEvgKvYL26hEAivOE14HbieG362Izn3SKIVzmwA6MiPpZvkV8tDonU3J9RKL16tbMRt7/u5f1Srlkt8YAMedybGFJZEZS7EyebE4YuL/w2p/2eMsM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 061a5f94-3b94-4c57-4be9-08db66706397 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:28:29.9019 (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: VUWopSdlQdT14iouF1t4h2ZLxi9Ve15M0Chkh83AEn+BY+5gMPbNOK3mutHtyLzYv1mgwFI1dZlHfln2sZqE1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4781 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: KqfMqnUeNmOD291pdJdM1MPiQG58jwp2 X-Proofpoint-ORIG-GUID: KqfMqnUeNmOD291pdJdM1MPiQG58jwp2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 27d1df43..6bcfd5bb 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2421,12 +2421,12 @@ process_inode( case S_IFDIR: rval = process_inode_data(dip, TYP_DIR2); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFLNK: rval = process_inode_data(dip, TYP_SYMLINK); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFREG: rval = process_inode_data(dip, TYP_DATA); @@ -2436,7 +2436,7 @@ process_inode( case S_IFBLK: case S_IFSOCK: process_dev_inode(dip); - need_new_crc = 1; + need_new_crc = true; break; default: break; @@ -2450,7 +2450,7 @@ process_inode( attr_data.remote_val_count = 0; switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: - need_new_crc = 1; + need_new_crc = true; if (obfuscate || zero_stale_data) process_sf_attr(dip); break; @@ -2469,7 +2469,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ if (zero_stale_data) - need_new_crc = 1; + need_new_crc = true; if (crc_was_ok && need_new_crc) libxfs_dinode_calc_crc(mp, dip); From patchwork Tue Jun 6 09:27:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268779 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 F366BC7EE2F for ; Tue, 6 Jun 2023 09:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237465AbjFFJ2q (ORCPT ); Tue, 6 Jun 2023 05:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237464AbjFFJ2p (ORCPT ); Tue, 6 Jun 2023 05:28:45 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD76E7C for ; Tue, 6 Jun 2023 02:28:42 -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 3565YZeu017868; Tue, 6 Jun 2023 09:28:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=e4WnsrtlsRM5AMCK2Mc8MpMpEHFxxIpzRyS8vo+6ZXUAzFifgGNnFHmfOBKfsNwwKoRI F0RrZqwhm74URqVfgj9uZUN67hxjUDp0B4DVQU4CHop7G2Ex+721ALOU2ZrtFLEuyu8f kl6lwlldW8w9WfwP+oEpkPHusE3hPBNO9qusMRn2QKssBDdIl5JBZZCXhel/5O4xLWaB DhB7q1HdKDHtHVQVG6mjDMDtJgoeCYNWvIJ/EAUW34N9f/ST2mvnojLy6rfYqlIgFpk+ G9PsoxhMoOeW0TStv3ogy34VVonaDIVcRqEe/iDDFOtNTzkHI9/UShuZ+l9IhazRdkWY 8g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2c5125-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:39 +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 3568FDGh024285; Tue, 6 Jun 2023 09:28:38 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvc20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LZhmaJHVqrtXhICAKZPmDpxbCkcjIIisr6Wjv0BJev3vD1FnDD1bpJXLh99fB0+idFKiV5gS6VTw4G2hSmF/UZvCcxF7kJNjxK7dCZqc0aK9tYfYWoZ1/LcVH/yUn5EzFt/NaP9AdUs4AzUHw7rcMol6PQPvUejYSMFcTB7crYINWLXEgNiZqC2Db6gV3RpaD/rdHIIZeC2rhyvBkeoazWmRIV/P+ZWTSaMFZhNioGlpiseWmnfAnCduJFGUBw712E4AKLAG+ehLC79f6DibTg2Aga/PoOrB3kdcecT1r+njQh0di/BPd3FjBypK7UzZnMBy5OZrRXnEn37Wyzf8uQ== 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=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=G8fO0Y1fOckZv80QHCwupZ/JWVeNPtPelgJu6Uv6v+T29YCDs4X9mxRo6b8dL4FTOnkCaFK4+jgmvYmsxhV/jzbl/MMDhfnLFYZicxAKFd+jPAuHjbs12+XHJx85sm6EmRGSBjMHy0G7faFDBA6jerOBqXBAhQqvn6TR4CYCaYYJXav5t2oNFwZulvAsVx+BYoE0DqTN2K/w+3mVj0995JRfluRZgj4hbY1PBDw7miyt5foWq1Q4jB9KOd7qiF7+Mu+miv8XwMeqjg63ZOaMdii73nBrmR3roY9pfIO8WSbeUzVt7rrl/JYn72GrBP+zr9LrDp/mnFD12Qgm3BKQAA== 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=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=Huau3sc4Dw1IXxXf5phP2tbdHpOe0RAw0B55rSsowrl3u9DdebcUQ/+EpRAV0r1Rg+ravqfguz0T2L53lSW7UO7tC7s5wlRqQMpr69b2H62CYS4y1X4OaTJ+fFX+qvD2uJIroUj5kGKnFClUfSLqsfCP/IhlQ2C8lw7CIhojrkA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by SJ0PR10MB4781.namprd10.prod.outlook.com (2603:10b6:a03:2d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:28:36 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:28:36 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 02/23] mdrestore: Fix logic used to check if target device is large enough Date: Tue, 6 Jun 2023 14:57:45 +0530 Message-Id: <20230606092806.1604491-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0017.apcprd02.prod.outlook.com (2603:1096:4:1f4::10) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SJ0PR10MB4781:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b50efc4-1a5d-489b-9dc9-08db667067c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Ub//wEQwqcwpPzsAjM4rFCUMYjD293YkKEWjvODZ2oJ/Ob7NJEYGYV5vxUKCu9tSCYRyIrbpxRAO/uRyJ1Px3xs/5VlcLQa45FvK3NHFP5fNeNKCIKFcLL6C7lHV9p9ozZXeGiTdUNIaOW61vfNsc87MfkkMzJ39AudOF00QPYOb/ZAHBubUjbL/YzGASaC1DmgQF1EduaZD9BSBLpa/nVyEGc5bU2T7wBsB9yEZTaUnQ6u+XwGkbeEyWlizCPLY+iYMXVc1XK/7/gv2jTjTx4Cv4ye561tfFWhGXW+Qu+0jg3XB+BB7cz2Xamt87vyyrnyORcDbCwa9WXW1JUwDvjzwVmc6l0aZor6vOaNnDBc272F4iCgXW/f7VWxS5g7PVhWJAyjO4qjzPuAMXmtwtZK6+sq43xokmDiW14uBTS7VWjhSr9wvnT5XJQp0xaItic7q+7dgleatCgr8UKZQjXxXAndpx17Xh9uOuJAim1fxUyb+nOb9/gSiRaTTehCwHykkIUSvTjMWrbHXiZCWWwYOH7MLyG71GfsvMDOFdxBDzZM3Z/inzFsQMXULrRt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199021)(5660300002)(8676002)(8936002)(66556008)(66476007)(66946007)(4326008)(6916009)(316002)(41300700001)(4744005)(2906002)(478600001)(38100700002)(6506007)(1076003)(26005)(6512007)(86362001)(36756003)(6486002)(2616005)(186003)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FMVKK+ShkA4hxYbexQfbIZpfXMW7Mvfz0Z4bY8c7vh46HbyVEyXCiPjpwQKfyezVPRn2QVq2+M7jcK46a8GnJ2/K7/6KiAlruzHYoKnRBMe2fBDE1b0Dx2dwjMDYoxHoNuTCXdtQgoVIXnorPkILIFXfZZdEveimckfOqlEtXHPuCsXqwGMC8/SgotfoeQtm8EOvOspKLypS3jlpyzPUw8J92FHkFBGcXBqPBYq+OQf+gfMRX26vk1+tyFllVTVtwx8y5HosHZ/VcsgBhdqUoZxwKLf2XTAZTJ2lLthxUBdue0yHmqKfckU+DTc0kh/37bg38zV5gx08/2kRJ6sszYiGrxq1mQISOCtZMhgi6VR18DpUE7Gd0X2+CvybAaz2W8FbITN8A4xWE8zjXVhXq1R8ew+3S9u3TtQvtV6+z/7nxV6HUjuwhEBJ8SmqOFYSDZ3muOqZu/Aeux7TDHmXRJNbK/g2A9wfb8xCYGU7+mnAEeA/ObrX1+MwhfjVCq4Vq5hPouBM3KDzsSB+y4zOw2QtNGrBD4rwTnNZii5e5dGvLxDl08quqVvWTnqzNLXDtQfsQs8EfS3OINMKDL51M8CQsGu4uCZf3KUGk+h5bNROHW+eOkxZkd5EXdnco14wEIJzJ7M2NHuhh2sIqoZYBkqZPPrc7SIquXlkN1mGoaimqrteEII/Zqs9WkkhCCnbQLrH6cCW29hDbEfRUtUNwHdtaSKrcBVsNU40W26iCy/Mix+0HJPNNTUJyRlnNXBimj37SlpPRy64iiulHUWPSmhNLXWWls9ft1JFNAkpoXP7sXTzGCKNzc+8GO/TxfapGXpTLGGZoFqMXyy0Rm2jT+33sUMa5AsjghCGrdGaTWRX+Lf3CPp2a5a8JfZeYWEpOQ4PjKmQmp+uI6Pd1/39JraajUDttG1o8V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Tbe5+SYWUUVDUyqr2IMM560qW8jG/ZBggFtFXI7RsA/cUHPp/ZyujFVL3ftaKmmUgCDq7q4X/yH4iMqSJNcD6CMN12hRDSCXowvVLshnVC30XbJ/n81JjXeY0d70uUeRjV9xZbkhkHePZv8VCMSgX46eBBG8V7txc/Ikpz2ltZ2O8D+nyfHUEq64innGfVZk5lmzaZh2Tv3G6nuveqK0x5eLdoS1aytCPRAEtztn0pONoosn1iMFGruVL6jwcDrcZ+ppbR9iFWVcftCRQe9meaG5ywm1Tf/oED1dc6NmNRfWPT9N0h1vp1d/uwzA0VCNigBL4yWi0o/9lTUx4yFHaU/KJhwnauVhQYciipn2Vq49HZWDzZ1Y+aWivfjWhOj7eEw3O8VNWtd+c/LfvXxfArRVDo8N/iZ290Avnqn/XZsX57xRyv3Q1kF5fxYJRnjCl69uZtz+n489FKyjNllErl9ZQwEIJbSE2s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b50efc4-1a5d-489b-9dc9-08db667067c5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:28:36.7131 (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: TVfgM4yVddY0b0X5wj+bkdTwhs9mifkFQ3AKTx1dXAC6y0ImHgXetH27TrC+ryOJZQxhDsAOFkXYGfP6MUYwxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4781 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=991 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: cY4HfcDKqAHKFDXqhO4VLCNcCmLlatxg X-Proofpoint-GUID: cY4HfcDKqAHKFDXqhO4VLCNcCmLlatxg Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The device size verification code should be writing XFS_MAX_SECTORSIZE bytes to the end of the device rather than "sizeof(char *) * XFS_MAX_SECTORSIZE" bytes. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 7c1a66c4..333282ed 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -115,7 +115,7 @@ perform_restore( } else { /* ensure device is sufficiently large enough */ - char *lb[XFS_MAX_SECTORSIZE] = { NULL }; + char lb[XFS_MAX_SECTORSIZE] = { 0 }; off64_t off; off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb); From patchwork Tue Jun 6 09:27:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268780 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 8EF51C7EE24 for ; Tue, 6 Jun 2023 09:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236651AbjFFJ27 (ORCPT ); Tue, 6 Jun 2023 05:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235977AbjFFJ25 (ORCPT ); Tue, 6 Jun 2023 05:28:57 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A169F126 for ; Tue, 6 Jun 2023 02:28:56 -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 3565vYdt017460; Tue, 6 Jun 2023 09:28:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Unsf/ykaBVUIqyu9RujVmDC5LVSI23vO9ARiq+Ht130=; b=tP0ys05eDp7ghIAM/YZC2T/3sWGXb1+Hj30Uq9aqnnl8H+cvuDubNoBplvHoEcJUrDu4 6LwSBWMcCZFtJ2jBvldIdCVTkVei0OtXB9K69EgoeV92Rr35fsDJosaVLdcZqgOzBYo9 yRxuQkRQ5mqDBCAaq4nV+iD8ilRx0m1Q2tfmPPtCAnenTYBGdKMMNVJavUxGIG8pWb5g iti/o42+FHaKi7Xj2TQ350ysQF4NdMSfjk5P1FWavTMhNmagYLF3l5dVfbCpGXJiyvKJ nV0wBk/TXdnRyahHK6oXWs5MNGqOzycp9YlM7GWMtlAHYp3wvHGHq4AEgZISbENVQ7H3 bA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2c512m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:53 +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 3569Rj0S023676; Tue, 6 Jun 2023 09:28:48 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tq8wkc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fPm4C9tre6ZslMq4eB/VEv2m1V/EA0eBjyIhGCrgM9OLL5y/C1/fW8tSqCi5ugQQ8MTf5D8CCZM97IFXlAp85lcTliY/A5x9dtRgwC7a0ZBZOWZQD7L6ZdK4W6O3yY8ZQkxf9GiECfmDwDOAeuB2kMxNxw5JU0XRq6kzt33Z2lvbtbOM791H4WkJ7l2NK+6H6qxWy3VuOGEs5l/TVT92cz2LWLK42uAKO0jOyQkSaJacEDoYxfmjVIIuxlxEoX2LVlVnrs1CUllC5JZvzA+J9yfAuDUU9x4B5iprXgjKwrb2tBtCL+hj5jg8KWidxz4NNVcbJUKhR/Gu2XH8p0pIag== 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=Unsf/ykaBVUIqyu9RujVmDC5LVSI23vO9ARiq+Ht130=; b=E+iwsFx9DUM9oTA7glAGJZ9Hs1k8WEGsv1WRsL42pPSm1AMREyqHdLYPhfEeHF4H4myToB08iXzLXwd+4RZBXVnpczQvwbIF7MoQLYy7Pb40knX2AMQ5jOcwyS+MqrpTQH8w6+tON1joMDswmid3QeVQVvBH0drbfGYG3PwRS+uDqtl54FJdRe3plW0uqIT+WrUZhXIbpecGtME0P54i+l6TvPsABjxM9XU2CrHyjI5VRClJGdGj0+AQkvdcUc3Lc/hv1Yq6GnKptSsGT7uJjim23h3veZVGj1c3yNtaFlJj3ud4ivqVV/pKXeY41XkT0SY8nQPJmV6yCR8xF2XOJw== 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=Unsf/ykaBVUIqyu9RujVmDC5LVSI23vO9ARiq+Ht130=; b=ZkmO09HoSQqHNGBQpceEa5SYRHG5/y58w/sTGKyQZ8oQvfA30AO33Jrpa6p2BDIo8/zwK9gbxFxy+VkiQBM88fOV6pYbIoKYZvrsl0U+tIfBau3HTTUOiup5i2rR1K0KCtV9dC9SEQtdwA+884lXzLAuUS2hKvP1+AiUeXNZHbI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:28:45 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:28:45 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 03/23] metadump: Declare boolean variables with bool type Date: Tue, 6 Jun 2023 14:57:46 +0530 Message-Id: <20230606092806.1604491-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0035.apcprd02.prod.outlook.com (2603:1096:4:1f6::8) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: f531ce16-2734-49e9-26a3-08db66706cbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G8SxR99ARUYd54A+wB0ur3lon8ElG+BuPW36/7OjvIR33g5dNxpe0X3wCzS9n417iaoL5A8KUTK+BueoXSazWP2x1ItjCoy1GFEzOSoRLy18IGRTU5agXLKoQH8FiDbPN3Qxg7QqlYiFVtrmLTk1VmnuEkSKZV82/+7zCjkdfQ99zcb0ZbxIHViMGLWJ2WjsyEgict5mb+KE2FQJye1Olvf44Vc+5ahzRjSqdr93Fo+P1yooIjGrmYd1aTz0CawUkmAyEYb/OqQoFJIm2UceS+s9t1dRfwub0eZP/lnDXInyRyvfeX/HxB29OSTcVwZfdPBDGgRgA8lPMxFsAgBXvnnvic0flDXzVAt6CKo7bcladFlNbKtgnfUJrvbgpVZYNNMPe6H3T+/l5JJQqlX26DFq4fqn3P922xa4B4CrMURf5svVDs4rnyjGR7BFjqIsQrh/7lNaHDLTjPq0wpAitbQ7+T/dur4KEdUjiZ++YtoK2nGWm0uJL5l9uDC3VlS9cCveZPtQFJ/x8IqLVnphQsoeiv0O0LVIf3vUZyGMTXhuxTeve/QW9VJnGCJX6Lae X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(1076003)(26005)(6512007)(6506007)(86362001)(5660300002)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AY34gthZWhciF55nXMBbOUrYQe8ZMPea958teColOr2SPzXIdQ/lBf0avUknJ2v9YvqT0QCX+7PrAIDcsM7/y/nsKS8HIn7/Eb8Jzf3N5E5Udq5SJrtSATmhUmiRmWRgVV2SwUrrUotc/aAxA0WN5k8vZJrbDfzwUmWvh3hCWzcyUYD7KBGNQlktk8ZmMSr1f4zLPie7s7s3ZCEJX4+mdrnwuD9zEQW4Z6aho8yP4GHZgvLD/7/LxK8D8IAEt2Opz8wHM1tmWhBFGdg8UALxOIp8ZaxOPpJneL8K4TKINK7gtG7/KiWj9HE5EwlwWRzzFXFmNqquUvKafoDGrkVAjJZSts6IYgb/CrH5MVxLaoezYiNk9gQW5a5pKRbj4aIH+5xTTKDu0OaJCMFJvSGhrYAogW5nhnaBZvbvWNJnqkbD4QQ8j4Fecu6Ryn6Q/wdt8ep4K1pCGm59txpKV5vy5ysXxAzTyElfpVExHE7CDieUc7GKjs3o4WeWl7ur69mzNR/mP5XrRk9lfZGnU+8AjUWGHcE6RfKZQ2l6WdAk/ZPqQHIdMPJyqdr7YsV6p52h4FGAOa4IK9nDSNET7nc/GOqPz402QJFGmkn9Ur0w5k/zeQypyr6s3LqzPNH9PcTT+MMzO1tYtDDVvNWZr8iEirSom1cKuQgYv4VxrowOYkRjvei57uqrldc+1B0cFxyDmwXN2FrR1nr7MOJu3oLy9Lx+dtjiH86N71hBS06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q9Vp+Wuj3Q9HKGIWmyMv7bYIJ2BzYWTxGx4/lK+5CFyOzCB37Eaf4undstoohwgM0hMX43Qp3BWuMISy/KGPhxP925iaxGI7oIFWt77eMLdmdLTZAFdSJ5k3zZvDI2mh7tx3XWdw1UvOp8eyyl2nxqZx4UP0wd8afQ2mxEG2yITldtMwPb1VJcmBB1TZBu4Qk4GMiic/Uae7DHr3bWD5WjKMzMiGfXCQUrSXmRO40KZXH4GFhC3M5mt37i6LF6D2ThN1gvpHwQxYV7ve4bI4gBtkzPPckQHLbDKMBGaI3j0I2axJz9LYPo11V83MF4lsAZlCZccjMziDYS//wzDOI826QOKmv98R6XRyYEZA/Q2QGUSlCQDpr4EnUVWfjxTiyv5GgppidsonrAIhL/CzqS01WSJGuuX+mnGEAjeurmN4rOvRhFTp/4+1U9bFmFNI+yjW6C6/ieliG1h/mCmuBcBU/OGervDMbGdMCFwUMmkG8H25+CmpgAgBPUdhMCygD9CInuq6G+iJ5iFFuyKJLp+qjaLXhTyRLJsihmMeyXByb6RiYWcZG6DszWybpjr8+8gpyrVPPq31a/lqv5RtbTUoaT+Z7UkJ7jacGHrPDNTfz8gjh+CJ+T61+SYSzPWFgtrMdX5LCZ3WzS9Tp8E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f531ce16-2734-49e9-26a3-08db66706cbc X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:28:45.2595 (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: QMijPC6XxhZMkY1xLYnRlb0fQ7SCJH+8Z4VIoDgeYuPW+rv+54eKZjKTj5ZWL9afxYg8vGIQSIpIEeqE466z8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: AW9356Gl6zsDZCp10jKPwE4p5NO_xnN8 X-Proofpoint-GUID: AW9356Gl6zsDZCp10jKPwE4p5NO_xnN8 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 6bcfd5bb..8b33fbfb 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -51,13 +51,13 @@ static int cur_index; static xfs_ino_t cur_ino; -static int show_progress = 0; -static int stop_on_read_error = 0; +static bool show_progress = false; +static bool stop_on_read_error = false; static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static int obfuscate = 1; -static int zero_stale_data = 1; -static int show_warnings = 0; -static int progress_since_warning = 0; +static bool obfuscate = true; +static bool zero_stale_data = true; +static bool show_warnings = false; +static bool progress_since_warning = false; static bool stdout_metadump; void @@ -100,7 +100,7 @@ print_warning(const char *fmt, ...) fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", progname, buf); - progress_since_warning = 0; + progress_since_warning = false; } static void @@ -121,7 +121,7 @@ print_progress(const char *fmt, ...) f = stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = 1; + progress_since_warning = true; } /* @@ -2979,9 +2979,9 @@ metadump_f( char *p; exitcode = 1; - show_progress = 0; - show_warnings = 0; - stop_on_read_error = 0; + show_progress = false; + show_warnings = false; + stop_on_read_error = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -3002,13 +3002,13 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = 0; + zero_stale_data = false; break; case 'e': - stop_on_read_error = 1; + stop_on_read_error = true; break; case 'g': - show_progress = 1; + show_progress = true; break; case 'm': max_extent_size = (int)strtol(optarg, &p, 0); @@ -3019,10 +3019,10 @@ metadump_f( } break; case 'o': - obfuscate = 0; + obfuscate = false; break; case 'w': - show_warnings = 1; + show_warnings = true; break; default: print_warning("bad option for metadump command"); From patchwork Tue Jun 6 09:27:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268783 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 258EBC7EE2C for ; Tue, 6 Jun 2023 09:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232959AbjFFJ3X (ORCPT ); Tue, 6 Jun 2023 05:29:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235977AbjFFJ3V (ORCPT ); Tue, 6 Jun 2023 05:29:21 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58AD0E49 for ; Tue, 6 Jun 2023 02:29:14 -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 356659Bl014649; Tue, 6 Jun 2023 09:29:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=T9bMGInRXpgn9uEXqPzAS5ctieyLE+cqeevRdNNKC5M=; b=uSPJ+BoQ8aZXS7MUm4uRTOVqMxdcatuCTeed3Vf5n9gMO5w/Ql7Ldvzwt8GkxsdijAsQ B2RSnsc8ZfokSK9FNWCZYoI68GnAgiZUDskpSANpbglEOk7Y5GH/GpP7Bw90aKND+c1R kd4S8F+A1qNM5CYONoZ5heOKTBvwra8Mb3PDXGgkuQKR65Csz60dL8/Kt0k/6EGD/hDS 4OX2a4uMYwgP/4cbK6gOKh8At4JU9VlxLAi/2v6/2gr2Hx3QlmOuPg1XcJesLnVqqKqy cmmv1kaJ1pFOrp37p7h8nbIMFSQ0qolydJqIw/QAGf7RJZk3L/eHOWTYNHSIbTk7Sywq Sg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2n4vny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:08 +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 3567c67P011385; Tue, 6 Jun 2023 09:28:54 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04qv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:28:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frLa5+qQheuMQ3tpR1b6bCmZaXo4ZcxF3vw2x5XLo+6r/0b6o/h38BgjtkUnLC5FkLPpK01u4DaNgW4xJk3oTT9PRd9B3SBga6bS/2DPrYk9vpYxJOZWZBp+JlxWHWK/LXADszEF+tukk3UHIH/jeGaFtz6A43JRP3yU0xBkPjIVE3XtQXFe6GUz6YlbiKJS8s2JO7sVEc21rSCRuGHHUEhgERIYWOI4CPe7lHkDm/RBT3aq0uHHoT/PzeKC9cs/q86VqFXger4fm2X0y70Qrx0MkRiiycNexYl2x2J7jCHfkoSzwPDuBtpfIVHCOLj3IIvmy/YKUPAXmqkk0gCQbQ== 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=T9bMGInRXpgn9uEXqPzAS5ctieyLE+cqeevRdNNKC5M=; b=RIqPiIpO6/YHjrb0tra0tBoBbXrYLA/qEUv1dwRNHm8LVUBwAyrLXhgdFR2Wo7IP2KJxpQQyeRwPFmFrkG9geKFRlumQJ8mxeDzfWGUCAqpXzHhdTABoJQZ8vP1urmbQ1z1FLCwHjmlYl5dPEx6tLES1WrWBYay+lqKDCd+Zjbkeyh1QNVqoYxhXIW0FJClBM24nkD6JwHl+vgGKHChw8B81sQC1Q3jqCg7TUP2cBfOA9eSkQWsYhxU+d3CquZ2IGpM91zBKqFiijXoWJg2EHWedAJ/OqCi+BZFZeB2c3KPExhMk1OjiSOd7+PbgiN0tGYUlNHLZB5jlm7YTt58aew== 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=T9bMGInRXpgn9uEXqPzAS5ctieyLE+cqeevRdNNKC5M=; b=BxxooUg//jRfjy1t6O08Id+WOl9xTn0XbUP4dfmSIOT+WOST3GPPr4j2OzuJct3w971sWZzDDPIJyBzbidAqDCQnRBu2E/Hqa7i55lp9sFnyk9zwvy8btxwi4lkBpRaD2e0zZgsnGgrXvhw73sRGIMSvzevcsM+rOGY1x3T+EO4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:28:51 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:28:51 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 04/23] metadump: Define and use struct metadump Date: Tue, 6 Jun 2023 14:57:47 +0530 Message-Id: <20230606092806.1604491-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0118.jpnprd01.prod.outlook.com (2603:1096:404:2a::34) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 87c01686-4c52-4743-5d3a-08db66707048 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hP9ffLshyCjXns1LaQuwdE/kWF5El3UJqxRWYV52Q7X1LFN+RN3rhyAKqACA2Vcewa4EoEY6Rq/BrCrTNnrq6tBqkYQhNtyiFX2KnPIecoMZOJoQfeyMLQDbLyZww/cqJh9pKP01izt0BnTH0+Lb6I/Vkkcjg3eE+IBu1F9Z4SpZVJnRp67hcuzeEYY7oacg3tfJ6H+FP8ZasOeY37h4MXgQOE2NrAJ02Wl2dBxP5+fFnkVFbzl3cijCp2cJsi3uEloLMkCA9X+IBeukaftbQHybWCY/D02zJ4sU/jXOzFJSUCSi00LMYK7xRK4YyiUPAdDAmqhfjNGJVzfx5p/dCwL/iWdkK/32aDTIxrkXYWet+VmJcFjW6XQgF8lu1Ch9cjcrrk82CJ7J0BVq65ODlptJI7/dkuABtbUQRi0ImPcESJlVdIz+veyB0S01z8BdZgLb1ZSE8p2ne/BW4uiuIcYQZmxQLyiusVSkmi2872FcWlEWBpLCFAIMRf2zwRCqP47K6jHxRI31psPbDqITHuDCde/MzdAcFqHWawcxo5CNqxGR4iXiTBhNQ2SHOU/X X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(30864003)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616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K4jjSBWSzFC0vqisjgR+3um8HxSvaFCjkX3iCcy4mqKHLZQlVxn0wEwS3KcjLjQsZWTn0snMNRHUW18SihMiIg8g2yRm870kHW0rbMxiytsL0F9O4M93VRfcFkH43fqk2PZJdno+hbqlIXx4Va58ryIUZH01oxu8dIDus4RgfEyG0Fh3VLRXe3NlfuNw9HrXDvJZI0x0ExS2ScKx0o2SiNb7JPgJdkwCE/HFNl2Bip3uhO4SJAEqcCYQG8pQaotaR4USOxrdUyfM9J63NIt9jOhSyzEUi8qjekEF9BnMARjlsfrsxmv5BJ5vo0nIh89St+ItIO2lPbcKLE3lSXQ7iooOVMVhYXpxTUVSPDBa9aYQ0jPq2zDebQq0t1w0cu5r1RbPATDY20WVqrKIAVSHhxymB8bDBCuWegRHgIQbx/l0FD9R6Er3WkylmiXlIVm2TRwDfQDSXFHZrPXBqAk4cYLQtcliWYNQZZQMD1LeaPznRG2yVL/zd76U+t/T64+77wbcqE2CQXLSdqUGbIsqyXa9r9G0i2hO1EfZ6IbYYCZN60ATM42gRmD3CN8Y8f4RhKKZlaffKiSo/IpTVEBVLQOAhjopcMuOD017r3VD51ey X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bRJ3Avmk86PY4e6cODG0RxGOkjmpaes7xnYsyFAp9ba5V7V23R/he9xfgXkTMo/6O0RTX+4zsCdFcTZ7tUQsjLJbtXFflXtyh4G7PyPGFWvdGsa7YS6DiImmEjf5FiDNCfX+wvvzSH9QD/LneebsuaglV0uwXvF+GvaA5gk3lgmPoDciOhDdpX6oZpoU1BFmy7IJiyjnNH0K173B1E69O1n4q24mNXecgFGhhey8V6IgR4sqxWgic8Cno64BmwO7F0rWt8sVUH13bgnBmerig04GQdNLGGugylIjTBHP6mcRUINwwO1HVb04OPB2DJ8vyOLIbe+77Rdb9P8EvD3xAblscGn8k4+KP4TGVVZIoxN/VuaBhnOlF8IMumSW/2QT6zGmPLJ0brzZoJUZuftMjZwshGxCg2BKDnIWCBF38mgsVba8+uH0BS/AgCnUa9ClMEACJQBJXgOO6ozLEgBpulIVz5krYz01Jvwh8+jTJAdbqZ2Q7KMqpe7mmwMPtYK9CU21vrOaoEWOplCPTJvvS3Fy0vXUqtRwhErfPp3znMv0TZ7z0sAu1RIpKl0y/XXL5SNWJiJXuIBsQdk4Ew2u8hsP6p33mvQAB+S1BWqD+5RdWq1s8IUXcRtu5AhbFGMxxIzpknBa3UJxOcqVXdcSZqeDn+6y2RVMdX2aqjajI7XIZBNaWYDLsn7yuAWoXS2TNN+xmlXGMFr78UleN8TGRbPp1gkoeB8gLrHnqglyVliK/ZI4YTwsrJjpBxIfb4ZLVE2YOBr2oAGNAXf2aIVlVvrs5wPKnCNGVbbvCwMzuQ8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87c01686-4c52-4743-5d3a-08db66707048 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:28:51.2928 (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: EVlXTAPnJIQ+jXWctOWIUJwjFGpMaGw9qA3ifZaDmaswYZk9ttFGDMOGBdQg8LqEcLygtyQq+3jmS41g/OLJSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: f3MoHsog0AUd_VelR0y7g4CMB0tTLCwr X-Proofpoint-ORIG-GUID: f3MoHsog0AUd_VelR0y7g4CMB0tTLCwr Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit collects all state tracking variables in a new "struct metadump" structure. This is done to collect all the global variables in one place rather than having them spread across the file. A new structure member of type "struct metadump_ops *" will be added by a future commit to support the two versions of metadump. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong Reviewed-by: Carlos Maiolino --- db/metadump.c | 459 +++++++++++++++++++++++++++----------------------- 1 file changed, 244 insertions(+), 215 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 8b33fbfb..e5479b56 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -40,25 +40,27 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; -static FILE *outf; /* metadump file */ - -static xfs_metablock_t *metablock; /* header + index + buffers */ -static __be64 *block_index; -static char *block_buffer; - -static int num_indices; -static int cur_index; - -static xfs_ino_t cur_ino; - -static bool show_progress = false; -static bool stop_on_read_error = false; -static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static bool obfuscate = true; -static bool zero_stale_data = true; -static bool show_warnings = false; -static bool progress_since_warning = false; -static bool stdout_metadump; +static struct metadump { + int version; + bool show_progress; + bool stop_on_read_error; + int max_extent_size; + bool show_warnings; + bool obfuscate; + bool zero_stale_data; + bool progress_since_warning; + bool dirty_log; + bool stdout_metadump; + xfs_ino_t cur_ino; + /* Metadump file */ + FILE *outf; + /* header + index + buffers */ + struct xfs_metablock *metablock; + __be64 *block_index; + char *block_buffer; + int num_indices; + int cur_index; +} metadump; void metadump_init(void) @@ -98,9 +100,9 @@ print_warning(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", - progname, buf); - progress_since_warning = false; + fprintf(stderr, "%s%s: %s\n", + metadump.progress_since_warning ? "\n" : "", progname, buf); + metadump.progress_since_warning = false; } static void @@ -118,10 +120,10 @@ print_progress(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - f = stdout_metadump ? stderr : stdout; + f = metadump.stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = true; + metadump.progress_since_warning = true; } /* @@ -136,17 +138,19 @@ print_progress(const char *fmt, ...) static int write_index(void) { + struct xfs_metablock *metablock = metadump.metablock; /* * write index block and following data blocks (streaming) */ - metablock->mb_count = cpu_to_be16(cur_index); - if (fwrite(metablock, (cur_index + 1) << BBSHIFT, 1, outf) != 1) { + metablock->mb_count = cpu_to_be16(metadump.cur_index); + if (fwrite(metablock, (metadump.cur_index + 1) << BBSHIFT, 1, + metadump.outf) != 1) { print_warning("error writing to target file"); return -1; } - memset(block_index, 0, num_indices * sizeof(__be64)); - cur_index = 0; + memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); + metadump.cur_index = 0; return 0; } @@ -163,9 +167,10 @@ write_buf_segment( int ret; for (i = 0; i < len; i++, off++, data += BBSIZE) { - block_index[cur_index] = cpu_to_be64(off); - memcpy(&block_buffer[cur_index << BBSHIFT], data, BBSIZE); - if (++cur_index == num_indices) { + metadump.block_index[metadump.cur_index] = cpu_to_be64(off); + memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], + data, BBSIZE); + if (++metadump.cur_index == metadump.num_indices) { ret = write_index(); if (ret) return -EIO; @@ -388,11 +393,11 @@ scan_btree( if (iocur_top->data == NULL) { print_warning("cannot read %s block %u/%u", typtab[btype].name, agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { zero_btree_block(iocur_top->data, btype); iocur_top->need_crc = 1; } @@ -446,7 +451,7 @@ scanfunc_freesp( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_alloc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -455,7 +460,7 @@ scanfunc_freesp( pp = XFS_ALLOC_PTR_ADDR(mp, block, 1, mp->m_alloc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -482,13 +487,13 @@ copy_free_bno_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in bnobt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in bnobt root " "in agf %u", levels, agno); return 1; @@ -510,13 +515,13 @@ copy_free_cnt_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in cntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in cntbt root " "in agf %u", levels, agno); return 1; @@ -543,7 +548,7 @@ scanfunc_rmapbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_rmap_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -552,7 +557,7 @@ scanfunc_rmapbt( pp = XFS_RMAP_PTR_ADDR(block, 1, mp->m_rmap_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -582,13 +587,13 @@ copy_rmap_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in rmapbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_rmap_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in rmapbt root " "in agf %u", levels, agno); return 1; @@ -615,7 +620,7 @@ scanfunc_refcntbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_refc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -624,7 +629,7 @@ scanfunc_refcntbt( pp = XFS_REFCOUNT_PTR_ADDR(block, 1, mp->m_refc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -654,13 +659,13 @@ copy_refcount_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in refcntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_refc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in refcntbt root " "in agf %u", levels, agno); return 1; @@ -785,7 +790,8 @@ in_lost_found( /* Record the "lost+found" inode if we haven't done so already */ ASSERT(ino != 0); - if (!orphanage_ino && is_orphanage_dir(mp, cur_ino, namelen, name)) + if (!orphanage_ino && is_orphanage_dir(mp, metadump.cur_ino, namelen, + name)) orphanage_ino = ino; /* We don't obfuscate the "lost+found" directory itself */ @@ -795,7 +801,7 @@ in_lost_found( /* Most files aren't in "lost+found" at all */ - if (cur_ino != orphanage_ino) + if (metadump.cur_ino != orphanage_ino) return 0; /* @@ -1219,7 +1225,7 @@ generate_obfuscated_name( print_warning("duplicate name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); return; } @@ -1229,7 +1235,7 @@ generate_obfuscated_name( print_warning("unable to record name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); } static void @@ -1245,9 +1251,9 @@ process_sf_dir( ino_dir_size = be64_to_cpu(dip->di_size); if (ino_dir_size > XFS_DFORK_DSIZE(dip, mp)) { ino_dir_size = XFS_DFORK_DSIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size in dir inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } sfep = xfs_dir2_sf_firstentry(sfp); @@ -1261,9 +1267,9 @@ process_sf_dir( int namelen = sfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length entry in dir inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - @@ -1271,16 +1277,17 @@ process_sf_dir( } else if ((char *)sfep - (char *)sfp + libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen) > ino_dir_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("entry length in dir inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - (char *)sfp); } - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name( libxfs_dir2_sf_get_ino(mp, sfp, sfep), namelen, &sfep->name[0]); @@ -1290,7 +1297,8 @@ process_sf_dir( } /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) memset(sfep, 0, XFS_DFORK_DSIZE(dip, mp) - ino_dir_size); } @@ -1346,18 +1354,18 @@ process_sf_symlink( len = be64_to_cpu(dip->di_size); if (len > XFS_DFORK_DSIZE(dip, mp)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size (%d) in symlink inode %llu", - len, (long long)cur_ino); + len, (long long)metadump.cur_ino); len = XFS_DFORK_DSIZE(dip, mp); } buf = (char *)XFS_DFORK_DPTR(dip); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(buf, len); /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) + if (metadump.zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) memset(&buf[len], 0, XFS_DFORK_DSIZE(dip, mp) - len); } @@ -1382,9 +1390,9 @@ process_sf_attr( ino_attr_size = be16_to_cpu(asfp->hdr.totsize); if (ino_attr_size > XFS_DFORK_ASIZE(dip, mp)) { ino_attr_size = XFS_DFORK_ASIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr size in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } asfep = &asfp->list[0]; @@ -1394,19 +1402,20 @@ process_sf_attr( int namelen = asfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length attr entry in inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); break; } else if ((char *)asfep - (char *)asfp + xfs_attr_sf_entsize(asfep) > ino_attr_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("attr entry length in inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, asfep->namelen, &asfep->nameval[0]); memset(&asfep->nameval[asfep->namelen], 'v', @@ -1418,7 +1427,8 @@ process_sf_attr( } /* zero stale data in rest of space in attr fork, if any */ - if (zero_stale_data && (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) memset(asfep, 0, XFS_DFORK_ASIZE(dip, mp) - ino_attr_size); } @@ -1429,7 +1439,7 @@ process_dir_free_block( struct xfs_dir2_free *free; struct xfs_dir3_icfree_hdr freehdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; free = (struct xfs_dir2_free *)block; @@ -1451,10 +1461,10 @@ process_dir_free_block( break; } default: - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid magic in dir inode %llu " "free block", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); break; } } @@ -1466,7 +1476,7 @@ process_dir_leaf_block( struct xfs_dir2_leaf *leaf; struct xfs_dir3_icleaf_hdr leafhdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; /* Yes, this works for dir2 & dir3. Difference is padding. */ @@ -1549,10 +1559,10 @@ process_dir_data_block( } if (be32_to_cpu(datahdr->magic) != wantmagic) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid magic in dir inode %llu block %ld", - (unsigned long long)cur_ino, (long)offset); + (unsigned long long)metadump.cur_ino, (long)offset); return; } @@ -1572,10 +1582,10 @@ process_dir_data_block( if (dir_offset + free_length > end_of_data || !free_length || (free_length & (XFS_DIR2_DATA_ALIGN - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir free space in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) != @@ -1588,7 +1598,7 @@ process_dir_data_block( * actually at a variable offset, so zeroing &dup->tag * is zeroing the free space in between */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { int zlen = free_length - sizeof(xfs_dir2_data_unused_t); @@ -1606,23 +1616,23 @@ process_dir_data_block( if (dir_offset + length > end_of_data || ptr + length > endptr) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir entry name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) != dir_offset) return; - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name(be64_to_cpu(dep->inumber), dep->namelen, &dep->name[0]); dir_offset += length; ptr += length; /* Zero the unused space after name, up to the tag */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* 1 byte for ftype; don't bother with conditional */ int zlen = (char *)libxfs_dir2_data_entry_tag_p(mp, dep) - @@ -1658,7 +1668,7 @@ process_symlink_block( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } link = iocur_top->data; @@ -1666,10 +1676,10 @@ process_symlink_block( if (xfs_has_crc((mp))) link += sizeof(struct xfs_dsymlink_hdr); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(link, XFS_SYMLINK_BUF_SPACE(mp, mp->m_sb.sb_blocksize)); - if (zero_stale_data) { + if (metadump.zero_stale_data) { size_t linklen, zlen; linklen = strlen(link); @@ -1736,7 +1746,8 @@ process_attr_block( if ((be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC) && (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR3_LEAF_MAGIC)) { for (i = 0; i < attr_data.remote_val_count; i++) { - if (obfuscate && attr_data.remote_vals[i] == offset) + if (metadump.obfuscate && + attr_data.remote_vals[i] == offset) /* Macros to handle both attr and attr3 */ memset(block + (bs - XFS_ATTR3_RMT_BUF_SPACE(mp, bs)), @@ -1753,9 +1764,9 @@ process_attr_block( nentries * sizeof(xfs_attr_leaf_entry_t) + xfs_attr3_leaf_hdr_size(leaf) > XFS_ATTR3_RMT_BUF_SPACE(mp, bs)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr count in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } @@ -1770,22 +1781,22 @@ process_attr_block( first_name = xfs_attr3_leaf_name(leaf, i); if (be16_to_cpu(entry->nameidx) > mp->m_sb.sb_blocksize) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr nameidx in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } if (entry->flags & XFS_ATTR_LOCAL) { local = xfs_attr3_leaf_name_local(leaf, i); if (local->namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "zero length for attr name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, local->namelen, &local->nameval[0]); memset(&local->nameval[local->namelen], 'v', @@ -1797,18 +1808,18 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_local(nlen, vlen) - (sizeof(xfs_attr_leaf_name_local_t) - 1 + nlen + vlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&local->nameval[nlen + vlen], 0, zlen); } else { remote = xfs_attr3_leaf_name_remote(leaf, i); if (remote->namelen == 0 || remote->valueblk == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr entry in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, remote->namelen, &remote->name[0]); add_remote_vals(be32_to_cpu(remote->valueblk), @@ -1819,13 +1830,13 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_remote(nlen) - (sizeof(xfs_attr_leaf_name_remote_t) - 1 + nlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&remote->name[nlen], 0, zlen); } } /* Zero from end of entries array to the first name/val */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { struct xfs_attr_leaf_entry *entries; entries = xfs_attr3_leaf_entryp(leaf); @@ -1858,16 +1869,16 @@ process_single_fsb_objects( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; /* Zero unused part of interior nodes */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { xfs_da_intnode_t *node = iocur_top->data; int magic = be16_to_cpu(node->hdr.info.magic); @@ -1978,12 +1989,12 @@ process_multi_fsb_dir( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; dp = iocur_top->data; @@ -2075,25 +2086,27 @@ process_bmbt_reclist( * one is found, stop processing remaining extents */ if (i > 0 && op + cp > o) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %d in %s ino %llu " "starts at %llu, previous extent " "ended at %llu", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, o, op + cp - 1); break; } - if (c > max_extent_size) { + if (c > metadump.max_extent_size) { /* * since we are only processing non-data extents, * large numbers of blocks in a metadata extent is * extremely rare and more than likely to be corrupt. */ - if (show_warnings) + if (metadump.show_warnings) print_warning("suspicious count %u in bmap " "extent %d in %s ino %llu", c, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } @@ -2104,19 +2117,21 @@ process_bmbt_reclist( agbno = XFS_FSB_TO_AGBNO(mp, s); if (!valid_bno(agno, agbno)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number %u/%u " "(%llu) in bmap extent %d in %s ino " "%llu", agno, agbno, s, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } if (!valid_bno(agno, agbno + c - 1)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %i in %s inode %llu " "overflows AG (end is %u/%u)", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, agno, agbno + c - 1); break; } @@ -2152,7 +2167,7 @@ scanfunc_bmap( if (level == 0) { if (nrecs > mp->m_bmap_dmxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s " "block %u/%u", nrecs, typtab[btype].name, agno, agbno); @@ -2163,7 +2178,7 @@ scanfunc_bmap( } if (nrecs > mp->m_bmap_dmxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", nrecs, typtab[btype].name, agno, agbno); return 1; @@ -2178,7 +2193,7 @@ scanfunc_bmap( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", ag, bno, typtab[btype].name, agno, agbno); @@ -2213,10 +2228,10 @@ process_btinode( nrecs = be16_to_cpu(dib->bb_numrecs); if (level > XFS_BM_MAXLEVELS(mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inode %lld %s " - "root", level, (long long)cur_ino, - typtab[btype].name); + "root", level, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } @@ -2227,16 +2242,16 @@ process_btinode( maxrecs = libxfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip, mp, whichfork), 0); if (nrecs > maxrecs) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in inode %lld %s " - "root", nrecs, (long long)cur_ino, - typtab[btype].name); + "root", nrecs, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } pp = XFS_BMDR_PTR_ADDR(dib, 1, maxrecs); - if (zero_stale_data) { + if (metadump.zero_stale_data) { char *top; /* Unused btree key space */ @@ -2257,11 +2272,11 @@ process_btinode( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " - "in inode %llu %s root", ag, - bno, (long long)cur_ino, - typtab[btype].name); + "in inode %llu %s root", ag, bno, + (long long)metadump.cur_ino, + typtab[btype].name); continue; } @@ -2288,14 +2303,16 @@ process_exinode( whichfork); used = nex * sizeof(xfs_bmbt_rec_t); if (nex > max_nex || used > XFS_DFORK_SIZE(dip, mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad number of extents %llu in inode %lld", - (unsigned long long)nex, (long long)cur_ino); + (unsigned long long)nex, + (long long)metadump.cur_ino); return 1; } /* Zero unused data fork past used extents */ - if (zero_stale_data && (used < XFS_DFORK_SIZE(dip, mp, whichfork))) + if (metadump.zero_stale_data && + (used < XFS_DFORK_SIZE(dip, mp, whichfork))) memset(XFS_DFORK_PTR(dip, whichfork) + used, 0, XFS_DFORK_SIZE(dip, mp, whichfork) - used); @@ -2311,7 +2328,7 @@ process_inode_data( { switch (dip->di_format) { case XFS_DINODE_FMT_LOCAL: - if (!(obfuscate || zero_stale_data)) + if (!(metadump.obfuscate || metadump.zero_stale_data)) break; /* @@ -2323,7 +2340,7 @@ process_inode_data( print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", XFS_DFORK_DSIZE(dip, mp), - (long long)cur_ino); + (long long)metadump.cur_ino); break; } @@ -2355,9 +2372,9 @@ process_dev_inode( struct xfs_dinode *dip) { if (xfs_dfork_data_extents(dip)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("inode %llu has unexpected extents", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); return; } @@ -2369,11 +2386,11 @@ process_dev_inode( if (XFS_DFORK_DSIZE(dip, mp) > XFS_LITINO(mp)) { print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", - XFS_DFORK_DSIZE(dip, mp), (long long)cur_ino); + XFS_DFORK_DSIZE(dip, mp), (long long)metadump.cur_ino); return; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { unsigned int size = sizeof(xfs_dev_t); memset(XFS_DFORK_DPTR(dip) + size, 0, @@ -2399,17 +2416,17 @@ process_inode( bool crc_was_ok = false; /* no recalc by default */ bool need_new_crc = false; - cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); + metadump.cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); /* we only care about crc recalculation if we will modify the inode. */ - if (obfuscate || zero_stale_data) { + if (metadump.obfuscate || metadump.zero_stale_data) { crc_was_ok = libxfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, offsetof(struct xfs_dinode, di_crc)); } if (free_inode) { - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* Zero all of the inode literal area */ memset(XFS_DFORK_DPTR(dip), 0, XFS_LITINO(mp)); } @@ -2451,7 +2468,8 @@ process_inode( switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: need_new_crc = true; - if (obfuscate || zero_stale_data) + if (metadump.obfuscate || + metadump.zero_stale_data) process_sf_attr(dip); break; @@ -2468,7 +2486,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ - if (zero_stale_data) + if (metadump.zero_stale_data) need_new_crc = true; if (crc_was_ok && need_new_crc) @@ -2528,7 +2546,7 @@ copy_inode_chunk( if (agino == 0 || agino == NULLAGINO || !valid_bno(agno, agbno) || !valid_bno(agno, XFS_AGINO_TO_AGBNO(mp, agino + XFS_INODES_PER_CHUNK - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad inode number %llu (%u/%u)", XFS_AGINO_TO_INO(mp, agno, agino), agno, agino); return 1; @@ -2544,7 +2562,7 @@ copy_inode_chunk( (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt != 0 && agbno % mp->m_sb.sb_inoalignmt != 0)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("badly aligned inode (start = %llu)", XFS_AGINO_TO_INO(mp, agno, agino)); return 1; @@ -2561,7 +2579,7 @@ copy_inode_chunk( if (iocur_top->data == NULL) { print_warning("cannot read inode block %u/%u", agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } @@ -2587,7 +2605,7 @@ next_bp: ioff += inodes_per_buf; } - if (show_progress) + if (metadump.show_progress) print_progress("Copied %u of %u inodes (%u of %u AGs)", inodes_copied, mp->m_sb.sb_icount, agno, mp->m_sb.sb_agcount); @@ -2617,7 +2635,7 @@ scanfunc_ino( if (level == 0) { if (numrecs > igeo->inobt_mxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s " "block %u/%u", numrecs, typtab[btype].name, agno, agbno); @@ -2640,7 +2658,7 @@ scanfunc_ino( } if (numrecs > igeo->inobt_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); numrecs = igeo->inobt_mxr[1]; @@ -2649,7 +2667,7 @@ scanfunc_ino( pp = XFS_INOBT_PTR_ADDR(mp, block, 1, igeo->inobt_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -2677,13 +2695,13 @@ copy_inodes( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in inobt " "root in agi %u", root, agno); return 1; } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inobt root " "in agi %u", levels, agno); return 1; @@ -2697,7 +2715,7 @@ copy_inodes( levels = be32_to_cpu(agi->agi_free_level); if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in " "finobt root in agi %u", root, agno); @@ -2705,7 +2723,7 @@ copy_inodes( } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in finobt " "root in agi %u", levels, agno); return 1; @@ -2736,11 +2754,11 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (!iocur_top->data) { print_warning("cannot read superblock for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { /* Replace any filesystem label with "L's" */ - if (obfuscate) { + if (metadump.obfuscate) { struct xfs_sb *sb = iocur_top->data; memset(sb->sb_fname, 'L', min(strlen(sb->sb_fname), sizeof(sb->sb_fname))); @@ -2758,7 +2776,7 @@ scan_ag( agf = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agf block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2773,7 +2791,7 @@ scan_ag( agi = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agi block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2787,10 +2805,10 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (iocur_top->data == NULL) { print_warning("cannot read agfl block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { - if (agf && zero_stale_data) { + if (agf && metadump.zero_stale_data) { /* Zero out unused bits of agfl */ int i; __be32 *agfl_bno; @@ -2813,7 +2831,7 @@ scan_ag( /* copy AG free space btrees */ if (agf) { - if (show_progress) + if (metadump.show_progress) print_progress("Copying free space trees of AG %u", agno); if (!copy_free_bno_btree(agno, agf)) @@ -2859,7 +2877,7 @@ copy_ino( if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || offset >= mp->m_sb.sb_inopblock) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid %s inode number (%lld)", typtab[itype].name, (long long)ino); return 1; @@ -2871,12 +2889,12 @@ copy_ino( if (iocur_top->data == NULL) { print_warning("cannot read %s inode %lld", typtab[itype].name, (long long)ino); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } off_cur(offset << mp->m_sb.sb_inodelog, mp->m_sb.sb_inodesize); - cur_ino = ino; + metadump.cur_ino = ino; rval = process_inode_data(iocur_top->data, itype); pop_out: pop_cur(); @@ -2912,7 +2930,7 @@ copy_log(void) int logversion; int cycle = XLOG_INIT_CYCLE; - if (show_progress) + if (metadump.show_progress) print_progress("Copying log"); push_cur(); @@ -2921,11 +2939,11 @@ copy_log(void) if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); - return !stop_on_read_error; + return !metadump.stop_on_read_error; } /* If not obfuscating or zeroing, just copy the log as it is */ - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto done; dirty = xlog_is_dirty(mp, &log, &x, 0); @@ -2933,7 +2951,7 @@ copy_log(void) switch (dirty) { case 0: /* clear out a clean log */ - if (show_progress) + if (metadump.show_progress) print_progress("Zeroing clean log"); logstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); @@ -2948,7 +2966,7 @@ copy_log(void) break; case 1: /* keep the dirty log */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Warning: log recovery of an obfuscated metadata image can leak " "unobfuscated metadata and/or cause image corruption. If possible, " @@ -2956,7 +2974,7 @@ _("Warning: log recovery of an obfuscated metadata image can leak " break; case -1: /* log detection error */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Could not discern log; image will contain unobfuscated metadata in log.")); break; @@ -2979,9 +2997,15 @@ metadump_f( char *p; exitcode = 1; - show_progress = false; - show_warnings = false; - stop_on_read_error = false; + + metadump.version = 1; + metadump.show_progress = false; + metadump.stop_on_read_error = false; + metadump.max_extent_size = DEFAULT_MAX_EXT_SIZE; + metadump.show_warnings = false; + metadump.obfuscate = true; + metadump.zero_stale_data = true; + metadump.dirty_log = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -3002,27 +3026,29 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = false; + metadump.zero_stale_data = false; break; case 'e': - stop_on_read_error = true; + metadump.stop_on_read_error = true; break; case 'g': - show_progress = true; + metadump.show_progress = true; break; case 'm': - max_extent_size = (int)strtol(optarg, &p, 0); - if (*p != '\0' || max_extent_size <= 0) { + metadump.max_extent_size = + (int)strtol(optarg, &p, 0); + if (*p != '\0' || + metadump.max_extent_size <= 0) { print_warning("bad max extent size %s", optarg); return 0; } break; case 'o': - obfuscate = false; + metadump.obfuscate = false; break; case 'w': - show_warnings = true; + metadump.show_warnings = true; break; default: print_warning("bad option for metadump command"); @@ -3035,21 +3061,6 @@ metadump_f( return 0; } - metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); - if (metablock == NULL) { - print_warning("memory allocation failure"); - return 0; - } - metablock->mb_blocklog = BBSHIFT; - metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); - - /* Set flags about state of metadump */ - metablock->mb_info = XFS_METADUMP_INFO_FLAGS; - if (obfuscate) - metablock->mb_info |= XFS_METADUMP_OBFUSCATED; - if (!zero_stale_data) - metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; - /* If we'll copy the log, see if the log is dirty */ if (mp->m_sb.sb_logstart) { push_cur(); @@ -3060,34 +3071,52 @@ metadump_f( struct xlog log; if (xlog_is_dirty(mp, &log, &x, 0)) - metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + metadump.dirty_log = true; } pop_cur(); } - block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t)); - block_buffer = (char *)metablock + BBSIZE; - num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64); + metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); + if (metadump.metablock == NULL) { + print_warning("memory allocation failure"); + return -1; + } + metadump.metablock->mb_blocklog = BBSHIFT; + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + + /* Set flags about state of metadump */ + metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; + if (metadump.obfuscate) + metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; + if (!metadump.zero_stale_data) + metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; + if (metadump.dirty_log) + metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + + metadump.block_index = (__be64 *)((char *)metadump.metablock + + sizeof(xfs_metablock_t)); + metadump.block_buffer = (char *)metadump.metablock + BBSIZE; + metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / + sizeof(__be64); /* * A metadump block can hold at most num_indices of BBSIZE sectors; * do not try to dump a filesystem with a sector size which does not * fit within num_indices (i.e. within a single metablock). */ - if (mp->m_sb.sb_sectsize > num_indices * BBSIZE) { + if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { print_warning("Cannot dump filesystem with sector size %u", mp->m_sb.sb_sectsize); - free(metablock); + free(metadump.metablock); return 0; } - cur_index = 0; start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { if (isatty(fileno(stdout))) { print_warning("cannot write to a terminal"); - free(metablock); + free(metadump.metablock); return 0; } /* @@ -3111,17 +3140,17 @@ metadump_f( close(outfd); goto out; } - outf = fdopen(outfd, "a"); - if (outf == NULL) { + metadump.outf = fdopen(outfd, "a"); + if (metadump.outf == NULL) { fprintf(stderr, "cannot create dump stream\n"); dup2(outfd, STDOUT_FILENO); close(outfd); goto out; } - stdout_metadump = true; + metadump.stdout_metadump = true; } else { - outf = fopen(argv[optind], "wb"); - if (outf == NULL) { + metadump.outf = fopen(argv[optind], "wb"); + if (metadump.outf == NULL) { print_warning("cannot create dump file"); goto out; } @@ -3148,24 +3177,24 @@ metadump_f( if (!exitcode) exitcode = write_index() < 0; - if (progress_since_warning) - fputc('\n', stdout_metadump ? stderr : stdout); + if (metadump.progress_since_warning) + fputc('\n', metadump.stdout_metadump ? stderr : stdout); - if (stdout_metadump) { - fflush(outf); + if (metadump.stdout_metadump) { + fflush(metadump.outf); fflush(stdout); ret = dup2(outfd, STDOUT_FILENO); if (ret < 0) perror("un-redirecting stdout"); - stdout_metadump = false; + metadump.stdout_metadump = false; } - fclose(outf); + fclose(metadump.outf); /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metablock); + free(metadump.metablock); return 0; } From patchwork Tue Jun 6 09:27:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268781 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 79E7BC77B7A for ; Tue, 6 Jun 2023 09:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234603AbjFFJ3I (ORCPT ); Tue, 6 Jun 2023 05:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237467AbjFFJ3G (ORCPT ); Tue, 6 Jun 2023 05:29:06 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B73E69 for ; Tue, 6 Jun 2023 02:29:04 -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 3565qooP009177; Tue, 6 Jun 2023 09:29:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=WHEkd7Ot2dctOxalJQqyCGzSMB8Jkbq4fwdUIOMbaSk=; b=3BdeDt1a5EpIXwXD0hpjiCAwZurZjeSzyBShaxeEIBt22Z/Hg/8dKHpfUjFmXknIjH3w ohwkcHrwYWf35f9nzOaJay3yCWWmGGSujhnhrTnxdoXahxnsfnveOUzVn4RPeHE9ZDPw kT7gQ41F/WmANcHq3xm+Q55Jr/pcjNS11lasyECEngxXzmd1/nRmXv5kv6x2zA62h0B4 0YHxRYCGlKqc/z4bR41MifBdJK70n6cDLCCWkICbNXuB0sL0sDICoV+289BC5zOMQUgN immDoPPdnJhAiPV98YJxq0LJVZbIQ3W3Q7re1k1tcpcfOQg/3KpOgmeb59OoCZO5rQIK DQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx1nvx5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:01 +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 3567J4dC024063; Tue, 6 Jun 2023 09:29:00 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tq8wkgb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m6vNGUIa/jPF7Hq5abFqboG0XQPWQz5azZNeplsFUX2y25yAdUtKjqMqjbTontsgKaJfs8C8jOgb5exChPAafg7RdSTjYZelvMUatzg1SkhdOd/dexmHZgQx/OorxOZDHLheKysoxem6B96jEse12cVvAFWevSxnCqeyg030JhFjIWTGckIY5JOhBVo5GrTN6jSQP44jrQVJ9AnA2eOzumwE4qhzLI5mXavzHxHizXGrMrWsAg5LQWWr+SHbeTGW7yUfzdYE9n4+q5xXU6nM2OwATVC5Rv7xGkcsKzDW0w8pZ7Y7V74Ir+aGjFRPXojZBxZAtxaYM1cUunkhjxU0Bw== 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=WHEkd7Ot2dctOxalJQqyCGzSMB8Jkbq4fwdUIOMbaSk=; b=Oew0BCW1RvNYNaLXculEIAYZERm27+CVtXTKeubuHc4pNPj+vnpAMWQlXYvKFdIZM7UfwA+a92CHi+WYUEFP0J4nLlYOnjxFFjvxt9Et4M8IJ6HJ+whoJu2xSjFGyiG2D0zEiTZhhG+6mTpM6XKblrpdxH4V636ZvnGN4USySnr7oIv6j+Kt0H6ciHm6rd7I296Xk6lWK/diIOx2BjF1Kb4vIErlwNnPRSjGeTNtd52ksBkWPGbjaWBjjvpa7saiZIvtRFNpqlGv3u2r+KfrjjVCYHNOzqW9STW9JW6XpjoLphrOn3jpmtJJ74DQswx1lGl/OyZH57Amyi42yc88gA== 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=WHEkd7Ot2dctOxalJQqyCGzSMB8Jkbq4fwdUIOMbaSk=; b=sUYL73DJj8YDgevHJse/KQ4E9BRzlJaphuTLDcsmOPqOBQHlJYLLrEtnUOmSb+htmQZv6J7sgZY4AD7+cn5/O3c+sqfKaUdy9t3asXTLPrlbj3nyyPEN0NuoNGA3uL/MbenYu3P15wPnXA6y3gfVlwSlQdRrD8fle7wz4mLneuQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:28:58 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:28:58 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 05/23] metadump: Add initialization and release functions Date: Tue, 6 Jun 2023 14:57:48 +0530 Message-Id: <20230606092806.1604491-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0097.jpnprd01.prod.outlook.com (2603:1096:404:2a::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fd0127f-9001-4d3f-e247-08db667074af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1B3+cPPYf4V9cTvWW+aswoDhwesjRP9hD6JrdOZ5FgxovXzXX+HhN7c2laErkWogrIA27Dh2cAMgcGdaM4CLRNQtYDVtoNpnOqPd3VRWLmvgFHjNkpYcekQoT7ECe+cV16P1GqTXg7viot4pA6A6Xmn9wrZviLs6GvWeiY2w8ln6ShgCwe+8eXdoM0+9BnDpDAdbD8gbpQdGYG5MNGar2O8toTi1YNFBMDnKIK8BfdH6C+/lx99V9eUVKWMMr4HRiSAsEC0HVDyMEjGo7LKviSkS8fII4TMPzqupjwixMJvHkaF3A7kqXKUFUsnYPzAx3fpdz2/+Kkb4KzqCBwFcu5vY826nYcMIRfgP/ZxIDE37RldqMPG0p8Yb1+GCE+62pUjECrYc8bZpn9223s/oEpYhKcFvuTgcyID9iUgg9dSCKA62bZtwbfkZSZsZgTr7kzRyUewaNlyaKL0eB4cbk1NJykk8j9irfEcKwWwMiJ9q32Tj/nBcqUbLANvrLnC/W/AUWEX5nSIrmSNrRGwlineylkXHiSQmGK1cDbFM/2aEFF2WjY0OZFeoNfuiA0Yu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DgbhiPZ5eYnX5Sa7v/W0D8TRQiujBF1vFYXIsg6f2bi2RksLVK7tfNr8752Apl7Bdjyy8iCc/Ihkt9TieayErOAAZ1rUfC1n7x7vUpLATnBIxA1Q5KS40sXLalC+giO0Ud2mPXM4GJeBU6whXU6rkxwLSeDV8yPQeRDSyeF8zhg0lFnFIhYhx6FMxAiCdkud335XH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n0o0NHa1ZugNHVNQybhVtU+mVBu/ae8lgqOjojMj4hkCtU/VEAdL9846IPOPxdQdfJUjtzBUfeEfn0nFjYcgpFftvBRy8GYEBwvu4Wkan3gxh/AxwcFp8l8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fd0127f-9001-4d3f-e247-08db667074af X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:28:58.5179 (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: nxWxSvqsXZI1UUsTl+vCfJyMl9tJcGe7McnCh6xTGXAi9ZqWs8/bSbBN9OF80LQ40BWzB+N30Wmks9D7kIUwXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=870 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: XUr6ntWzcExmmrt1d7rTsxb9Ur449JU3 X-Proofpoint-ORIG-GUID: XUr6ntWzcExmmrt1d7rTsxb9Ur449JU3 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Move metadump initialization and release functionality into corresponding functions. There are no functional changes made in this commit. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 88 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index e5479b56..ddb5c622 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2984,6 +2984,54 @@ done: return !write_buf(iocur_top); } +static int +init_metadump(void) +{ + metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); + if (metadump.metablock == NULL) { + print_warning("memory allocation failure"); + return -1; + } + metadump.metablock->mb_blocklog = BBSHIFT; + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + + /* Set flags about state of metadump */ + metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; + if (metadump.obfuscate) + metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; + if (!metadump.zero_stale_data) + metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; + if (metadump.dirty_log) + metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + + metadump.block_index = (__be64 *)((char *)metadump.metablock + + sizeof(xfs_metablock_t)); + metadump.block_buffer = (char *)(metadump.metablock) + BBSIZE; + metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64); + + /* + * A metadump block can hold at most num_indices of BBSIZE sectors; + * do not try to dump a filesystem with a sector size which does not + * fit within num_indices (i.e. within a single metablock). + */ + if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { + print_warning("Cannot dump filesystem with sector size %u", + mp->m_sb.sb_sectsize); + free(metadump.metablock); + return -1; + } + + metadump.cur_index = 0; + + return 0; +} + +static void +release_metadump(void) +{ + free(metadump.metablock); +} + static int metadump_f( int argc, @@ -3076,48 +3124,16 @@ metadump_f( pop_cur(); } - metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); - if (metadump.metablock == NULL) { - print_warning("memory allocation failure"); - return -1; - } - metadump.metablock->mb_blocklog = BBSHIFT; - metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); - - /* Set flags about state of metadump */ - metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; - if (metadump.obfuscate) - metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; - if (!metadump.zero_stale_data) - metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; - if (metadump.dirty_log) - metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; - - metadump.block_index = (__be64 *)((char *)metadump.metablock + - sizeof(xfs_metablock_t)); - metadump.block_buffer = (char *)metadump.metablock + BBSIZE; - metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / - sizeof(__be64); - - /* - * A metadump block can hold at most num_indices of BBSIZE sectors; - * do not try to dump a filesystem with a sector size which does not - * fit within num_indices (i.e. within a single metablock). - */ - if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { - print_warning("Cannot dump filesystem with sector size %u", - mp->m_sb.sb_sectsize); - free(metadump.metablock); + ret = init_metadump(); + if (ret) return 0; - } start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { if (isatty(fileno(stdout))) { print_warning("cannot write to a terminal"); - free(metadump.metablock); - return 0; + goto out; } /* * Redirect stdout to stderr for the duration of the @@ -3194,7 +3210,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metadump.metablock); + release_metadump(); return 0; } From patchwork Tue Jun 6 09:27:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268782 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 6B70AC7EE24 for ; Tue, 6 Jun 2023 09:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233748AbjFFJ3P (ORCPT ); Tue, 6 Jun 2023 05:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbjFFJ3M (ORCPT ); Tue, 6 Jun 2023 05:29:12 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 629E4E62 for ; Tue, 6 Jun 2023 02:29:11 -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 35668M5u014864; Tue, 6 Jun 2023 09:29:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=YkXznlCTOEZa0oSUo3/RPQeSMEnPj3y4gKdf2Dx6IRs=; b=qbwkmt5J/LlIxqI9vUKES01xEpgrR4cPhzulskJlRfzAvG+RxZi7F6hL6y0qsvMVu+M2 CXHznQL8v9bSdk/UrnQHqkCIAuF2982xdF5VMSjVXuamokx3qY+oiQatZmZthvcUVWeS gR4aU6gj3dRjJQun5fskhQpNpblXakPXNq5K+76lw3HHzG1UO97SwR9HNsECBiL2KWIU IYBtKWgH1fLML0MNWUI7xlbSe0z9DDz+LmjMB6uvAtNVbqDTRuWgQV7ogDmCRwt6YzYN Mx0iNqw6iDAJIXmNX/Bb8TAvoX696BWv2cWN1sUOC+Ga7CG/tySvLy712Dz6Eu28vPM6 YA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2n4vpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:08 +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 3567J4dF024063; Tue, 6 Jun 2023 09:29:07 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tq8wkkh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CiCLAI6i+PDnM/sMgvDcCIEoQS9YJk+mW62hICX2/ia9boarudYDPzNilX+NtBuX6PcO5Ncmo+Ek8o2cA9EJ1wxEKZuvF5DBmZtoJjxtAiDkGuGa/hUhT/4/8w/vAGiuB7SgxLfnkgfY6koqAOXgLqD+4Ie26lG62FSpRayheoTcOiJXFeJHkwWFWzObNRIbQodBMj1BuFytJyE/b++TCU2efJl3W6ButT0Hvror2Y7sB/RVsR/4DetB1x2yurvV441qCFNxSighhQGQ1Zftndq7q9ri9VF2yuOsg+9KR6l4722o24LjF6WWYRn1LmNcTk3EYVh32eJCor1oVKBHNQ== 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=YkXznlCTOEZa0oSUo3/RPQeSMEnPj3y4gKdf2Dx6IRs=; b=E38E0f9ESL3YyMWbL+JeRfrhAT3UWmwEAFxBhwC6H6zl4gBpwWZ3O6k7wUn3ACcU9iv1OWlHqUsRLO0WkU3x8+joUSWODzYpUNNAFwxAc6ttvhUhhqfd4rb9ykv6HjEjNYCfJiHW2JjtFC6wBYAxYwmF2bPBkJ6/LGc1gVV3QcInpkHY6nr9FZHCMBLkEXyZULUymB1m7K50dxWj41WvDT8HcOnXdpY+8bOCtpINWkP7SpYoyQlyirFK7nlxRiUT1lqueI5cy7ibxT/HLsQiYVaP1is6xvNfsJRIWW2rdCt0TepPL6lCA33lTMUpf9et8bViov1AvhyExvir4qimLg== 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=YkXznlCTOEZa0oSUo3/RPQeSMEnPj3y4gKdf2Dx6IRs=; b=gax08a5dofb2OeDEVNVaBFAcy6QpPPGL3+f7p28et9qH2f9WLidu5kg3XU4dQ0CB2llXrBaNbOpIrrQ5w2nJKCzahUHyIMxZwRmPDmVLICdV1xcxMbwCf1VzEkWAyBYrawbwrzdrFdcCCOe8rEkKV9gsfZSVacKR7u3lld1JVgY= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:05 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:05 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 06/23] metadump: Postpone invocation of init_metadump() Date: Tue, 6 Jun 2023 14:57:49 +0530 Message-Id: <20230606092806.1604491-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0229.jpnprd01.prod.outlook.com (2603:1096:404:11e::25) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: dc8ed328-dab2-47c1-584e-08db667078e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ERSEsOpePCIsyQdSGYyHRuht3Y2DcSoN1rM+iYNXbsOWKNw/E4EYyk+HfrxYiLVr1TgYOgvdTDYSOpLq/Ogbz+8xi9iyVSszV1mXsqSv66Cqf13OdMejf6orWZ5q/rR04GihO047e6bF6xQqgy0Ry/IzY0x291Yp8+HjwwRSCJQDmI90nunjFMLjYq+CAx+Go5IyhLEeIUjJSmwC09duchsPVbHZR375sUpuZAvJ129yie+dxeZvVx/xpqrhMvRkmqnaxjYiA+6jaXscf6cIfIgd8nsVO41tFuyyqfojiUSR+Cvn4L/DuFxEgVAwXeejKxVhDn9gHOJ9CFle5ZCoxF7UebfSxoyp2//WENumGFUOxW8vVE9bgpv7h9ZWRqkVnizGPvVuNQVFZmWlp6Tey5Lyf/knG6qZlpVNkz+PuPrqo+SKOgy1XMGRIdv6p9nI/VDnrFG4NF+1ZlSVgxqLUz877cuaz0WlcXGzbw64vw5pA/gJjs3sXinAMkPU9HywkOFFQEVRTlyXHBf9ASFdIMVOlOHX1dMOkZ16gx+0c0itb1twYCRJ5wXoLYn+qEAz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(4744005)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cnMDpSJryty44mYRt3CqaPcPtpmRWqDM5RDZ/3moa9mOQZZ6gOyQFElVQob7bNR87YSdIZ5lnQM4dUJvUolLd/xuzYFB8txCQKSt/iGeUP9KZ0JrsSdn0LoNB/7Y6q4NuMwR0IwpKliHmrhlYxuyRmGcdV8bpedkBpqB0j6sJNb+PLgeIWHh2oOeAcpNHRzYPeBKYxpuvOsT6WoAmRTloNiGp9iVhqBUVHnkBJvyhVM9JYazOz++zELOSfb6K4MHKJWv0pwv1Qga89kdQILQEn9jooB8erSA+p2zEfGh1ufuW2tLKYz4w11J3w7xZkSPtUJ4gVgPOzF5X7jF/i4HfhPshlhcr1h93B8L4pH2DRMyEqR7xwvIPb5u7857mY3lnTJDBRJSi6ixf+AgTis80VPU2lF48FkhB0RzvR7kjAzxPOKFnVOWtKo4Q7BS9a6EPcQJCWahZS71c8q+OwkHmkQHHZO6rw/LhXvhEpx+l/EifqfiGdQ3vsjARCtluJWPlaxcktx8Fbgy+fNWVYefa+wcTnNXXIoiILx/ICi0AZ8De9qCUdp+EAaD9wffxC5qZN8AtHR7YSviPW0Ns1YXIpaduhQ1s52o0kBXo6kDemGHnXrJOmbTuBuckoikHoWHsQHSDZy95SdzMDpBXGvZbm83uPCIBnC7c7VVjQYrYkEVG+Da4dH+sQ8I234PgIUdKhPETPv1nqdGPQOLri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w8bjqkO+v96GDw76EbGobXtwvXZD6uTCJqGJmHqxso56+ithYeicwwYHNvWCzAPfmL3q9rg29SJ6Ga/Sopmab33NHxp2yxSZIU43lgIC6C0uvoryDe6frET6LQUXE7bdISbeZFyZyL1KJZCl38r2y8UKMabqCTpZpxrRWlQbOM5cEIfWhlxqAXsiFuuIKVbbu9RoJK0EDMEK6dapJjyz3zv95cybrcprQZ/LbyCl53Ot+RRW/qP7nf9XCalhT8QhLrxCvc4XkaWkdfkq0M85W4RMEx074BKrh6fCHrb5QmAsre28SNw+TbbXMH2ZYFGvd7IprU5+XjlV8jG5IuyVsoCEb/d+LzI0EZKoB6hPkW0GbMpLUukcKH2UA+MNHqmB/dneEy9rgSUu9A0hBFJExyrowHb6Lhi4x6m1V06nEUII0rA4PYSepHLGOeoHsj9sZIPVNk3dxooTaLUA7VLiA5SpWD3PK3i7JJzGObmjwTKo6L83KRPSXzIb7i11Mf/jYMmxaTfUpQ+17gcgfabUnlQTcVhbWllIm680gs1DMKRkqra27Z38PIaJihJTWTVfKzb/OKKwk8fXWZmG9TLqb72VvqwQD3BP+tBBgywCyO8ZKS6IcwhWiY3D0aHaeJ3+Vpjgcl+5WGLjQrBx+cxiC06Vx2UGdsMZmjW5nU5jbEEMgMQ9RbaV+s1UH8TVdw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc8ed328-dab2-47c1-584e-08db667078e5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:05.5793 (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: a28MRSQK/omZPVAu+HJ/ng5PwmbV7d9TyBSUFqygbP3dF2jRizytAK5k4Z+q/Za9dyE3KLDwAvHCd3+XqxNC8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: LqaoiDK7XwN0dv1BWd479Vv1vvL6W3dw X-Proofpoint-ORIG-GUID: LqaoiDK7XwN0dv1BWd479Vv1vvL6W3dw Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The metadump v2 initialization function (introduced in a later commit) writes the header structure into the metadump file. This will require the program to open the metadump file before the initialization function has been invoked. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index ddb5c622..91150664 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -3124,10 +3124,6 @@ metadump_f( pop_cur(); } - ret = init_metadump(); - if (ret) - return 0; - start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { @@ -3172,6 +3168,10 @@ metadump_f( } } + ret = init_metadump(); + if (ret) + goto out; + exitcode = 0; for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { @@ -3209,8 +3209,9 @@ metadump_f( /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); -out: + release_metadump(); +out: return 0; } From patchwork Tue Jun 6 09:27:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268784 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 DE113C7EE24 for ; Tue, 6 Jun 2023 09:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235977AbjFFJ3c (ORCPT ); Tue, 6 Jun 2023 05:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbjFFJ3a (ORCPT ); Tue, 6 Jun 2023 05:29:30 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96FBEE62 for ; Tue, 6 Jun 2023 02:29:29 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3566ZxSQ003789; Tue, 6 Jun 2023 09:29:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=gWIEyQi3Ld9suOZUcyl9idVEUtlapqFb8UjjxZqPeBY=; b=E/m8o5ExUQQsLhndfpn0szkGEnzFq+ImadpleY+FAAvU+dhfcD0hTqAfPlFEyZOck6Pv DlsWMZXHAxcQTUx0HaaHhYzu4J3hRNtoRNyMPXIH5G62ulRpHnmuJ3R9hVSsQOzyJBn3 M+F6NSugTKiW4pqSx96O//FbMmySOZjpOMN1IxFVQXPpctNns0SQ6IvuiBbByEXXR62t WVefVm6MVqKLmJBsOk0RCHYyPPotb25GHeqcS9I8owbq3XSwtPXwRadKOePukNq/cAnP Oulqzi8h5324v60J17s6oWUWIu5c5/xvNvjt4EW/y1uB/oF7dKMy1jzVaJPbreXPIM64 AQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx5emtrj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:27 +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 3568cJIg010417; Tue, 6 Jun 2023 09:29:13 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tqcnwwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P5r20UhX8BJB64uVbwxPF8JtZDmVa/B7FpHfADV5W3UZwh4dYWgZRf9wL6ofsulakfHqF8EyVZ8umJ0pjxyO8Yntcupsfx+lPvqq3oW1r/WHcgl9V6s2afona6wlYW7HU6RLhmnBUpsoHUayHkWYOyakw3e0iF0dAQOSALZUjWCIhvyoasBoIzKYdpLPe4G7u13FKJY+pn171zibcdQZ6CRnuS/qAedFnyHKEGutZfKVj2vIKec3EiUDR93rzl4XYc6CasxILmiZuGqJMk85jVxziNWtMW4a1XblJAzNH69ZGIn2EAPzTyl0FvQ7sLhaBhYNQ+4w6VGqdautOKE9Vg== 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=gWIEyQi3Ld9suOZUcyl9idVEUtlapqFb8UjjxZqPeBY=; b=FbyKe71+YwL76HBFpjQ2XIyqhYPI5EOU0kxhaV9X6AJEYAnl4UKcTTs73+88/S4i0JZQVXx7eJycwt9nIPTfGW7rzWhgERxP4ayh+Z88KuF1Ritzg4U9l4z7MsvEGfGZpi9NZC39Z8PZFZrJQn3UFGXNj6GjjrZ50PPQRlSpGgCwag87ICXp96nUGgCn18yhjcSWvVMdjWrUFuc97Wp3uYmk4AUT8D6HJqI4v8yFLUvL6crzdgjzK2C2Cr7zIFbBPxa1bi5+CrrHGg1S721rsfWWZfFSfpc+u9sUTLsGjGe5Cz9uAl8KdKqHF6K7sEOuUQCDzst1mpElxtba3oHF4A== 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=gWIEyQi3Ld9suOZUcyl9idVEUtlapqFb8UjjxZqPeBY=; b=0D6cgzUXeWiHh1KfDiVbVz+hLvI1oeAwbyF9k/YiDZp+4IXCq49g/4hmQ1k8sQziI6e8g2p8Y5V2hi7EaZTMv7bmy5VH2qUmV8CNNk7koVbw7KMp/DSTbQU7NM9glQNUCZoBrUeCVEiU9J0lZ61d17VLS7ffW1AVdZgw9UI41Bk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:11 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:11 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 07/23] metadump: Introduce struct metadump_ops Date: Tue, 6 Jun 2023 14:57:50 +0530 Message-Id: <20230606092806.1604491-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0290.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::7) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b58cd0f-454a-498a-ce4d-08db66707c4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zlZn41GqLTL7PH1Raq9i+8XGN+CqCjxv89arm1T5i5rYosGObli66Z84wqgX+lA+kcdHgU48yJd8m3E57vDF8iegQtsFEK5BlOeiXI0M2uIhRdzJTP0OirFCUoLAcKMDmbW5ejgNyCQM7aoj3s4zH/Gt/t82B2CvUvEZTBU/jZ1gL5YFiW3LhsLzFLRUa6R74GEbo/3hFOyaTjOZzA1z+7J6dYfYcpf9cIcQD4KyKpsnwSMv/4pNfmTdhrnFokDtcZWZO7o748yCZ2bra/9Om7rHmaFv5oGXsLz5Qop9xM92zjhskdMB7LX0ya3b9S1cy2qvkK6zbSNvXAkyVas98y901g4WfUE7hfmKmX1o8orcC7BhgBet8D49fTvdZGQB6u9tIsQEyx3vllYtyOVZ0dYO21c8n1cCCtoOIe8Qbe4+SG2jftagZZCEfMvkT50wbjGqB7O4DQIRGOufq9Qf3IdpqWhYrd9lKV9CedI2ycgSv/3tLKjW/HeNzexJ4IJfcNXzxfDCvtLvxGLEiTf2z8l6yV18jYGmBCWUVMSpZ0jEMUeYq259SM8io8H99bPz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lhzgM/lAlpYVTAwG8vYAm9H0/wVhNOC3qP2wx/rofJ4C3eQ/ZhbAic29NqVDPg8sw2x5Q6QHMYYNE2dUbj+YQ5XZZCAd6Z9x2cJqz9vkko5P0weD0knkYPiowMOrk4GGML2fAdIYx2riwNhIWGjqCqNY699OxdVupZg7pB7eHboM5fwm97AzRPBRXNJtdDRnx27G36aqwzsjNcmaO9bYg3qII6V6KCJgCmitntAD+CoJxkBMePmQkLOhsxcLMGWk3IsWgn0RG9QrLuIyFbF22vvIskxL8b7fm+sFKx4jJCIomi1RWitsLKYDUjzfoevNB6y10hDTujo+Tu+d0ezHNYy1h81U2N2Gib5n7Siwuf+L0ysoUDkydI7nKxVZs+rtn81HN9omMlkvcvwMU5XR7D0Y1q53SYyMRmNT+1e/M1H6vtu0EZ3q5R+FIXZWvUZ0dBlsh9l0q4SbyY7H8K2PTe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8eOmKAVhNom6ArJGMTWbT8ndiUZ0b6FZpf5zmyNVeK7rI1L/ X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: XSzklMI1VNl40MVDM7jXHHPUB5dXqIyef1PN7jlcGMZPojPAUPzgIOzFE+CbkEhnPDyyTTB/jqWdIQgqY9bJEaGPSmnI+2GlSZRPrg7jLtKRX0Z1DEr/jScFht0alvXpV1w2mBAk4EfVu9QV5DAk9tGHApy7/ujqofcAea6Yi7wPx5ZD0DC8ud4x5RzTSMyiY06yjAVs2++UxCK1hNMZd2EPxPuoML7TWwW3Y7cu+R4hnKZBcU2VnCHUAHuZs1AkLcFTuvigi8ukMx8LOcJnPkSIOqEh5wJqyAlv69pw4cdIzQcaWC3SFJMurQAMOuQbCPQdBnzacvWPLA4aOEbHYkJjTr17zUWCcz8t5bJMewHi1FW7NOuSjZZiThUttL+qearLCmN5GXB2+ymdUf8idN0n7URrKweWxjJja88rcPHPoZtxynnL1Iu+q2LgkdD/TDDvewHDbR9pi1j7d2NYhC+Oog7oSsHBFzE13u/lG3GwUHXB9RjN1vkDYX5dshd6U57eNKxMzDWV6wpIyS+PMGuO3NCmP//qaidxr2UUKTaBAEnb+yiC5dC+riLUWush3C/kBTRhGssVI4lJHL0OZJ0izujVvAKIGjqGTDcC4TbEAMrKG6BqOgqXvSF6GAMSL+16HSMyPYohRgC45MfQ921rHedffgiTPjH1bZoU1R6OuGmeeycsbdIxkDh1iV99ZSjKbgiYsuh4keS5KMBFg1kR09pFfxcTtWgJlerM8hxCvW1Faqor+IcDk+Gr5NG4S9quj15K8nS/+v4+1zzhr4yA8OqOiGx5Aiz7DoMj9e0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b58cd0f-454a-498a-ce4d-08db66707c4d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:11.2772 (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: /CJmsetWe9VP1hiANOcTN0r3zxQQMb47WsdBMfuz1gVy7Vd+yqSAlcxcpa9kK/r8irMBgZerS0P/Xx04ypiK4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: ClkKyU89mhv7AATie1HnbKLvnLLlLFWU X-Proofpoint-GUID: ClkKyU89mhv7AATie1HnbKLvnLLlLFWU Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We will need two sets of functions to implement two versions of metadump. This commit adds the definition for 'struct metadump_ops' to hold pointers to version specific metadump functions. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/db/metadump.c b/db/metadump.c index 91150664..266d3413 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -40,6 +40,30 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; +struct metadump_ops { + /* + * Initialize Metadump. This may perform actions such as + * 1. Allocating memory for structures required for dumping the + * metadata. + * 2. Writing a header to the beginning of the metadump file. + */ + int (*init)(void); + /* + * Write metadata to the metadump file along with the required ancillary + * data. + */ + int (*write)(enum typnm type, char *data, xfs_daddr_t off, + int len); + /* + * Flush any in-memory remanents of metadata to the metadump file. + */ + int (*end_write)(void); + /* + * Free resources allocated during metadump process. + */ + void (*release)(void); +}; + static struct metadump { int version; bool show_progress; @@ -54,6 +78,7 @@ static struct metadump { xfs_ino_t cur_ino; /* Metadump file */ FILE *outf; + struct metadump_ops *mdops; /* header + index + buffers */ struct xfs_metablock *metablock; __be64 *block_index; From patchwork Tue Jun 6 09:27:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268786 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 AFC68C77B7A for ; Tue, 6 Jun 2023 09:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235996AbjFFJ3j (ORCPT ); Tue, 6 Jun 2023 05:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbjFFJ3h (ORCPT ); Tue, 6 Jun 2023 05:29:37 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8974126 for ; Tue, 6 Jun 2023 02:29:36 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3566K3WJ028671; Tue, 6 Jun 2023 09:29:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=IjnpYrE8Mt3s4OrTm6TWK+ndOWR0ylQnjuwgZK9oDz8=; b=c0aXi7MP41qYmKCUAbqort4LfUkVvMiI/IwYP8Ad3cD+ZFQgkAEApT6mAM+VP/wmlr5F PB0FOTya7byXWGBoYz9jXVRxV4ew2qfL//XzpKNn/ZA5vU3J98GjnAZQWKgxK1zwshvT O4r4GWHo4jKLMIqHpiXtO1IkJnvNKVzRMEXHJOax2iua8U0JneEMM5cLONQIUJJIU/w/ +X6uGly8O5PQ8rDA7FGDtDRCINP3CNyF8tUzRfMVBOLZ4y1odrLEQYsQkykMU5siC4hN Wj0nP9YHvpTcfQrIYaMgNR/NAmoUsK4NW7ve/g5OhR/zZ57y2tGcgJqa2PdQI44F9Vkz 5A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx8s4wsf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:34 +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 3567kvNb011175; Tue, 6 Jun 2023 09:29:20 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04r7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rp44VOdikmYgRirpHH9dpAKWWMQBueSNEFI44sU3gno9cmbIHvMVBJjmWSfgnu4SD6kKsDlfUdxVKMqhV/a6p4ulgBvcWMHwf9ZWvodP8CBSMU0OFig08YOvm1AWGGYtWZzDYJ87vd/3xkvMJPRy7puOhM7tkgI9/aYyy4iYVlU1jZucSySU1vWdsQVz92kl4lLIq7EZPGtEHcCj1koZVaC97iZoukHsY2pAq9A4A2B28fmhLzNk0p5ojLolNx1GPtqFKzK+6gotQ2ja5A5lyhzeTx1PSp9XNP+wXMc80vfEy28/+t+S7gb5W+Wio+nbWvFM6YU2+FKQq4GXGjszhw== 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=IjnpYrE8Mt3s4OrTm6TWK+ndOWR0ylQnjuwgZK9oDz8=; b=PFR4247VITkd4luelFd4XxrDl4RVghQm306VQwsCb2fEjCg8bjH7Tl69ClnsmLZBi7J1Fuw/pNpFISwHN4cFCxMLPNAtyzuals/wggSm4TY6teWHGO7qZCA2BSJZwUUYb9K/rIFqLovBuNZqI1LJP9syDPXJ0T6oz+LxzbVKzcVV1q3JNR2E6f+Y4ttKKjl+prgELo38RxzcI7utZDf4grgrKM13X3qwan3wUS8FUvJlaW/qPi4TdJ2TxR+0VUll/l+FiIfHDo5w6cUm88sw/tsD3qQrZzpBW39CaOjZIZBzD5x4Mki8tDriKeijC+eYbVdrvHuyz9mf6pWGMyH3mA== 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=IjnpYrE8Mt3s4OrTm6TWK+ndOWR0ylQnjuwgZK9oDz8=; b=iJPW5f9WMaAHtN2SbOFGso8WTJNhiox+nfbtr3fN/odEzv4yA6908ymBwuKY9uUYIj/dI1fAStnzm4Wu+HeewX836kn+/tIJIpsk61QGmiSvkz0f9ZfI1bq1QP/A+uX0XPNFBgnfDE869v374pjIEwzctTncXlU4LHEpwXvPpTA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:18 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 08/23] metadump: Introduce metadump v1 operations Date: Tue, 6 Jun 2023 14:57:51 +0530 Message-Id: <20230606092806.1604491-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0289.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::14) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: e8ca01c7-16d2-4afe-7889-08db6670809d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nNR7AzvUMX3Wx6bLG+6yJQKNdzOVVo0HnS0kdes2YNoWitEjchKdaSwgZYqvD7fNiV/INX4+JS8+abrjVl8WGA/0wBsIJ5KK0NSkOFmHl9oScjk8p1IEGOUHvEXfrS0NRxr4QFpdZLR0R8tga9odzfBi+NDIBEGyqj6uy+aa2HXy/hejTW2yZv3aG258FCNcrmj+qJLyJVhBGVxG0mSN1U6WPi0urxIOVkgQRnXYXNY27uqrzdBThu7dQhjTDkrs9S23aVcizA+rlaghxZ7mX3tiZK4+KIrZHcivjT4NEcOEYfuXejm6rF4uWN4S6FqVQ7kNqReSbY3ZpzGkWzEOAcTRaYLqvZbA/VvQZv/cIrWCY29D8k6hJlc5+HESamBAA9NBSEHeMLzC0jEjFaqMaA+BoKe0Sx2DkVw5w82aC0qyvBHpfzDn4mEBpAa2Y+NYTVmlhookOiQRANN1+2yUwrF+ktaEyZzF0x3s3SbCzd1I2Yue6ARy5zz/pOq2utaAkc3t3sa3aeawrn1HEe5npn9k/FdFJ+9UoEF0lnaKA+rPDQnJDyNlJPC16cWXTsIb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Te4/h0M+2qnWNyuw+OnB2/yra1XRkbq7qfXZJ9s/HYDlGushvhfhvaC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aAYRlg6qKrLVVM3hp+7fuYd04ylQ6PQBnl/jcb2EUzXpTj/SHvFc2wk6Xhn4Van8JMWOQYXg88hDoi1QE2RTF6/XoR9JiaMlv2SCEzpAnOqNODhNSxBKfArzSdAvCcKFc3Jd+0uEQeuLS0rp0mhVoE8xdd5jTQTS+yPTWzXjPTug0nOBi98rWrtIu5/6qoisROu899mCrLO2ZWFefbD0xe5Nvzuq4s6cu1WcFJkBlCPUhotyGm9MZBhiRb5hqzyv7I0+5XWY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8ca01c7-16d2-4afe-7889-08db6670809d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:18.5184 (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: euTlgURxJT4TEQoy850PjUZ3ioGqADjdCgmQzGwjqF1zDljaDn8tABByG5gLjR9Zj78Yh5lghdvo+9AH7cK3EA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: K14nPbGbiUwZzT6Slw4e5PFHVnsYQmUH X-Proofpoint-GUID: K14nPbGbiUwZzT6Slw4e5PFHVnsYQmUH Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with writing metadump to disk into a new function. It also renames metadump initialization, write and release functions to reflect the fact that they work with v1 metadump files. The metadump initialization, write and release functions are now invoked via metadump_ops->init(), metadump_ops->write() and metadump_ops->release() respectively. Signed-off-by: Chandan Babu R --- db/metadump.c | 123 +++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 266d3413..287e8f91 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -151,59 +151,6 @@ print_progress(const char *fmt, ...) metadump.progress_since_warning = true; } -/* - * A complete dump file will have a "zero" entry in the last index block, - * even if the dump is exactly aligned, the last index will be full of - * zeros. If the last index entry is non-zero, the dump is incomplete. - * Correspondingly, the last chunk will have a count < num_indices. - * - * Return 0 for success, -1 for failure. - */ - -static int -write_index(void) -{ - struct xfs_metablock *metablock = metadump.metablock; - /* - * write index block and following data blocks (streaming) - */ - metablock->mb_count = cpu_to_be16(metadump.cur_index); - if (fwrite(metablock, (metadump.cur_index + 1) << BBSHIFT, 1, - metadump.outf) != 1) { - print_warning("error writing to target file"); - return -1; - } - - memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); - metadump.cur_index = 0; - return 0; -} - -/* - * Return 0 for success, -errno for failure. - */ -static int -write_buf_segment( - char *data, - int64_t off, - int len) -{ - int i; - int ret; - - for (i = 0; i < len; i++, off++, data += BBSIZE) { - metadump.block_index[metadump.cur_index] = cpu_to_be64(off); - memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], - data, BBSIZE); - if (++metadump.cur_index == metadump.num_indices) { - ret = write_index(); - if (ret) - return -EIO; - } - } - return 0; -} - /* * we want to preserve the state of the metadata in the dump - whether it is * intact or corrupt, so even if the buffer has a verifier attached to it we @@ -240,15 +187,16 @@ write_buf( /* handle discontiguous buffers */ if (!buf->bbmap) { - ret = write_buf_segment(buf->data, buf->bb, buf->blen); + ret = metadump.mdops->write(buf->typ->typnm, buf->data, buf->bb, + buf->blen); if (ret) return ret; } else { int len = 0; for (i = 0; i < buf->bbmap->nmaps; i++) { - ret = write_buf_segment(buf->data + BBTOB(len), - buf->bbmap->b[i].bm_bn, - buf->bbmap->b[i].bm_len); + ret = metadump.mdops->write(buf->typ->typnm, + buf->data + BBTOB(len), buf->bbmap->b[i].bm_bn, + buf->bbmap->b[i].bm_len); if (ret) return ret; len += buf->bbmap->b[i].bm_len; @@ -3010,7 +2958,7 @@ done: } static int -init_metadump(void) +init_metadump_v1(void) { metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); if (metadump.metablock == NULL) { @@ -3051,12 +2999,61 @@ init_metadump(void) return 0; } +static int +end_write_metadump_v1(void) +{ + /* + * write index block and following data blocks (streaming) + */ + metadump.metablock->mb_count = cpu_to_be16(metadump.cur_index); + if (fwrite(metadump.metablock, (metadump.cur_index + 1) << BBSHIFT, 1, + metadump.outf) != 1) { + print_warning("error writing to target file"); + return -1; + } + + memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); + metadump.cur_index = 0; + return 0; +} + +static int +write_metadump_v1( + enum typnm type, + char *data, + xfs_daddr_t off, + int len) +{ + int i; + int ret; + + for (i = 0; i < len; i++, off++, data += BBSIZE) { + metadump.block_index[metadump.cur_index] = cpu_to_be64(off); + memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], + data, BBSIZE); + if (++metadump.cur_index == metadump.num_indices) { + ret = end_write_metadump_v1(); + if (ret) + return -EIO; + } + } + + return 0; +} + static void -release_metadump(void) +release_metadump_v1(void) { free(metadump.metablock); } +static struct metadump_ops metadump1_ops = { + .init = init_metadump_v1, + .write = write_metadump_v1, + .end_write = end_write_metadump_v1, + .release = release_metadump_v1, +}; + static int metadump_f( int argc, @@ -3193,7 +3190,9 @@ metadump_f( } } - ret = init_metadump(); + metadump.mdops = &metadump1_ops; + + ret = metadump.mdops->init(); if (ret) goto out; @@ -3216,7 +3215,7 @@ metadump_f( /* write the remaining index */ if (!exitcode) - exitcode = write_index() < 0; + exitcode = metadump.mdops->end_write() < 0; if (metadump.progress_since_warning) fputc('\n', metadump.stdout_metadump ? stderr : stdout); @@ -3235,7 +3234,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - release_metadump(); + metadump.mdops->release(); out: return 0; From patchwork Tue Jun 6 09:27:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268785 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 300F2C77B7A for ; Tue, 6 Jun 2023 09:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235764AbjFFJ3f (ORCPT ); Tue, 6 Jun 2023 05:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235503AbjFFJ3f (ORCPT ); Tue, 6 Jun 2023 05:29:35 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9AA126 for ; Tue, 6 Jun 2023 02:29:32 -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 3566E0tD009966; Tue, 6 Jun 2023 09:29:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Qc5bK7CI9ehwaMRVDUn5JLVZgOF3y8Kt/sSCkHYgUSc=; b=LS3wGY/plRAF232uJIajogoaDSWW2FweChIbbi/NU8fhUHmJ4YKcbA326HFzy/uV87n/ rU7fNAlk5ubOVP1DTFGpnzA+BktsPvlA6Kh4xoh/xxEQKoxjS54Ryg200ezS6Q2eupJa kGwD35+PckIu4+Fuz2qZ2ug6SDhrmUC6SX14pVVlOu/hoHzcYaqun9OorNNQFv9AZZWD lboJBsj2ubaKVhqcatIo5/0a0Tp1WqMd2yBGn1iIR17Mi21omi8L/gwf+vP+s0TuCw/e A/oBg18zKlHuM/+YiuBPRU5lj5OgYueocOKinS8FHsN3EyNZHaWw7tuAsiwluFFfVUNy LA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43vvn7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:30 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3569DOt6001871; Tue, 6 Jun 2023 09:29:30 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tr0c79t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lOIN9MWQS6T/FV4pEiRFP/qNrMBgeHuuShGuTwEBf1JlbZE+i/xZ6PScdlLCQpXcDsKl49uIrj0gmMe5rDXJDzNoCBduRQSueMmZip3S3ELbmuUFjkiVJCVRfgGo5SZuy/KPWJQpwPdcfYviVdZptfpZ29KpJn04hZJsxjuoNmEXQktsw1vVz5//zHniGbadShNUo6QeVs7wEL6dRwUKSg8+HS5NV0CE35B/T0+TlBwwC8amCy8NHYrZ5t8W+j3JSNh2VJSjs+81ipn53aGtweC2Eezg15Is3R2Gbqer4SdyE9YLN5Y/hh4dgoupPO2h1ZLl7UBrDPceyRlccJg+Ig== 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=Qc5bK7CI9ehwaMRVDUn5JLVZgOF3y8Kt/sSCkHYgUSc=; b=VJfWdJQOoyWAXXHnUydx1qQvr7T5zwVfhPAK2k/SJTqk3U/Vd9ZsAskRSnENr1XTnJvF2yN7iRT8JVrLTYGqFwscMXzVWN53fybzUrhR174paW0W+kDW2PFnDq19ZVsv04bpAit+CZF9jR5PHDPkkPM59LiDZZ8VVfjosm/dkpqpte5FZifMugB8WN/ph8cyaXeHwsDuMgYTPcHjJz7piUEJJm3IYeMtxU8pr+Xj/UczkxR1FS2VWB1hnLqMwFh/vNoorM+tM/nLZIGN464Af9l2LeBrNDn/588V5PE7ncqow/HkVZPZwOl1tbL37Zo3X3y14s7g3PxSkmNG67LQFw== 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=Qc5bK7CI9ehwaMRVDUn5JLVZgOF3y8Kt/sSCkHYgUSc=; b=ZOGWw3CEG1JWsoze8GGfXTrhN+Hq5u8MvKX8BcumHk59nNDT97WRMTL/GIg4MPgKoli2cGB4XTORp/VWfEQCsxA06mvS9SNSf6WLf6OG7fIglE5wial6gTpJdIRfBfzstLFE2mWiXxXNEHo2xCiU5zDgpR7+UiqMWVZVwYzFICc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:27 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:27 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 09/23] metadump: Rename XFS_MD_MAGIC to XFS_MD_MAGIC_V1 Date: Tue, 6 Jun 2023 14:57:52 +0530 Message-Id: <20230606092806.1604491-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0153.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::33) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: fd72f571-dd95-44aa-a96e-08db66708620 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aejqaJX3L6Rd4+Z6KzlzM6lo3jzaF2i9z9gVwRgcterkA3iunPhcLHMDFHNFe9yYa+y7eGV3qxp3EMz5TX6+zqDjKmwgPlc67Acy3Pq3TjQ3wQel5YC9FvIdVdD66X+4pMZQ/OaJVQCqVcFXD+iid3EESV3xnbor6ttdEkI+4+D4Nh1MyYjgguRrJGcYMGK6OjOfnxf/P+rVhf+0yB00kbdWWee5QiIZNMlO/+D9xUtxCPWAqyxoD8ia5wn0VY5RjXGR9ekU2JTbx9p6vYPA++99NIzXOSoBoEqLXMZXOSjaLZGdZsgQeBsTo5exfabOvfozTEDMu7/xDMQXvEPhm/pHl1/D0+wXhR4gLKKTxPpgPloZdgxZWP2HtaQwId46O1h3d0U7ovroc0Tp7t8wVjvnOt+QlxsDnrlC0EuRo6kJRmnbCxrQseZ4ZgUIWtdqoK5VaCvxoq11RIqMo1DrmpCvFZa50ERJsMRGX8KREcJCWxRYrvjlQWtefd4QYkNNBEIP8TS6QbQFdQA5YmMIUXpwLSCPLmlxTJ3I6euLnGzjZAVaC3q7v1rOg+iHzg3l X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gItYBD8HLR+BH9/l7tOEaqYSCkMLC77yu6vkXdO+5BEP/Dfi2LQOPucK3dRin46qLQpOMKGesmytLs3NiWL0XNurAG6ElBTvCEVyDX6ObXb1bGui2bVRjhxsEiItK0CRMHzibTfTm8DJT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YpS/BO7VIaqtDU/v9nphZe9IxQL77VXepJncUF/dnECDMUC6fvhZPdsKCoAfRB6TJVnS5Ihec334oXGptmb+ZahH1QofwKdKMj5VjKivkzBDjQhMpJjzLGYr1STaQ1LZpjkc8sTzE1VwITKQVjg9ot9lUewdrd6TXdZxjxQJnncpokadi2MuRzP72ToW8ohD9OD2iNNFqqbk+yDjEMWiHQbUJyjHrF+aEsodvSc1CBM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd72f571-dd95-44aa-a96e-08db66708620 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:27.8477 (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: 8GXWPxAyUOm9SEyKsixcPQPfS7miOIzCOybJ6ApvyeAqQsdP2AUVUUrvE1FW7zLEBKtu8H0udj1kIMMrPK+rmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: CSTd4kr-1Kinw-HUbQerhJRE7IrcJOKL X-Proofpoint-GUID: CSTd4kr-1Kinw-HUbQerhJRE7IrcJOKL Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 2 +- include/xfs_metadump.h | 2 +- mdrestore/xfs_mdrestore.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 287e8f91..b74993c0 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2966,7 +2966,7 @@ init_metadump_v1(void) return -1; } metadump.metablock->mb_blocklog = BBSHIFT; - metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); /* Set flags about state of metadump */ metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index fbd99023..a4dca25c 100644 --- a/include/xfs_metadump.h +++ b/include/xfs_metadump.h @@ -7,7 +7,7 @@ #ifndef _XFS_METADUMP_H_ #define _XFS_METADUMP_H_ -#define XFS_MD_MAGIC 0x5846534d /* 'XFSM' */ +#define XFS_MD_MAGIC_V1 0x5846534d /* 'XFSM' */ typedef struct xfs_metablock { __be32 mb_magic; diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 333282ed..481dd00c 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -240,7 +240,7 @@ main( if (fread(&mb, sizeof(mb), 1, src_f) != 1) fatal("error reading from metadump file\n"); - if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC)) + if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC_V1)) fatal("specified file is not a metadata dump\n"); if (show_info) { From patchwork Tue Jun 6 09:27:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268787 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 24142C77B7A for ; Tue, 6 Jun 2023 09:30:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236090AbjFFJ37 (ORCPT ); Tue, 6 Jun 2023 05:29:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237323AbjFFJ3o (ORCPT ); Tue, 6 Jun 2023 05:29:44 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD5A126 for ; Tue, 6 Jun 2023 02:29:41 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3566P7DE003844; Tue, 6 Jun 2023 09:29:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=p+MszovmGui6BPu0ZCS88WXwgy2jxhc11Swm6Rnk6gc=; b=bKFwq1dDcksJHg4aYPf8O3XiFTETiREvXJujeB8WxG0PPljzaAU24Mao5jo6riH+o6hw CwoyTrxMq89caOlXQP9aOARDOLNTTED0d/FXMoOURDu8SFdpgAeiSDqjFb9/dwkBcoge dzBqmUKXaSuc9HcAfXDp3Jg4N3fNUv5E2T27SqSYhrlizctahW4croK/DvTfnqjFmf1z 2rLdPsSMZr7BF2HLW0TRE1g12FvwCUwy0bqPDpDrpXbEXCRE4H0N3VxvGwzjPNCMLRMl 6FjZTk2fiyGbeF3eWlJ8/Y9EozVS21xdSEO+A9ZA/gPvH94twehsA8SOzuURWCjEmMW1 +A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx5emtsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:39 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3567fhCs001615; Tue, 6 Jun 2023 09:29:38 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tr0c7f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8fCG+XDHbHvXnuNTiYsy+k3+UjrDMEYd3/401wEGItQK1wwGS/v/stDBwi8PsAAsH7FobLeED9iB2wcmKsaJoIihHUVmPLI7BLyi3fr7br0l1pqiTUqN35NVJ1DfgxoHk7Zb3BvN1QTlALBMMURXMA5E2JKoDFndMCjKOmIXhP0DMp7K/VOz9WGMBKx+e7HcxSJzMB6jAxMkK9EghFl2Tf+Li9J0q5ITnpQseXgR/kjnWB50O0oaSFb01VY5wD1mvtntCLpMKC1bBa5gaXR48kOZAAL0mdFhDVBjYXugStHCZMjd16rz/Xd05Wf67JasyUBqSm73/CbY/EKHaonvQ== 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=p+MszovmGui6BPu0ZCS88WXwgy2jxhc11Swm6Rnk6gc=; b=ii8X3CJaDli1PK79hKC8qYDht7d8txwgs1ZE/j6SbAFEJx1lBZm+IKW601y3k0A8kS7dtxGEA9HB/Q0p2+TMDqjHVBj8d2TpUVPq0pM7XfaZB/Hu2jXs5ZIuwC/oK5YSIjLqwOlGWfnwiXscpUmMOxJ/ArEqTdzw5dwA2wzhVjdpJEnR0pAzN89EleiQqC4+5PB1MaUjhJpfYNpoeeT7nnjDAYadrqbh4kAdd52CW6mKtT/oDsMzdtYfGuhO7OSPs7lzNohzw8ulTpmq7Addtcl1VrUbuKQb9vbXTmWbLLz4TvtzfL2oIA9Jba2DZQGPLv7ze20eubjW7Oo2srA8uw== 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=p+MszovmGui6BPu0ZCS88WXwgy2jxhc11Swm6Rnk6gc=; b=pRyODqsGgpsos7hFo3lVyDPchFfOv+F6yx4Mhi65q/1ExkEGduKm3z5aV6TGf4w1NLcqNaio5uAHhPfhG5IJfHHY1BSLkUPhW4hCcvvtwqKc/t4ymsNN0LyM2mPPw8TkR8xwrB2acwbSngrDJvjNvI+gH19s5L+lU5QfZlm5UPE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:36 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:36 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 10/23] metadump: Define metadump v2 ondisk format structures and macros Date: Tue, 6 Jun 2023 14:57:53 +0530 Message-Id: <20230606092806.1604491-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096::28) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: a502e1a7-8408-4e40-b8a9-08db66708b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u51xdSLg5ejC/8UTfuIad65ZWN+oqzQs8KeMTDI3NYNb1qHjCPu76eCsor55quI/eZYe2nL8fXGgsURaon/qP6+yjyFnj2P7ylM0IDo2Aej9wXxpPIeH9ABtbhyJwuwKPkvHe/y7nG3Uhh8sRhm6Xjx8LLzTcoZ+/rZVB8m9PHrIREYrSIVq70wFNyns3INryxWdYMkMoBTIXwtL8H8x7/LZpmuwDqD7TC8k4ObGyzkdUCvver7n6a0r0LFsTxJW3ekOI0Jdkg5z9Hzsnd9InNCPZ77qGYoIno6G2VwQvhqSaspHAHyxG9LUo3+dNR/urRAxPL4aDoJyX89r8+YK00CHNai9aeiI/mDAbvU9yVidJcgMhEWP/MRTJuEap7S7gVL6AuuQsNq4K8w5WEm2nBlcprAP8ZcSult8GgJl+3hRjWYOOVCrswNjO04Q54jw0BmF935oLNZnH2pKeDcxC/tYBd1IWEDQPTDfWyLYs3jlJcbIFdQHVCsRBswBa3OwSz/CRad7EHwSbVR+2pvwRIGPEITJoF/rQRM5Qv6dWReVGzUMxCAHvah1KWwXWgiU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fehVq4v2Ggr8+Lp0jmVWD/FvwtlNPgEJaORChQG8xXCG0UrLU5aj7l9KWD/ni5xcqmuopVoLpWhp4ql/einWoH09UN7RD4l+oxEU3lVn4sj/TOB/UadoIpYVkTOP388K27/9DwaZk5NEQInuRUWsm6XtnSUjr78Shd0KOY+HX4IIfeUZMJPvbwFQ5GTRwerhwH1/OCtINvGGu5mHqCm3i287Rj+SFvcxRra+a2m2q9SZVIPTYGZ44EbZkNdOYs5DkvmNB6amq14Zu49qlbHU/gOYnZHuWXkO+8uolAJQV5pm/oFFJYyufLj93aDcewCCrOkbgaPG4Wtn9tmW17KOR+/HBXWfT7mfSVseunyEgw3GZ/AXbQUC3H6JjVYbTS1w4yCLP69Ky8Woy3NmCHeyihrqbiJDox5LV2wS1FEaOrPxLejFp2h3GYQBfSRnVvHflcx1R6EViTU+GKwAUZnt8oeUV7HIR37vK3K3xTLssuvAE6Hs5SfdBnIANbSGUEU5RTu3XZlAmxAIf03PbHr358nAsgq8S4wja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ntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: JP+UsiQFD9ucG5TeufWJ2SiyFSs0/D+11s+Yekc3XuLu5by3veYej+W4Pkl/OB0NbBfTBoqbm2YimhhZkB627ShdJHAuvXrACXW77xzl32vVd5IX2ohDTL8J+6stH/Y/TGKmT0dMyLeEy3EWHXpzjN7n77Mzq+oTWbV0qcZCvsoH85XlV6g9J7Et1SzAUPjuwsywX3LJycZ9NUeJJNOpojNX1E/PMJ+KW3DclQz288zZJzMrY9vOjU0nByIzh/1LkFMuKz+7F8kQsBWClOipunlA+FucVElGDSTq6juK2Havyoy4ktQZ61cOQM0mD0ZvPmqiPNo/ATLC8pAbmYhMCaJHEZXV/CUhLZ8Y05xuDUNSgjtfF6yJQ4jDasKTyYDZgUU+xgtHax9VD96rjrckrKm9pHG/a9roTu2gBJCh7xzOQdruRxXjdWNEKsk05efh4UWVoSZvYuqFejoK4nuc7dq8h8MNvGMxRgkBV9b2+oHHNEDHkQA+Ulncdf0/Fp6/w4AmLylhCV31F8PhPmySMnAbG1MXzfyxDg48TYXk29gWAcDcpxVmBz9vaRc2Vw7gIX5R6Z/DC8JqqqIUoA++wV5ED0SMFHy3ACdwnU1oDa5fqBgFeyX50mTYffCsTHZgwp7z+AoiqX7MqvwEIEnB09uK3Timir9oN2HTIH4FYe6r3V2rcjltq1pLf/OTsfuSqvhYDVzBMEYV+TErjchfZmfILHagFi+j4SJ+jjlbTRIqaim0npCxBwgVQE5c/4feoF218RczVBabH9+md7NjQ2EGAEaaW6b0hJ3zTa+xLYM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a502e1a7-8408-4e40-b8a9-08db66708b3f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:36.4344 (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: XMuDbG8J2YDz76G33ApOQUkOA0IXPe0qcQuM9L+XgaAJ2gqfpq80XAnQRuPWleKt1jY9yBT/VMtwlG9kfPRMdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: _avHkhE41PS6mPQw0QpTZF90j0IVxE4n X-Proofpoint-GUID: _avHkhE41PS6mPQw0QpTZF90j0IVxE4n Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The corresponding metadump file's disk layout is as shown below, |------------------------------| | struct xfs_metadump_header | |------------------------------| | struct xfs_meta_extent 0 | | Extent 0's data | | struct xfs_meta_extent 1 | | Extent 1's data | | ... | | struct xfs_meta_extent (n-1) | | Extent (n-1)'s data | |------------------------------| The "struct xfs_metadump_header" is followed by alternating series of "struct xfs_meta_extent" and the extent itself. Signed-off-by: Chandan Babu R --- include/xfs_metadump.h | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index a4dca25c..518cb302 100644 --- a/include/xfs_metadump.h +++ b/include/xfs_metadump.h @@ -8,7 +8,9 @@ #define _XFS_METADUMP_H_ #define XFS_MD_MAGIC_V1 0x5846534d /* 'XFSM' */ +#define XFS_MD_MAGIC_V2 0x584D4432 /* 'XMD2' */ +/* Metadump v1 */ typedef struct xfs_metablock { __be32 mb_magic; __be16 mb_count; @@ -23,4 +25,60 @@ typedef struct xfs_metablock { #define XFS_METADUMP_FULLBLOCKS (1 << 2) #define XFS_METADUMP_DIRTYLOG (1 << 3) +/* + * Metadump v2 + * + * The following diagram depicts the ondisk layout of the metadump v2 format. + * + * |------------------------------| + * | struct xfs_metadump_header | + * |------------------------------| + * | struct xfs_meta_extent 0 | + * | Extent 0's data | + * | struct xfs_meta_extent 1 | + * | Extent 1's data | + * | ... | + * | struct xfs_meta_extent (n-1) | + * | Extent (n-1)'s data | + * |------------------------------| + * + * The "struct xfs_metadump_header" is followed by alternating series of "struct + * xfs_meta_extent" and the extent itself. + */ +struct xfs_metadump_header { + __be32 xmh_magic; + __be32 xmh_version; + __be32 xmh_compat_flags; + __be32 xmh_incompat_flags; + __be64 xmh_reserved; +} __packed; + +#define XFS_MD2_INCOMPAT_OBFUSCATED (1 << 0) +#define XFS_MD2_INCOMPAT_FULLBLOCKS (1 << 1) +#define XFS_MD2_INCOMPAT_DIRTYLOG (1 << 2) +#define XFS_MD2_INCOMPAT_EXTERNALLOG (1 << 3) + +struct xfs_meta_extent { + /* + * Lowest 54 bits are used to store 512 byte addresses. + * Next 2 bits is used for indicating the device. + * 00 - Data device + * 01 - External log + */ + __be64 xme_addr; + /* In units of 512 byte blocks */ + __be32 xme_len; +} __packed; + +#define XME_ADDR_DEVICE_SHIFT 54 + +#define XME_ADDR_DADDR_MASK ((1ULL << XME_ADDR_DEVICE_SHIFT) - 1) + +/* Extent was copied from the data device */ +#define XME_ADDR_DATA_DEVICE (0ULL << XME_ADDR_DEVICE_SHIFT) +/* Extent was copied from the log device */ +#define XME_ADDR_LOG_DEVICE (1ULL << XME_ADDR_DEVICE_SHIFT) + +#define XME_ADDR_DEVICE_MASK (3ULL << XME_ADDR_DEVICE_SHIFT) + #endif /* _XFS_METADUMP_H_ */ From patchwork Tue Jun 6 09:27:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268788 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 0E948C7EE2C for ; Tue, 6 Jun 2023 09:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235503AbjFFJaA (ORCPT ); Tue, 6 Jun 2023 05:30:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237481AbjFFJ3v (ORCPT ); Tue, 6 Jun 2023 05:29:51 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E66126 for ; Tue, 6 Jun 2023 02:29:50 -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 3566Ba8N009932; Tue, 6 Jun 2023 09:29:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=gFfz56/iayADeJ/or96nB91bk5qUqbLWaIIosYI2tGU=; b=wJcLJmr1STGzCMqQWGHB17UGQWvErkXrcGgZNEAy1hXaNhdUBTpNcNKJfUJ8TAnwmKhi f00yzZzZ2R5F+o/zjVh9mA8poqceCvMfaCPl3jdVWlotfbVqDTc+IK5KOm8jhKrLLK+P K/uTH8Fh9ppyO3mutEE9dPLqY+iXlXHqJlWrVWlELK5KlAKdOFT4Ta5KReNlO6N0+tiY gRoPH7M4p4864IzqxCsv5rsUMfARSkCaenyzOmABuewckVC8DUEfYcS+PFSzyFjvUdGe 0xNF7XwFWdwYKK5hZTJDcuUVMw/V+9ixI+u0rnZjI05ntyZqEh7FZvoIjBfgsoWTHyp/ RA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43vvnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:48 +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 356857rx020075; Tue, 6 Jun 2023 09:29:46 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2175.outbound.protection.outlook.com [104.47.73.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tsxcw7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+LivUMpMRz9qCMWzvlI4nT1goQTctaT7AFARa/EOaaXYlAm22C8AuoTOpuO2kG8A3eLvkf14wyAvcUTc5i4zz+2De2Uscu/QxTwswDuxO5eDyZmp5e/pCHy6vVt8D+ZDz2YAvj8OKF8Xc9ARt9D2UUmNuPCu/wRf/mMZQYPFX409oZXJ3Os8j4wxxS72JTQqx5U2U86hs6LascUNUI5964yx1SabRtZbxVjDOO/inaI8PwMpiLrEAvHcb7tB1qy+X8BGidXzz2zGgbMh79Nt2RpiKrL/aFB7H1o7WiqXv4oTc/7duyGXnEk2esGDMuHGzdASAsho3VVnnmGlDBNHQ== 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=gFfz56/iayADeJ/or96nB91bk5qUqbLWaIIosYI2tGU=; b=kYeWhdS9exqspyKN4Qf4v+iCnJVnwTV4QASvi2aStrPCWOeYGNS7Fu5hAc42ZAKM0bXq+BW47wjIlVU+M0TArIqwjqYr4skmXuVpc75zH7VtgwuDN8CE2SMP+kxiahH0mW6D/5tp8iTly/sm49fSRsgGspWn/XNw2n3Xgt12F8uLQ8TOj5tmpN5kXq6E9y35O1P9qt63NlisqjXds3sgcAiixuc0mD6A4NHjAyt4/9V6n+JnFCE0CdyLe1SIg3K/aXAHV5Jqr0fE7y6+zjh4c0EQFCcNQ1EGv81uQMLVFUm1u5u0mrxITuBT9t2h/QfROupYbum+NCveTabYYdfu6Q== 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=gFfz56/iayADeJ/or96nB91bk5qUqbLWaIIosYI2tGU=; b=YQ5MifMe2mh+Gxr/bUSUp16t5m3DAl9FcB6raSr5d8EFjEMRu/N3edm9TQ0Tv+/BCWUhwpcQt4rndyoezHuvhB+1rA6cbRmPMZUf9sOyPs+8tPfokxSP2ZZiT1ujiSSJPXZuoi27EKKFA4Jq8a1UuVrwpRU+XyGhERl/BzV5PLo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:44 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:44 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 11/23] metadump: Define metadump ops for v2 format Date: Tue, 6 Jun 2023 14:57:54 +0530 Message-Id: <20230606092806.1604491-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR03CA0093.apcprd03.prod.outlook.com (2603:1096:4:7c::21) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: f702885e-5324-4533-bd29-08db6670900d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sJ57DmyC0wkfwZRyb8XPK66vk6P1UnEtHUx8aO1u1gS/Qm/al4jbfOXXP681SN9NGYiFyxcOyBWrXa5OnAx94lYiajHkQPSdG6snc1lT8rQrBv/shuF25lZfLzxmEMO7mEtuvleSdgyGVVORDNXlDgkuwZgCt2hLXVMdS0E2KzmY8fyxPuXaMSxW3Jt5aE07twPfCoDBl1WxCxGA0CftzAw/KQNBOCEDiCVWf96/tpAbEdjWG6SrVSpZILjpmhG4IKbpBedF6S4gB7q669wUDCQJDIYymrM3VYuCTu0Igh7iRFZvePvTtkAvAlNO7pMq+wfX/e5mRV76hFfSxPrkA5oC0gov9WWCNoLOebNt3M41xWaNVnZdjCfrKdIHgt5IVQWgApobZOsB8H2VlFSJkJLqu1d1AfsIqBgZ6AeGxzczxuTxYG7S2A9enqHYVgYri6HWjN2F2cPaBL1mmHc02GQAkeMumsGdVnQTvEOzQSkeWoLr/JZWbYkV2FYOBbGgqWXq4j0B0P84qxhlhfu5f+vUcJKqfom/3+38ZAogpGlFVHpb5+yxjgEPU9gUHhZ+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Zbdm/fcDWnTCNid/Sqt7i61WzhsIy8BEtRmxJ6MEp5LHD76Jrs9JcXxz0KH13CKeVWO58mw1TNYeKeXB84SLkVvP7/yRlUfb2FDSHlZBNWhcK8IYvvd7KxDIKv2+h7sO9RERqWiNb3ltZ5Pn4iSjvIl+l9i4oy+buLoLNgI+vJJgvPbBQPfGKKW8/noYQWJz4ujU5kFfu1MagCoHzmjIZxAlMu63FZGukoA14eYJcKyK+pyYyqrXh2JEoxbreqgANbLrPordLsbFzo1Wa5k1WWpT8F8Oyd94bOYwAArMPWSlUK0fsin0LjOEsYhMGivvIZPa8Y3aqmn2PLjWb5slERvNKlUt0Fcez/APfRd7tsFEGH20Bwiib5IGEsQxbmoh+iuNifVpb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5r/2osCCTBmUq006XYU4jc6JeCvO1NGAM2w0QH4eynUCs6LULEJek3RGMf8wE6cw34rHjxaVI6MCiTDTJMxtVyK1npZFoJMEj3wVXwnMAnYEWBgKXNF/TATBTO4QGPcNrq1W/cyLzv4hvcJ9GiYpyd1A1gxSlePy9CFzj3A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: iqYT8zt4siyqGzWiyd+ffH8ivRl0WXZXeOgzHEL2mJb8b23IRKUGR+OeRj4IhULy3DFIkAZvMO2OCd1GPjbzzP+TQCUAAD/B3rbmsuHW6tYXgt9W0RRWnvqjb4NxzDy1YGs8xOHCriaeEtBp+B7gR018vW/P+zOlhtIvwDCVSGXl9O1zU04D5SZmj+z2oXasQtpf6t4Xtv6DwYfaopcp0LccDbRCYUAqImW+xzJgbYNiHSZe4G/MgoQmaj157dBXCwfEU1dn+TOQxhfhDafj/gYLcXvY25A/koXkpN3/k8JIuBi+9BTkDLXyqY293EoD/QAy6Tz86HX9ycsOZi9yQ9smRBOpYdMaD1d7Z43p+gSdyd712zNVS7p9ypev4BVvJKdwWHjTyhNURSmjRM74wbFJmX/cLKIhr1oPiwqGXRY06+hd+Ts7u+Xe9vbVXLtOFAoeUhzBfycmW/R/CRGVmgCmwbSUcFWaNKir566hp4cqdSg/wrxY6u81TSfgC2mfC3FDxEsRXFqdYT3v6DHRtInyd8k+5zvKv8uwNMb+ZaGjiwGwMco8aXN6MywLSpH/oeEwg9b/yjdt6w3ZU6VbL0fAk9FMKqKjY18gK5IwqZtVvV8XDn5iskEGcWFAIzfpKS0u4oYp5gNQQAve4FlrqD5cvGat6MXiI2JxKbe7uIOqTzQhjm4nqS8UujOo3RS0NIh0TaNTn+zeXNieAHkB2XZmyrv3lfE/a9+ebjh/GLtdl3VvJxFudbBgoCr2MPTKm/A4Vxd86UJW11yHsatv3SPYksmi5KyAN814pw21VcI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f702885e-5324-4533-bd29-08db6670900d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:44.4853 (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: In8XhZW2bUw+qsY+g2WvoaleLsQmAeOo56xnnyZrNTsXGUpjg9TAAA1WUBbIXby92jNyLwlo1Ci3CLC1Ne7gmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: gsNWY8WRtuOWNX7ngwEPa1iXCo3DNle8 X-Proofpoint-GUID: gsNWY8WRtuOWNX7ngwEPa1iXCo3DNle8 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to dump metadata from an XFS filesystem in newly introduced v2 format. Signed-off-by: Chandan Babu R --- db/metadump.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index b74993c0..537c37f7 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -3054,6 +3054,70 @@ static struct metadump_ops metadump1_ops = { .release = release_metadump_v1, }; +static int +init_metadump_v2(void) +{ + struct xfs_metadump_header xmh = {0}; + uint32_t compat_flags = 0; + + xmh.xmh_magic = cpu_to_be32(XFS_MD_MAGIC_V2); + xmh.xmh_version = 2; + + if (metadump.obfuscate) + compat_flags |= XFS_MD2_INCOMPAT_OBFUSCATED; + if (!metadump.zero_stale_data) + compat_flags |= XFS_MD2_INCOMPAT_FULLBLOCKS; + if (metadump.dirty_log) + compat_flags |= XFS_MD2_INCOMPAT_DIRTYLOG; + + xmh.xmh_compat_flags = cpu_to_be32(compat_flags); + + if (fwrite(&xmh, sizeof(xmh), 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -1; + } + + return 0; +} + +static int +write_metadump_v2( + enum typnm type, + char *data, + xfs_daddr_t off, + int len) +{ + struct xfs_meta_extent xme; + uint64_t addr; + + addr = off; + if (type == TYP_LOG && + mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) + addr |= XME_ADDR_LOG_DEVICE; + else + addr |= XME_ADDR_DATA_DEVICE; + + xme.xme_addr = cpu_to_be64(addr); + xme.xme_len = cpu_to_be32(len); + + if (fwrite(&xme, sizeof(xme), 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -EIO; + } + + if (fwrite(data, len << BBSHIFT, 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -EIO; + } + + return 0; +} + +static struct metadump_ops metadump2_ops = { + .init = init_metadump_v2, + .write = write_metadump_v2, +}; + static int metadump_f( int argc, @@ -3190,7 +3254,10 @@ metadump_f( } } - metadump.mdops = &metadump1_ops; + if (metadump.version == 1) + metadump.mdops = &metadump1_ops; + else + metadump.mdops = &metadump2_ops; ret = metadump.mdops->init(); if (ret) @@ -3214,7 +3281,7 @@ metadump_f( exitcode = !copy_log(); /* write the remaining index */ - if (!exitcode) + if (!exitcode && metadump.mdops->end_write) exitcode = metadump.mdops->end_write() < 0; if (metadump.progress_since_warning) @@ -3234,7 +3301,8 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - metadump.mdops->release(); + if (metadump.mdops->release) + metadump.mdops->release(); out: return 0; From patchwork Tue Jun 6 09:27:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268789 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 B1E55C7EE24 for ; Tue, 6 Jun 2023 09:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237276AbjFFJaC (ORCPT ); Tue, 6 Jun 2023 05:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbjFFJ37 (ORCPT ); Tue, 6 Jun 2023 05:29:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0C2E49 for ; Tue, 6 Jun 2023 02:29:58 -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 356659Bo014649; Tue, 6 Jun 2023 09:29:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=jhn6nq6C7fDc9WQ3zD44XC14Goexu+Z166kOo+NIJqU=; b=AvulMe/GHsJo7sjruLdNY8gu15ISpI8J9LYg5Jzbp7k8b0yhgpmlsvuzNlzS1t1DcgtB fujANexjRivWFU2DSnNJOuPfadHyzYSxarM9mhyhlf8jTVOI3jerXyCW0xZWwkr/AqpE gQdtGa/nXdiDFLpybRVFg5ChTqiDSFRXpnu00lpkH0773KUyFi8uvpnir4f5N5d/cywI /ecn6g64g5NicBWLMfZxtJuufPE5JqKkRd7rY8E1B+zUj9MyhAIci9P2uH/oTA4/Zqhg j5O3LwJO4A/8D7aWLHx8qhAo+896JsTQ6QJoK6o6LVX1HRVEJsxHNoVrLrb4ubnrOfxK iw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2n4vpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:53 +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 3569IOgp010350; Tue, 6 Jun 2023 09:29:53 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tqcnxe6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:29:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TAzj2mCLXTn5VoKK14Hm2dJ7WnhDsKXUWWllAHFq+IkZ+UIbBc3JexBljGTi0Eyev1iVGk09fHt7M7KvmA0jnEesaa+pWpl+RFZQ1c7SBU3a+Y4Iw9PEUTI4Gg7gTOkMJtXHF4YWVYhswbmur08+LoAbAnrsudCGeQRYfpFeTQmM0zC132Z85Y8ueO/4QWc8B6xrCZX5q3hFNVYd/HebPWq6yq7L7fQG6eaPKPO9RTyt/HNZ7zMFg78FnCCYwX9oZLGWVBbIfA/NnV/s7tZ1ZcBSSrxbYnbc/JbED2HCik4jH3P94s4M8hRf6HIG8YsouivBseewlwe9RrjjJLlJ8A== 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=jhn6nq6C7fDc9WQ3zD44XC14Goexu+Z166kOo+NIJqU=; b=K57R1hTLMVnwUKVe8Fcoy8rrWAlcrldjfPSvnTMvH+AXPAorDwAGTOiJCo3qSEZI3cgGJ8IOWl2LrS71Zs6CQuVJ6LhUWmPP1X1hHQJG0NzfurvgmdPwyAB+6x9ke/uWi1Kc56enZTqM2TOoWsHZGTJ5Vioj+O3WqzdkJkbXwN3gwAgQEJFpxKe3/XWJo64Wr3o53InOCH2L32y3ywSoanie71HY1WGw7Yu4rDCAgyBsJIFYFT9QdNF0KW9Dz7r3TCGxo7xFnLQFwxHiSecVCDwX7xI/fj8WmYsWTvKQhnldh1D+56JparDnFeO73lNdTtj5LeXFBJgzhrWHc9hBlw== 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=jhn6nq6C7fDc9WQ3zD44XC14Goexu+Z166kOo+NIJqU=; b=s2gGJzfRU90LadKZafBlN4Q9iXhad7iX3M+fvJHiq+7f3yflVP5GEHkN1t34ROY+8E8GvLqRXSmplZIKwBYCRUv0hrQ7n0rfP1CC1YYchAMfU/qXDVSmGYCosRHeoZyBaUdjrLuhF8Gpl1ha03AIeKouaYo8kbf3vRq+wVJ5BHo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:51 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:51 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 12/23] xfs_db: Add support to read from external log device Date: Tue, 6 Jun 2023 14:57:55 +0530 Message-Id: <20230606092806.1604491-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0328.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3b7::17) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: c95846fe-6826-4356-7095-08db6670941f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EkOS2DLz/9Txn3+1bBb5sP2uTqygFCLJ0s1+TXFtQIaX8xyk2aasnOlkHHwtwzaauWgXxzoG3FYoQVvIqZolmJUQoEAqKImYLAAbhIRPmJHuU3FnnFKWG1KjtkYu10ICk73WLLTZfeFMb7gmn0iFIOAs8nrCP6wony2dMuKrol+dLS/8OAGJfnrPfiLtXerUFeVU33B7nxXS81lrpzZ5m+krCmCF2kxyr2EECIXhGgKAiNsPuiSHiadooFYvKKJY7J/9TZhiMcW3O4Ivvqh0C/9uwsnv/wjtRa1XrQ2ClytQFJEHUz8uDGt+yE2Ejwoi1ryoMwYh0cMoija4O5WUjC9G88LQC4OZbR/o9j6TKqnZnT0AwU1INn6ut/g5cNtGdRwcU7tlXrdFGQqV6EPX2Yk7I8cJGsVvo9rzq6JWnvSmNVqqV0CNNO3/qhgF+5Lklrc7c4xzAa5S8rwenDdXMF55fXK8uSWk3DCfgiNCS2wL3NuLUru66ICNNjhovkLfMDIz9GQzh+2fjySaM6ZOH+FnWmqETHsKMCxha45R6+rP6U7/0nUF3y6sqQemVrNi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Px4GqF1/v3ZindoRQ1uLEmfv9rrk243HlQ9QU6yEE7QpKUX3Ymy6NqoaEL5DCSRI7tlVASJB5sT1KJG5uHsBigPnnXG7k/iwp65/HdhauhRgBb2N0kn+dqRTlRhF5hPuFEGw+TFxYI6oCzO1MoMGmG+iMgTkKHQqgexOlTiBM1E4ZvXSvDccskVDeCUBoWcx7gmCVw8MHcB9p61VUJWFUnjt1hcGLnQL/nUSWo3xmFgj8rRwzSeyAjIEwv1dm6LKqHT2slVM8y14m9e0fzpp67vuNxOAsDIUbtJwKdg9KmbxqSWv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QqB26YjNsYTOMcnt+vBq4M0whr014fvSfcAnnbEBbNk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c95846fe-6826-4356-7095-08db6670941f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:51.2412 (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: ZuM4Quz3QhtkTM+KIv6Ix9P/+O+7IGo4DEB3Fw7fbwuBzuF4YSDDvkALwiExuKcDT82zebL3YOm0VpgawGEl4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: IXcc4fXBRVr8w6fvIgt3RPc2wrJDdJHq X-Proofpoint-ORIG-GUID: IXcc4fXBRVr8w6fvIgt3RPc2wrJDdJHq Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit introduces a new function set_log_cur() allowing xfs_db to read from an external log device. This is required by a future commit which will add the ability to dump metadata from external log devices. Signed-off-by: Chandan Babu R --- db/io.c | 57 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/db/io.c b/db/io.c index 3d257236..a6feaba3 100644 --- a/db/io.c +++ b/db/io.c @@ -508,18 +508,19 @@ write_cur(void) } -void -set_cur( - const typ_t *type, - xfs_daddr_t blknum, - int len, - int ring_flag, - bbmap_t *bbmap) +static void +__set_cur( + struct xfs_buftarg *btargp, + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) { - struct xfs_buf *bp; - xfs_ino_t dirino; - xfs_ino_t ino; - uint16_t mode; + struct xfs_buf *bp; + xfs_ino_t dirino; + xfs_ino_t ino; + uint16_t mode; const struct xfs_buf_ops *ops = type ? type->bops : NULL; int error; @@ -548,11 +549,11 @@ set_cur( if (!iocur_top->bbmap) return; memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap)); - error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b, + error = -libxfs_buf_read_map(btargp, bbmap->b, bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp, ops); } else { - error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len, + error = -libxfs_buf_read(btargp, blknum, len, LIBXFS_READBUF_SALVAGE, &bp, ops); iocur_top->bbmap = NULL; } @@ -589,6 +590,36 @@ set_cur( ring_add(); } +void +set_cur( + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) +{ + __set_cur(mp->m_ddev_targp, type, blknum, len, ring_flag, bbmap); +} + +void +set_log_cur( + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) +{ + struct xfs_buftarg *btargp = mp->m_ddev_targp; + + if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) { + ASSERT(mp->m_sb.sb_logstart == 0); + btargp = mp->m_logdev_targp; + } + + __set_cur(btargp, type, blknum, len, ring_flag, bbmap); +} + + void set_iocur_type( const typ_t *type) From patchwork Tue Jun 6 09:27:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268790 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 65DDBC77B7A for ; Tue, 6 Jun 2023 09:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236274AbjFFJaH (ORCPT ); Tue, 6 Jun 2023 05:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbjFFJaG (ORCPT ); Tue, 6 Jun 2023 05:30:06 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2CB7126 for ; Tue, 6 Jun 2023 02:30:04 -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 3566LAlq009960; Tue, 6 Jun 2023 09:30:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=07h4OUrfhmpPO8gZtIcQLLl+RexBBOVYbmLN1mh99i4=; b=REt1hTTAI5/n7jU61jC+xEMYhM4/ShuQCoK92w6cEQLnSh6/YwbUb1GAcPq49eJC1aAQ CP+zUB1JZNQvsAf4bOeL70dEaFQI+b/V441PmVP9K8k5En0OoplzEnF1Hw1EOc7cWuUN uB1Ut4SV7bBvgKYZ7lCtKsVTYA84oWqm2k3tqCXnjA6lFjCGlS0yTzxlOTg87b+UGnhF uY0u+cXyK7HRbxBhCnKjTG/qwqc/gkUvAiRoLfQySjF3D6fV5mvL+0o2/qStf7ZZq6jO kHCypG9IL2T9TayrICfLDL5UoknjfxYE5bLGScoNsm8im0Jrw+gh9gxdkz9S4Pwok1ds 7w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43vvp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:01 +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 3569RUNY010876; Tue, 6 Jun 2023 09:30:01 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04rn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ks+w217imQs9CyXmWJonrdrIYm1lbsXkbAyCDwnAyn+9o32u8asP7J/CaiS1Hgy6HfhQKcPdf/bJKlp44b+uR1vVd8XtiFTaxZcsdnAdmcAltqT+jj2BXkV0b5EdgZNePJeS6q27aiOqoSi/el5+bPPpxvnpgVMEv+1H/ngXXk4hQJF2Gk6bwN4++i9z/PjKnC2N9jO+6Rnx+w3xobsQdcM7aPB87B0vyVJJG4jzvgqRFL3m3Wnk1FGE8GaPEiBHl8j3QibNAB7S3bLQyGsDAlDK9k9lKOcBHCTlls3R/aWq43ROGiHaDawPz+9TQCTUR8Nb6K6Ep77mYNLN2A2I8Q== 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=07h4OUrfhmpPO8gZtIcQLLl+RexBBOVYbmLN1mh99i4=; b=ANh6fI2fEfZeIKVPIbi6Dleq0J6Ub3EQkkcm0NsMn8SPnsYMzNuvUXN/Zf1lAxEen5YMqjhCmE4UhZhQ1AyISbLjd7LCtbeamCmqVp6GAc3akQ5FgO4ftOnrF3HyY48+aL/fyhwOjN1K0eJz4S2EzLel5JBr4EjFPxpgHg+BfLrYUgU7l8zEG/AuxeGazRYjbPmwTJso8ANYCuj8hzbX1SeroclHEeXkSSevjbFG2zDcu2A4uHixtwM1oQTkLES44oxjfBwD2i9THX4+5eC/jmU2wMjwXaW5rwpLhSzUcUPlf/qvx5TT0cTNfpOxQYeyDABpfELtN/1ynYbWjwxoVw== 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=07h4OUrfhmpPO8gZtIcQLLl+RexBBOVYbmLN1mh99i4=; b=C8+xBfq1EQRVE0V6RblCA5PNXCZwAYXko6irrnclqqRh1LS6gzDlUHk37Kf+/7nQuk02Xil4L0FYbJ1s0MGcQ7YWZymhoq30ZYH90v8BdpoFtRlljDITTskt/JVDCRxN4DznBfcaD0LRLGWRVqq8sr/lNmOzu+QrC2us+vPaX4s= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:29:58 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:29:58 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 13/23] metadump: Add support for passing version option Date: Tue, 6 Jun 2023 14:57:56 +0530 Message-Id: <20230606092806.1604491-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0011.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::18) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 70cab119-b367-4ce2-7d96-08db66709890 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ojMp2pTqocFMPT1/u9NpJxc1yUtATpFd7BiigC55kFdLmXD+g3H/FDwoiaz+c+RZOjpEBR0V48kuLjnwG+APS7Ap2RGtxNa5RWeqoSl9+9zHKNUHVL2X/IZg1PEa9EjhSBdkIdwfeug0P63QKq/MjqnNjd5n8D2XEoORuj4aZ4cYLkhAUBjdrVVWIBl6WW+LyFhRJIENEwRNIgVM3B0aA+XYiUQKjLf6HrwGgUkeN/nM6HuXpfhJc3rYRpHG/BMG7YoxaenOsqJydYRzJZ9V7yBL3TDNBRGKE2ReHtvE9rHt4PXjuCZGXeTuEU1raYo0QklYKbAvQGgjfgLDc4OkXEnWkr7EqqKEWPAjnS7++HY/iGr2LjQqm8sxaqO2hWb6A2ySfajp9edIV6W+nekGsIssjkaDzHBGzqoQY2BM3JXOHQJ7gPbRwG70Rmg3/Ldglvtw8KpTDVlqxnb3ZKLIiaCG0WYZ9vzIMTnR3nMSH62lxtpeJ5ZkXwacHwpqKOhjLX9oWxInXl7chczftw6uxW8YDZQW0FPu/q+OvM6td1q3ygIyKKJuEuPSoR7huqK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bkGecSthyIsxE4lR3uAKR5nTb3B0PmMjT2H+1Qx3sJN5Q5PDwE0t4+zPa2nqInkn64BIX/MxWiZI2nFwCy8Xgdp67ncfA9f9DnZNj4whBqUX33ICtDe/4PN8bqrl2po9Tb/PjqON2oGxchA1jqrRCfH8yDKjuadFw53dA7ujKKHFkQcrJZbwYtrwdGDrgRgwh326EFZRPCxpnrMREqv71/q/yYQE7cQj4Gz92xb90rXTLj+dJfIDm+obyaOPFEwQo+HhbkaOolByfyOYhAQWa+8XqVc8wAtI7D+bxb6YnZSw1qWf4bNeVFRmMv5McXjjte9dpiBU3+xFGcBpnticpRezq5DMv0wGupp7j0klB3PuvZi5149Z/Z3bxClCQiD/yuAdXygEek3ZZW9/Ousyx35tmvUIHuAbeTqGa1QTBUMyjsEESq68fSBvej3uuibU/f1TGvNU4dd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seZVn6nq7zUEY4EAKFz1OO14h2vR73MXfLyUdmyDYZtQCjxiXd6A6crlb3H0BYqfhJhZrwO1ye4qx0MzoWQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: yz4Hot3CtGZbYBUixMWHO8AxA15miG3+UxNU4ubMHOMZr43X0cWeR6d1gSRA/fccvlQmpjVpJz0r/wqUVmXYIa7mzpAON3LBoTQB4cCcf3JBugqCdUXVfn3HzrmgXfV1uA2chMkB7Qy9r/dvc+9L5iCOlH3gdpd89hAXrzJMDoVnXh3YHEr6llR2F35LGoETAKkHllpXq9NU4TzZlCtiEkpmPYwEek84Owa9mSjVU/lp53rLpqSLNlcf0nZxxPZaIUTAbAA5Vf73xV8qCAf5/uWzIEJSegFUbgmXclTYi31FhTwpd0IhINJv6o+uPnbYdY4R+j1JJbQ+Tx7Ya8YzmmBe13sdhMHEhflHTtkNX9rPD5zQI7OPuZFnuQS2DcG0DKExmrVQV+UDJU8oUh9TvrtJHQ98TVUG5DYaaDq2jbQy/59SsQMjmb40twtlEhIPFWrvSRtUH1Jj3U7ay0DP+hNTz6KypQm+NXz03d4caJbPm0OauDOmGyAR3CstEJUyXhF+r/CNC4fSxGdaj5LaxpaD23XSnapKAZrhyb/NE7CPaowROWf0beJ+klhhhrcSD2ZKTjJhBSYlss48mbJeFN9xBtAbT9c+ByoqF3XZq/2IRFIfIWPs8nNP6BVSeWkHMZOdyhjePtpqtoVaBkrFwfMFb4Nn2FMiQwZAMfHHnAYjZIpORMZQrVUYPzcTVN9GAvLNl/wvGLa0IqJK3UzPxeYPQxyHztYU88Q6fZT4dthqR3NZOSmNvdkDx1B4IODkel/+6zhVi+ZcTGtWb2wU9QTQ5Hv2uBPv8KwBSHx7t3c= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70cab119-b367-4ce2-7d96-08db66709890 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:29:58.7014 (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: q6WzmN3XU454CvwpNNfRaxILsFCGkzOkrwRe5eKXHM3FIkEO2jo+sfO9PuzmnVmGvTuQORztcwBj++AKFIRFsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: nlnpiE3ib8PRp3M2GEiplcissH0pB1xh X-Proofpoint-GUID: nlnpiE3ib8PRp3M2GEiplcissH0pB1xh Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The new option allows the user to explicitly specify the version of metadump to use. However, we will default to using the v1 format. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/io.h | 2 ++ db/metadump.c | 53 ++++++++++++++++++++++++++++++++++------- db/xfs_metadump.sh | 3 ++- man/man8/xfs_metadump.8 | 14 +++++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/db/io.h b/db/io.h index c29a7488..bd86c31f 100644 --- a/db/io.h +++ b/db/io.h @@ -49,6 +49,8 @@ extern void push_cur_and_set_type(void); extern void write_cur(void); extern void set_cur(const struct typ *type, xfs_daddr_t blknum, int len, int ring_add, bbmap_t *bbmap); +extern void set_log_cur(const struct typ *type, xfs_daddr_t blknum, + int len, int ring_add, bbmap_t *bbmap); extern void ring_add(void); extern void set_iocur_type(const struct typ *type); extern void xfs_dummy_verify(struct xfs_buf *bp); diff --git a/db/metadump.c b/db/metadump.c index 537c37f7..a9b27e95 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -37,7 +37,7 @@ static void metadump_help(void); static const cmdinfo_t metadump_cmd = { "metadump", NULL, metadump_f, 0, -1, 0, - N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), + N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] [-v 1|2] filename"), N_("dump metadata to a file"), metadump_help }; struct metadump_ops { @@ -74,6 +74,7 @@ static struct metadump { bool zero_stale_data; bool progress_since_warning; bool dirty_log; + bool external_log; bool stdout_metadump; xfs_ino_t cur_ino; /* Metadump file */ @@ -107,6 +108,7 @@ metadump_help(void) " -g -- Display dump progress\n" " -m -- Specify max extent size in blocks to copy (default = %d blocks)\n" " -o -- Don't obfuscate names and extended attributes\n" +" -v -- Metadump version to be used\n" " -w -- Show warnings of bad metadata information\n" "\n"), DEFAULT_MAX_EXT_SIZE); } @@ -2907,8 +2909,9 @@ copy_log(void) print_progress("Copying log"); push_cur(); - set_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), - mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); + set_log_cur(&typtab[TYP_LOG], + XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), + mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); @@ -3069,6 +3072,8 @@ init_metadump_v2(void) compat_flags |= XFS_MD2_INCOMPAT_FULLBLOCKS; if (metadump.dirty_log) compat_flags |= XFS_MD2_INCOMPAT_DIRTYLOG; + if (metadump.external_log) + compat_flags |= XFS_MD2_INCOMPAT_EXTERNALLOG; xmh.xmh_compat_flags = cpu_to_be32(compat_flags); @@ -3129,6 +3134,7 @@ metadump_f( int outfd = -1; int ret; char *p; + bool version_opt_set = false; exitcode = 1; @@ -3140,6 +3146,7 @@ metadump_f( metadump.obfuscate = true; metadump.zero_stale_data = true; metadump.dirty_log = false; + metadump.external_log = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -3157,7 +3164,7 @@ metadump_f( return 0; } - while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { + while ((c = getopt(argc, argv, "aegm:ov:w")) != EOF) { switch (c) { case 'a': metadump.zero_stale_data = false; @@ -3181,6 +3188,17 @@ metadump_f( case 'o': metadump.obfuscate = false; break; + case 'v': + metadump.version = (int)strtol(optarg, &p, 0); + if (*p != '\0' || + (metadump.version != 1 && + metadump.version != 2)) { + print_warning("bad metadump version: %s", + optarg); + return 0; + } + version_opt_set = true; + break; case 'w': metadump.show_warnings = true; break; @@ -3195,10 +3213,27 @@ metadump_f( return 0; } - /* If we'll copy the log, see if the log is dirty */ - if (mp->m_sb.sb_logstart) { + if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) + metadump.external_log = true; + + if (metadump.external_log && !version_opt_set) + metadump.version = 2; + + if (metadump.version == 2 && mp->m_sb.sb_logstart == 0 && + !metadump.external_log) { + print_warning("external log device not loaded, use -l"); + return -ENODEV; + } + + /* + * If we'll copy the log, see if the log is dirty. + * + * Metadump v1 does not support dumping the contents of an external + * log. Hence we skip the dirty log check. + */ + if (!(metadump.version == 1 && metadump.external_log)) { push_cur(); - set_cur(&typtab[TYP_LOG], + set_log_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); if (iocur_top->data) { /* best effort */ @@ -3276,8 +3311,8 @@ metadump_f( if (!exitcode) exitcode = !copy_sb_inodes(); - /* copy log if it's internal */ - if ((mp->m_sb.sb_logstart != 0) && !exitcode) + /* copy log */ + if (!exitcode && !(metadump.version == 1 && metadump.external_log)) exitcode = !copy_log(); /* write the remaining index */ diff --git a/db/xfs_metadump.sh b/db/xfs_metadump.sh index 9852a5bc..9e8f86e5 100755 --- a/db/xfs_metadump.sh +++ b/db/xfs_metadump.sh @@ -8,7 +8,7 @@ OPTS=" " DBOPTS=" " USAGE="Usage: xfs_metadump [-aefFogwV] [-m max_extents] [-l logdev] source target" -while getopts "aefgl:m:owFV" c +while getopts "aefgl:m:owFv:V" c do case $c in a) OPTS=$OPTS"-a ";; @@ -20,6 +20,7 @@ do f) DBOPTS=$DBOPTS" -f";; l) DBOPTS=$DBOPTS" -l "$OPTARG" ";; F) DBOPTS=$DBOPTS" -F";; + v) OPTS=$OPTS"-v "$OPTARG" ";; V) xfs_db -p xfs_metadump -V status=$? exit $status diff --git a/man/man8/xfs_metadump.8 b/man/man8/xfs_metadump.8 index c0e79d77..1732012c 100644 --- a/man/man8/xfs_metadump.8 +++ b/man/man8/xfs_metadump.8 @@ -11,6 +11,9 @@ xfs_metadump \- copy XFS filesystem metadata to a file ] [ .B \-l .I logdev +] [ +.B \-v +.I version ] .I source .I target @@ -74,6 +77,12 @@ metadata such as filenames is not considered sensitive. If obfuscation is required on a metadump with a dirty log, please inform the recipient of the metadump image about this situation. .PP +The contents of an external log device can be dumped only when using the v2 +format. +Metadump in v2 format can be generated by passing the "-v 2" option. +Metadump in v2 format is generated by default if the filesystem has an +external log and the metadump version to use is not explicitly mentioned. +.PP .B xfs_metadump should not be used for any purposes other than for debugging and reporting filesystem problems. The most common usage scenario for this tool is when @@ -134,6 +143,11 @@ this value. The default size is 2097151 blocks. .B \-o Disables obfuscation of file names and extended attributes. .TP +.B \-v +The format of the metadump file to be produced. +Valid values are 1 and 2. +The default metadump format is 1. +.TP .B \-w Prints warnings of inconsistent metadata encountered to stderr. Bad metadata is still copied. From patchwork Tue Jun 6 09:27:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268791 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 D1FF5C7EE24 for ; Tue, 6 Jun 2023 09:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237323AbjFFJaL (ORCPT ); Tue, 6 Jun 2023 05:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbjFFJaK (ORCPT ); Tue, 6 Jun 2023 05:30:10 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 714BC126 for ; Tue, 6 Jun 2023 02:30:09 -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 3566FO7Z009963; Tue, 6 Jun 2023 09:30:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=khcOiKP7FdVbfyXrnzOUJXr8D2pCtkwLy0RqJ0MJsts=; b=G7sNiyTrzGdRoK3/8JS+uai757eD1fHdvnjSjp1ZjyI/UV9jmb5YE6cj/2pBTjQQkrnN 7m5KQeKbElpGbe4r6ZntEckfGZMWCNcINhYn2YlsbGSzbWrpE4DACc/k7jCCFWi45UO+ TXuOnK1t3EeaackP1oFWJ5LHwkYoMzkPCCWaXbCarJQy0GtSB7qLN6v0Una5qK0RzDNW 9xbu4BXEYHiNbfps6XWeH8WvM+J+8dlhuBF6BvcoQVPm0KQhhRIjkJX9EACgAhg5fhTK 5sgZlV0Zi5XRhUw9I8c8IDsZBbh0J0SnC0AJkyKnfnKRdQsoI3d1UD/SqEIwsO7WFGiO 3A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43vvp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:07 +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 35680if9024018; Tue, 6 Jun 2023 09:30:06 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2175.outbound.protection.outlook.com [104.47.73.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvd88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RdIht+nHy0o59tTHY6HXZvv75u3dbwcxyL2dFxpjp6FBo4YwWZlsX7yAFn1FhHnDYMywFNKPcu52IZQJVwQIt0MQAmEdBUzlo7nGSpqc5xHCAskkmZxbH7M1v7UyS9wZIwCocFGuMzc4ySuF1ky1BdnP3ilPN7pfW86udpvAkRuajsgco1QCZowNLSIiHezqht+omJhtcd0cFvnasjDy5qcA+FPoW1YdxRdEtulW1vUdJmdN5CKhF7vsxNziUFsDueICGEwtcsLL30vNprZqW+2lUMxOYGIjYlqBXf1A/okPzmUHPBXd8VWnvYtXZsVfgD6Dowcq+lImnA4N8IrYVw== 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=khcOiKP7FdVbfyXrnzOUJXr8D2pCtkwLy0RqJ0MJsts=; b=ALmeZb4XQz+3sPakgtDl65R6U/j1OAeVa9ciD/YABk7ikFGY5Co+6KO49OtK+PZnVuhNAvxBEewF2anVGsVeNGptsktAwdt2DFZpOyq92i7JjPFJ4s9DLAyjiCoHgqGyx3B5q/oOjIwS8BY6nyLslPmoW8YTjZiuiRng/YKkYUA5tNAkDOVNdiVWhnqsvi1Y2cEmztbKcAmkPQnZVnZT+oeljXGJxnrZNjBc+61n4LOokM+zOtDVtwM9kakf5VTw5nbgigThgKOrcBGn2VVIuSbHTCSXdexPnINU/E4Zuc/OkMHfcgDAgev+6m8bB4CInl8deSDXvV0PlTxSNWGfsQ== 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=khcOiKP7FdVbfyXrnzOUJXr8D2pCtkwLy0RqJ0MJsts=; b=UT/+zKjOy1ke0DiFIxCOTMjEVMYULzQQttYkU4F9bOl6OT5Q7hKkgjWfmFqCulgi1oEscbr9qDsJpshRcPiWv+BrCgI3WpAqvqoayY78RijQ9sG+emZwFotSepLOJ7VZnBMjxMNesW4eKSSMGwaznOtCbEEZY26/g5I/P1zvtKs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:30:05 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:04 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 14/23] mdrestore: Declare boolean variables with bool type Date: Tue, 6 Jun 2023 14:57:57 +0530 Message-Id: <20230606092806.1604491-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0172.jpnprd01.prod.outlook.com (2603:1096:404:ba::16) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: f944d33b-1e75-4822-15a9-08db66709c3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6h1tBzlk/ZwPs1FZEgxOUrlS4F1xspjrgrd/CEmWsLUnghKa+crA3tbjmxBc6Xsc/h9Ymyn2xwc/JlheP07QP+hTZrasdA2DKij6IoqJoUtDTSjdbxHjXDLetqyJpDoAt3d8EryQdavcMn9X6hm5DendZL6Kw5P67NXhzVeIt5aIBeKkc2l0iObkEf0kUPhVvPlVtfG16b+X37C+l8gM07SQ4gxbhuHNzASLm9Fhotdc2E0ETk6lpPcZZ8Ky8hZR4O6AVDZSOmqmynRqY5RphcLw83oWSPiQOh2VbRvvlwZegxOyCh101Qg+x7thQ8phshoUmvRA5pQV5dRkPwCgehjCHyEiAj16gh+bvizdLHpYpthvnE0bMaZcqsmBoTkSWTiSxZG8H9v/JDQ0E3ifuyRIeecW90lohd/Wfn806iq6dLAQt2+UITwBoKQ293bIaIKThK7w6g3W4Hki7Nip3c0p8q8EGmfIA8mVi3T87kRX0AADhawKYOFGd8g3+EjTxfUB8NOB2inYTTKwH5Ac/smGEWRANqQUDNDyHy6IISaFpdm5yPDm29EkzbKbo0ma X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mw5S9vWvK9yeiZZ1+1PlSEJ8AYz9+OC3SS8rOjnA7P5g7Ek3cmC3J/i6e8/599t5GPOXbSe0P7foa0uMWhhlPCLIRycA8uVwnJ7XfNWtV2WF5Z7Tqj7U2cAgDPjjMx1oTD0UYW5K5FceaDe8uaPvAm0V8pdV4RJ/R+ZoKXApAEn7NvGxu+9r5+f+31npPRRdMwetxsOTYjjDZTV2AGb2XDAGZRkZQbXGdDcebj/A9grz6/Lmls2bIKa3Qk+DL0nhU2AU4fN7972/FXOm9PLVebAGkIF+qNijhPD4ZLLxWfQjn/6qTUqGYdYv7/26h+1ntHVLiYteVfrjLgRuEtuAq2eOTkBT70mAqgLkLgc/6U7ymqN0O2FRR/0lFvzp3VWuUXUPigoc7soUWgues7hJ8vi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iq3Lcko9Gd6O412qKJ9raJFeHdG0UXdFlLi0JrfuAjQTxaXm+PWiPtA9TjBosKxoGABYDA6C3FUISY+oS/jiMa8SDYC6lNnHd17p8FESgf1SPU9MwkAh7f7GWzcN0cN4GWVZfBTV7y7Ur+w4Rvxeyw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qOTIieBJBjXth90M/1fDfrxbuuM3BcVrIrxv1JmvuIwku05yaV0/vqrLeYwRRMBh8cOHfgpTRTGrnfN3VKXL6rqME4HljcHNfVq8OLZlL+sFlm/eQ9vkk3q32LtXrtDjgZcOnqjMCWMwdg2UUcQCacW7NH/d2BJMG5+rHkv7x+tmWEiz3FJI0XWCNJQELqk0vwzhNI11iZC2Gdd30HIqGnoP6JU/XLeUfqcKbBcDb99gKZR7fDhDJm83f8C0BI5+L/qBHXmGrgdNjrK3e1Rucx/yhsbF8M/oxYmuqs5IPy9qCSsUvcUfxh8CPsEYI/gJQlCOizGn5pKvpmxO3gEAnt37H6WESWqSDf1fzEapGXmFzAsBECSrlPqaUhb4IvShDs41pjV/I8JCzcUCJtXVXcf7EjWzAqwBTize8oFxnIhLdM/rpylBAEWVSlNAJCTWvTd9GDcSpL++aklHuaHZ1sz2P1eEVqeXYvc2F7cZsIpummB0Zzttu+aP2DTBiwUNeLOIEICUeAdHwUXYBXXeaM6yel7dWVXPIE/tz4izMIzAjFfiiVHyHj1T7qSzOY2VyzN+HPUkwnzdk8DwZgNaSALwL/sQ8zeLmXFSfb1pciBk5/+N0LvfP8F0oT34txOtefM8kudBcikXBC8ve/VQXPFMt50B2oA37WpjXIX/ksCw4k6PHpXk4NBVqr/aeDOhGtrrAftdIKanJ9WIewswnF+kK7m4wwn/jvOl/2v6oC4jjDGQFPkh7UjuFwtg23QavrdZWs4kIw0tJWVFAx1dt7fsDSOiGPxCTsPcdt6CkmA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f944d33b-1e75-4822-15a9-08db66709c3e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:04.8733 (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: 3Eld/mMS3DjJNK3fSJdBOok2r/V3sAfp4Fs2UWcvOydBfm2VkepLc0Vk369wGxnsrAE2lmwrxLA++3G9lrl2Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: q8jr8harFm9eiyoq7p2FehX94KtDlGhU X-Proofpoint-GUID: q8jr8harFm9eiyoq7p2FehX94KtDlGhU Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 481dd00c..ca28c48e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -7,9 +7,9 @@ #include "libxfs.h" #include "xfs_metadump.h" -static int show_progress = 0; -static int show_info = 0; -static int progress_since_warning = 0; +static bool show_progress = false; +static bool show_info = false; +static bool progress_since_warning = false; static void fatal(const char *msg, ...) @@ -35,7 +35,7 @@ print_progress(const char *fmt, ...) printf("\r%-59s", buf); fflush(stdout); - progress_since_warning = 1; + progress_since_warning = true; } /* @@ -202,10 +202,10 @@ main( while ((c = getopt(argc, argv, "giV")) != EOF) { switch (c) { case 'g': - show_progress = 1; + show_progress = true; break; case 'i': - show_info = 1; + show_info = true; break; case 'V': printf("%s version %s\n", progname, VERSION); From patchwork Tue Jun 6 09:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268792 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 7CB5AC7EE24 for ; Tue, 6 Jun 2023 09:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237469AbjFFJaU (ORCPT ); Tue, 6 Jun 2023 05:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236558AbjFFJaS (ORCPT ); Tue, 6 Jun 2023 05:30:18 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8712C126 for ; Tue, 6 Jun 2023 02:30:17 -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 356612eU009154; Tue, 6 Jun 2023 09:30:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=bwoEs74Vh3Dw80zN8jiFW56tbx58MwyXDnWCjeWwXIQ=; b=PGvYn09rgMhudmbiO5LPJ0K59N0IdiAyI7fZrH3CAEgjBt/dREWV0og4CZtxH/lSIm42 P9UZ2NYs/tK2cjf7K7+W3YuX9YT7kRuRfGzpOFOVBqYSBDMyptJB8JKj7IY+OgqIhuzM nq7ankLpDCCycD7m2dEVRl6HYrIDnP9C5zjyzKIIpUPhs+fwn6BE8nhE5YOAq9ajjSuo eCorLR4s0GCuzrB3RfHP+yv6ijiBANGR4MzAfbn0RYZkff85fcHlxvBOnm7vHklypB7o mfoqtQaxyzsSM8rrOF2kqdFaJI47HDNkwEVdSQGSpA5CrcpeINZIGLBUn0PRnc1Q4+XG 7A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx1nvx71-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:14 +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 3567fuee011244; Tue, 6 Jun 2023 09:30:13 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2171.outbound.protection.outlook.com [104.47.73.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04rtv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fowf8LqrOIodr9j1irovSbO/VsPoOuTHw4LS4W2lNzTQB7F7074fBtwsxqtTzHOlkt3pZ/Dxx8fGMb2OA/brfAPpBVomP0SGTyZVVLuxjHBYrGUdd5oRzOrDWVjpSM+j9e6FDGIRBpx+tZfH2LIks+MOy1f1eARbtkEpIGnqhX9jyu4tBr6kYcFuYvvsvUMRSD3s0woaiMOTFmMlmlCSm+Y+vcscnGqqrOlq9+4jAZoxhw1yZTfcUcW2ipTx04vbwcaszyPCxNIt7RnimuIdJ6wZNUk8JwVfl0zKspgehFO+uBM2XYP0//v7fG9aKbpWi7zWIzO7eiksUbu+ezoqqg== 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=bwoEs74Vh3Dw80zN8jiFW56tbx58MwyXDnWCjeWwXIQ=; b=cOsPZULrIzrTwHKkITno8HwqS4wnG+UnE+TSZ1Mhsv4qVwKwGwr4yUY1KWqLVNWGdpFg+qblVtoeQwwzvqjFxtUxvB8T14D+ZaKgPukzWrsxbo/Wo/W0wd1EFOaApKbpxBesJI+H7pqCI/T6tk5ePEk5p0XZezNH9OxVii0odaMO0IngG0UIeFdkVOx74pMXVGbhOIxCTBAsaNsL3zPDiYYm4Vl2dJgdBxD2Px00TMPVbp4q48NMdA3sIue/pu3HL8uCjGpamD2iSAhf61/LNv/aZYVnJoIqSVqlNOWoCPBHeFez//lD7V2SqG+Yy+W3jqa/FC9vkb0+UIzfnCP++w== 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=bwoEs74Vh3Dw80zN8jiFW56tbx58MwyXDnWCjeWwXIQ=; b=m2LvOfZSq/rE6fxJQAeSL4WWC65sBculX0/VEkshJipwmEEzTPkKRSyPV9ULpv7cGp1RqwUrrWT3YOm7jFSD+JMDPJrjPl+2kkUFVdQ+SEmiSd3O60BULFBdl1HRrnOdIOz3VSDAWwetMRQ+ijgqq9IPMTD86LkfBXcaGw+5rlI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:30:11 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:11 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 15/23] mdrestore: Define and use struct mdrestore Date: Tue, 6 Jun 2023 14:57:58 +0530 Message-Id: <20230606092806.1604491-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0185.jpnprd01.prod.outlook.com (2603:1096:404:ba::29) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 4501e754-10a5-4023-8a8a-08db6670a054 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: agpL4KWN8m0JrJj25LumNNDngwdNGr0slKfcqlp8b2mfR8UyDrK+TqJC1OMcFRJNbembbD+z28orVvheOjU+MmhkqGgkUrAWJU5fSOetF3pGwJoukVVOHyCpdJKGVk4SdS/z941XkKw8Ees7Itz0U//oZS9iJCCQLaGUKH3GiLJKyqY1OlxKiw7GjUTsf6zFh71Ofe331kvktl4xqFvwwkw0TVjvIreHeDUlAl0fGdFdv7Djf+w+MculPFA7nftREUWpvQjKio6j+YsTzHHvwLyYKkDswQAKoN1oHDCehTAwpvZjX5adn/WrTgNjPDgaR7TvjXGHqjlHKJoJCS+EPKLm72C4srtKg5BMUHsueivTrKTeoAmspPznGnbSSHQwzKShfcsTkj60IQ0uPFY3np+YLtexF2HjfN57ZHLWztqnqqufVAKW4PxG9ugZfmJUdhPjbFXUo/ROVxaDOKEwH5HbiJvXZC9wzJDLXMHYDro7RNHrxCZ2jFWOiNjqF6bVNR1moceFpC8z4y40it1V5SjoM5cfJdbQuj4cxS/lLWLqo4IWwam1DLxFnMmxK6TR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PrqaqcaK/FPdd5nphJY1rVuBHyJpCJwcVly8jsJN2bccA4FekA6zFWZIP537XUDKjVGzXpiXRn4FXtWyNaPbNPNtjthw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fvgx6/D14U48Bv0sGDpoI3yaRCFtBtVAsErY/zEAh5lu48i61ysfn1K7MtzhqsLWDqGulKIKd0LVkB0rZ2oXCTLEEwmoBBSChJoeOD7OtruaqyIu2k5MIfboaXfpxdGVz8VAGXz88MuYfvrywi/EBCYEAj1C6lUXEk4nP3YQIHEMituDSAB+B/Pm2SLG4OBKNcAQ8u3upPkIAgxtN3ZJl+UMcH1z2VcLIwwA6uSuxYXHszr+jThI7pXLo+Vw7w3rpOutU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4501e754-10a5-4023-8a8a-08db6670a054 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:11.6095 (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: xbyafoKGq8fbhYdj00mpdeCWWnyDt1h1P77aZLeUCDBMqwVPNkBoKs2ZqhSPiWdszueTWQW97l8X5Orw+dDhgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: gPqjKckqptriOTes6zrYF1ygJhVSvQNb X-Proofpoint-ORIG-GUID: gPqjKckqptriOTes6zrYF1ygJhVSvQNb Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit collects all state tracking variables in a new "struct mdrestore" structure. This is done to collect all the global variables in one place rather than having them spread across the file. A new structure member of type "struct mdrestore_ops *" will be added by a future commit to support the two versions of metadump. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index ca28c48e..564630f7 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -7,9 +7,11 @@ #include "libxfs.h" #include "xfs_metadump.h" -static bool show_progress = false; -static bool show_info = false; -static bool progress_since_warning = false; +static struct mdrestore { + bool show_progress; + bool show_info; + bool progress_since_warning; +} mdrestore; static void fatal(const char *msg, ...) @@ -35,7 +37,7 @@ print_progress(const char *fmt, ...) printf("\r%-59s", buf); fflush(stdout); - progress_since_warning = true; + mdrestore.progress_since_warning = true; } /* @@ -127,7 +129,8 @@ perform_restore( bytes_read = 0; for (;;) { - if (show_progress && (bytes_read & ((1 << 20) - 1)) == 0) + if (mdrestore.show_progress && + (bytes_read & ((1 << 20) - 1)) == 0) print_progress("%lld MB read", bytes_read >> 20); for (cur_index = 0; cur_index < mb_count; cur_index++) { @@ -158,7 +161,7 @@ perform_restore( bytes_read += block_size + (mb_count << mbp->mb_blocklog); } - if (progress_since_warning) + if (mdrestore.progress_since_warning) putchar('\n'); memset(block_buffer, 0, sb.sb_sectsize); @@ -197,15 +200,19 @@ main( int is_target_file; struct xfs_metablock mb; + mdrestore.show_progress = false; + mdrestore.show_info = false; + mdrestore.progress_since_warning = false; + progname = basename(argv[0]); while ((c = getopt(argc, argv, "giV")) != EOF) { switch (c) { case 'g': - show_progress = true; + mdrestore.show_progress = true; break; case 'i': - show_info = true; + mdrestore.show_info = true; break; case 'V': printf("%s version %s\n", progname, VERSION); @@ -219,7 +226,7 @@ main( usage(); /* show_info without a target is ok */ - if (!show_info && argc - optind != 2) + if (!mdrestore.show_info && argc - optind != 2) usage(); /* @@ -243,7 +250,7 @@ main( if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC_V1)) fatal("specified file is not a metadata dump\n"); - if (show_info) { + if (mdrestore.show_info) { if (mb.mb_info & XFS_METADUMP_INFO_FLAGS) { printf("%s: %sobfuscated, %s log, %s metadata blocks\n", argv[optind], From patchwork Tue Jun 6 09:27:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268793 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 9AA7FC77B7A for ; Tue, 6 Jun 2023 09:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234792AbjFFJa1 (ORCPT ); Tue, 6 Jun 2023 05:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjFFJa0 (ORCPT ); Tue, 6 Jun 2023 05:30:26 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D01F0E6B for ; Tue, 6 Jun 2023 02:30:24 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356640bY022359; Tue, 6 Jun 2023 09:30:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=fMvGXZexfWN1ze0vCgPVXTtiwJ4yTHJNInnU319l360=; b=2SKQ36YEH2IyINuUYMQclkdlsexuyL1E4jiRW3rRNA6brMBci0ZPlqGHNXfb8iwJsCsX wmM8gwcIj6foY4NC6b8LMJ668H+LO1uSTLqCXLRbk3EuxnubQTJ4Cq9/1wbsJva97GR1 8x/hMxj5mrZakGsHIJaRNvyDJ00tMSJ05LrdP3Lqu9C7sVDOYx3ChVAYqtPukNC6H6q8 OFrN+HOjPhU42tuOZ7t8eiyanXYmdkM7tfLLvNqM/VoBXtXCC414oeVNbo6w60XpYI6C RawIz0tesFoMurl+r3V28uMImM0YlsbhxzShAACBv+OhOrx1NKuJ1PldwJfTxEO2jqzY cg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2wmxqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:21 +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 35680ifG024018; Tue, 6 Jun 2023 09:30:20 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2169.outbound.protection.outlook.com [104.47.73.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvdju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7LoOA/1I4bLmlVhvXicLfu+dBNM1fOvhrRbxybuUHAT3hAXkpmbcaoVvTNlIEXRbISH5JAXbigwJEZ4M+ajAUBHkaIkUM4ImEm7pnJbRMJb586LnKGQG6XTGtLUdpfMZKiXztMQllFajBLJyCH2wAkgROgd49YiOGybczE8fPUg4xVd3ndCknOTXf9iR1uWVPTgyEEJjS05ZQxU6+OYDdkspYMWuj5gWSqekv/osZO14vVsBn2BZCK8hvPXWPRzbuuNssJ7/2pwPLfn5EHWjadfT67dlwZhO5avVZ9HQkbB4czwQuYxYxcXVzZg4GEg86ugKBG2HeRHUmH9w5Uc1A== 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=fMvGXZexfWN1ze0vCgPVXTtiwJ4yTHJNInnU319l360=; b=KO5VHkNszhEwPmUTKW4+7SrfrG6ycce1kkl+GUHctSnJERoNr88HHeR/5xmhLrTJ9WatzCA+1+ubqIMUdpHHgLZN3ndKMOyIlecBhHcXEp6cEo6dWp2zqcYIOckYLESdnSFWDg8JJf9NTSucUyv9MEVsj03tMtB6XAa1OIhZGyR2YEyBA0nHjlg7515CuMBXnurkJTECUeTUoOMVafGw8GZ38KSsgg3NcW5XNmBr0CxywQ04CRHPJSPPl61YED1zvgk2WqNulY7TU7hakW91NBncTjrNhTBAcQcmoKCcnF7qA296pDAZz1XWuyWKFpPZUZL5A8RENynOpaiwKaKzog== 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=fMvGXZexfWN1ze0vCgPVXTtiwJ4yTHJNInnU319l360=; b=fOQNjz6kOsvWpLY7oknt6eKpNFEg2FgTX/ifGz8HeGTMUSdZvdljNz+8zqS//TElnSbylXPKw1rXuAOW0sPly3ghq3BU7lNko99PgfHk0KYQjzeca9JadqX5TTqGpy33V0WrzqU5cozskCoxMKoWAsxtxTFqmdvF0HrIBwqSoSI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:30:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:18 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 16/23] mdrestore: Detect metadump v1 magic before reading the header Date: Tue, 6 Jun 2023 14:57:59 +0530 Message-Id: <20230606092806.1604491-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0127.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b6::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: f7aabc9a-22ad-4cdc-ed74-08db6670a476 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pmlY4KGxSEd/cHw2vfIcdBfJgkAjaz274PDi/We8AFjTJYY70SlWc3DYfZF5x4qR6aocG3p028jT/A682g52tuEoL4DDNUzZWnzFswBMjtR2w0gwqG2kSmkoIgqPN+DR8J4bHDs8lKLHQbe12Nm6bnDbQ0taa4oUwVZleau8J+2lJhSu0QVBB/S13SQJTXYulMA3PxvJq24fZ/vWfTmZetsCjY+6ti4zgXel3BR15KFHpLcSOW4civVeD/toH2Pfoyp1SXBpTXDQYD2qF40KkrzkX+Fxfx085eoeTapV4ccTwwEyuOWR3L5UGicNU3XWCQ2EhCmoFGYChYPxKfLR1zVLz6y8U+8EwOuaReymK2FGyeBw4VT1oED42RhMQRj5I0/btztn4TUrVe8uhV704+tCnZDiAB4xchpUMOjofOEKeHGwyqFAzBPRtkqGDQRwP9bIhP84Grlsqk+oDl+8oooF6Zj+CgDJHL1FTtjUR1YEJF0x7zVLgxYHidtaVeiZd9SVPeNmmSJXO1o1L63hyLkmywT+/m5ittUnNO4Sk9XtkmxzYLjTtd5HPQEim+wx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1ezPqvWcNw/7os75Q3hU5WaVDD6yPE65PxVehMVGqt5ll1I2cvEhlucm6OAxOppBfy1gqXX9WNkjdg1r9si767wmOgZtZMtRzubcGKLbFQAVdq/I1g8aY5/Zeg/HglAGgbHsGdtLIZjJdsJAYq/d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StLxfSj1W1yXUp4CZo1xY6sbS8G2aMxcw/wAIET6fXjQTJNRG3HXaGieiESkGaDqbBHwfF10r+KkpOtTYGqpKFd4o7A3QEYBbJQgDNwlMYi7PF8aeoUFJkN2gtan0z8WaAxLHRsxZijb3HH+TYGG8I1GAVIoULres5L6rj7IKPNyou6TpgNOJnwd7cE+5haBDWXknTT4jSReY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7aabc9a-22ad-4cdc-ed74-08db6670a476 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:18.6570 (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: 1c4BW3VIglAvK/Ffcs9GYqVgnoJcmxA41qXVFYKgMSi/2rC3b5IzH+VqO4o8wgHn1OHXWPq6bwAzPlGPprHvJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: z11k_BMKlbgtuVJnVgFrvwHDUVEYQNIg X-Proofpoint-ORIG-GUID: z11k_BMKlbgtuVJnVgFrvwHDUVEYQNIg Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org In order to support both v1 and v2 versions of metadump, mdrestore will have to detect the format in which the metadump file has been stored on the disk and then read the ondisk structures accordingly. In a step in that direction, this commit splits the work of reading the metadump header from disk into two parts 1. Read the first 4 bytes containing the metadump magic code. 2. Read the remaining part of the header. A future commit will take appropriate action based on the value of the magic code. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 564630f7..2a9527b9 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -198,6 +198,7 @@ main( int open_flags; struct stat statbuf; int is_target_file; + uint32_t magic; struct xfs_metablock mb; mdrestore.show_progress = false; @@ -245,10 +246,20 @@ main( fatal("cannot open source dump file\n"); } - if (fread(&mb, sizeof(mb), 1, src_f) != 1) - fatal("error reading from metadump file\n"); - if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC_V1)) + if (fread(&magic, sizeof(magic), 1, src_f) != 1) + fatal("Unable to read metadump magic from metadump file\n"); + + switch (be32_to_cpu(magic)) { + case XFS_MD_MAGIC_V1: + mb.mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); + if (fread((uint8_t *)&mb + sizeof(mb.mb_magic), + sizeof(mb) - sizeof(mb.mb_magic), 1, src_f) != 1) + fatal("error reading from metadump file\n"); + break; + default: fatal("specified file is not a metadata dump\n"); + break; + } if (mdrestore.show_info) { if (mb.mb_info & XFS_METADUMP_INFO_FLAGS) { From patchwork Tue Jun 6 09:28:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268794 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 18DECC7EE24 for ; Tue, 6 Jun 2023 09:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237481AbjFFJah (ORCPT ); Tue, 6 Jun 2023 05:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237474AbjFFJae (ORCPT ); Tue, 6 Jun 2023 05:30:34 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A898E5A for ; Tue, 6 Jun 2023 02:30:32 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 356605lQ023149; Tue, 6 Jun 2023 09:30:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=OCK27azeuYHDTsG44+AcffrQ7nMDRFPqzkD6o6M/kv4=; b=w66WuWF+kj3tShSbnH4VVOsFZ0PCHswNbeVrRRde5rVAL40qaiLeeZhEi7QLuqO77qAc uq60jzbWwOb+z5YGEZA6bsCt0zC4qASbsTrgQO8sKPY4IawgDPaJKDa5PmuBa25EeM9h 4CoaL3QumII0XRrghiQgGjNvltfTPRfivicZcOWSOggDPY1KdBDAlWm/zidW6y9qzZvC 1xzLwlk2UyDLCLaX3ZcOK5SCCxrWm4f2TIv0E+YMqt2Sn4Hcu9QW25fUrDkiozH+xgLM vQRyYFJDT7e0cz0sfeiQRzRSb0uWVIN5a9BHGcP3qRUdcuvZVFjIeWMCIMWcRTC6CVXj Wg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2wmxqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:28 +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 3569PwiT024059; Tue, 6 Jun 2023 09:30:27 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvdtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exsQISib/UUuUj8jHtAcqqJ18E7tek3kpzDaW9gv2JAeqDtFj0+aELrgZ9wwYQ1TCm+2/0CZaFy5211pB3HtUWgBaSMQKonhon0u704ZyWlo6PfmbBivwmybD1mVOPk13xWdQcI+LGXmJRbf9WuRoNh/8XWJtQcWWwhczxL+iHQQAO/WKPnpq0w5P/Yk/6P/gqRjBxxxQ8UCvP0UX7dKo4X2Ju43829RvUD6DIl6F01BYN93+9+XGxU+/6HOLzMzoTswjHe/ynuU1DHS87HDj2J8ENilDVjBfaLGXWx2XxjnndqdIlx0uV2HNvkFobCaQEnshOHCLhJssWTWPWUY1w== 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=OCK27azeuYHDTsG44+AcffrQ7nMDRFPqzkD6o6M/kv4=; b=bnEP3cAlXzDJaB19WK3apzBc9PEXtIR3f5xad7d+kjV3iBg7qX5+1iWP8IJzlwzHFNy5vkPzPHP0naA6SJ1isMAoI/wUqmJxX/6zeaTT6uLxPhlm16mUezm9WPZi0jTbR8rfSXgablMjTE+srTabzRog9l24SU13TtZupVFrdXZRR4+0z5sD+OoXnZcasXtR4qicjKeRFIPI1IJHrs09VP6FzsnG+0nInPYbyhAtzj6GG8ZE50WecXCHpxs+fHZetljxDRmxyPvzjLV9ehEJuO7MNwGZ+GcvUvTNosbdTOVpgdew6aZe6uwPonOMna6VB7aFNSFBvGzbGorCCNFPsw== 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=OCK27azeuYHDTsG44+AcffrQ7nMDRFPqzkD6o6M/kv4=; b=PFyVtZmnTViCrCeETHQ07KWg5xz8cAlPzPd2Pg0HL4LwRKEwcqZeB4ov8W749tlMl6+8gFn3mLWMoTskehHpFQJ0DF1gAk8gu6e83ZFWMji5o8wDtdzRNKPbEm0SGxZNRMKOHN+tTBm9yAS+Wnb4czZa3ofPm7EjYKUVZF3V2Ko= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:30:25 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:25 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 17/23] mdrestore: Add open_device(), read_header() and show_info() functions Date: Tue, 6 Jun 2023 14:58:00 +0530 Message-Id: <20230606092806.1604491-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0129.jpnprd01.prod.outlook.com (2603:1096:404:2d::21) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d746ac1-5932-4237-dc30-08db6670a883 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3f43vFGdY/kAv8PObG7n+sDp0nmA494pPBOj+C6ZVzh4em9KPIY+iWzEEz8joNOpa5omH/iKho90hDY55oUdZid74ENTUxT3AB9/TozDJNIdAoZ3QjKVhXboqeAk1vuuAFboEmWLZEWujb7KYJkB0E4WNFTS6FtvvumeobT6kkoQZPCMvVwaYJIp/W6iebYgeYG4kY6UhWuETqBUb/XV+TKpo6ZAD4pBu9+QSyqveaRn3DPziAlPAAFnpv/g0hseo5Ig+vkoB4FbohZ4sMILJZHnY+FRSS2b0B9y25cXrHrLHrfg0kQD5B4jPnSnaAGgk8Nh8HxNE5C8UUV6uN1b6xyp0PdTCjAjc7jS6fC+xKhmo1YVcbXw6TzX6vBUZVE9ZxSOfU9k3R190aoZwgC2yo7gDa/Rf8qnAm7ZKJvqUWBwbolku6ZY2genMVAwd2Of4VloELzU5oCYObKNUqLNUSBBuG0N3ITYV0JxoL6dbU3aELWllyORIgpzjl3LWVDk8ydO7+5jqGyATIBTgNHDXCTqVFEVzuScq1dS2hcwlU+iCRzauNUU0I6LN3Wl/okA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lnHtLdhVTaGHpZECh2o8tAPkKmm0toORWTwMQFeYXIei1Sp2sCOgEZ1aeAB0axrpLcUq1O3ZxUtMefwcGVCpIYy/MjzmsazKdQvFfhNi665znTVlsNsEj4B9NQGx4Fwr37Lez1fKW3YJLjIefvvDLdrNDYvNBUigDsvC1R+uSZ+rNtQlCP/Fm+56gg9lMUriZbyx1Dkq9gPvi/4GfEyGDlH6KfLFfP6GmxdmqDeHgwEBhxkl+MDzIRuKCmuDf9eSLZcYP4xo66YEU2DILYZCstGFXR/3asnAk78ytEwTcCaMJES1vxSA0mHe7mDa4hvwtvYqA7aL7LvZdO43QjqobQQIXpAjUou75bmnbqq0IUrwGW2zSpMTPkW9FaYJakkYWOsg8pCVNddRKXj2YDiql30VPMG695DgCnYzvD3BLPTDjYRJo4shAN3KX30aXEgCDRVU4zBUyW0NQBp+MSD3LryBUHm3q/QGcHleK9AUC9GUUW4ktrER/CDjQ75DySYDVOjfG/xp4FgrhNyc0qQ3xm+KtCDBRg7Jg+ctRoKUeEukAVSceuah+rVRumWU7HIIIFkNpo4uc5sc38Y2OxWM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change-AntiSpam-ExternalHop-MessageData-0: UaHEkmQ4S8gDNR0Du688di+PcQAHjd/lOeU3Ls+2kitazL/GIOhfHSWZS2VAP/9gBMp07yP7KDgyckVMoOWpOX62CDfrSORZ3NwIuq3eYX93+JhQkPqBnEuQtq7+mj39SelIGNSzMz9X4rN+hmf1deOl3SKTn5bcM9frEOSIN/vaoXs2ds7vL/T+2gFku6oA1d5NF5Av79ihwFFz8Z6lVhb+YdWVz3uOHpIvH4nKvZxocwcY5HxeVD8Hveh8rtiNvV1vwCIQBM754H8/mD5wnRdJEm8Z5OhZIMXWrT2AUCxeN3FoKn5QXoq2TEDTGEudYTNSh5bN5fLqz7iwhVUnfwz3+HLa7Y2eUybrrWDHwUdmeBDP6t1DTCLlZRYgQqg/DIhp51drmbFAeE0ciM1vF5jSLyAB8hSiAWV/OYyzgP9x5Pzig/YG0RR0mxh/rFdQn0dsACrDo51HxcnL+NRyJEoPSO2OTboGYIw1SEI+bj5ODrXGH4fT9YgGcAnv7KH+U/lpPF2yq0sIl/Sfs8bLqxuvrz64Zt+nGnb3aT/+XzgdSEoy71byBfUSFqFHoYia3ltq2439JGme+UGKsdg+4c+8PE0EEdAjGSSNE4eiFD2DQy48L9iYdUB3UDySOrOwkz+Ag5ezNLjEARAwMSe3xeliBkrt2o42EkJ130iZIFInKTMvNVpaeLYkfocJJsj+e9E9ezp1bASSIAOIfDV9rWj7NYDagFFapT+Cgy6uo6ZWIG3sIo4mGgVvdeRyhpzyCks107qo7K+RCcE9mIRZpQL83BFfHzfugwEY38Z8GJ4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d746ac1-5932-4237-dc30-08db6670a883 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:25.4615 (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: jUe3BCkZ7HiIxpFPiSXKJNmX4oO5oDIG3FY81bX8nAN2/TIlKCf/HoEhm/HQQD18c3tHy2fk3/4NOMTqLK9CXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: 3YsQrUeK-Ylo5gqSG9__rMX3jfsMrjj- X-Proofpoint-ORIG-GUID: 3YsQrUeK-Ylo5gqSG9__rMX3jfsMrjj- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with opening the target device, reading metadump header information and printing information about the metadump into their respective functions. There are no functional changes made by this commit. Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 141 +++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 56 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 2a9527b9..61e06598 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -6,6 +6,7 @@ #include "libxfs.h" #include "xfs_metadump.h" +#include static struct mdrestore { bool show_progress; @@ -40,8 +41,72 @@ print_progress(const char *fmt, ...) mdrestore.progress_since_warning = true; } +static int +open_device( + char *path, + bool *is_file) +{ + struct stat statbuf; + int open_flags; + int fd; + + open_flags = O_RDWR; + *is_file = false; + + if (stat(path, &statbuf) < 0) { + /* ok, assume it's a file and create it */ + open_flags |= O_CREAT; + *is_file = true; + } else if (S_ISREG(statbuf.st_mode)) { + open_flags |= O_TRUNC; + *is_file = true; + } else { + /* + * check to make sure a filesystem isn't mounted on the device + */ + if (platform_check_ismounted(path, NULL, &statbuf, 0)) + fatal("a filesystem is mounted on target device \"%s\"," + " cannot restore to a mounted filesystem.\n", + path); + } + + fd = open(path, open_flags, 0644); + if (fd < 0) + fatal("couldn't open \"%s\"\n", path); + + return fd; +} + +static void +read_header( + struct xfs_metablock *mb, + FILE *md_fp) +{ + mb->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); + + if (fread((uint8_t *)mb + sizeof(mb->mb_magic), + sizeof(*mb) - sizeof(mb->mb_magic), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); +} + +static void +show_info( + struct xfs_metablock *mb, + const char *md_file) +{ + if (mb->mb_info & XFS_METADUMP_INFO_FLAGS) { + printf("%s: %sobfuscated, %s log, %s metadata blocks\n", + md_file, + mb->mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", + mb->mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", + mb->mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); + } else { + printf("%s: no informational flags present\n", md_file); + } +} + /* - * perform_restore() -- do the actual work to restore the metadump + * restore() -- do the actual work to restore the metadump * * @src_f: A FILE pointer to the source metadump * @dst_fd: the file descriptor for the target file @@ -51,9 +116,9 @@ print_progress(const char *fmt, ...) * src_f should be positioned just past a read the previously validated metablock */ static void -perform_restore( - FILE *src_f, - int dst_fd, +restore( + FILE *md_fp, + int ddev_fd, int is_target_file, const struct xfs_metablock *mbp) { @@ -81,14 +146,15 @@ perform_restore( block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t)); block_buffer = (char *)metablock + block_size; - if (fread(block_index, block_size - sizeof(struct xfs_metablock), 1, src_f) != 1) + if (fread(block_index, block_size - sizeof(struct xfs_metablock), 1, + md_fp) != 1) fatal("error reading from metadump file\n"); if (block_index[0] != 0) fatal("first block is not the primary superblock\n"); - if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, src_f) != 1) + if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); @@ -111,7 +177,7 @@ perform_restore( if (is_target_file) { /* ensure regular files are correctly sized */ - if (ftruncate(dst_fd, sb.sb_dblocks * sb.sb_blocksize)) + if (ftruncate(ddev_fd, sb.sb_dblocks * sb.sb_blocksize)) fatal("cannot set filesystem image size: %s\n", strerror(errno)); } else { @@ -121,7 +187,7 @@ perform_restore( off64_t off; off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb); - if (pwrite(dst_fd, lb, sizeof(lb), off) < 0) + if (pwrite(ddev_fd, lb, sizeof(lb), off) < 0) fatal("failed to write last block, is target too " "small? (error: %s)\n", strerror(errno)); } @@ -134,7 +200,7 @@ perform_restore( print_progress("%lld MB read", bytes_read >> 20); for (cur_index = 0; cur_index < mb_count; cur_index++) { - if (pwrite(dst_fd, &block_buffer[cur_index << + if (pwrite(ddev_fd, &block_buffer[cur_index << mbp->mb_blocklog], block_size, be64_to_cpu(block_index[cur_index]) << BBSHIFT) < 0) @@ -145,7 +211,7 @@ perform_restore( if (mb_count < max_indices) break; - if (fread(metablock, block_size, 1, src_f) != 1) + if (fread(metablock, block_size, 1, md_fp) != 1) fatal("error reading from metadump file\n"); mb_count = be16_to_cpu(metablock->mb_count); @@ -155,7 +221,7 @@ perform_restore( fatal("bad block count: %u\n", mb_count); if (fread(block_buffer, mb_count << mbp->mb_blocklog, - 1, src_f) != 1) + 1, md_fp) != 1) fatal("error reading from metadump file\n"); bytes_read += block_size + (mb_count << mbp->mb_blocklog); @@ -172,7 +238,7 @@ perform_restore( offsetof(struct xfs_sb, sb_crc)); } - if (pwrite(dst_fd, block_buffer, sb.sb_sectsize, 0) < 0) + if (pwrite(ddev_fd, block_buffer, sb.sb_sectsize, 0) < 0) fatal("error writing primary superblock: %s\n", strerror(errno)); free(metablock); @@ -185,8 +251,6 @@ usage(void) exit(1); } -extern int platform_check_ismounted(char *, char *, struct stat *, int); - int main( int argc, @@ -195,9 +259,7 @@ main( FILE *src_f; int dst_fd; int c; - int open_flags; - struct stat statbuf; - int is_target_file; + bool is_target_file; uint32_t magic; struct xfs_metablock mb; @@ -231,8 +293,8 @@ main( usage(); /* - * open source and test if this really is a dump. The first metadump block - * will be passed to perform_restore() which will continue to read the + * open source and test if this really is a dump. The first metadump + * block will be passed to restore() which will continue to read the * file from this point. This avoids rewind the stream, which causes * restore to fail when source was being read from stdin. */ @@ -251,10 +313,7 @@ main( switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: - mb.mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); - if (fread((uint8_t *)&mb + sizeof(mb.mb_magic), - sizeof(mb) - sizeof(mb.mb_magic), 1, src_f) != 1) - fatal("error reading from metadump file\n"); + read_header(&mb, src_f); break; default: fatal("specified file is not a metadata dump\n"); @@ -262,16 +321,7 @@ main( } if (mdrestore.show_info) { - if (mb.mb_info & XFS_METADUMP_INFO_FLAGS) { - printf("%s: %sobfuscated, %s log, %s metadata blocks\n", - argv[optind], - mb.mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", - mb.mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", - mb.mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); - } else { - printf("%s: no informational flags present\n", - argv[optind]); - } + show_info(&mb, argv[optind]); if (argc - optind == 1) exit(0); @@ -280,30 +330,9 @@ main( optind++; /* check and open target */ - open_flags = O_RDWR; - is_target_file = 0; - if (stat(argv[optind], &statbuf) < 0) { - /* ok, assume it's a file and create it */ - open_flags |= O_CREAT; - is_target_file = 1; - } else if (S_ISREG(statbuf.st_mode)) { - open_flags |= O_TRUNC; - is_target_file = 1; - } else { - /* - * check to make sure a filesystem isn't mounted on the device - */ - if (platform_check_ismounted(argv[optind], NULL, &statbuf, 0)) - fatal("a filesystem is mounted on target device \"%s\"," - " cannot restore to a mounted filesystem.\n", - argv[optind]); - } - - dst_fd = open(argv[optind], open_flags, 0644); - if (dst_fd < 0) - fatal("couldn't open target \"%s\"\n", argv[optind]); + dst_fd = open_device(argv[optind], &is_target_file); - perform_restore(src_f, dst_fd, is_target_file, &mb); + restore(src_f, dst_fd, is_target_file, &mb); close(dst_fd); if (src_f != stdin) From patchwork Tue Jun 6 09:28:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268795 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 DD9A3C7EE24 for ; Tue, 6 Jun 2023 09:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237475AbjFFJam (ORCPT ); Tue, 6 Jun 2023 05:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237484AbjFFJaj (ORCPT ); Tue, 6 Jun 2023 05:30:39 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C1EE62 for ; Tue, 6 Jun 2023 02:30:38 -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 3565qoro017272; Tue, 6 Jun 2023 09:30:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=akciax8ZojrrEBxVK+N6neGuysZjYM0hnAO0E5CO8qw=; b=DI7/svWhuB+QNZ8TfNExrIVPAgha6I2EBMXVaIRr0+J1gx51F93i+JLiqo0vj08sRn9M AOoTV5I+tVWHQmWTyYGEUbQ2PJ95UifP0jlHkLgCxDFokcKuvQ2awmaGD5zaoLJPSVNL cE1nUzpPFzKMOcPIj3DGW5i7kRetNg49bwbffhsmViM0m0WvKC43TL6TxVmp8omcMNWF gW1FUC83Laf2RyExjlaOqK7q7/3mIDiVKWqimdycdaZHMuJH9OKziRb2VZLSg3vboBtZ +TLiyK3CzmjY7F+JJBrM5ey4r5Q/rBp8CCG9t5nyVL6hHInN7CUjLihFKCdYPm7TeKeu 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 3qyx2c515r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:35 +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 3567pE7m024146; Tue, 6 Jun 2023 09:30:34 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2171.outbound.protection.outlook.com [104.47.73.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgve1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mzaVwYjAF2Rau1kOwVrJ1Jku4L3Jk5lJV+hDLQGKF3Sz7GcvpoRtKU6utWio2wkWnvyA+qLOEHaaBEQncyD5tcrMekS9MGD2OkKPZAn8FczLFAvLV4zKAuxZd+zf05tAoUv/iTbMc/03EsuGa1HnjkFNVZX2cWEinZx8NPUAvuGSWJE+5MenrPCMbVFoshGYnmaNO8GbwoI+nZ2AX6ZYQV/+3AIQt9KDVgwO+MEResbT78vIu2RUDv99GUgaQPvl5UFPlWDggP9oNTMg4n/ybtY0KSy14zzHaUjh/PeX1xmqJ78i4J8SnWaxH3I1ZzkS6qduulzgATjazh26EmEhzQ== 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=akciax8ZojrrEBxVK+N6neGuysZjYM0hnAO0E5CO8qw=; b=fRleFEXV793qdI/+SQqd4rGiXy2bd/UGs/p5e1V3fNgbU7BV7UnaoY9f/1q9x2NzYJ3KaNivWN1k+FEp48YMPP9Gylq2fEhZm8C8Og2IrbtQIn4L6KKagC6UjQATJQ3kVxeZiPWBggoyyvfFNGcTnGplGuPsKDZss47aw2jIs6VRDl3HxlITq5VVz0k9dzwYAiBimsmuATNjH/cM8GGYpaLG2S2A28b3OAzzhGPY6lJhzWYOkHFlghJ1jaCT/+KJWtsm54yMe7bAb45g25dJiupfvMrONl8Y4ERIbg6HgWuJLVSpYPwzt6DBvmJniyiM/DMPt7CSS32IbcJTOqq5dA== 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=akciax8ZojrrEBxVK+N6neGuysZjYM0hnAO0E5CO8qw=; b=av0l1F/ZWS9MfwQyG2JNh6k4o+CSjtdxtgfr4rVA6+c+9cjIj0FN13HkyPocQMW6irXW0EHBr5tPyn/U7P8U2dQjveup6g6jxSHB/I5yYi06g6VZRSLe3mGnvbi+y/iY5R/t0xii8NIqj+GmttA3Qn/NCp3adLory/gUYvJwJyM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by CO1PR10MB4562.namprd10.prod.outlook.com (2603:10b6:303:93::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Tue, 6 Jun 2023 09:30:32 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:32 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 18/23] mdrestore: Introduce struct mdrestore_ops Date: Tue, 6 Jun 2023 14:58:01 +0530 Message-Id: <20230606092806.1604491-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR06CA0042.apcprd06.prod.outlook.com (2603:1096:404:2e::30) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4562:EE_ X-MS-Office365-Filtering-Correlation-Id: 1145b1df-e9cf-4613-8966-08db6670acd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DfWRBzzkvVoCA79X3Lj+UYct+TgyXLOAiFY9eaj2Habmzwyyz609husxBIO23CQRZPITxgf9v0p53NY3XurDE+KGt1msePPxQGbh+D+JI3+riEQw+RuAGKQrl9OY8FaMNml1bIse27UnbiO6KXjP+mZQW/xDv1L9HjVmTHUJalsLh+f6+cDGg6eKWhSE1LD3m0uO3AM3uIvVHH+6lTaJwusu74P06+2q5+zzqCmcKl+cokr7+mNLYyd/F2PFC94LqCf5/ysjbP9SdLe4BfPrd8aZUctoqLR6/SjeE7DRHwy+CSSInpSt44G+XOdlHsiHXzR58F6XhAe1bWFK/9N3d+O6csRUJ4ovBJ632JV9CCLM/4lF0fKMDwqAUAljegBjOSoE7YkntjWF+F1p4enIYZbKmTGTFpuqkRai/OoKhpM5o3E87r/TAhU3L2vB7ay7kdMg5ARIAD4ziSRrtaILUKbVK5gW74Fdr6oBNCPlvmse6XFLHQPtNEe+TwAAVgYzVyffLRlXY2WKCHIbZVh7SCV7mSoqIbCo2H/YTZr75btzpMoRbHZYFtDYXMPcF9hY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(396003)(136003)(366004)(376002)(451199021)(8676002)(4326008)(66556008)(6916009)(66476007)(66946007)(8936002)(5660300002)(316002)(41300700001)(2906002)(478600001)(38100700002)(6512007)(1076003)(6506007)(26005)(86362001)(186003)(36756003)(6486002)(2616005)(83380400001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oCdSyuOggfHvIk2jcUoocuwI3zlY6f1+/6Dwl+K4qQcBgonasJFQ/ZemM+QlXXwc50GcWXbwK9DF13FFLbwGNRQVFZjjbLniO3i6GRh1euzVQFzSB+gy9MwZt5lzNC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7Wm2hNWOqqjMBaPbjPkZBy/VpCesSdZqSL9lct1xcvfvGgyaa9et3EBZ5aTEfk/VwYh9xrCCOeMdY4RCzl2200KcFb+f1eRZPHsxeKhgTjYHU3/46S6r7dWSFMSSqtiTRnM8cqO+9R8i8EmkWn9JAtd/4St9V0pKIqvsTa3rUFnqnPi4L106cvJbED3G5nhbdLfdjtjMEFhYHKS4Wdf9aZnOXGyEm2Tj6lgIo18= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1145b1df-e9cf-4613-8966-08db6670acd3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:32.5581 (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: xVM4EgRwy4ZYFXuwOUeP31cYqJQnysJNChenIuaLGYIBWoJdBciWiG4BFOEVfbAz9zhEdJP32dJtb8JALVuXPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4562 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: 4SdhqGJMqcaz8ahg33NDABsg13O7rjHD X-Proofpoint-GUID: 4SdhqGJMqcaz8ahg33NDABsg13O7rjHD Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We will need two sets of functions to work with two versions of metadump formats. This commit adds the definition for 'struct mdrestore_ops' to hold pointers to version specific mdrestore functions. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 61e06598..08f52527 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -8,10 +8,18 @@ #include "xfs_metadump.h" #include +struct mdrestore_ops { + void (*read_header)(void *header, FILE *md_fp); + void (*show_info)(void *header, const char *md_file); + void (*restore)(void *header, FILE *md_fp, int ddev_fd, + bool is_target_file); +}; + static struct mdrestore { - bool show_progress; - bool show_info; - bool progress_since_warning; + struct mdrestore_ops *mdrops; + bool show_progress; + bool show_info; + bool progress_since_warning; } mdrestore; static void From patchwork Tue Jun 6 09:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268796 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 3A589C7EE24 for ; Tue, 6 Jun 2023 09:30:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237484AbjFFJaw (ORCPT ); Tue, 6 Jun 2023 05:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237341AbjFFJat (ORCPT ); Tue, 6 Jun 2023 05:30:49 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0582E76 for ; Tue, 6 Jun 2023 02:30:45 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3566I1uj023432; Tue, 6 Jun 2023 09:30:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=ZJdBaXmqIOv9kW/ReOI9djwlqPDft8L4lTUbQ1cH64E=; b=r1FrrQTXywLbRu7H7tQhPuudZewRxTYruDKrdtUVuKnb4Cx37r/Xn9cHu93GUBMQtDhG L4NXMtkQMe3/eYK8qzViKhHriuAmlo0SgKSLrFhMk34X8YhErQbJdqAQ8ZWV355f22jJ w5s2BM2ph41ijOy/QBE4AzZszxnAEeQwbuWtBuNekXhH8HmUv/CLPz/Yoi0sNhVxsY78 D5j2+9pN1tD80khA/n8PIbg3LJ+l30M6qjQanBU9YdA5nxhG38Ld5D2TrELS+tQjbTO4 8/Na6jvc3MPKo4QnK9DGESs4wU/Dpd2P8+rRQGj9aWIXHC1wDF/+zSdAAreIvp7ei8Ro Pw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2wmxr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:42 +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 3569NvcV010306; Tue, 6 Jun 2023 09:30:42 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tqcnyqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=htuENhMoBVvRVHdWjXB9M68zJ2/29GuFXPtcR4ThBhO/PH4lCSZyxZsDYbEQP9ru+4ZwOyyBRYf7RUFHJCkK7Hx8fidhxM/IDQkTVg5bgOIOfha6OfwNGnUGveEqbwoIuxnl1hBSXKwomj+doODvr7/ZkwC40FD3l+4hCbpafyMXXKaljh9CN6FFqRcq9VrgybCRYuqYcNRzUfXIvh4FKh98eU441TeKgjTf+rVcrcxQeFBKXBe/fdQfuZJcj8gF9fGSX9ok1CCKgfyX4odirvO5qZFFYWUozAAnZBEotSY6GwtcnSiTQb882qgrFhQD5PqeEmenkfAtrm1iy0Feyw== 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=ZJdBaXmqIOv9kW/ReOI9djwlqPDft8L4lTUbQ1cH64E=; b=dWkyjxtxmTUzjN0g2ri0gTOWLfzOtc1sgCMUElg5/JR4ckD87WxMgYVnK9+E3VB2Jmry52zsb2QkeZWt88MWjSqes0uaYzutSUqMJIl73NzTfi/EvCX9055lTUdZDR5gdpknji6zi2gcVWQjZOBToRchW3e8uvaoGJBUCAB5Ejbrt9c2bh8U7gL+CcVF/2wI6b0BVhaCHnWeuxs+2Az4BVr+EuDiHbC3UYCxWAkQKfdYyDypB67gyEectrbHRfg8JaITXAGWrS548H9frEuUz0/TGwZ9uAtXzRMVBrPfDR2tbORBXP8qLwEm30K9xA9ysHMPCU0g23woEYmwv2L48g== 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=ZJdBaXmqIOv9kW/ReOI9djwlqPDft8L4lTUbQ1cH64E=; b=XasCL05Wmn5QmQNuqlUnN0F2gKs1dlhGEVwvKLRQjmpkM47veJvWC0zh650szO1K1eYzfZ0P+ukd47FTt8INGpufP+XPfraEniC+XRvkqFK6Ctopz5piUe0QZ+2cdq8sIJwqLjHBA9NPTYA7OEHpR4akZ/Iy613BZ1c+49VlKqY= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:30:39 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:39 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 19/23] mdrestore: Replace metadump header pointer argument with generic pointer type Date: Tue, 6 Jun 2023 14:58:02 +0530 Message-Id: <20230606092806.1604491-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0143.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:31b::19) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: 17d48cec-5ab9-4f6b-3f31-08db6670b0c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qseyx5OkfoN0LgXe0TQOM+Yzg6axl/t1gZtTD908/tcY7Ol6yRxvOlhGtTlyrAjdIOrIce0JVDlPqrsqBlt8Lw740h8TY/7cF7VQSDPnl7rqyN7059hZyaWPlubqXlRsJF65MHTnyZWgL8lJb6ET89gGcNvY6z1gg93ZquySyfndzGn2TaDAe6W0QGYc0Yc3vOEB0UrwYeD2lSKbXu8PjVvL0c5s3VZTCtmtqeTiYAz27S49YmcYUE2g2slFZ6hHzCxaK8clMsHwSxh+ZO2X0fidGyDMckRBmPSiN+pHD4ImSug7q4WGZZBwUXSqvdfoHDLgamneSwh5sdE5ZiRo3HeAjSAs9CHgYQV7Uz8HZhdjKTfWZIuNsGyKslYWs/K341PEHbWAZpaNivE1JGoyCioC2dnGJVhtFbTIYEPvOvZlFgL+OOXQ2WRKapm3kKdR7l7P7EpnLPjg+ZI/EWsRAWOepLa8tND9jBOEqx+x/TLkooc4qk+ARgyVvOC63HIQWWLtJf7Sj2cWFnzn7EfM96mfyQmMko/IwuxSCSLnBq0aNYj2jmPqy8QnwcaHVUeJmhvtAfF/VTPsDI7BN8EHFjz7QE2IeYqrFMkQs+Zekjc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(6666004)(1076003)(26005)(6512007)(6506007)(86362001)(5660300002)(2906002)(36756003)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yMCitP199eLOQU45SvMnx82VshSMsEh/JZDMJiSTdzK35aAp+j5xwFT2eL2XgKmwJHCgOxRoqZEf84m09eqOLRZY6FMBWPSgyKpOKj5AB0jTvamAeZVZibTGNCm9bTXEBiBnEoBC5EjmsI3WjrUVQIl8WmYYvE9B4VEZh5M1Z9xVZeTJdXkGs0o81dWk22nHwqYImA71wTJF7pV9VPJa/3XtKX0CyXOoNoBgilxyhGMS4A+ba1jV4H1AgHWa2/kIW/lsIBLsThvrOFNuPLkSrYTZ18P5DkljsxMT0pd/NSNVfnNy5PahSDQczsXD70vzkWaqgRdja5JR/SVhcTyCyei1DI2mqc9axoRZoN26CzXbKKJqHbp1WYXAhdy9U16bMiEGhokwwTjAda+MmSYDNz+gQ4YYFk9+2BlqOkjr8QKPpJSmatWwUe6vuHuMxl4OFmXbOSBr/nXEDNaNg1zM+8s0WXtVjMLyhz/pMEIWzap1W7MpB9HLkDeEyA0oUFKKxKixQC0JtuoLweRx6mPXqpzEIuaGymxb/zQDrNhYdMhXkvTRmWANlGX6hAhPeDsbotIWT70tzMMVIFc0VnsZY1v5cO+0bllLXEhBlS0HFkmknTn2ZMRu6/5C86o3LfK8KWdRsev2QGIYv0qvSvFYZHaoOAt2JDglpFS/rsTxaczLH13w7ceKgmaCnxU2qAKETLC64QnTlqsAgXUlSd+JCQXA0jyya6KqNN/oKESUmZKZmS3wVSf7NMyeSiLISd36+Op+NABvUGrP9q8K3ChY0uwhUAoVfXFAqF98VAthVhLgUxpOi57z13d3/1QXaKHj+aa5uawACpPnMH/+Mba2NG2CACQVYRgEhsm+0V5ngLYs89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yMRxsDaeNNCm1QVwnpkMoE8I4ZNf6DSbP49v5RpGfIdX2x6nb9ZOxBtR/BAQJiHjiuU7+uG7yACI0F+4UceI0BbdD0+2PfyKK5ZRYHCOvqt9dalGvykoFCdCKFkDvOnoVJW00vTZ5MpkhdoPbGYKhoZdSU35i6C60BTMjcXsTTFb9PaoLMTaWYtMGR04oms2EAfwtUTMutU80RPkOBidOvLbx2MwnbSEBD6szPiKRKAPb9RDO94xykl8eBpNsSlstpSwuzeKRH1aBh+cP5oMEFnKZv7v/fDUKoibvLOZHR/5KKZBXq4GwY2PhJ91nON1Yn26VZ9KWcQ2xM1rsK8gbIrlcs1HOs119fcTMdHp5qRVQIRFvTTsJ2Ai8TC/5TVMebIBVgGvxo9iQV9douuZfi7xNYWIQOAZFPWQ2cvbvc1QdjltxNOC/iqkynNylyNXIIx2eDNDKblpYCLulSxBEbj0osdQBma4+ktKeKDRRPwtk0TQidki4CVjrc/auTOleWOWkdrTTPrICBKPZrbkvm4EtP2EW4Pjd9fCOso7JM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17d48cec-5ab9-4f6b-3f31-08db6670b0c6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:39.1873 (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: SXGpeD/z2ePTCPEy0oABuHDruc5IZH8AV22gC0tVksxBx0+WOVxW5tEr5zhrFr+CquYPjmUaQ4Nl6Bs33G5XSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: e9SlGNIUpEUKt0CPzQ40WIP8CEjIYy6W X-Proofpoint-ORIG-GUID: e9SlGNIUpEUKt0CPzQ40WIP8CEjIYy6W Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We will need two variants of read_header(), show_info() and restore() helper functions to support two versions of metadump formats. To this end, A future commit will introduce a vector of function pointers to work with the two metadump formats. To have a common function signature for the function pointers, this commit replaces the first argument of the previously listed function pointers from "struct xfs_metablock *" with "void *". Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 08f52527..5451a58b 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -87,9 +87,11 @@ open_device( static void read_header( - struct xfs_metablock *mb, + void *header, FILE *md_fp) { + struct xfs_metablock *mb = header; + mb->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); if (fread((uint8_t *)mb + sizeof(mb->mb_magic), @@ -99,9 +101,11 @@ read_header( static void show_info( - struct xfs_metablock *mb, + void *header, const char *md_file) { + struct xfs_metablock *mb = header; + if (mb->mb_info & XFS_METADUMP_INFO_FLAGS) { printf("%s: %sobfuscated, %s log, %s metadata blocks\n", md_file, @@ -125,12 +129,13 @@ show_info( */ static void restore( + void *header, FILE *md_fp, int ddev_fd, - int is_target_file, - const struct xfs_metablock *mbp) + int is_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ + struct xfs_metablock *mbp; __be64 *block_index; char *block_buffer; int block_size; @@ -140,6 +145,8 @@ restore( xfs_sb_t sb; int64_t bytes_read; + mbp = header; + block_size = 1 << mbp->mb_blocklog; max_indices = (block_size - sizeof(xfs_metablock_t)) / sizeof(__be64); @@ -269,6 +276,7 @@ main( int c; bool is_target_file; uint32_t magic; + void *header; struct xfs_metablock mb; mdrestore.show_progress = false; @@ -321,15 +329,17 @@ main( switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: - read_header(&mb, src_f); + header = &mb; break; default: fatal("specified file is not a metadata dump\n"); break; } + read_header(header, src_f); + if (mdrestore.show_info) { - show_info(&mb, argv[optind]); + show_info(header, argv[optind]); if (argc - optind == 1) exit(0); @@ -340,7 +350,7 @@ main( /* check and open target */ dst_fd = open_device(argv[optind], &is_target_file); - restore(src_f, dst_fd, is_target_file, &mb); + restore(header, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Tue Jun 6 09:28:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268797 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 7B03DC7EE2C for ; Tue, 6 Jun 2023 09:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235961AbjFFJa4 (ORCPT ); Tue, 6 Jun 2023 05:30:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237497AbjFFJaw (ORCPT ); Tue, 6 Jun 2023 05:30:52 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3D010C0 for ; Tue, 6 Jun 2023 02:30:50 -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 3566HeNN017276; Tue, 6 Jun 2023 09:30:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=dcva5siLPay8IRF9eBR/PBNk/97Dab2XWuV/EHFd5GM=; b=zhaViF/s/Am6r+3yxVEEaVkyQ4Yv+NW+qD/S7Q5Bb3v5PvMmk0sYlDy2S+5YjtuWKgJW mkpJk9dSESqAGRO/hwgVH/pFFf8+rMBjGLZef3DpwVHOzMq1sWNZSDugu7btIpe3gMht eqShMS3O7oXVL0CQ8t4jSlsgZBuNloRI0iVu+3D++RgwRJa48Nwk+8gUj/XIdQ2X2if9 UlwH2r67bKIejR/gXdORJZJjU8iMei+JP/LiThbluno27lQUL1niQ8xE2weVCH7PXa1R +ttuVmJQsk2bfltl0cdOb8srMIpZ3X0N79agJ6qjLAqAYEqHrUzCNnPRs62R0M8zVwyE jw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx2c5169-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:47 +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 3567c68J011385; Tue, 6 Jun 2023 09:30:46 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04sua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H7w8/VU40y+6XueAvjDD3Hvfs4FctzbspodaZ0LGT5Z+9E2bcVI2GjDQJ4zeeC2dDKYq58nYosBUahd6Tl1EUYor/k+uQRciCb00auRxJ20ScVZgOdTDDh2EsZMIAP6WEwJg2ygpmFTu/HBP4Yw7JitNGHGZh2bqY3NoECYxQNXmbUSq8M7dfL/p0hAdFFzAHHre+OR2r3U+HaCWpjN/9t6949nKaK76Fa4Af3bEGp1KOu+i/Sxy76pI9JnfXFsuHUrzOtGpJXrxq0J/KmErt5a7IYccLdUx1lRvXYYuzr6HwT/bf1e3eqnDr4/PoZV0hjDRRTaqeq8jWl9TeO6wbQ== 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=dcva5siLPay8IRF9eBR/PBNk/97Dab2XWuV/EHFd5GM=; b=mKYizB9fa1w+hCQe6w8f1N6mLiKLKSZdwTMG6KEy6mu08q2bK4KwNLfqlIgC/biVlpCdf69IwSG4nQPalaUAA0crtv2x4k+zBd+8i+qV2CD5uye7EELutcGGQ2SJC7gadJlCf8vf+6M0D0loTrvij7Bvb70jc5StuaYic912qbepn6EUFIGjpLdl9nOCpGbtIkDHe6ch1Hl35ZxGWOkMLi9PcHMnfEnSz2iWrCzv9Us9STenPw6DiMJ0h9wMWg718WaExQ6XPI0Cxs6Vk3oaNpJrVf+zgvUgrHfh0Vr6jOT3qRuYKNSBCUrhtAkNkly+9wRhuovSnUUGVe2IZUoC7w== 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=dcva5siLPay8IRF9eBR/PBNk/97Dab2XWuV/EHFd5GM=; b=du1mW4TAsIerOx2dnyKll8vz4XnwD6aMgE8Ee1biQ36CjQEQaqP/aMgYb+5xnJIMAgUJWQhvKlvoAXh/HXVCnf2UYqYmvhA4dn4bnkmI+gEu1A6IAJk27mH/8aqSN7cWT5jRc2HKFm1pfZHwM8V/JAhz4XmBOxXGUGSIhBLunlQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:30:44 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:44 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 20/23] mdrestore: Introduce mdrestore v1 operations Date: Tue, 6 Jun 2023 14:58:03 +0530 Message-Id: <20230606092806.1604491-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0310.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38b::7) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: 909de262-1b18-4746-7d63-08db6670b3f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UfeTTLPdMil6ZuakBRB7fIC1XSJL2gL4+GVRvt4oduwBhMEUKezfqr6rQ67c1y1I92+3onYam9pckVrg8llL0S8REUTnE78D/KcRQyytEa+f9HdizAQwtpqQ+xkv94zr6hE41JEP557UtXEZI8TpFTyuUKIGeVgRxFHiC9i+QZSCFo6fjLrdmZ8rgOix7O5YWpQ13XErFtuh1z6d2vS0eGPBt6DzXMTH5ZuyE0+GLAk/PGjE+5i1cgxezQuq9c33Ki1h8N70e7fTUDL4dx8oFw5VA8hjFsMF3tMVArD0uMxuP4pddM5RdJieYzPa4szBa2PrBbJHdz8c1OGUMtWunaZilm+82clW9WVimEKC2c+aUqOT0OU0rK0Fpqx3Ga7nrmW1RK9FjZ/p7p3goYiyqay2hGzt8fh+W8toelbbHGadtcGjzVW6VzuryTorEURGBejpHMCIs7kFv4YTpfVCcbfZ2Mj4QrjVnN7f4uStK2AbRCosjLLLluLxkUpV5YoozncHmaHAuvvXReTE3AdXc4n5j4rJw/D5u9+yU5RaMP4D/3zkghiqZypFSrqilBpw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(6666004)(1076003)(26005)(6512007)(6506007)(86362001)(5660300002)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /G1vBvFvOc2TBHcYQ88JoxTT/Nr0MaebxAbpfCBC7r62twE5RRmxnVJYEzFOEEq1zQcO+0uN6Vi1JFD34vShPfjl6hTirMvdkzHt2+rwY1T4bJK0vIQ5oaNtiVBOKJwpJDVSalJ1n1L1JiTHQx7wYZs8XkwVwP+DniSRCa54p7T7JhNMzrVg1v64kadJvgoZIXqD5talfH/LMhT4Ef1yOg8V8sZaigSqx93nu0lhyJvqBcgrW/q7EQ1xLoG8NZiCaLS9UGYWzRU3gJsf+oM3MixeO1InTotLooLFmygp9xjztt6pB4mcP9iLH9/UMTzywgC52VWhLsltfoKyafLTvjrx8991twrQ8+YZXZfPBgDUnqA6JMPhXV2ACcO9Tk5BFEQU/+jnaqFuRMUDpqhiOUUIDvflbJrXccALGiAfpbmcUZx67uhbiu2W2rmOU4uBWY8NdRdmgLvkyy7bvvRU7aLeD0lQEI3bSrHI8c6ugiq7YjQo2dgQqDCH7/ZX4GBuvFNMnpe27G2ufhgr8P1AmE6vbYInMw8uIIW5MdfRSug8mkkcoTMvGMLjIJuHNkAsnK0q1/Y5Nb5Hoti0Dq99GwEus4QukTbkQMUTyCfSiX86Q+DG+4WKr4gG0dGjgPIAQL/kSsph5SaTOmT6Si6eumQCRWKgJhh3knzHv3Gw2V8JpFmJV7jJ6yUlvL5P6GT/ma3Uv/V0SP9LPVIa877mLZ0MOwt3Lzeq5xavBsXmEwLVfFxgjVmAAWrHUCZDE/VGj0CQCiKuWp+F+97jLPIbXyqq/IWJZ3cW8n8gBcR+bzebXIHzSARDNrSZbwoHK+3O5uZIkStNf8hgTw4cbMfhVKJ6VUTuQh8tquuL01ZtjXSadqLDkLgIHIuK2VEE0f4Noqw4MK+gM68yS9Pg97YGq6xd7DROjZtycd+9NX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S5JStINSrz9deEGLwkUkSsEuZwuGJyk6dBtuXJI2c9myEqMjkZX5mpD/mBSMSSRqHu7P8V7ZFclq8o2qbOz0u3s1BG4ysXv37ZdaV0oDFNkzj/vTfkXM4qVvcHF921uqyWd6GU60xlVqq4B0kv+Qv/MCLT8l+PfvUudtH6uFoChuH7JiOvYbx1QcHLknR7ojw1kuTfKwYzMqJGthTXTtlSni0+zGFQbFKMWRd9cCFap29m5wTQrv4AL5AtIN38z9CVzeG3NiMMa69tOf/dEROHhxXTwH4/RpDmCAUN8ieY/q+EZSjYqDGKixg+Ea3wuz+XgGn6/bWLwX4eUIb1jdo/kWrsaHKInO8OBWBvv4ThngkUtGwxpA40byQstT4qhDPJdkl8hi8TKSok2J1SZKLLP1oE+ytVdRAsVDIHt2mQH8PfdK8Pp5o6zlShSVMcqKYWCwp+NgUncHklidTRkyoxaDGX9RDSzYQn6JAtGuQ2Co/qahBEq9VGqX40o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 909de262-1b18-4746-7d63-08db6670b3f5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:44.6749 (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: 2+iN2MTSAhw6Ub4e21KtbCCQkzQ0seNe6UnYBRiPbB5cN4bumHaVUKHzxBrXT7BbjheiAIhPb68pskOkkrMjFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: btcRCR9PlOyRRz8NMW8fxqSoouBmnSsM X-Proofpoint-GUID: btcRCR9PlOyRRz8NMW8fxqSoouBmnSsM Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org In order to indicate the version of metadump files that they can work with, this commit renames read_header(), show_info() and restore() functions to read_header_v1(), show_info_v1() and restore_v1() respectively. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 5451a58b..b34eda2c 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -86,7 +86,7 @@ open_device( } static void -read_header( +read_header_v1( void *header, FILE *md_fp) { @@ -100,7 +100,7 @@ read_header( } static void -show_info( +show_info_v1( void *header, const char *md_file) { @@ -117,24 +117,14 @@ show_info( } } -/* - * restore() -- do the actual work to restore the metadump - * - * @src_f: A FILE pointer to the source metadump - * @dst_fd: the file descriptor for the target file - * @is_target_file: designates whether the target is a regular file - * @mbp: pointer to metadump's first xfs_metablock, read and verified by the caller - * - * src_f should be positioned just past a read the previously validated metablock - */ static void -restore( +restore_v1( void *header, FILE *md_fp, int ddev_fd, - int is_target_file) + bool is_target_file) { - struct xfs_metablock *metablock; /* header + index + blocks */ + struct xfs_metablock *metablock; struct xfs_metablock *mbp; __be64 *block_index; char *block_buffer; @@ -259,6 +249,12 @@ restore( free(metablock); } +static struct mdrestore_ops mdrestore_ops_v1 = { + .read_header = read_header_v1, + .show_info = show_info_v1, + .restore = restore_v1, +}; + static void usage(void) { @@ -310,9 +306,9 @@ main( /* * open source and test if this really is a dump. The first metadump - * block will be passed to restore() which will continue to read the - * file from this point. This avoids rewind the stream, which causes - * restore to fail when source was being read from stdin. + * block will be passed to mdrestore_ops->restore() which will continue + * to read the file from this point. This avoids rewind the stream, + * which causes restore to fail when source was being read from stdin. */ if (strcmp(argv[optind], "-") == 0) { src_f = stdin; @@ -330,16 +326,17 @@ main( switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: header = &mb; + mdrestore.mdrops = &mdrestore_ops_v1; break; default: fatal("specified file is not a metadata dump\n"); break; } - read_header(header, src_f); + mdrestore.mdrops->read_header(header, src_f); if (mdrestore.show_info) { - show_info(header, argv[optind]); + mdrestore.mdrops->show_info(header, argv[optind]); if (argc - optind == 1) exit(0); @@ -350,7 +347,7 @@ main( /* check and open target */ dst_fd = open_device(argv[optind], &is_target_file); - restore(header, src_f, dst_fd, is_target_file); + mdrestore.mdrops->restore(header, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Tue Jun 6 09:28:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268798 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 21AD1C7EE2C for ; Tue, 6 Jun 2023 09:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237489AbjFFJbC (ORCPT ); Tue, 6 Jun 2023 05:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237325AbjFFJa6 (ORCPT ); Tue, 6 Jun 2023 05:30:58 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E95BCE6A for ; Tue, 6 Jun 2023 02:30:55 -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 3566KoW7009936; Tue, 6 Jun 2023 09:30:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=ZU0dkQwnlZa3pocupZd3MHbBrekBsL4NMR76JxnBYyE=; b=LpgxppXEVef5DnfEHD+tbu5uIEfnPecMj30gEFngkeOTcXJkCdQwZT01E01jRTK54gSV 6UzrkfX/wOsqs405hrGVhFbtfureqQuuOpJFSA6Vp+M40H2asbpuBfMLq2+zY6rV6NAO WdBcfGe8SIFXxckj09GNFzsPldWQMZpS/+7szLjcpN40lCWT1vxgw86dszikjs1uFb/u AVi+y93B7nCjIW/OpPK9kX7KB4nt8VcuL04c7aArvWu7Uno5H4i3XoX6bLbM+/okhRhG KlJdiAXxxFTrygU1uBPoKirNxjFg2m1vAjWqEWjeJTpUsA6h/3maS2GtCgKZqVhTLblM xw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx43vvpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09: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 3569AeQV024171; Tue, 6 Jun 2023 09:30:53 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tkgvegj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:30:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DtLebMxEigyu1r4AkVCDxxea+h/QZ6Wagq3w8nz+jZCPFJxGiz3RUk0oZRYrsz86znLf0ZUVU0REJe7Msa4g3mI/QLfBm6DgOhS5T0KwzVf1tdwuNcQ+6JH5W48kXJZkyuMFN+z3Mz1hj7Ae1aN7jpTfLmiRRcaC3JvoBZb1AQiCttRuWRYK9Z7/CeD7VP3eckE0E+cOn5Lc+Mo13WDGC1j91PiwC6HR6s19dpHVCQeWMTW4ZiIxfURZjI9B00rBHiEBfYI4RXCEZwqdS2YnZqqU+gvcbksv+S9rND2wEk8FYsravBZOkQjjY3TTHZZt6aayKrLkES/Zqh7z/6R5hQ== 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=ZU0dkQwnlZa3pocupZd3MHbBrekBsL4NMR76JxnBYyE=; b=TXEH+Cvwqx0I4OxNM57GGZMHR14riU7+PmrimuFofr/uYW6vLDTvUDqaUIUYtxSYY1tYJhfaqmz1LCuu7fIIPUDpphlAxgdR/koDg5lSZrQjoegRPTBsjLFbsENxMG/dhc7K9CLa2tdeI+vY/T9LP81h0giNkH1PIK65T15oeXfXMRiOoA/29uhg2YAUUyqbX6SJYuZttDgHprHVjTdgULHMQnMEHTYfBL5l+DSJLCKyxjQa4nR4eRNLeLxDWVLw3U443L0Cd07PJjr/rCZK61zNUfVHs6r2/Mk+Kd6VBdWMohelw71MeauDJzIEwf6A4zkMVty9a7EHsgeb0IhawQ== 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=ZU0dkQwnlZa3pocupZd3MHbBrekBsL4NMR76JxnBYyE=; b=r6StREAw8f55/rttGeXvx+F2Bd/zcOL1xbo1FDZlq5mMyM7xOtE8X1b9N2HTREq3a2RgPSay3f0hvsKO79fn92X7g59rZ6U7diPmyN5MEXEbtcYDB78QGFrt5fRsPv2sBUS+TQV3NvPpxus5r+tCjJs9MGfeRC1Y2eoBiH6oNnw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:30:51 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:51 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 21/23] mdrestore: Extract target device size verification into a function Date: Tue, 6 Jun 2023 14:58:04 +0530 Message-Id: <20230606092806.1604491-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0190.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:382::10) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: 35b5b157-223a-4991-aa29-08db6670b7de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f08I2OMUNjeWgjDlMOwA3P9WJyPoF0kRb5aFqUReG5B27y86MgnBJNZwQB32ZMmjyC51ttU064xIzBuCTrLiDJRNatZ0pggV8FndHVmegG1jP+V5Rq6DmDPD9kI2mQ8yxRD+dPiVQslohlxNzuWRTpSvVOA40RvEkCu+meeF6YTm4mdCl/0VAILnh+Tl/cvNaD+39XZ1e6+EDuaHS/EGcms5GajLQKFStqQCz1aQ/MK2tBrmJbUIdoLHTmDOoKzgXOYR230JKV/BHcretYV7p2eAvMZlIHfdEq4BUJPl3QBu7AKj2iIkY/FDdnKXoq0m5HapOaHfI3tU9DFVNkBtYdF3rI8em3AVN5ChFZQwWb8Ty+1gQaQAjbS5ev3muhW7btA8O7er1F463b6qV4ogXsEpAKsAXolBAPkbVyL9SRcUA+A1I4c1AkeDAzFxn7ReiboZC5VtplXsCz7/IAQCqXb/odSwkKZsSmhFOAb0tO3sbTK8m570l/l7zFZ2D0pyffjCw9Pvnj5Jjq9IHqU+qzT79Moxe9LWQ9kRwjIR4YhM6n1LnHISLGsQbKdxSYL9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(6666004)(1076003)(26005)(6512007)(6506007)(15650500001)(86362001)(5660300002)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GlSEnitvMTdmzSRIHqWl5iHMa4gJsoj12Dqbw1/z7YpQkIF+0vbIVg3AluU2pVBr67VHOhvgVAfwo6jyUm3pbJgVxp8ViWWnQZI7MvC90oIpv85VlQ9p+RhZEnnKeGvnInSc2luJ21G4cvAADJ/IxXxLEMXl697lqu6xeyXYCauBaMnTQvOoAPhXRediAXJP5ZZOEiMvNJxDu4Y4z0GqwQTKawIw7NBfp3t0uaCB4kU4xDWSoZCW/pFwJAED0iH3NfXDM+NZtHs3zxj6P3ASzdo9sV85jUK5fwPMU3lZX8zGEXiPpB8APQ4ZMTC4Zv51L142tl2HTsAnL+pxIh/8NVpE6LN0HhfnSGcwaP00m5KH3GLhgzhkNqHj3wHwo42wtSJqir9LDMvpXI/0IlIHs2Wll/Sq4KypffW/zYzVtxmYcyxH9VEL36S3jUgL1r1v2Lo72t3VQjTVcE02Lvtj9YGbPs20rhTlgHir2J+sfFcYIwK0CkDrHxU8IiIcJf6cvQ5bc4RWkQF7h1I3KWfDAS2EwEeBkuW+Bfc11IPPNuXys72dOlDmG07A51jCU24J69ZKr0i9Uf8NZpjup8LTKuXrnZ5bN1fAjeAGsTrYO1DaIaIDyKbxlFOZsOPba5RfDM6XHmpiNMb6E6Zi+SerEDwf6VsMT02uMfXR0arxvKJzXqal1059MWLAyeGJTUL5MeJuLGOcO/J6u45nD1gV3p1rjBAwpFWEeAUx8UAUt1KarZwsTGJ0pL9JiIMsicHFLeleM7AfqhBXUwnyVkKhOAp/XqOI5wfU4wFiez2tp7m0EbDx8a+YS6ZlY4MsYmmkq2c3h/IEbC2nxSzaR8uQhyOLAsyM3bw+zMvzOKtK7VlzwZ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sS45pcK2RepGwkFMY+oPnFfPrjIBkt7NwjALCG4WvugUnM4n2brDtB3Xkcp9RvsuTVakxUssSZNBGsCRalol42sZAPUSdBm22xDO3Dh1ih5MAhQn4cNhFlVZ0XrljRKLSSZQ2FOiF1htJL9v9bZljsg8sZsKihxQPGUXnrDsjc4aKg8B4KguVh7ZfAgY4W/ELYN9eRUyjjpGIF5pMCtQQ51pdXoyPd37vxqSBo/ChoGL3bHHUfsXUyuFmColTwKGlgdqn3UG+vJ2tpq0tRIwpy/4XwaJvPHuu9mQsGj42sXY8gW5v1TWSKozMWr/esOcSj6jPO617yWWcTSxnKKyaJXDvfEaAuIcu/eRVwXuYX+YxSHeDEfWAEeaeJfkrCmMsR6BbXgLmtuuNO4eN2xKThp7AE9TVhBZtj3vXU3dvTCh5xm60Db2NF1N28mzhgb4YfCHScQYc78e5eblh6UVw6+SXAMuNLkWQPPvAd+IsI6DY7oTOcxNteWb8y/jDoIVLJ7l03fSGd/3KXTRzpyAtInukYL55FGOg0sWkdowd29Q= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35b5b157-223a-4991-aa29-08db6670b7de X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:51.2289 (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: /Pz2iZeKGcwUwDjmcvUq7qJfBfchk+HxKYUG0umtzFFYVBCjzgdsAg84yGg+mjY1/q354wYPWXJGlj3MBJwkPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-ORIG-GUID: WLL23C267RbPt17tT04rTJtAczK3hU5r X-Proofpoint-GUID: WLL23C267RbPt17tT04rTJtAczK3hU5r Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org A future commit will need to perform the device size verification on an external log device. In preparation for this, this commit extracts the relevant portions into a new function. No functional changes have been introduced. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 43 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index b34eda2c..c395ae90 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -85,6 +85,30 @@ open_device( return fd; } +static void +verify_device_size( + int dev_fd, + bool is_file, + xfs_rfsblock_t nr_blocks, + uint32_t blocksize) +{ + if (is_file) { + /* ensure regular files are correctly sized */ + if (ftruncate(dev_fd, nr_blocks * blocksize)) + fatal("cannot set filesystem image size: %s\n", + strerror(errno)); + } else { + /* ensure device is sufficiently large enough */ + char lb[XFS_MAX_SECTORSIZE] = { 0 }; + off64_t off; + + off = nr_blocks * blocksize - sizeof(lb); + if (pwrite(dev_fd, lb, sizeof(lb), off) < 0) + fatal("failed to write last block, is target too " + "small? (error: %s)\n", strerror(errno)); + } +} + static void read_header_v1( void *header, @@ -179,23 +203,8 @@ restore_v1( ((struct xfs_dsb*)block_buffer)->sb_inprogress = 1; - if (is_target_file) { - /* ensure regular files are correctly sized */ - - if (ftruncate(ddev_fd, sb.sb_dblocks * sb.sb_blocksize)) - fatal("cannot set filesystem image size: %s\n", - strerror(errno)); - } else { - /* ensure device is sufficiently large enough */ - - char lb[XFS_MAX_SECTORSIZE] = { 0 }; - off64_t off; - - off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb); - if (pwrite(ddev_fd, lb, sizeof(lb), off) < 0) - fatal("failed to write last block, is target too " - "small? (error: %s)\n", strerror(errno)); - } + verify_device_size(ddev_fd, is_target_file, sb.sb_dblocks, + sb.sb_blocksize); bytes_read = 0; From patchwork Tue Jun 6 09:28:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268799 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 79B11C7EE24 for ; Tue, 6 Jun 2023 09:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237529AbjFFJbZ (ORCPT ); Tue, 6 Jun 2023 05:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237502AbjFFJbK (ORCPT ); Tue, 6 Jun 2023 05:31:10 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A55610C9 for ; Tue, 6 Jun 2023 02:31:05 -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 3565qooc009177; Tue, 6 Jun 2023 09:31:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=v1ut+JtTuUrN4YY2A4fXuv3POhNx3S2nZ/HBKbyEXRI=; b=CEkHPXE1q5mDD9sOObGliFPiWlELFtw2Nv9w5UuBdmIOISRm6J5hQ+JYwlZ/Ba03Gec1 imNCHpURe9e9EGMS6x+FXedir6SeVZCBWS5xH+bJil+dRH37D362wPORnw1mMlYuciap TKMPPTnqZgKXndQKr3RcRDUdCgajzjDPDVbfUWLzz9yHoRW89nrlbsfHRJFd8Lo7wQvr NjkvicuJQ26JNF3AwdwWxJnMPnb8g3uFiYG1VYmhLFnBTXLI0Qsrk8It6n7oT3hFUi8e aIqT5jufzOq3UwQeOamGXoJ4VFX9cJRmmT9o7ln1BMVUtXX0zevbgTRK+ynJZ7+Kcsc2 Ag== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx1nvx92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:31:01 +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 35680X9d020039; Tue, 6 Jun 2023 09:31:01 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2107.outbound.protection.outlook.com [104.47.55.107]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tsxcy1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:31:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nBLYK2Dtv3qiZXzB82QVAw45y6XeetDJNwKz6Viq6EzyM6aerXya7r7ni7WfnMvfOnZu4yThPIjL/8rRxNT0KBT1lmQC1FJecOXF0ZfarWpvGSkxKQARtGFBgyQRUi91HQ7vSm//LTehSWAeQ07/T/fZcC6YUfZCnwxZ2osU9GG2WcgxC87u6fdqi07DhQu91IQqFbShAlsUS9Rjg/qjwqlUFOesXg0g1tIyNZm8z3M4fSKDTwSYNH9zqaGIlxPhZzjCwpNh5DIRLAgBZVPsG9g0cOUYmMyefjNtiNywN9HDOWWi6bCtiErz/OqxQgv3DjF2IzzLsQ1us5glYmovOQ== 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=v1ut+JtTuUrN4YY2A4fXuv3POhNx3S2nZ/HBKbyEXRI=; b=KB5uEGKEx0Q8Y8bOBtPW2fN3nSxmK8ayXgmGBOuXT9LYcOIBy8J4lfLJgAk8S7xs/fb9PG4GqqfGpPR7aVTYdnVIFfUPZuZraqyMfevwmPEpwWcszjCXJx1P7USSbTpvcTLA7HQ2S8rTfiM839W/ZdTzItlBhuAMHnTMIzXlmehM4PJCvpJ+05UsdcZsQPMecFupfrH4HvBKW9GUwNL7HJv52ij+CQJTPeykrCW7OphWgVmkBIQBmZ7irMsNZiYoqnPJs4+wN9YYb19SIhCbmNo6hiwhD0lzZIWHLsZPrBUfqpNr3zA6LxD0prZmJF0dhkB5T6rUvVZB2Vuf56s59w== 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=v1ut+JtTuUrN4YY2A4fXuv3POhNx3S2nZ/HBKbyEXRI=; b=oZGOI/0Agn9AiXMLOvNMDN42MXbib4wfejk05Y06PC+IuXyeNEgQpjcqS+Kcg1TeEUzjKTf6Qe4XAMSOb2exhrpWxu9/+RX2u7as6rjvwgrSEjg1LgKYwrqOoqWNxz2xob0RZ7a0MMYqkN+Z+TUmyfLPtD2UQh7iFsIGcqIf080= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:30:58 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:30:58 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 22/23] mdrestore: Define mdrestore ops for v2 format Date: Tue, 6 Jun 2023 14:58:05 +0530 Message-Id: <20230606092806.1604491-23-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0048.jpnprd01.prod.outlook.com (2603:1096:405:1::36) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c730d49-7b4c-4b13-1e98-08db6670bc14 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2I3XIfBoolCNA2JB3Jeyi2z6KqpfIlap/OYN+1OeKwW7ERfMCXDebbT8Q2wEopCvTATT+Mv19RRY0hr00L5Ddm089gd5+THAFODhH8hT1aJGuGEzcdM34h//ieV1wmpZWYHWCmsQ0EammqYYaJejmQogBkZ6nQjlx+Up2V5FJjuJ53qrLVBSDmXyzaZ0f74B8dEzZFYz1PatlwskDQFSK9frFxSCIBpq1OTRx4TugGfHeEi07MjxENa7e6zNM20zocEidRoeGBl0h/KrteBumVMIz3PE78M9WkP0ZwOTEn/Tznzg+Qwwfekxlrp5WgkE19rbyRoqM9ISSGNT42ZhtYON4Turh8+MlvDbiVpQW1MfZor8Kpw8Zktr+rIHbUxj7t/M3Zxkt7cgQ3zLyzhphk1nuUXucW7L9HIoV852x52vs6SWU49y5/pleGofQgg0T1FIzP0gCadzY4QXa561qAhspoBbu+H96QnDvnAufI9ZBcRcRynsTjHrE1D/DaA9oLhQs8st/j2NMD3wsGKXFwlBbcQyyDsSSQIsH5RXRS6GMtrLGHRV1Q2G8mdSiEi6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(6666004)(1076003)(26005)(6512007)(6506007)(86362001)(5660300002)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p3hE32QwQQXk1tvBMMmT7gxkLujTkgdx+0V4eILYYqyo1ZBMy1niSem4kfNQugxl0+6Q3c6aFkkTd5s2RrRj6JURP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XgZvR/VOKjmIQNIZvVrUdQEdU++9LLFyiyKL+OsWmsdm7dHzL8CMz9xFJUIUBImqMyPhuaAcOTnD9HA5wQZwBwQ9tApo7iAmFimRT1W9LutcHc/VlpRXLYesamraOIWjOVAVITKIeEGf2JnJJi+qpnT3Zb5ozgYdXYuc6qxXMVa1E5JiPBw6wpNlSYvPOebXHdbRRul7k8MMc5Ec4X1AicY8sNZWe99/2djlKHI2rnupRFp40Rt0VNNvn3w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c730d49-7b4c-4b13-1e98-08db6670bc14 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:30:58.2876 (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: 7vKDB2jXuX0WCG0BLtB8a6GMZfcw75Z2zjfsPg4KUMR2LY4TRJYE2SoPJkO+sfkR/2A5SNRzGcYwkwMW2XvMQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: 74VeqHj3gtA3FMtyb9jE8rVB04ZlTyW7 X-Proofpoint-ORIG-GUID: 74VeqHj3gtA3FMtyb9jE8rVB04ZlTyW7 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to restore metadump stored in v2 format. Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 251 +++++++++++++++++++++++++++++++++++--- 1 file changed, 233 insertions(+), 18 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index c395ae90..7b484071 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -12,7 +12,8 @@ struct mdrestore_ops { void (*read_header)(void *header, FILE *md_fp); void (*show_info)(void *header, const char *md_file); void (*restore)(void *header, FILE *md_fp, int ddev_fd, - bool is_target_file); + bool is_data_target_file, int logdev_fd, + bool is_log_target_file); }; static struct mdrestore { @@ -20,6 +21,7 @@ static struct mdrestore { bool show_progress; bool show_info; bool progress_since_warning; + bool external_log; } mdrestore; static void @@ -143,10 +145,12 @@ show_info_v1( static void restore_v1( - void *header, - FILE *md_fp, - int ddev_fd, - bool is_target_file) + void *header, + FILE *md_fp, + int ddev_fd, + bool is_data_target_file, + int logdev_fd, + bool is_log_target_file) { struct xfs_metablock *metablock; struct xfs_metablock *mbp; @@ -203,7 +207,7 @@ restore_v1( ((struct xfs_dsb*)block_buffer)->sb_inprogress = 1; - verify_device_size(ddev_fd, is_target_file, sb.sb_dblocks, + verify_device_size(ddev_fd, is_data_target_file, sb.sb_dblocks, sb.sb_blocksize); bytes_read = 0; @@ -264,6 +268,195 @@ static struct mdrestore_ops mdrestore_ops_v1 = { .restore = restore_v1, }; +static void +read_header_v2( + void *header, + FILE *md_fp) +{ + struct xfs_metadump_header *xmh = header; + bool want_external_log; + + xmh->xmh_magic = cpu_to_be32(XFS_MD_MAGIC_V2); + + if (fread((uint8_t *)xmh + sizeof(xmh->xmh_magic), + sizeof(*xmh) - sizeof(xmh->xmh_magic), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + want_external_log = !!(be32_to_cpu(xmh->xmh_incompat_flags) & + XFS_MD2_INCOMPAT_EXTERNALLOG); + + if (want_external_log && !mdrestore.external_log) + fatal("External Log device is required\n"); +} + +static void +show_info_v2( + void *header, + const char *md_file) +{ + struct xfs_metadump_header *xmh; + uint32_t incompat_flags; + + xmh = header; + incompat_flags = be32_to_cpu(xmh->xmh_incompat_flags); + + printf("%s: %sobfuscated, %s log, external log contents are %sdumped, %s metadata blocks,\n", + md_file, + incompat_flags & XFS_MD2_INCOMPAT_OBFUSCATED ? "":"not ", + incompat_flags & XFS_MD2_INCOMPAT_DIRTYLOG ? "dirty":"clean", + incompat_flags & XFS_MD2_INCOMPAT_EXTERNALLOG ? "":"not ", + incompat_flags & XFS_MD2_INCOMPAT_FULLBLOCKS ? "full":"zeroed"); +} + +#define MDR_IO_BUF_SIZE (8 * 1024 * 1024) + +static void +dump_meta_extent( + FILE *md_fp, + int dev_fd, + char *device, + void *buf, + uint64_t offset, + int len) +{ + int io_size; + + io_size = min(len, MDR_IO_BUF_SIZE); + + do { + if (fread(buf, io_size, 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + if (pwrite(dev_fd, buf, io_size, offset) < 0) + fatal("error writing to %s device at offset %llu: %s\n", + device, offset, strerror(errno)); + len -= io_size; + offset += io_size; + + io_size = min(len, io_size); + } while (len); +} + +static void +restore_v2( + void *header, + FILE *md_fp, + int ddev_fd, + bool is_data_target_file, + int logdev_fd, + bool is_log_target_file) +{ + struct xfs_sb sb; + struct xfs_meta_extent xme; + char *block_buffer; + int64_t bytes_read; + uint64_t offset; + int len; + + block_buffer = malloc(MDR_IO_BUF_SIZE); + if (block_buffer == NULL) + fatal("Unable to allocate input buffer memory\n"); + + if (fread(&xme, sizeof(xme), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + if (xme.xme_addr != 0 || xme.xme_len == 1) + fatal("Invalid superblock disk address/length\n"); + + len = BBTOB(be32_to_cpu(xme.xme_len)); + + if (fread(block_buffer, len, 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); + + if (sb.sb_magicnum != XFS_SB_MAGIC) + fatal("bad magic number for primary superblock\n"); + + ((struct xfs_dsb *)block_buffer)->sb_inprogress = 1; + + verify_device_size(ddev_fd, is_data_target_file, sb.sb_dblocks, + sb.sb_blocksize); + + if (sb.sb_logstart == 0) { + ASSERT(mdrestore.external_log == true); + verify_device_size(logdev_fd, is_log_target_file, sb.sb_logblocks, + sb.sb_blocksize); + } + + if (pwrite(ddev_fd, block_buffer, len, 0) < 0) + fatal("error writing primary superblock: %s\n", + strerror(errno)); + + bytes_read = len; + + do { + char *device; + int fd; + + if (fread(&xme, sizeof(xme), 1, md_fp) != 1) { + if (feof(md_fp)) + break; + fatal("error reading from metadump file\n"); + } + + offset = BBTOB(be64_to_cpu(xme.xme_addr) & XME_ADDR_DADDR_MASK); + switch (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) { + case XME_ADDR_DATA_DEVICE: + device = "data"; + fd = ddev_fd; + break; + case XME_ADDR_LOG_DEVICE: + device = "log"; + fd = logdev_fd; + break; + default: + fatal("Invalid device found in metadump\n"); + break; + } + + len = BBTOB(be32_to_cpu(xme.xme_len)); + + dump_meta_extent(md_fp, fd, device, block_buffer, offset, len); + + bytes_read += len; + + if (mdrestore.show_progress) { + static int64_t mb_read; + int64_t mb_now = bytes_read >> 20; + + if (mb_now != mb_read) { + print_progress("%lld MB read", mb_now); + mb_read = mb_now; + } + } + } while (1); + + if (mdrestore.progress_since_warning) + putchar('\n'); + + memset(block_buffer, 0, sb.sb_sectsize); + sb.sb_inprogress = 0; + libxfs_sb_to_disk((struct xfs_dsb *)block_buffer, &sb); + if (xfs_sb_version_hascrc(&sb)) { + xfs_update_cksum(block_buffer, sb.sb_sectsize, + offsetof(struct xfs_sb, sb_crc)); + } + + if (pwrite(ddev_fd, block_buffer, sb.sb_sectsize, 0) < 0) + fatal("error writing primary superblock: %s\n", + strerror(errno)); + + free(block_buffer); + + return; +} + +static struct mdrestore_ops mdrestore_ops_v2 = { + .read_header = read_header_v2, + .show_info = show_info_v2, + .restore = restore_v2, +}; + static void usage(void) { @@ -276,17 +469,24 @@ main( int argc, char **argv) { - FILE *src_f; - int dst_fd; - int c; - bool is_target_file; - uint32_t magic; - void *header; - struct xfs_metablock mb; + union { + struct xfs_metadump_header xmh; + struct xfs_metablock mb; + } md; + FILE *src_f; + char *logdev = NULL; + void *header; + uint32_t magic; + int data_dev_fd; + int log_dev_fd; + int c; + bool is_data_dev_file; + bool is_log_dev_file; mdrestore.show_progress = false; mdrestore.show_info = false; mdrestore.progress_since_warning = false; + mdrestore.external_log = false; progname = basename(argv[0]); @@ -332,11 +532,17 @@ main( if (fread(&magic, sizeof(magic), 1, src_f) != 1) fatal("Unable to read metadump magic from metadump file\n"); + header = &md; + switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: - header = &mb; mdrestore.mdrops = &mdrestore_ops_v1; break; + + case XFS_MD_MAGIC_V2: + mdrestore.mdrops = &mdrestore_ops_v2; + break; + default: fatal("specified file is not a metadata dump\n"); break; @@ -353,12 +559,21 @@ main( optind++; - /* check and open target */ - dst_fd = open_device(argv[optind], &is_target_file); + /* check and open data device */ + data_dev_fd = open_device(argv[optind], &is_data_dev_file); + + log_dev_fd = -1; + if (mdrestore.external_log) + /* check and open log device */ + log_dev_fd = open_device(logdev, &is_log_dev_file); + + mdrestore.mdrops->restore(header, src_f, data_dev_fd, is_data_dev_file, + log_dev_fd, is_log_dev_file); - mdrestore.mdrops->restore(header, src_f, dst_fd, is_target_file); + close(data_dev_fd); + if (mdrestore.external_log) + close(log_dev_fd); - close(dst_fd); if (src_f != stdin) fclose(src_f); From patchwork Tue Jun 6 09:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13268800 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 534A7C77B7A for ; Tue, 6 Jun 2023 09:31:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237519AbjFFJbg (ORCPT ); Tue, 6 Jun 2023 05:31:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237528AbjFFJbZ (ORCPT ); Tue, 6 Jun 2023 05:31:25 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AECE10F3 for ; Tue, 6 Jun 2023 02:31:11 -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 3566EAs7009199; Tue, 6 Jun 2023 09:31:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=AKnz81ct7IrmQ4SHxlXKP036DcV8oQnEYxMQtgGMyXM=; b=sBv9deRozDTgH3PlTfEMXhsVoO++WFfzQg3lLLYZCHHrnCuy82DbQdR0P0wcM5/VQLWm ypc3MzyuggRI74jbb/+5079MsuI3H7NObmwiL16fuOBzpO/IRVcxisYZMOZiOwGvWuFG C5c+pkzVhiDR1erDX8lvo9bcbaPhZ6lb5J6+g+SScrdtWpHh7bVDIDSqSIGdczIL6oF3 ekKQhC9p/AHtsiROznMSR6R4kHr1qTmL+ro0j9EMEGRj63K8wmvrU/pUwwXw8LmV9Afu +Frg2SLO7esSng24gufDA10VLlHovoJ124Rgmx+wmL4xKt+E/Cn9hoSFLv4744HqBr4p lA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qyx1nvx96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:31:07 +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 3568l3MR011250; Tue, 6 Jun 2023 09:31:06 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r0tk04t78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jun 2023 09:31:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I4zFf5pcBUde7hQzzJzB+IVSwf7zb9LsCZ4qU7elCLpuuP2MvhCRfO4DHJDM5GFtVtg9eHmJWUoGrvDwO0FBTGf6juVgUKs6h+EqZIvrWdPHjrdnuHBU6wKWrtBLaSSozdy2imoI+C/E3372oLydBDB85oHZ7nX8ejwkfUsiOCWYzkxg+dtNCYCfxGdADYFYOQyTZQiWSe0OB2+FOvJs/1sVpqEeJX4L9Z6YXU1n1WhLFmY6Y44bXVueuzQTRxI3UC3o9Na7GC/bsNTbJI4Iodrh4KCIpQxOdnQwgaP1czffIUOs3emDT0R4lcmlk7GyEoGfxyFZLujPdKYfHvqCDA== 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=AKnz81ct7IrmQ4SHxlXKP036DcV8oQnEYxMQtgGMyXM=; b=C6y+gdqKBw4/+1KTWAu3shIUytTgYIFRGd1IX4eI5wEVpcXDYHEXien84tr2jba/tNVmPgH8t4NPT9IY2QgBJoRHDj4fENK+AxRmE+XmgkOPW7dTQZlD8yM0CwuFUilFHsIprCz9LN5yI7VM3NKnJMaYgLpOLwS0j3qFyJopHerOUFQIHY2fTkaZTrsgwOPO/tV81NYw01aDhaR2J/03iK0di5UKFeU8bbbrRlKjJU0gGCl7uLsHgFLcA6WutpYePhhhOYhr6Pu+XJ6kJv8jH1ICajrsAbARQ93FjbRH7xZKoxGQ3OSSVi/wJf50wT4qCBgl+UUJXKtpzBSgPki1dw== 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=AKnz81ct7IrmQ4SHxlXKP036DcV8oQnEYxMQtgGMyXM=; b=XgTTvE64k7mAkW9BYLV3pgTVlznk6XDnsp4tUYmNdv0iA+EJuRWMREltST0VKZajC0fKekngGaUYZTumyimtRm7V/2Mqa80778OPXa+dmF5pu7igCsEs9Uoigi2HA22LeuatR1jS+9YVPxFZKDuz0BkqA0j8rxsxMLQtUDdIiZQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) by LV3PR10MB7747.namprd10.prod.outlook.com (2603:10b6:408:1b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Tue, 6 Jun 2023 09:31:04 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::1827:534d:7d96:20f1%7]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 09:31:04 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V2 23/23] mdrestore: Add support for passing log device as an argument Date: Tue, 6 Jun 2023 14:58:06 +0530 Message-Id: <20230606092806.1604491-24-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230606092806.1604491-1-chandan.babu@oracle.com> References: <20230606092806.1604491-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0140.jpnprd01.prod.outlook.com (2603:1096:404:2d::32) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:22b::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|LV3PR10MB7747:EE_ X-MS-Office365-Filtering-Correlation-Id: a13b3ba0-ce32-4330-12cd-08db6670bfe3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fYqjha5/ByI+Xi/JLWWnRhSPH6zBcTkieNDryreFblZrfBq2NLjwnT4e10pZQaA04WMZUct6zfmua8MJX2pBsIGvOFfBaXWxV0fYYU/1aqPVm2AYWQYtEnbWq+XIQ5uHq8ioKkzVMDg67Ui2Y6n199o1eCsMFwH9o8XjepNJIvochtpxDf8hWbna4HagbIpHqjzLDxPLUs3i6GNjch34T6J5kzsm+6x70ywkYZj46ce5qKam6ktOJ1/ZWZmXfhaAt4p61nFwWIiy4qyVsJh+R2bybr3Iuq50mx0fuDDxte0Vxy2Ddz9Z/C7wrII8lTG4SGg+15XbCP5Y6N1aikyBZo/8QwaQLsInEOeuPAwiBwqKfB0vxX+GcguUMupodn32MiWnQwQiXUoks9FDKqbsq34o+E13BL2+5L4ZO2og6rioTEMfzsLe5Wn6sbWLiYe+CMgS3LRDyNTawRq/KdyQtTrR28GCjIbqtt3+LVPkF2SC6lEfCy+/EkmD9Nu0aHulIqlKoVzZSqdg9pv9+TrJBea6RphhMcCNTW8CXP8by7YKEMyhGknFeY9FphFOWLI6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(366004)(136003)(39860400002)(396003)(376002)(451199021)(186003)(478600001)(6916009)(8676002)(8936002)(4326008)(41300700001)(66946007)(38100700002)(316002)(66556008)(66476007)(2616005)(83380400001)(6486002)(1076003)(26005)(6512007)(6506007)(86362001)(5660300002)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MLSFPuBbS5M8iqbfSXTuTyWNMXDsKy2seAjQu8ug3stgUv37T4wwqMo3/4xqWsDfR23tEt2YiX1Xyi8G7CoRNrvwEoYYPGMObq086lqXHjMng/z0d9ahUdY7V0YGQkZIKq+L7iVlMf940siWP1mwthsjxu+LEkE7ysCN7iRXPKrBCAPk+Wsacs/yv8L9mVTQK60BMlvGDkVacyUX9O8BYx3Jao9k59sOI/FOq8xYoAovUcUQd4ilSzPmKdL5DPcpODkxRnT+fZ8QIPKEdJdtNwrbTH2KDxsDJK3nvKRFWEoy/lvt6UXuakraS3F7s4d8MTsJo2zho9MDIvpGP7VWxCmhLO5ErVXw6Wx6J7UQx2wFiW9su+OSIlZ8DAdCMuJVDJzMReydil1zItJgLjYETfaKcNYXcmSsRLrEU83jRSusjlJt4Ig3PuAv0BotexwsWFzaxlQy1mA9RwJMYI1mKZWL7d17MoK0gxWVdwZ2ciHHeGxPgksHSKjZG0W+dkAJab8f3e8UOgoy60Ov3TWYa0AHGJ3jYs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Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OlY4+F159RW48jX8qmi5AE/6KY5AUzZibx0q0mUhfOXiN58RdCEDPoeQTFoQCoXKNtHc7tlMJVO6GJJvRrWVY45A4HU4b+oRB1ufEwF7V+E2z6KZeQijrI4P18aR/CLi7276Ov2pF7X07seFZJjcbliLXwakOu7fzGxihFUQ85xSDv81KPySRcahIn+PE9N4EQ5jHp5Vd3CObEkLDQzmigNkMrM7s3qzqBkfhYd/DaCOcoaJ1JhD7NOm5Nh8EvaytIRx4QZ9fkD0qDYgQPip4RiqE477bDYBkF+ni7ZI7tXnYtHL3XuuXLWt2CFiXSwBlq9R6AkI33juwxdQuG/lOOH0mO378FZaAw3EhSz4WyvO8Vp8JNmHQD9FcSbmkSgc0n06FqWzn5u9CPBA4bFZlTN3XJdmsK0nv9qTqQ0YgWan60Jhu8YOlkQXdE4INZ37w1rQ5vP2mdFfTcgP5R/zOtg/7Plet61fnjbvd5S2PdcfPYTi39xoWLgPIYAgdR38pEGksl9bDZVwTvo511KsLBTiyB4vEMi9hUrhKreTKs8ZrMlKq+Q7WOPJw9gjJ5ps2ZwAi/cmv/jeKrQjxHHrrNW+GTjBiY1Ie48px/xy2J6UjLw6r+97sGy74R+9Ct7mO/1iTcFWMQ/yOis0LRE2p5JXXdrNnNzhkXMF0BoPelpCYJ6lIsiJAffluSRoZAuiVJT0IQFax1qP0s0a4LAZBA0X4EKn1vB5HbsjG6QVPnN0UDe+ata3cdKZCq2MpfOZc4h9acUASIl1CS0DJh+zesEe+XWwxEPZJY6F0o4zDjw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a13b3ba0-ce32-4330-12cd-08db6670bfe3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 09:31:04.6784 (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: cTR9BE1lQ4xsDo11YF6JUgtL2EEeawPWavOhiIvvJXPq+2hPGQ4mOYrqNEzb7Hj9EngNG4fs5PRVbZHgZDyJVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7747 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-06_06,2023-06-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2306060080 X-Proofpoint-GUID: kzMC5-ifSmN7IaiKOuLJMrfKGpDWfTtL X-Proofpoint-ORIG-GUID: kzMC5-ifSmN7IaiKOuLJMrfKGpDWfTtL Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org metadump v2 format allows dumping metadata from external log devices. This commit allows passing the device file to which log data must be restored from the corresponding metadump file. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- man/man8/xfs_mdrestore.8 | 8 ++++++++ mdrestore/xfs_mdrestore.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/man/man8/xfs_mdrestore.8 b/man/man8/xfs_mdrestore.8 index 72f3b297..6e7457c0 100644 --- a/man/man8/xfs_mdrestore.8 +++ b/man/man8/xfs_mdrestore.8 @@ -5,6 +5,9 @@ xfs_mdrestore \- restores an XFS metadump image to a filesystem image .B xfs_mdrestore [ .B \-gi +] [ +.B \-l +.I logdev ] .I source .I target @@ -49,6 +52,11 @@ Shows metadump information on stdout. If no is specified, exits after displaying information. Older metadumps man not include any descriptive information. .TP +.B \-l " logdev" +Metadump in v2 format can contain metadata dumped from an external log. +In such a scenario, the user has to provide a device to which the log device +contents from the metadump file are copied. +.TP .B \-V Prints the version number and exits. .SH DIAGNOSTICS diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 7b484071..7d7c22fe 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -460,7 +460,8 @@ static struct mdrestore_ops mdrestore_ops_v2 = { static void usage(void) { - fprintf(stderr, "Usage: %s [-V] [-g] [-i] source target\n", progname); + fprintf(stderr, "Usage: %s [-V] [-g] [-i] [-l logdev] source target\n", + progname); exit(1); } @@ -490,7 +491,7 @@ main( progname = basename(argv[0]); - while ((c = getopt(argc, argv, "giV")) != EOF) { + while ((c = getopt(argc, argv, "gil:V")) != EOF) { switch (c) { case 'g': mdrestore.show_progress = true; @@ -498,6 +499,10 @@ main( case 'i': mdrestore.show_info = true; break; + case 'l': + logdev = optarg; + mdrestore.external_log = true; + break; case 'V': printf("%s version %s\n", progname, VERSION); exit(0); @@ -536,6 +541,8 @@ main( switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: + if (logdev != NULL) + usage(); mdrestore.mdrops = &mdrestore_ops_v1; break;