From patchwork Tue Nov 7 07:07: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: 13447951 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 B870CC4332F for ; Tue, 7 Nov 2023 07:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232365AbjKGHHl (ORCPT ); Tue, 7 Nov 2023 02:07:41 -0500 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 S229558AbjKGHHk (ORCPT ); Tue, 7 Nov 2023 02:07:40 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 455EEFC for ; Mon, 6 Nov 2023 23:07:38 -0800 (PST) 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 3A72NoLa031653 for ; Tue, 7 Nov 2023 07:07:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=S14jmOs3UNY4owVaJg7ygwSYz2i+rWJtyRJZB/fspU4J02Sl3/AYm+uvO5ReFu1XmPM+ 5uvCzqV0vK3xnMjXCh5bJG4r2GsXEuIArf7uA1LMOaHe9uv/95SMXHSTklIdRApKyERl EopV60EA9VzIkfdvxcLs8B/u07XM/ITT2pAg/I9ZWdgb7jCh0ce1+Jfz0vots7IsTyv+ JAadCNHifc2pIb4txclO0bjlnn9UhlscK6KpHBcb4Lr/iuYFq8lmrcMtxPcL0NUzB5KJ +kG6+xybVy5Cn5dRcNcCgyCjpCpo0WuIWN3jtMggyVXY3kWQ1qy0b2M3vIna1bLFMDq4 Og== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cx159ns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:37 +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 3A75td7n020719 for ; Tue, 7 Nov 2023 07:07:36 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1v3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4JoWwAAcO/PCXjTZZ6U1Vv6DDjWZTZ6uCuzhpC2MplHWc1iMW1XbeWSbBN89vI1PjTjB+LAdvbzx+lHeKlj4rTp45U+qS48FFiaZoIqpmg/UvLEdfZ++GXbB56lrOaaw0ZYf8vqhEFKtqUKLLaouLdjPyoshqaukEzOf+YL8gXJJNnMpp8nbJ1SVA/omcxER12kQ5RPS3KN5HlQWyAw9HBBK4O4cXQ4uToJuD86eqN8d8Tct4jjpMbhHblObRPlvE+uaHci78Ly8EsIMNlpAYD8duvXCXMlY1SX4LVazKvnTeyajS6LsNn21dYm9MfFz1DQoM5LjO2CaMSnoSwwcQ== 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=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=EHIDZp8pRkO+5zdpjjz0Cugf7Hj1tPBwGQp7AxelgQOOAA+/BLUKXZP91bpbpDty49MBHcFh2bVIDEWHJ4R0RESLjxluNEQ+ZBacABgr/XbkLAxuL+/yTcFUCNtL0DYW/r4ulLi+xDJCN7eQKLEl3z0D51xCJ0laXwxdDi2sqYwdpdVqv6ONhwrqkZTRb9PJBIMAN3BUZHa2Q4JOc/Arl9TGX0BPtLices4jZ1XlsOEZ0wC4NGhHlRficQ2SjwYcIPv8XPMxRuugOLzVSnzhOwrH05IQF+K/81EmFE63ayd9XyX6fRQuvGWC/FIqP4Crp8Maugy2V/XMg97u6Zbw3A== 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=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=EkpnuXiVgTkrhAXmegRUMCpbeTCdFFd4EtDGMSIb5ZOH9zzoP2X5bLo+Um+CCdAfxA82QGaI995H1pigK6zkKAUdXlfvAxGQSHkuN13fkJQwdTXa3ljVpbRWy8UvxCnfqBXN9+zXLzY/JP7Jp8miJ6OeC4d8Sd4HyVEMl+y2Tzk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:07:35 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:07:34 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 01/21] metadump: Use boolean values true/false instead of 1/0 Date: Tue, 7 Nov 2023 12:37:02 +0530 Message-Id: <20231107070722.748636-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0096.jpnprd01.prod.outlook.com (2603:1096:404:2c::36) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 80d8f252-093b-41ec-54dd-08dbdf603789 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 74kfE7to5wrfkFCtoi3QOZ+hIIF++95J+QZLr2/MR+XcWOZDh0pXQ5xeMLPRVVZOXNVSVpmx0Gl8e5zsnGNTxf7SlRArGS59g8xGPe4XMiQmp904sXegMnyDm07Gf0enrDXJBSpz6NuMyPrBrhuP6fH/Tq1k06XSru8Yc5slVQWikI4UxnWemVFUq7WndGAPxv75OWV3ZYKZ0UXJG5T5QToB6WO4ZpRbEHb3o3EwSt2iYa6Ijoa9W9g6U8qRC4OjyURAbQ+AMQyHZI0QyONaTVpYt0eReGrqURnZF39WGBeEpCf8osTbXWDMz3nhfihW+nfrMU7zUVm9748yGo3FNcvRAprR56B7NdTdd4cAH9Q2+EzWbqNZe1insBlh41ULB4Of4hQnY9Ej3Y3Ku6XPR+ERmWrx7KUs7FZAq6O6++6BAXR6OA6wfeBAKXVRrSLohh402I6o4sVFdtLrbXYBS0E4DIC4NdPvjLL4RJ/f4WgeiRZyr87MfoA7FfUpDUFuZDTgoZrShgcyQTXyi1EMljzRMjprT/s/eHSWy594JMfillccCl+wj7pfQAFYmBpe 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(6666004)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dTkeFQIzZjpmc8CpSG/L9Oa6DzM+NlgL5TEEHUqWf7LfJaWZwB2p6Cr7BuhyTRUAGLSkSygj+i/zqpWAoMK8UEJL4AeLgcs4dc0KtbIARdHsTaaG/i488k4D4NvVmcD7uUShfqF+WyJnhwYURNz3F3LK9BomkcSTxoVQZVmT0uu3jy5VtL7r8h4djckI3ARnC5FAPrWVMQS4fP5ks0iyNg4fi3t/afybiiR5XK6UVl7yXHZF5DfsHaDQIpsuHguBwftwg0N/1sSNv5OihvDP5gJgwybW1myd4W68Z3DQB9EfxVP649/HQn1uNpFjfAHRyUaOFTccpHjrKbzcsAwPLxubXEiVOuYifFX8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SQPwt9SgAmmVPqWpHF5rz7qjuFlUBaQ32qpKtLbEGthzQppfO32wu3AVPbMrquLVhDeK/ANqHkG5v2bBXas4hQVrAKPEPjJJ3gWU5owwC8LPs8M8pK2ZJ0PjLw3F/w3diEGOl9A+CaQZMKrmAzpmBxMBqvb//YKuLylZLNqJoFi5m3QJukkvdaWoYWwalwsOx+4aw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IcpTPhdI0GMSuMZ/g3JZ5y3R89nEDDufNdndbffAhRrlJiqwkulD1pvGxnxmpIUqRdZbgY/QxL+RcuVcdkSOLxXys3U+3ZKPOOQKKNHPA1FWBVIWRufiRpYK+/1OmtGSwphpw26C5ln2hXaFeERwcf3cfDktlRHtxwLAjC98cMCO8O4e5knX4ztaa2+fi/s+dqDPKZZmhj2rJhQrSpeH066f7IO9xHCNWh5RpV4vaP4i3EJJRwmmgsrFitzYvDz375SHtsGzv+ttODzy0oE2rGBdQ8oHCQkdZrj2qGTtcz7jwBBaeOyWuXKQQn6pr/OfdbPhxv+zSaHX9eOloEm5QoaPzI3ygvoCSswhZTb5m08yzw8DDYusV7xep4L+13tTrA1NZExelfNHyx45saZHbau8gaqdaYXSxmv7hXkWmb8xXUpYBN83FWzjsxbii3GXqTOlzsCXvuMgq9qlYdCW91LPIlCzRNxHNzwSLhOlLKJ3YDP1U3bThd/tsqmF9LB78rN/AVjtJ81jE7oAoxzCI2uGYLLC074FjrQtsurPp+f6oAb02fd84GhCBUzK1C8S0sIwwTCvEDeXX9j9+YIKYPmne4GdXFXXr+XlNUM1Djej4bNmOllPXdoNVfG9wwtID1k2fhwntmiA1IpUoLTjkmA69J0vpgcHFy13qD9gC3YHBpnz7UrIl3tQnqQBn04xtG5Ehvz+X7JdgHHWPkJPmQXrVlKENxWlIuGLyLELhWb3F7dYjcZRS0wLdaYLSTwUr0Crse2OMJboNt7aiZjmHg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80d8f252-093b-41ec-54dd-08dbdf603789 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:07:34.6606 (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: VBBFMPCACfXhLxWQR98j3wuAe6Hlg1zkVGVURPsAOnoOIcDiemJEAh2BkBA0XErqX9OzPxov0oyuMI58PUR+YA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070057 X-Proofpoint-GUID: evpsNTyzJdpU2pmde5mIStz38EuSeHkb X-Proofpoint-ORIG-GUID: evpsNTyzJdpU2pmde5mIStz38EuSeHkb 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 3545124f..dab14e59 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2101,12 +2101,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); @@ -2116,7 +2116,7 @@ process_inode( case S_IFBLK: case S_IFSOCK: process_dev_inode(dip); - need_new_crc = 1; + need_new_crc = true; break; default: break; @@ -2130,7 +2130,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; @@ -2149,7 +2149,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 Nov 7 07:07: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: 13447952 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 0CB1BC4332F for ; Tue, 7 Nov 2023 07:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233029AbjKGHHr (ORCPT ); Tue, 7 Nov 2023 02:07:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjKGHHq (ORCPT ); Tue, 7 Nov 2023 02:07:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2062FC for ; Mon, 6 Nov 2023 23:07:43 -0800 (PST) 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 3A72NoSE031388 for ; Tue, 7 Nov 2023 07:07:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=tPlU+B8jNJ81vIfAGO8TbJzjP6vw8cSZz0JoI6Sl23ZfyVmO8WeBJXYao/ZE1pnM+x/b wBR30WiPnhV/cUolF5+iO3cHmEvd4kaPtnAn9R4Qp2kN6CGwR9IoD8X3FR2ygUWCd/ue eYoq41NnK7ymo6qvw/y2J6k89rEMsmWz0ctvPUdD6fvjAo2BnqR4oHphuh3YMddS1Aq+ aOrlRGcgVHXtFvU73xdSaaC3zTr2lS0SUw4q2AVWIyX0DEuxoHDV0hFZrJumNDTL37k5 VrYVuDjHdqNeMHmXsDSz106els5SvqTWBurbrYRyu/ZvCrSCSE2mMcauPShj6kNNshyO Fg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdw9v0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:42 +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 3A76dAr2023603 for ; Tue, 7 Nov 2023 07:07:41 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63bhc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F3XT+GN1cNw7ylKJ+CQ1a8gHODsprgO2i8M8zaKeo9dafwTrIsDp4JPIQeP0zMGzRw0SdpXFCJEO2T3CxXioIQLkM73ggRQYNSBxU0GVj17KqdV3/2RG8hUBkVzVzan3YLeu5kgNjuUFRo+U+1A+d/g+/rtZ5vTobzXOtVrVdEvBSjDJOBZ+06JRCIuUauRwoUSS6M9JTZeMCZQmLzddZnVfhDEkv49zbaxvKBlpECmj26I9wsN0rv5KgP2lpjeJ60hl7hI/6dKZLk4Cr4gmt5QV8ywFMdAF4WLnEVDimY897yQdKGd/FiCA6ktkXPxqe/419OpcKgcmP9w8hBbLLQ== 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=a+xaGI2yJRzd65AqOM9xg0LRW6c9snoGSe57n7dTeK0z3+ZNOUbDV7BsqYzdOZPrHib5fLeYx1eYjpR299fdFNAQ1AezgaT5y+AXBFzCiweTjgF+ZKFs0G5i/lrmq0VwP4YMYI5M3uda5rCx7ATkH+fhgDkm8m3unH8z8Xnj8EWEf/FGIT9c+lotwgPJJwGCS9gqrnjz3tletqTajusaCS+NfG/sA3VxXxdfAxW+exRh6sST2GPbaGgyEQiTRSAYd1yhmoWyIGtkoCzhpgpqIF8O7Wzss34lccMbC1K6gltG2p/zbm12+tpvx/DXh2BecL0fZZxL2C5YDLRSkVmQgg== 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=dSF9Eu7bNI4nl07UxhdO6YplX9RfkvO48kfXdGaAw8Djf70WSC9sH0qtA6Zmfqsjw3Tk+tHbLp0iOTLkP66YjmzGtcu4SWQWfTh84foaCe7VDKYCkqyT+I7oDtDFVNY9JVuWcC5KbF8HCb3nxULe7OQE+V/lFJQ0YRikF5FnXJo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:07:39 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:07:39 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 02/21] mdrestore: Fix logic used to check if target device is large enough Date: Tue, 7 Nov 2023 12:37:03 +0530 Message-Id: <20231107070722.748636-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR03CA0019.apcprd03.prod.outlook.com (2603:1096:404:14::31) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 80ba02e0-8042-4d7a-0b3a-08dbdf603a89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1vsG+6MFzKDCQM2oNy2N5Y7qI7JKNEWSiXk9M56SuNNc59p9JdWBv0ucU+lYkOqODR5j0EvS9H1VF1Zsu0ftXuHseOkbVmkSCdBcKDjGsEjFUumveTlgy1SNUsWrumiS+W7UIdhNxcRBmCmy7ZZqycZI3nancn7DkcqulCedOzYmO446jFBdCCeQXAfQ959nuCsTjyugpBCQ4kvfTOWD6JuYwGOGzegldjWIvA2fA2gGkXWZXU6Q68CA4j00zar8LxMbfnyZXqJOiY+vpdTQamO3G4uFnFaGvWf6Jryt0gGrI5dYufTMcbz9cR8KZT+oPQCHE3W9yMbAvSHj29SZWtv+HjQuDuVWZKIur+MHmPnzwsiogpeMWE8EJ6YW+wUjlYV/h0o3jb/IowWvQiKJ7m4g9m1c/chyLmeNlUkL//p/8mIwVaScRv5gWosCQPmCS54rag1w9vKlMO3xATGwTu903BdAHvWWJEoeYLLaXjwkE3zANL7uYfJajDBHxqyYqcOlafYujyEpBB445Tlsq6PjUxvt7WEqPKbaJab4bCD004Qo4NvUYw3s0jbslQ/9 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(6666004)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(4744005)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tJWsOpC07BHRJJHNThhkhxKal1l3ZOUk6VvjqVt01RVjjdOUisakl6ZXsSxCva9J3yShfyTO0SDpdAuEyAjgePuELPAxsqt/OEGC1U0BVx+6cdC1g0A++j/9+l/hsaXzCll6yCB9w4sAivgv5uWkuMrTed+If2HQEc9sfFOQ882UPbd3+N8okt+NTrmpvZH7Oe1mj3/YXII4nJiewW40Wj95Nm69OateNugFnQn8TbeL1eQO03vH777jfJ7arUbClZfNglp4AkGFAu9/t1yMhtovn5HNxfiDZRDquAOpAqSgnvfEppw5lybqB6VFNROzoXROIsFTnuTall24FERZfCuqLcDVxZjD+1l/4ZfRCDoy7PTUG0FmYuaFkM7rVTOWgTDSzXmH3CAtEYD3AwBoyQJO8qWG/7pr6n4lcsyFLjHU7nKd7q4V/G5UJuKLbopI4PPEsjD2t2ybdwWVd8ft8f4wLf4aYatcVpWYIeAw466XNlupvQeZaXQ5PPTWHXxxQWzoUXyYhmrzZbGVHEiGdZqYJVW4ApBynCmANvguzCRbS4Nc8qYqrrR9g67CNtUhxCCne9f0FNbARpZzs/EWcedJ9NTnXvQ/YYnMxUbt+xAqoQXRjpCOYKXDgTcP1ZMQbizotcSIN7pnCvvhZNiOrSsR14Mel0CvOdSlDZuU1v0384o6eOnGZVsq7ekwf4L5RtQth3vZHOJf6pp/XVD/A95XpxFXy0cUvnb3GzWmQ+F01/jmr6FAQAW/XBhU31wHQRYbcBSdnd5OvbfzxvYkh08Xjrr7s99MpbtcWzlTwtAmIobiNcX9kXclMAJP6ezN3SFLspQRxrXSprxTTRrK0gatn7ZvMqy6KJ28lnsLKOQCBpUqoQ0g3VGRnTQ9IBKemwSL1UDQYzKKvGiBlhyMQ+qb6wcVRmrZ0x3NRBGbCmo54Ld2m1MyZITpl42hQ1U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UDYxQ0HePVY9tp5u/20GUugTP23cN3ChdtJPh7FVtejGzeS1tunRCfDwYWferiZ2UcGpu7ho33RbK07W+6VQ6uleMz+wy63OZm/ZBM3VnYcvWn2UoNC9/U0gGY71vbcsexSjWGG7xyIXgZIJpR9tzv99rF13jYfXCr3J9ysBB4Ga53MPfGxP1utzEm306HAIf7H4WxDHyz6g7TljqP8EgYfIZP+oW+tfXyya6DjmmENULT2D0WAFRzpPWKN68on3W+mkQVyNnN3A0W/abfKNjlxFzTzoaoi8gHKDhWS8sW6296ivWGJgpTFlItPgqzF3zPFo5jb8w7FXp0eKuJMFjL4JsQ451NUfElN1yODtT1PknaJaN+BOkDZT05NOuXHOr4Ym+G1AxextVnkWu3Yx/qJM9mWMQQN6IQ0e2es59hdDfN7pKUdK6Rr8kNdhMVrDr+VQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80ba02e0-8042-4d7a-0b3a-08dbdf603a89 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:07:39.5634 (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: f0QwjRJFGelPR4DQjq3hSlRHBODuuw1FHYCfWUgzjgSXL/ASwMjp/17zjPr3zdunP+clEpmV/T0yXxzNKENqRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=931 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070057 X-Proofpoint-ORIG-GUID: ST0tx1kVn9epg-TnatJ_YAJLRlo-Rrat X-Proofpoint-GUID: ST0tx1kVn9epg-TnatJ_YAJLRlo-Rrat 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 Nov 7 07:07: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: 13447953 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 8897EC4332F for ; Tue, 7 Nov 2023 07:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbjKGHHw (ORCPT ); Tue, 7 Nov 2023 02:07:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233135AbjKGHHv (ORCPT ); Tue, 7 Nov 2023 02:07:51 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E44410F for ; Mon, 6 Nov 2023 23:07:48 -0800 (PST) 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 3A72O5wI014497 for ; Tue, 7 Nov 2023 07:07:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=RFnzGJ+7mlKq3JvJmYOrc0cMNk8D+UOEZVyLcHFkKJyCWPRUxxMWYDz2FbFUGJLDcuEv ltcLUPUVnKz2RbkJuvJErqROsqKU//gSLarB/sw2KvWdG8vhdRNCffAduZhS31T6LiMI tBdk47yf8dhoswVpmnrxHLPaAUS1jNUcEKPt2yZv9nhpFwJYUm1XCYJuP1Vk918pWsgf 6vAR3lkSLoaKGcSRVzNX3ugEOwUzgrV8Jj5OmRHklnhzQwNwxoH01TDM7lEee4gjfMKE tUSzSalJYPagJPa7I8Yg5AV5jspQHMMpoSG+ZxWPsJX4YfTCDGF41kP1vIzPrtE8PERn 1g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub5767-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:48 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A76sc8x020774 for ; Tue, 7 Nov 2023 07:07:46 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1vcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TngL0in2b1//kWrr7JD3kmOmFQ0gu6GlcOhFyOPezXKbQ+H+jEx4RgdgMRD7lMaJ46/GwWvF8FMTczmVV5aN+SF9FtteqcMMHhjRSkWAYKZXE+FAY2llg8tH0lbXrz+UVxIVwcJAZ+sLpLSU1QA1hj2UQepRvr/3S/51QLTsClF3okQd7g4gNdo7y2PaGGnVRyMLiAj/QAYw731dKDg0pwKdqSdhZKFdaQfKVtRwge41OcyMp7FP5TRAhSMc9RV3KfB9WE9+9z8wgM/VKROtpHA9pmtSCTJTkN59pKP8QiTaPEv8N475jnS+whuBK4eVbEaPXyd420RwE/EbsgTNkQ== 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=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=a8wE0KdYJ7IwLfbg+aZfmcP7k8kTL38GoOblCqJf7qnoDhq+RXhFwTvEUTa4kFDfzM4saOq9MzuZB8RLJCq3X9FtQBOzu/ddnuAr8oYZ+FYyM1Bri9aA+pH7h8vp55E8C6BEKmyJBPr9MI5eQENE1V5SykG2JQ/xMbQ2gJIB/lkv80mCI51q8PgdIhpn77hyjpLvdjeLb1viLF4utx5wRISIKE2bQBOdA7KlfQ1bmo4CDDpqYNGvx0BquSUWtaprfduonLrkTglfEWihjd0IiMSXEyfNoLgGLKL+j9dRdTylxtONUOnsjC3bmCftlQoH7mqY5FnlgC4DEACx4bkBfw== 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=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=VqbgQcNlMKH/ctTbWV19VcWVTVmOyJ7aWsC0s0kVxLtbgZYj65tg8qphGPHFvvLM9uphFWmuONGT4meBDATnRFNC5mtgoDeX9spP+ayD8hOlGmysxw1xaqoP79qi6QyFUdEY/9pIz7g7OkhrEmLPaDbG0fLHgGedjdGPErYiWyE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:07:45 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:07:45 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 03/21] metadump: Declare boolean variables with bool type Date: Tue, 7 Nov 2023 12:37:04 +0530 Message-Id: <20231107070722.748636-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG3P274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::17) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 3447e4b8-9753-4602-33f3-08dbdf603ddc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OQswZOJH1VWIZEumsNELcA3dmwlzdjOWloKTdUw6Zlkec3VA0AxLRp7c9JKWGFlBfn3o13HDqrb07SJuhZLs8kKet8w/Iv0aHjECoyXvA+4Z/inLaryjZlIdHKGAzd1ZEkPmtR4I2yI0bZVTmKROUPStiU/cg/Oj8tQUmWCwsmyCOFAA/znhykxItnQJel6JidoFbnROl4gd7F7X3YZceXJiYeVfzXFuf0kPDkJhqn078cBbSF8APKiyyHzC9+ki4ztkWnIF0jFSRYENI42+DnZBY7Ujg2/udpa9OEtSfGOXukaQaa/0LMWeuHzLYhKToxEAXX57G7g2X473DgW5v81sm+uhq20G4MvWARRflaXS2kVwfTX5tBI/W3AZho/f6NvheX8LT78YCD8bGUPhUh4EurlZg/HCDRO9yrXI1vBSZJpDE5Emhner5KETx7pBxhAlmXQeX+RWNznYudFpimoPVn85/te3SmHo9oP80pmO/SkfRA5yPeMSf1wKsdCAKrCT+/tm0UVxiHxmEEJCtImyHfCzGW8ahvjjnRo+BnoXMMzVXmra99NITcSJ1/8APf0J0g2n8kIxqdcyK7SenOAU+fvqLm+Vf+tmcCQ3FI1X15us3EIzigMAWAFNacQe 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(6666004)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eYkdEaKnGQfb5epBm/531WmIaEU0NjsPC7jYdogP5cFy48G2yBJV1Ms/TotTv31azYn2pRLapxJ3DyGboImFQVJRaIXwpUYJSASzANpn2it7vQV9vJHF39uZUVXkhm4/m5b7Jz2kcyBE0gstrLbXlZwYoI3ibjxflkaZk0iRkx7eHTnpWU/uBBl1ktr9NP/7oOa7JM7oA3GogM9ZiRroNGS0wT2rxn7cdT8qMJclzUzkIY5B0z2JDEVaeBMx9BmO1XyRLJAnLvCRsUMFGKwN5cMB6BcG5oKo/HqnEy24ERmYV12bd3PWJSrsDnwS+ZbZ1ZoduvmJ1ZPY8DAthbRtJjM3/rAOJRGeNJDbZJStKXe7cXSlSdvcf0eeZYA3pgyVFhvpG052XdqzjiLe5z2gd9FO1P763D/bO7EWn9RsFRPrN+ftWmbf+MFYi9bQTujCNAPSnF3Hl8/9IdwiD0TCxdALxF5yQzBRhiLy16vcD/HZzRvI9h9rQjpu1+YKFvCE1m4CAjkoC7gqcFTXnIRhNwW2pySFdxZEp67gtdfDPQOB2ciZc2mOOWRPkDyTsWvt91xkmLSuKcn5Pv9jS7YalKIJAPALUy0YgQ909/rBdW4TnslYeGeQqlWbqZSiYsy09gYm70BRsYZBwvFObMsb/EkBqugdxv00I+jBtu33SJ8U6FpZyCHsb4AhwSBnbg+4V0/1ztgOS5KpqglirRzFsF4WZwAiZIRlH+3kultd4tMIHMZTc56VctVA3m1jim31zhMTMxZxfx772aZHCyKklFeb4NwYawEuUQQ2nvnlkSZmlH2EFFqUUekLU3vRjVbG5SbbuXgBxGe/gUlGs1Yrb1S1losKZnt2g0pcvlfmWKEaBI8EBhS6K828Gldt/jLXMSAM6UjkwA8QoaVylDj2WZBzRKR4tDu5z+6yXpNSLvBC0XbTGloLT8ap2jZr9zj/85cPYS+FouPctvGSJrERs/bcwnZVBBVNEMwF95erXUyLr/ySp38HhfmVVa1LAJXvBq2TTuXu6HOyz62I7+2U+Ap63dLEUcdDPztKxSDQ91GumhNQtPt2txEcTAHACZEGjkHdANSVSDlsAXE6xm0Ad2Yvy+Gmosp2i1SqQSWqb3QO8CtyYSPSEJj3h2aUL37kgacSfPrx6IOr7hRFJubNXNmNg+tfRSYmjCRXLvAezUajW9jU/EL5VJdGQxpPMFye1mpb2j3DHigUvQ1bpRbuQqQmfMh2P9yTU4nAju51++EBHxQTxPK5kJY54TwDV89gP/YZbMGYCUQb0U4DvrvRwUQdRvfIcA13qfR5dA++cgnVjdE+QqhuFLDcIgys8kougpGVo4cpkD6qeVs8TXIXP5foRMoaOqgygpQnnkG64tWUwBiMUjUqFtM9jdk5hpDpL3JFL6TKW9voI35WqFOIm3ujretKfCl6itmY7UzvkZ/YiYJRhK52SU/V12WiwVSTQeAzhIQHh/+kmRvmu+JEjPMZNUpkQl1toIexwKVTjdfgUjmNeE/JfmtH6CBPRmXjh7Ln1a8XTZyOVuQzBK3ShITGzCsYPQEOwvD0zHFeoHBz7RdHR0UHx+2r4v0W/ZzQ7Cix+QsmEC/lJ1eYloCcCQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6+kte8M/Hpn1NyZLF1aDQKPcWgKSRXQc0Oodc5NktE+kx66YsciSpA/melPp4vcmsa1djZ/PlfnVvHXOoXSbywGF6EINutXCzBIohjSiI8D08terQx/O237FUSMWKBG07x5q0MU1GtZjbM3wOKSb9pXERuUrLO4xUrHBue2cWoVCysvOMmL8PBfPWIoV8sK6begrVDzlusZhvDs8+mOhyzkPxcNnnGKpO068fSGFquOlNIoC8/+tP9siE4WgRW1IzBCEgX3BRDuzGYzajCqQ19uUlg88TBcIigAFU8020JO/tVaJyx3j7eE42Gpgz/mCFIPkV3Tec1IPZEo7nJY8rQD/SsFrL5xMMVHyMP+uhMTtKhaL9xZGJc3NMFVR+JjjoHd+czUdOnyUvacL7ml7tsHn1zztKhKvfygQAbiwRLy4rev6FEab9WQVfCgw2sXI3R2mPf/tbXdV2izLjgQlS9cFFKfpViaY5OuBZg31CVf4f3WcMMQutGSGeQ1fexsg5MNGUcl5BMPQNxLzJNh5Epoe7DY3wCHOnfkmrw8zzehJWunE3E+rMGEmuG8E9FbPT+f1wq1Fw8MCPruHIIZyrU+WbWKXp2lnqmDndSBxqZy7DFUaWA3gvfnN2owvjGQ6tB9OSjoUjRNpMWCCtA1b2jNHf134d/t2TpOr9IEsK+517D6EYshwxoH83uHfzO7rdwv8e6ale6Y29COwp+LK+mv/n3JUkXTc6pJiR0+MOW+rjUXBBvs6lHUnk8YcW/qlL3gHcTCR+INM+itm3xmmUA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3447e4b8-9753-4602-33f3-08dbdf603ddc X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:07:45.1658 (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: OkIfIeVK9tnAdmbX0/5cjF55JXXnRTu/Dj1GxhnZImoGyzWr7whLUwZ8CtYN35I9OmutCgDGEpy2k572psNaCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070057 X-Proofpoint-GUID: iHM4XBMO9A1vRZjGkAcSL3UTEuIxwIIh X-Proofpoint-ORIG-GUID: iHM4XBMO9A1vRZjGkAcSL3UTEuIxwIIh 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 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index dab14e59..14eda688 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -52,13 +52,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 @@ -101,7 +101,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 @@ -122,7 +122,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; } /* @@ -2659,9 +2659,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", @@ -2682,13 +2682,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); @@ -2699,10 +2699,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 Nov 7 07:07: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: 13447955 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 8A43BC4167B for ; Tue, 7 Nov 2023 07:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233135AbjKGHII (ORCPT ); Tue, 7 Nov 2023 02:08:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbjKGHII (ORCPT ); Tue, 7 Nov 2023 02:08:08 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BB611A for ; Mon, 6 Nov 2023 23:08:00 -0800 (PST) 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 3A72O5oh014504 for ; Tue, 7 Nov 2023 07:08:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=aJaJzmuCJds9EST94iK3c3l/XUmLbG8LUxaNX7AEksPbNbEYC3Cg0LIMeaQFRZaTJ5WX fclWytSiI3BEpzw7BYudJAfcLwInWg667jVWvce98AD358mJ3vJ1PhC1mi5PutzFicDR pZzkHqPxdMTbmLaordpVFU75pA1SyrsdCQap0vsvACJIys7711PgLTVS8c/d8cW51eG8 Rlunc+FnBqTltQ0MLbV6BBPkXI6ddvm1Cg3UWyFrocKxLcjXJIPhKz8Z28aRvSzfCSE3 li7fDTwUPFk1oGf9h8t7nUfT3n5BcAqQjMqspkcu+dx0VuYVOII7lC4fcqYQtW9/9m6A Aw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub576g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:00 +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 3A75BLrV038278 for ; Tue, 7 Nov 2023 07:07:58 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdda3f6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UTTw4KeuSd2RM9F+yoHK9lmuKuVYqmldznBNV6M6LiFifVgVKWEfOuE/cBAeWZPFSI65VqvCAvT3k0r10gaSk8VMykKPDbSou3tCTryF1rj/AF2dehmMaPO6WrSzTpVWxK6rB+jpK3dBK30gWnOCwxYyPHbe9226UUa1roFzBH/xxX7LpDqZbaluY4KFzZZFOuBFGSgKpJEGAHqEtA2R2TD9PgH6u5+qPUMkIQc9oftU7qo86WAV0VodRv/Wq4kMnZzBpoQ8l+qvvOgR/SNa+/eY1xuSQHCU3AUpjiCl8XGGyw34SbT928+PZ7oJyzZPaNDkuAPJv4ddVJbkv4vzqw== 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=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=lFAQMvc7DlNrng9/EcA8d8ngDLM0R/qh/CBFNPVoRehOxpOjCdEspjw1mLSvb0/VH7FCCUs0MUkx5hCuLsJh7MuslCGMhSXxxKJ9MR9pE1dqGbC/lB7JZYkiHK6D8ITF3KYu4mUY6KSGRbSFL33vDUAwDmTHXpYEvL/RjIUGRC4gZc34sWNTOjhEE7rwbJVofiqk3NNNsMoZ7vaskR92Fw4gARdpOyLdqPsd1ONY7zBIP6F0slebSpaRbZ/bbfetzHDjADxjg6UTvX0Fs10Adt9XfWZQetLgycKrGT92GHw9UbTP7wbLqYSqDdFx5IIhCy3ZPi52KVZmN3IbHuFxKg== 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=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=doglMbIAQSIFONBrywCeDcvpoxJES545RbysJB0JnsOkluRtzZII/7mscix8k89PXQZaPKHL2zMhfgYIIlZjTlh4V1I5/QvYm5/MGFxjybBvMgpEq1ELDUZo36ql6rSQD676ZVKlQWUVBoav6uB3FTiDYfdHw2MZmgOICu0YN5w= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:07:50 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:07:50 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 04/21] metadump: Define and use struct metadump Date: Tue, 7 Nov 2023 12:37:05 +0530 Message-Id: <20231107070722.748636-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0053.apcprd01.prod.exchangelabs.com (2603:1096:4:193::7) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c89f1cd-69a8-4a87-84bc-08dbdf604117 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9wJqYaReA9zx0+ssDlUWVnz2bUQCTWxnDrmN3XKvNGygmutgCHcdxZYxA8wIq3RbFv9bryp2h6qg5cNLU8mOV/2Bj/pR7FeyJIoJD0OhuqDnEOMiYWjbw/MaIK5vOVRz+KlFixkESI5woiL7Ju1H052h91oKkUhcZpTPQhYYbB7mrTwzCo4vb8pOdY2N56zIszyZSSKsDmjjZFPJ4rQkLfNhVqqV8qFsFWi7JhQfukEVhisF/Ro0V4YKerD22BaTHYp7s2LlT8hPGcs0WA4QMzm+wne2PrXtNi4dn+/8gz36IEVDitMGQbwOiE5CRACmQCVdqkLzW1DQ5z4qnHw0FwiQe/9K4EHg3fozfox5uhC+qhje818KlkPQSvf03kdhH8nYb4PwcXTjn7Sn2OHa/akc7djnPJTxO4h70ek30aJAdR6n8T9/ti1MIo8L9XeWiz9gIAmM7m/fZydayOnNUFmJKq9EN+wME+EajR8YpWCH3fknb2xoEVTKA7pJI/eDhlBaw3atKuvKNMOdbZfuLruSWIOaWYQ0/bQSYAOktNrPVy99vPNhuOuwppCwr5O69cjQxHQiTBu7IiicGgRaWm5O0/NWgIinuphMYGss1hYz7ySjHqHIVy8UjXB+WoNL 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(6666004)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(30864003)(41300700001)(2906002)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: taLnmhOO3r+YIE2Tr0nzvoi8Kgou5fv//BwUjmIffsbTbZz1ZZQfTaAkLgig2f0SoxJuPxCIlAbLPewzbGr2j/mmcYJYFP3mm3s3e8Hj4H8RVgmJcfhXZrMwUPkDq+d2lynlULSj2o9rbI9q/8xSaRH48A6ps2NgD2tO+smtHlxU+azOs9WahraOgny8P40Y3xAFCRPqVlSoqIBZSxQuAG3kSsgXZiE6BL8gRhzzUSys4HGnvCNBh2Rz0tJhx9TBbiqp/e585QLvZdZ+ORIHhz+EqORnztj4FxLtYsm0WnRQCGayWicNO/ZHFRxAj4+9IlHicIRjz1fTYSdGoumolyYTbwIANn2cPB71OcUJj09ZbAh/qB6rjis1Pi/OuFLsRnS4ta1IT+X0w1Gwxf4aVfS0/DZQ3NJ7Bdx/RIec3Qy7G8hn1Fqt00L+SFchnw0JbyNQmbMYdMm8wvXdIWqrm5yGbuTqLLpwPG/WZ0BJbANGpoKiRky0DuqQI+4cOeVqBM8+DFYnKw0iQ6bK5Nzix2AE8NlAljEoADQ7TyO72vV9vLX/eQBeiYtXI+w9bTeY0rp1ju9yKWVZIvgO7vylQVvOmxuty2GkemWuV9Tj1I3JKkWibISb/ayj+rVxAHacH/CgXNhQyQBsvhpS+G22G+EKODq6Au7LMmEd0sOJlcRjoquIubrrTEr2KSCewVIYaVv6sHKzxeura5YTVWSzhKh19Cvlb59LKMbsDgHWsyEC9kWWO3z7aDBGS+eO0SKmEAQ/mDt3TxRFeC1Niw+vMOcBRQs75Zaps/ER9vRnJ8MZvSjg0a28Yj0PltrjhtcrhoPeoWKy4Xhxnz//Z7enQi1iP2BtbvEif1gwr8vM20yVG7BVBN5+jwmMpG/7BdEArK+ODEKya4E19XG4U91v7b9DBZPi4BrU2QWxy/kO/ywFjbsBCT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rwRFZZMjHusU5EBzMnd6zAizxVmLW+C9DaTDtvAbtS8UCqgMCvxnmFchMhQdhZmnMwndyb/2mVAxZHPZtO9MHM3HYhoqhSXAvLO8tz3O5uhWeyxIKkkElauNiZfOQb9ktNSOoiRVMZG4dhPQPJBon/g8EEukCYz36iHrCYGzzudsxKcpkz4shcFsr00znCQpVDlDSLtCRGs5stB0KlgLXHJf6ix8BoO4Db8WGt5ysrStx/kv9VmmC843lFf0VDwhWPU/lRVIxYofMikRsy4k6LTS7lPe0eoLo7yahkTqtfKXItIXCTuOlwdpDijsAfDe3ymEvfuo/8uEPhqYDfLTX1h4T7Ys/TeYjNovWt3AkqnfiHqk0OaXpYWasWcD9VEYcmnyumHxgI0amU/SlasimvfXSXmQkPpUc2ncXwqrkHbpWVlTbtgJTOrksfQeGUCJ/hhmkk5lAA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c89f1cd-69a8-4a87-84bc-08dbdf604117 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:07:50.8497 (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: uwf4v/sFIRUED7riEn9hl6TrYPUJobEXnxl8LRq34h3KjUizmbC9eeTGyHnQo6WNnML52vUScEzSG6To1DS94g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070057 X-Proofpoint-GUID: XemXiGt8NnnaEOJGFEYMvyqRpove698V X-Proofpoint-ORIG-GUID: XemXiGt8NnnaEOJGFEYMvyqRpove698V 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. Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 458 +++++++++++++++++++++++++++----------------------- 1 file changed, 244 insertions(+), 214 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 14eda688..da91000c 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -41,25 +41,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) @@ -99,9 +101,10 @@ print_warning(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", + fprintf(stderr, "%s%s: %s\n", + metadump.progress_since_warning ? "\n" : "", progname, buf); - progress_since_warning = false; + metadump.progress_since_warning = false; } static void @@ -119,10 +122,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; } /* @@ -137,17 +140,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; } @@ -164,9 +169,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; @@ -389,11 +395,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; } @@ -447,7 +453,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; @@ -456,7 +462,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]), @@ -483,13 +489,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; @@ -511,13 +517,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; @@ -544,7 +550,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; @@ -553,7 +559,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]), @@ -583,13 +589,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; @@ -616,7 +622,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; @@ -625,7 +631,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]), @@ -655,13 +661,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; @@ -773,7 +779,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 */ @@ -783,7 +790,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; /* @@ -897,7 +904,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; } @@ -907,7 +914,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 @@ -923,9 +930,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); @@ -939,9 +946,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] - @@ -949,16 +956,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]); @@ -968,7 +976,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); } @@ -1026,18 +1035,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); } @@ -1062,9 +1071,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]; @@ -1074,19 +1083,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', @@ -1098,7 +1108,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); } @@ -1109,7 +1120,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; @@ -1131,10 +1142,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; } } @@ -1146,7 +1157,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. */ @@ -1229,10 +1240,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; } @@ -1252,10 +1263,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)) != @@ -1268,7 +1279,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); @@ -1286,23 +1297,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) - @@ -1338,7 +1349,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; @@ -1346,10 +1357,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); @@ -1416,7 +1427,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)), @@ -1433,9 +1445,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; } @@ -1450,22 +1462,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', @@ -1477,18 +1489,18 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_local(nlen, vlen) - (offsetof(struct xfs_attr_leaf_name_local, nameval) + 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), @@ -1499,13 +1511,13 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_remote(nlen) - (offsetof(struct xfs_attr_leaf_name_remote, name) + 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); @@ -1538,16 +1550,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); @@ -1658,12 +1670,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; @@ -1755,25 +1767,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; } @@ -1784,19 +1798,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; } @@ -1832,7 +1848,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); @@ -1843,7 +1859,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; @@ -1858,7 +1874,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); @@ -1893,10 +1909,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; } @@ -1907,16 +1923,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 */ @@ -1937,11 +1953,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; } @@ -1968,14 +1984,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); @@ -1991,7 +2009,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; /* @@ -2003,7 +2021,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; } @@ -2035,9 +2053,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; } @@ -2049,11 +2067,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, @@ -2079,17 +2097,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)); } @@ -2131,7 +2149,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; @@ -2148,7 +2167,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) @@ -2208,7 +2227,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; @@ -2224,7 +2243,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; @@ -2241,7 +2260,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; } @@ -2267,7 +2286,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); @@ -2297,7 +2316,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); @@ -2320,7 +2339,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]; @@ -2329,7 +2348,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]), @@ -2357,13 +2376,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; @@ -2377,7 +2396,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); @@ -2385,7 +2404,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; @@ -2416,11 +2435,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))); @@ -2438,7 +2457,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)) @@ -2453,7 +2472,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)) @@ -2467,10 +2486,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; @@ -2493,7 +2512,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)) @@ -2539,7 +2558,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; @@ -2551,12 +2570,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(); @@ -2592,7 +2611,7 @@ copy_log(void) int logversion; int cycle = XLOG_INIT_CYCLE; - if (show_progress) + if (metadump.show_progress) print_progress("Copying log"); push_cur(); @@ -2601,11 +2620,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); @@ -2613,7 +2632,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); @@ -2628,7 +2647,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, " @@ -2636,7 +2655,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; @@ -2659,9 +2678,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", @@ -2682,27 +2707,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"); @@ -2715,21 +2742,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(); @@ -2740,34 +2752,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; } /* @@ -2791,17 +2821,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; } @@ -2828,24 +2858,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 Nov 7 07:07: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: 13447954 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 38386C4332F for ; Tue, 7 Nov 2023 07:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233245AbjKGHIG (ORCPT ); Tue, 7 Nov 2023 02:08:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbjKGHIF (ORCPT ); Tue, 7 Nov 2023 02:08:05 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E9DC11C for ; Mon, 6 Nov 2023 23:08:01 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A72OMBr021377 for ; Tue, 7 Nov 2023 07:08:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=kUjGFGApv9TnsYefqDPgpYsuOPuY7XLvO+BAORE4s7ydJ+Bn6hCgFYaIq80BVVfdQurP /fcFHlwnzLOvO1m5b/bhNDqEQDl/nVUhdjRcMzRGNjM6rdWv2jUW5MLiqw66W5Q5qyO7 qcarGsyV/BRMopF6gGPYt69S5VspHtrXEQAiPtFVn3DWW6vwL0Ng0bFd7r/GXA0WS6ds o7s66B29OIzCKuZCXmBiHPcHPvqtxQF/lxIOlkHGiZA2U6t3GjRa9npM/MqJ/Kn4vZqz mK00hL+MsJV+T6qK2j093PfqfXZfnRNUD286KgU0KC4d76Aac3Y0MpdDK+pQbA3AYSlo 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 3u5egvd8kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:00 +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 3A75BLrY038278 for ; Tue, 7 Nov 2023 07:07:59 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdda3f6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:07:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WOO0kZb1tsW3VPjb7CBAU9bDM6b9vQrVcjCHELqQeWlvwxJU8NSRYhm6hogyVLbtAXbdmBm0Onr8neopMXy2BY6pW51/kLTSdk3sRygQDc/8gCQBelNPwMh9uZkvcq5RJ8HWvGha3wj5uhptxrnsTFOmxJmysOFYwtNm59UtgDs2tUOt7GDdIXQv7WJIZC890JGMpfK4EClzoos1fRGao1ZGiUU/Aa8SAj1DwticRprdS10oIYjgTRbx9+G+YjEcuiwH9A11L5xK4/TI5X8YCuSMYXcNizVmC16wMMB193AWapkLNz2nXfh5EuLHHv/MNUbP//F+H68IFc+55UBXpw== 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=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=SylYmLAMYpDGaP2V7pMYmmT/nJvRzr2/AzuBHWyGpiOUFvI+ZW8Pk8hqTSdrBpG0VPFnqUf1xs18eEwOT7SXWndaWgVo1NqbYtwObFhyfRMBT8Q0ju6DZLDxNzNr1d8/1RKPxx+ZHCkA3RaXBVNALoa21QFt182xJ95hL20rXXzseY+Co8t422n4jrkP2JR9qYmQGOOdx1AZVJT3oMijggkr/5gOZOkG354SO1mXQbl9yzKT3zbUBbfJ6T5/b3sKC4aVwuc0TUs1HEXtIJbH5NLcX50/LWUGb1nqwXIiY3xWcfFTPriOgoiXG8nUIOA9Yx0Iz/X3pdBh0dKWiTA+mg== 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=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=ibCxsICXZ+quIPEGBPK00wscp8mB5RYazYiCtlftz7CzHNhgKicZfzTrm64RaOB6Bg43zKAddozzYRlaE4rMGhp4b3Syci09I+ZTd++z9agctZItvSOyaQ33q0a9dIGHsztb78AK1jEt/bvzvoGzvIXlxvTtgyCecpl8CMixXag= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:07:56 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:07:56 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 05/21] metadump: Add initialization and release functions Date: Tue, 7 Nov 2023 12:37:06 +0530 Message-Id: <20231107070722.748636-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0049.apcprd02.prod.outlook.com (2603:1096:4:1f5::18) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 14a4b3aa-fa95-4efa-c025-08dbdf60447d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aw+OTfCBQV8de4YDVM07DjT+KvZevEn+9E94kTmlzdEdRcsNMWn4+PhixB7ZeFTaddpOcYtoq5USfGjJ6bOoXLeuL2asBqnxxGRwpWMIOXsYysuzczroP3c9zR7Cks/Z9ZjnpgH3JLxUFrTeWfQdsAK8ET95DiaKKORLlSW9sPTMO2SM90QmYnC0OeQE9c0n3y+IvSuh2y5Hsyk/m111pzFxNfeEXuqc6JkixajtwvUXSXOS+CqilBD8YLqrJ2ia0FoHvgwn0yRabRepwMJmY6z4y/iuwXOxWT8bdsDdiCVuVA1wBw7ClUaw46YeKOtpoLDDDAkVbCMG209BpfBkAx8IaQAdJpDbZp+RxuAF+DRY6Vs1S3AinjMYTU1EXMO6XJ55KyIIZwtKpU1WNHClot7pSymkgqog3+tVMstSOTbAwKBCrRn19AXf5gazmklgr5dMiK4ekD26D6lqr4okBekNirNGg5d1d+9wLIctSQ4B4Ppbz8UlZzCGDvuza6PZc3gtGlgSusZ65fsgno3TjQBjEympatw0AZfDRXMmCJqJ9zcHRDp4OwigZFP7Hgm9CGUlENY938J7qm4IFiwJB0EeQ4G8bKys6yTm4d7uLldZuEwnVSFvZYfftswNFLiz 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(6666004)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SdgjGXij4Jnvk58MI/SCgwpE53HNyYDKXtTGo9SPTDWF0vYwckAXX9oLeRLkFQiZmk54bruBGNNCP/uzK9F5n4vKQ/vAHkzrTd/dFqT7poWy2ToPvGDbBo2kcYBoPMdfrLypUBO8zvyCwpK1VVzI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P9jWUYZ/usvohtC1Sfls907/2+s7rg0qo4HsjyeoS/4F0p4XsfV7hVOPOToOmKOfTZXpmJ1YzFe4/9VEagskP0wMvY+tAdBVWsn30WOxHhG28CcN6++4NTyhnOSvDS2F/9bxFZyi9qFqVQqtoktJEDmlRuiezJMBjzd4ENmJjvnWg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14a4b3aa-fa95-4efa-c025-08dbdf60447d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:07:56.4543 (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: /TbX4BjOp+w/QsbiKQoV9zxx7gg2O1aqcDCKGHbgCCKXlD0h7z+KvmP10qTJD8LsYkKId2R9nbFNDl2astJVOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=861 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070057 X-Proofpoint-GUID: Bc_CzkukT77wIlJgrfcPSbKOGqol7Jul X-Proofpoint-ORIG-GUID: Bc_CzkukT77wIlJgrfcPSbKOGqol7Jul 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 da91000c..8d921500 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2665,6 +2665,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, @@ -2757,48 +2805,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 @@ -2875,7 +2891,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metadump.metablock); + release_metadump(); return 0; } From patchwork Tue Nov 7 07:07:07 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: 13447958 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 9F0A8C4167D for ; Tue, 7 Nov 2023 07:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbjKGHIc (ORCPT ); Tue, 7 Nov 2023 02:08:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbjKGHIc (ORCPT ); Tue, 7 Nov 2023 02:08:32 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EAA8FC for ; Mon, 6 Nov 2023 23:08:29 -0800 (PST) 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 3A72NikT005300 for ; Tue, 7 Nov 2023 07:08:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=ZFjm9nTyws6Len3cf3btMLR6R2iy99U85M3UEKugHvcqsAsEbDNNzs0/ceuQqf0EsPiy p+N6uoI5PFHd4MWCuOGVczW5BxSBN/3LUq+LwWnP3trLeqYX2YCrp0BhOKmrEbCOhr8C 2GUUSmSulDg/4nL0x/mfBeoEckZ5NP58j48xy14PaT+aimCeAKZzxpOAIXIekhfZCmf3 o7878nyUgFsZMeUrCSXbAfkVn6eSg2lZkIoOnx/WV+nekJQeh0UCPU/KQqQbTMCjY+x9 +m8rAMaOHT8W2a74uLpBYY/2/WY0V4duGzsbvSkEf/yxRgH3ymWQ9QeRAOMZdPawwgYT QQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5e0dwach-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:28 +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 3A75sH8s020794 for ; Tue, 7 Nov 2023 07:08:28 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1vuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CldopGfTMzqpPN7j7boDxYyYcSdqg0NLZBOsfbeFW+qoZKfiURus03K68xy8hsr8xcKfaCeeoolblwRWcm8TAgtLxfzxCnWk4TqR48Y8vxxc4T3pnO6h/n2R+wG/2MU0/kwvVp9At6HjQuFptJHYH5nBsbqx6dDTIlTqWqBhPK5TBvJyqmWeVxcPiL9zjw9imka6AClRS/ZpUcb7SS8Kyena1xySPrI/UaUsm2XKdUscKjxuxSuOEMh0xiLhzS3Ox34m92amJ6/pZLOVZHwqofZQeTWmEiuqRoDOvw3c//kmgMtrGPb9telmoAf1S/nekn92N7WSvftneYWCuScUTA== 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=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=VIlkUE+dgJZR8VuRIcz0u2bHgb8RrVJZ8pOzy44tlGOowLAeWgUUtkSAf+YOVDZk7slQ07Wm/tWZWxnDWwII3v4pOnguj010NXEbn3ZPB+ULcTJSNK59iDAvXoHED3wzg+98sGvTIDtPPEbcEdX4SM/w31fixHdCPwBzOOANOz+ypcSGiionuxw7EadupLD8uA6ApMkvGZ51hg4AT1vRcNP6C/C4aIXx10hZ39jSmmfh93iwzyu6x5Fb+9/D9A7s23bt0MzVxzB5skG5hxOSZz31/zUrxNWSEdTfWLHbKjCcMzjgpi7x0TVEgLhlxOhXhOcIO4e0PuW6WfX8Ft32Cw== 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=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=xX/WfGbuNphnpCJpUoKGxEM20rXPhZaYLHf2baQ+J/23ZgzCFYcV5UzomV2ILZ2A3JGXBHkh8E6M/Zvgmhjk6cnpA3SRBzFzStJuHpLd++ldQlgOy1BCrBg/4q9+KmpiXB+VyCTPEoDehd/3bnqQwQXjuIM7LNRH2sHVT6flGJw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:03 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:01 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 06/21] metadump: Postpone invocation of init_metadump() Date: Tue, 7 Nov 2023 12:37:07 +0530 Message-Id: <20231107070722.748636-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0050.apcprd02.prod.outlook.com (2603:1096:4:1f5::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: 044ba694-3a23-4f64-113a-08dbdf6047b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EzbPrEmEdGXtRlrIqUssrcyMbZuJQUoIcuEaXZQn0GptDabzv9J8g8Jzs8ARAUnNVTcye3Fb/WBMpQNRHPo4ryBJzX7P59czyzhO1l2H7nQyLJ75mpmcdPtBGjqvTUROyqAzdvYGePyWOLlZCdXGNR8yIQI9IQQxRkPUj7ftbtQm5LD9DYhTq1wRpauMMs7TiW4u5Xd6ZPw113U2RhQfqXABQmZBUM1arB+H8nHLVO0RWbh1bt0x7vXUPDmT1QoqpnCLJTA0QJK2CiDK2sB5nmd+C285Cf7h6D5w4F10iq8iVd7q6vkFq/n//47zB21hkalDNb+vuXCS28igh0t4T74cqVAIINI5HYvTE18GwT/tp5phIgEGCrUs9db8bvOhAg/ki91qW94k3d/x1WEOEm66u7PU3a1bgQPUenQuKcPutu/64JUd2d6yYKsVgf9enxjAWkWqvvVjlJ+SuvXOPG/6hjRpwkJr9npy+Ja077lkEy2EdAS9YQ7NCq4Q4vcG/Kbiy3VvtVybSq1Exbx8eXOgfHw8u0tvq0slht0mttsw/Z0HodZYBssfK4hgHZjM 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k8mjWL5A+yrxdWgMvIJHcDZEKjwQXK0p7kChdDPY0oTsjeuYkJwbczx6GVlPegOcoZzpJ5yE38LCCZ04PWR4++k00TehP85CtUjHRP6i0xydKuXP6jB4pTZUzcZbEJXNDH4QGoJSPhb+Fq57ZIcTAewlZS232mASj3S2i5malO/07kjz2RIpqp16EE5GPA/0KCULqBNSnD82TDTrDuE4wLk39xI32EOywN3EnkSND6U8ngVO5l5PpwfrJtWOwmgtIRjzsr8ZEzexrLiLffuLa91Y8aYgunz38IAkaGpCxQsYZkHjMzo86l72XR6qNfXedm4BmuEG6D3yxSjk9wJNlgUEJPFArEwnmIiIm0XjZ7NhYhCr/oH3IeE5Ob1OBcDXdJBIGH5RNZrSEGpKsJzcqP5nmkLPK5itVIUXAczpM9PvPKhlIOY0DLkYfSJwejhHWL7Khxp3L9uPg9Eqb4RY9UHJGOVNy8BAvNbc8D2SnQwAK1SoZ+1SVLTEVSuUF9Un+kOLxnDFxv/TK8wOVsOf8E8b06B3rhQysfva5eFfFmjiAJRWUqh454Z7sV8ZgOT2MJogY9ZPJFraZH/nNg1nf286J/i/9nqpGVamcAAY/t2+dzDCkTspzUDp45M0DlO5BIzkQAhes69Cz5t79mDb9T40R+oteF/63MtFrVZwJiVacHfIND5CLqW2UGXWCih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7cr93UU1Pm3gqd0Utk6Qs71FRoiD0CxhGnje3PuGSDbznKR8WuTyhsvE+5YNJ+Jq3D+oOEGz+7F29RMyZf6fUiR52I4Gl1YH13k+9PLOTMsMBqKAXxOkz8eF7tDTqufGSLkZp3/vxAw4qfcaQw9eLqW1xqBzDNIKrBoSkGFX5pw/3rnGCScgOalP4Z399qbCtE+bzB6GADvj+aswfk0ovhgUCJqEJqm9pnHQZS4j1MpnS33Q0pyGMehR7Oa/C94XjGUhrQNRyx4b21vhDhzFnIK8HzmgbTnwLF10Yu/NZJCfdNNJ0pjcXhYA7hP9eBtBPRNvtjD8e33R+qngARPXVfXr7mv+Tsr9X+vtBmbxeU6hPse4G5gQNJEsyUmwPYDMlIbTjOX5w5EswLYnEOY8E3YYttgncS91w3T42e0aO6vlhyz0Wfm6aSyXOTVuBAi45Q9kmsSUtcCgx8n2YE5C2pdS3iOf0kBKc0z8A2+uChDoL8SxfaaU43312Gcf6JTCxdtA6yroIN+iqjFswNuMp8qzKWttXAoTGKAJiaJKFZX0ozckpW6jkDqprGvuokDs7BYTPIX/hwOPNO8PBhr+P/4wwExhGGED0sRQxXdrg7NDkEqEQrvuqkOXiKo3n+g+p6OQ1nv1s1K8wgjh7vFNaRTQml6EXKcW2CSsknrBhOiMayBcrvJoKP20JeWA2Kz2yiPL12w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 044ba694-3a23-4f64-113a-08dbdf6047b9 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:01.6990 (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: CXmab9tQ9u0+AxufJ3bRsSGMl+zFT3FZrLZwI9c9Wb5KI1Xa3bbDF5HJZ/7LhSKDP6KOR6PHMyjowEK3hq2y0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: Dag2_JZXlKly2ymNcEJsXBCyyKyaBlca X-Proofpoint-ORIG-GUID: Dag2_JZXlKly2ymNcEJsXBCyyKyaBlca 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 8d921500..24f0b41f 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2805,10 +2805,6 @@ metadump_f( pop_cur(); } - ret = init_metadump(); - if (ret) - return 0; - start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { @@ -2853,6 +2849,10 @@ metadump_f( } } + ret = init_metadump(); + if (ret) + goto out; + exitcode = 0; for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { @@ -2890,8 +2890,9 @@ metadump_f( /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); -out: + release_metadump(); +out: return 0; } From patchwork Tue Nov 7 07:07:08 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: 13447960 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 37E57C4167B for ; Tue, 7 Nov 2023 07:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233251AbjKGHIe (ORCPT ); Tue, 7 Nov 2023 02:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233518AbjKGHId (ORCPT ); Tue, 7 Nov 2023 02:08:33 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FE511A for ; Mon, 6 Nov 2023 23:08:30 -0800 (PST) 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 3A72NlbE031838 for ; Tue, 7 Nov 2023 07:08:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=D49uSDNzl3t2uoxTfLE1CtEU93q8GxbxxmCuLi3YkPCOSJNLHQUBBnLuchn1vXFjpDgl JBxuZQSrN5UPezVxvoDBXTrzsTRR4yrkKBW03LGUL8HLvetvEHfYBIY7J4Lu+McEM6Pk k3nN3d51DoI99brKvXjOuvxHvIGEo9wdP5odYC85HSo4zcsuUvQ0wTgJczxhIeaPG9Dt 9UjWgui/7rdkud1vIFa1J8iguKJY7G2rfpOa0HguY0SlXi4qFBSlQTUH4FiBCbfEs9xs O5PeF+izZ2ZfzeqE7W/84yFPRTxhUlIGZPevq32dcCLVVE90quWAanJSGPrsMcPQPSLw Ng== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u679tm2jy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:30 +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 3A75sH93020794 for ; Tue, 7 Nov 2023 07:08:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1vuc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0nOSD4XhdiU8H48S2Zykc/FxI48wfmHhwTb7ywrZ9Pk3Q9HZ6/5BbjuEtEW8PTCSddAytTn2WkhWuLLYLKDg8QsqgprdLcuaBLq5FCaNZsp1hhPZy1r4/bz8ShczUvllf97UKJNVzxgt9AFS9AXv7DojLz9acp0PCBku8DzrwBBtyImdCnAY3SPcGGOGwbVNSB8GkYZIgz+c251Vdh7LufXgR74onLWS7s85s1suXoRzraxi7Gu5OzZVL0Oc3SF6hlKfFZBFS4HP1Y0epR6cFeQIXrtiVREgTdmP3tdlbacTWHnJSs+JZh2SImCyRxd18iQHxdbA/WRuIKhsoYynA== 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=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=nrxQsEA1gWk1oFXAxIPsbgIOovERXtcAbYaqIBUdmvaovdvqKPXabx3r53Uj0+AR1xNstv+3xSxA5/CwYRxJFweuPRd6udmGSzxB8niqQse52DY7m6XHCfCA1vXlQuM73UZk4FOWDdN9YW3TLtDsjGVFE7sz9pOsJ1hFgaZtREqv3OPW5y6r/n33UTYhuR6Hh4qxteQIE1F19KbPBPKBzGxYyCH24mwQLxsMaXINo8ICxN0rTtXED2oqTFKRV4tE4lsG7WlcO5pm7NzjPgl2npqPQPgRCxMDecy7yUIu6tsU9k6b5OWdWPozHfsrCrZy76Mn1vEMJS7s7sNmyY2smw== 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=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=oGB82ko2ekfbr120D9BuVGFHZvI4oyiVwU+oPRwQ7WL+Q3DFicAysFmugYulQWFtD7J/fa7W4E3OOck4q0DqoHDVYi21OjoCgJrh+m2Qp1DXmCDpDXkYCE1FLkDF0zZOgm6CGX5+DF1CHhXTLDxfixkyjyFVBTECaAKyp2NneWw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by IA1PR10MB7263.namprd10.prod.outlook.com (2603:10b6:208:3f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:07 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:07 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 07/21] metadump: Introduce struct metadump_ops Date: Tue, 7 Nov 2023 12:37:08 +0530 Message-Id: <20231107070722.748636-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0022.apcprd02.prod.outlook.com (2603:1096:4:1f4::16) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|IA1PR10MB7263:EE_ X-MS-Office365-Filtering-Correlation-Id: d52e5a5c-bf03-49d6-2744-08dbdf604af9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MaVlvG3FtGJzaFI0DQApFvCWGOscwILJmIJjZvPkRHthHygBVzFIySG49ZeCiBkoFlnNEOhXIhZDHBwfKdHOm8hjcyBJTOmd1mU0WF0p4L4LmG8TccwxAVFTb2SKjbbuFFQwAddyWo1i1pROXnlBSLK7BtAaGb7UwPrNoI8hK1ixrnL9PtvGV3aMtP3iH8ArdxfkfASwo3wAy1oCCBpVfanlOh/hIDDqvAFdq/mvbfU4wP5X19vZGny2GYtVxCt4LTWfuYQZAS5rmDs+grjw70m0U2Jh2Vgp2um4hac1p1UhtBspDSKiZ/AwjOrpZh21c5MF7MNLf3pf5DfYvvoI+ve7ybcOdWPx+KLwqZLa0l107tZ7yeVEPATAFJU5+xV/2g62MvCpMHjFVY0UqMt/ytk+Nvm/S0Xgiq8IfsD3NCOBHG7ac7mEksfcAUffYoU2xcYDkb0T/g51OE5xPVxk4Z1Vpao3RDv4qjht95EEpHtN1PmyPUnpBSEcVcGb6RsV3EiZ3CjvqKTJCla+AfvwAP1qsFwT4EUEAd86wVvPZ0B8+T+/bzTMRs34T6JjhwlB 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:(13230031)(39860400002)(376002)(346002)(396003)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(26005)(1076003)(38100700002)(83380400001)(5660300002)(2616005)(6486002)(6506007)(478600001)(6512007)(36756003)(316002)(6916009)(66946007)(66476007)(66556008)(8936002)(8676002)(86362001)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IJf0iQdWOt6TaYUcdMJ4NvpuxRFSD7rMggPqZ5nWkDdunr9EEKbofgpejBUTxFkYRb95w5y/fjNnjb0eLCepvA43n/Fiz1No93XCUI3HDxypQx7xZCjPnl+2By7fV14vc2ytZ/dw2HOplZ7svwacUcbvRB3F6jyoIxWKXLp+B0aoVlq3C2qG88/8uw2cqtOX2GmVN2PwvzWp/siMGg1Njl6KF1pQqotym+5SBJNHYPvwwrwQmTc6Ry/U/KHdWzf7QF/JT7mKpo491MyBy7KNvoa+zqTUow1oe1O//e9LFvEw6HqsqgEg+JgFaxOJxGk2qxblbemZOhA6juIMlmUI5/3lBa5lyVKF65ef7hJszcVEYJhSeKtstWxMx0HbS1xl95WX3K4GapTvdvc5K4jdeTanGmOJTA31LE0dxqM6MIYwbtHEfeR/sxPKFORWP6J/Rb2ckBYcYadlTt9zBa4T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kMfTKUB33yMCzhbmnyG4SnQBVBQyfXUz80YuMf84fLZssMlKlYm6aCJhEqNBwjoUOJMHM7dTg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: r+Lls4O11j87cRzWPLyddYGX+ygWYIq/jzhEtENifY4WESl2tHmqCRxJZ648PldIsvXNcYdxd/Ah4eANhKdL+DwRoM7gVvkacx3Gmbv4FeKWt/qp59pyeSN0gFcqnugn4TCi/WuTqhbqNpEajP5RRfAFMMCj4jbnavWC/XsKHQKNalcuSTK9J0hFPqwx8R50JjbfOpiwPclh6pmBhXV+2g9JtnwW3W1ZqDmAa3nGbL8Wwf7c+KK/QZ5h5/QuebsqRnGhVnasG4wciEe151RwC4EFqEA2aG4sY2dA1c2Mo8YkDRl+03NtYBLmCxD4jH8UUilxT339HJm6yC2Y25qrwYkhrg7j0j/UikxViARWppWOtoWxYsYIuNMMln3TKf02qSdrHNDAt+JozYJUgWTvzeV5egYKgtvw33MJYZ4/jZvxRkCNaT75P+L4jqlyp7V1lyBzHXzMMmvxequH4yDyxJ8mRT+8kF/XOvkDjt40wwBPs2hPxSCvrrx5erY1JHdDRT7K323rTQJ0EA9kSfKL2q+4uFXHGlS4/2AIkSihGUXwXEFcay5oufSp9qhRMvjUg8abuod/mT5S1c+dQAVfiie/pny/v5Tb/hXugtRhaAsh3Ugv2dx9ZvpDyVVvoRoVdRdMCTTv0cxk4btaSYaupbsiJ7IGGtT+e3dD+PVI2C1T16NYEfFXBBdn/j7lkWWp4fZwuuawca5CY6p5ouh956aZrspViq9/sdnFsQF1NEXAS/SbbqJRsb+UvCBaek3WoKDSTqYzP9dNDhURfOMFzA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d52e5a5c-bf03-49d6-2744-08dbdf604af9 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:07.3356 (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: cT84FXxe5Fu3y9kiD5mvDVPX1CslR8lyAo3HVw9D3zlV0w7s+OghOEWiqW95GoQy0lk+Xe2Sxn87XJz11Bh5lQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7263 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: OU75lehwllIY5bRaSNWGh40qCcYx3GSz X-Proofpoint-GUID: OU75lehwllIY5bRaSNWGh40qCcYx3GSz 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/db/metadump.c b/db/metadump.c index 24f0b41f..a2ec6ab5 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -41,6 +41,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. @off and @len are in units of 512 byte blocks. + */ + int (*write)(enum typnm type, const char *data, xfs_daddr_t off, + int len); + /* + * Flush any in-memory remanents of metadata to the metadump file. + */ + int (*finish_dump)(void); + /* + * Free resources allocated during metadump process. + */ + void (*release)(void); +}; + static struct metadump { int version; bool show_progress; @@ -55,6 +79,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 Nov 7 07:07:09 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: 13447959 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 561DDC4332F for ; Tue, 7 Nov 2023 07:08:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233535AbjKGHIe (ORCPT ); Tue, 7 Nov 2023 02:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbjKGHId (ORCPT ); Tue, 7 Nov 2023 02:08:33 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68DCFC for ; Mon, 6 Nov 2023 23:08:30 -0800 (PST) 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 3A72O5V9014505 for ; Tue, 7 Nov 2023 07:08:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=jg7a0BiNV+ofAC/KN9gqtdnH5dIiNG4CyN/llAD5OwPT9celVkpfQNEpu/jBwrV19pys LXi/QuSrwbFS3stpaWg17Syiw3xhlCu6r+Ty1InD77qI7vdp5aAwz05pC+uw+FI5aJus ghouVoP7S/GBL2iU3ZNY9SAsg1fhngb/IzkoYDqmj+y2d0wYWPQHFKdaCRZ34/X7IdLN hbQTh1ggwHkN4PCnY2P2GSynPZledEBn+2rB5ltKoZfvDTEclwvxafDdpnJDt0pnNPo5 SMQCXLMT7GSwtUSIPrXw3EN9W8lyaGPp8zc0/E4xe+/GtIJbj21sa537xWPNDVjIOjVw Uw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub576y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:30 +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 3A76Fmiv023555 for ; Tue, 7 Nov 2023 07:08:29 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63cag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T96AbIsswi5zRnK9V0NffH+Fsi9oU6rxD6KgvK+GMDcJWdujHOlMjJvzg6/8rPMPVmmmDV7xQ2+UeVTV5GHF6qadSqrvrINMl9Au1FnpB5ErRrjSJf2QYcccvNhZa2826OAAb7QOwR0RnK1RoisG7HZ9LaUzhnNz0+Hvu3PRSoUwtHlNzYefYb0za7TPHx6M6X4nP0oX1s7SO8fiMMvnPzst7Mtn0uhBYJlJbTwY2397vpaFlUqSAIIIt64Tcl0dZbKiW6222vjw4EGTBjNbO1imMLy8R+DzR0am8m8/T8ySbakzX65s5DBFxWqRE3o2XXfeerB7ipjE0VfV3UqYiw== 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=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=h5hNUz5tlWoJqqWSIJoNxvMq8vJ/GtialWg241XM5z+dl0xRtBcrDwO0NmyvgAEvFaMrVDjO0/KmIuOBNQ3200oR4ZVgfr+w/dgTLUvNpnHai85IIZcNjGD6SjT/BseEpp6LCQGhXzF/7T3Pk5yF9KkaWCKaONALmS07AfVPCAlAUSwWxNIVtoYU3nPDHv9uz4SGg+SNb5xy98ks0UPpwGj/X2slr318yFNWsi5iRP9zFDqwpKWMvfIz5HbwaXNhbfXF3g+zeNYmGQRO/fi5K6IS0Z7ZFy5Xs4WntNHo9+ybevxWrtkYiqtNH4Di7WGD7iU4o/gXbEKlZxa+A9G7sQ== 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=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=qcK53SZQbwWchUGDisKtMEm9YCL0xZngZRHxIJpVdCEoE9aRWaqNlhDws0XNXKT/Kyo3ewqqVYDm1qLCJRPas1ZwVfaO89AZQmZKl3+J9SlrmWn7C0tgZYAYL1nWyu/8W5Fi4K8ai/Fmr/h8tZXNYjfWEmdJVX4dWwzkoEMVw4Q= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BL3PR10MB6138.namprd10.prod.outlook.com (2603:10b6:208:3b9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Tue, 7 Nov 2023 07:08:13 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:12 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 08/21] metadump: Introduce metadump v1 operations Date: Tue, 7 Nov 2023 12:37:09 +0530 Message-Id: <20231107070722.748636-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0006.apcprd01.prod.exchangelabs.com (2603:1096:4:191::14) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BL3PR10MB6138:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ed07900-71ad-47a6-3d1f-08dbdf604e39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b1BJnKx87WkDj9laTB2LPTnive3PrZf9LTYmD6aHuGTA+yn1e1DmeDBze5T73ifYLgESLWSO5x/vdhIpJ/hyJLhyb5lZ3saAn6wLBZU7qOl/Q54rTQyiinlqiYN1P16vDRv4CIFW+yun7IsQylsOghKb/B5haEECh5CP3t/jUtp2xjzJAyWPeFHb4rFmUOIYo42Mx++FF1B7BtjIdAUEPbqyfSBkdXVCSne82c4yFwGzlIT1LO0bpStymyVMXsNZcXoSgoKiXt/FjZy4zYrsFQEvRKKnIDEHSb2pJ2Nx1cSchqxGx9w/6gueiDU7J2JNGMUtM4+ECjLZzvy8q41zVPGB+qhYPI0h7Lbgz1I5T2sInrXi75wvlZFcnHty7zZTRm0K36Yw5FJGFbr3BpApcom2bnXtzjTSCGFAYT+84LWjiPUkR8kFtLk0hxoE8a5reF3y6f/Jzp2v0+q3IRIWEktU/jV7HeqjSAwLPDOdurvi57rP74amiUsGIkNW8wed/kBBFNGcJyDIWZLCE+nmPtvvZm20wAq00gErZtjD96vk7TlMivDC+eleoH7TpjHqs3KyrLQztwTWaHmmq3x0t9OcU6ZTGcYXnJVflUqYTfnLkOk74gJDCgsHqLG8BE59 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:(13230031)(366004)(396003)(136003)(376002)(346002)(39860400002)(230273577357003)(230173577357003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(2616005)(6506007)(6486002)(478600001)(6512007)(6666004)(26005)(1076003)(41300700001)(2906002)(5660300002)(66476007)(66946007)(8676002)(8936002)(316002)(6916009)(83380400001)(66556008)(86362001)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiS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Z/iJRDaSMhMl4j8hlB5JPiQVIU+yoOyCPrTz51Uc6WilFrLH5oz/78i7MigJGI4Rkl/x9JBqU5/8yaoxmXsybmXBSp6LylNghLTliH60CIJxbLMdNWCABTAGj/uTMXEeMil42IHB+ISJlBBSu1fMh09MR55P0wxwrxliGqIc3dI6L7yBzuZrPjj5hd0vVYPOVK08rXfr/6meoFTJpaQQOYGBoAM3cqsqqyrQFgD9YPeUByT7u2VIm6raF1yTGXmIvhvmQbTHAeJDeoIUW2X9W8fgHxFVfDZMKDXjADS2AU/RUvRTHFty7LHT1izX2vljNoVIJTQBC+f2G6pQIkr5PIDgL0m9070/njKQWVftI6ZFbnidE/A7PdV+rc//fSUa1IhQRBGOomPuY3o06ZYh9TqRLkOknGEldDSr3GtjyZl23UvhW9J0RhAQ0VMgZWCLejD/zIutENx2msy0b2sYlM7IPABR9SOx6LVEFNVh+y7e/9xR+bNVWB0LZQiJq4uQDRFgHttz9j07/q8W4URJ0G6EhParVfGoeoVy0TE1r2Pohi6u7BRGZYYA39yuG97MGmIzho8bggt/MUSs9g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: GS+GnKPgAP+dyKnwHJkvQyn9KBJmhkSV/Ex+T/4KUqUHjw1lBNCuRVLyAwCI7FoR5GwOO15st4VvPEDVBgkijpswa0k/lmxwWdLvp//pHVCOsVSVMGKfAChkEcXfIzi19I1c5Ow6GBTOXb5RHm04w7BraBgwWOUkUy5QmAlkNj1dLPuAJhCF0KXrDeckJFRIW5N2m3fMdjzxlqlxslAcygKYIOXPZ9G6k2sgwPFlSTknF8npwySCtadHCYe4nHr9RJTUt6ueNcE75Q4DDivS/JGTkyW3Jdw0dHUk7hnuY6Rj/AuYrnwkz7GB1uZbnjNla95fz/3iQGyfNlf17z+xGmKPs7JvnElrN7a22OsUjiEHrGIGNnhAFYIek/dQdzJVPWFEICYee72mKUPP/Gk4uPgd9dLoWrK9RD+wL+pduosZ4UaF/ytft0EJwSnXYMYndZlan99t56+AX9ERrtpPtPTy7mzDc0+Jbv//BRuaxWFWNTmvg8TLY3a2TbjoD40HXHzqn9zyxKoJbESgH8z7NEhJ35YswIDp1OpeMKwl7YHT0O4Z9i9NKj75iFFoOhUxve7se8TVYVm1AHJ/WvULigOYywOkwATMmfBr7u5Se0/6oBt7iqjWu6siusYRzgJgwjkheKbfuI79/5yPrRYUA56kjBZpo18Mcom+WQnxPD5Ht6TDE47rhf8BX4UbLox6a6+X/iB0W5xhLtzsl/UO+K00aWcyIzzuf+RCr0kJMe4YkKUe8bQIHWpFFzKxn5TOycxGUL/xEi+h1AcyfBj3VQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ed07900-71ad-47a6-3d1f-08dbdf604e39 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:12.7887 (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: pwOQfNXzHIVaGrdhAAeU0A0OJsFWj/WBfw6Wn2N1WtSfFKvZ1icjKfzFbI9NMXatOOj1mlRNK8qc8PzEzXK3sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6138 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: M1lxnQyIK5FBfoy528T-B8XUVOnppfNv X-Proofpoint-ORIG-GUID: M1lxnQyIK5FBfoy528T-B8XUVOnppfNv 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 124 +++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index a2ec6ab5..c11503c7 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -153,59 +153,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 @@ -242,15 +189,17 @@ 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; @@ -2691,7 +2640,7 @@ done: } static int -init_metadump(void) +init_metadump_v1(void) { metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); if (metadump.metablock == NULL) { @@ -2732,12 +2681,61 @@ init_metadump(void) return 0; } +static int +finish_dump_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, + const 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 = finish_dump_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, + .finish_dump = finish_dump_metadump_v1, + .release = release_metadump_v1, +}; + static int metadump_f( int argc, @@ -2874,7 +2872,9 @@ metadump_f( } } - ret = init_metadump(); + metadump.mdops = &metadump1_ops; + + ret = metadump.mdops->init(); if (ret) goto out; @@ -2897,7 +2897,7 @@ metadump_f( /* write the remaining index */ if (!exitcode) - exitcode = write_index() < 0; + exitcode = metadump.mdops->finish_dump() < 0; if (metadump.progress_since_warning) fputc('\n', metadump.stdout_metadump ? stderr : stdout); @@ -2916,7 +2916,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - release_metadump(); + metadump.mdops->release(); out: return 0; From patchwork Tue Nov 7 07:07:10 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: 13447956 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 78EE7C4332F for ; Tue, 7 Nov 2023 07:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbjKGHIa (ORCPT ); Tue, 7 Nov 2023 02:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbjKGHI3 (ORCPT ); Tue, 7 Nov 2023 02:08:29 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3556BFC for ; Mon, 6 Nov 2023 23:08:27 -0800 (PST) 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 3A72O5wJ014497 for ; Tue, 7 Nov 2023 07:08:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=UXHMv748MjZ/DvsoA/LRHAnmC755DOPKe8TNNDdAVjdwYXk8+qLepeEyknuOqT3mNheS adJOFxdfGEL2TiKpEzB63R9qtcqNKILsKZNtSPsNij8ATSwts+x98pcE23+EEtbrqfti /ZIycR9+6q8RL7KI7K/SJK+vJGTr8z97Jw92DYmtzp846zagqzTeZ1XmtzyDGR2bTTrp j79E7HrmNgOvq2tbYBgFMq/AmohVHhCn//MfMOZ9B8jtCyADK/WHMPBTsdSpGiWZSSop gyEA9TogqNlgE+oF0fXd839h0ouU+lzY1R8XCrfoypQTL8D4kMjleeNkJn+vA8EL9tMz sQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub576t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:26 +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 3A76hKAQ023587 for ; Tue, 7 Nov 2023 07:08:26 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63cd4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTCWcuo1AswiZu2Bcs1+xh9wMcPUF6BDNPhaRMNAocjOiH792qgwpzBN5uL2vQxpGTzBd3zpk5CDvmOdyvcLV9fOYWOaau1FA3l1cacNmRIcumcd5pAYeriWcJstXOkYv7/kz6ivZ4NyK4UG/efYn2XEahEWMv/SeA2YtUXLRU8XgD/Wstzws7c0qgcjp1ELmUcEa99lbz5Exd6eK7ATYmLWRh/P3spgOlzowbdoaXdCoy53KQZLL+2+BcApj+mvn44vw8zthadIzUfQDplcldLxHQAIeWTguVP71q1CFUMPbKpj2WRI6B0B3l5QnjFWDV5HxpDy5R2PnLZ3F/AO9w== 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=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=n5BAug+HStjQeMAnbH5v3o3akK3YvVQcuWnRvob/06Ofpoy3bZqFOlCeQyH/AvQBsUhjDmV9X/i+Mxmyjo14jW7XsjHOFgv1MJG+lE7FU3QtWxRMZSJJuiqi89yt/9r4DN+4AYgvIfSjJTIzctuk5S7bLAkr47DLCOPZLh8yD5P3wtU8NHE+mhgPQfugp+oseCWdFFaxl8fWzQhvkRI0JaQP8Vy+QijKyfuhtjHmTmtkVre1W7Suh5aiMrJeh/r8ayerdSv14qV/JR3k0VDKZQPRaYa3hEmM9Dk1MfjC7lPW2NFL5S770ZYRym0PQG0ZPf23lvIORo8CtN1s9dGKHA== 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=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=yTZ6WmmZf4O8kjxt8l4qa29DZ3xwOBwKeRFqdrFy+HSA9w/LdLuw1ylaNNtHMmM1MHsDaiHMU61m0hD8i/uAxqHbX6H0/HeMdlRF54dNJfsgLkitzyBuP8LozOJLDoiRSxetK8tATOEN9QOgN3WmiWxZ7sWQhus8FjNy0DD4Sb4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:18 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 09/21] metadump: Rename XFS_MD_MAGIC to XFS_MD_MAGIC_V1 Date: Tue, 7 Nov 2023 12:37:10 +0530 Message-Id: <20231107070722.748636-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0025.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: 243da1f6-f5cb-418e-8f3f-08dbdf605155 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VU3DFAegh7Gge4aU2EkqNvI9n+A3KHvOvESG5XDK58z2NR+PvEci6PW0VNJXNo6j25ItNnVeSFhZHrVs8wDoBaWIlOO58C6DSP1XIdJarEw38n1R99hMXWOPSQYd0Y3dtGf0SNYlT+nvtHpQr3BCWdgM6jMSnrMvtBZXT+NWx4rZ83Z4l4ZaTzQ/G4FfCy7T++E3vrsm7miw8Jak4cuFy6jJ8+XFRS9VjeiMc4+8Lr6G7RQBFUzhH5wlyPOZc3B9EhB1582KsxeaYOf+GNM4/POQLXzPDXCTY6lL2cnw+UciLyfNnAhyTYFok7VAznVCeCYmQTsnVdLItjIzXZmt+JRbW7gQHxEkmBg9MWY3JvQEY4pKJRaLKsS5hI9f1LITuFF6NczdAI7bKHkCDw56zYamlGMWSyxR5cjC87tXAMaQex9lax7Hr1deSzlupBdgamDfJG/R67pdrK472ZfXN1SIovppuc8GPSNVWi0FEfhPe9BV1s4qyvPAHTU8GscwIRRUBY85jSr3SYEUHxlMdhpTFxcVLRRdfujWJqKoHS2wQBGDFS/Ih1i7BBly4Jil 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YtzpLOo7c7ZWUOeJM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b1q6p4WNzSiqx81xgnZjxy1cnzfTyHimuQVAUitVf3oe6ToN2z26OG1xobPIW5Dubp57SaDbT8Hl9ed92nO3OfqA6KLGm+5bzn+xMuBMLRbFksJWQE8wn74cONkmtwmxtge7tL3TXEVhhOUj1gqWeZOZsVdOT4rXjjsF/HslAKslRa3p8CRTP57eP9mRi4JK1TLW8jSsAB8+Uus0NRFppVas6G5f/uc/idZgm9K8NBqZDAcfd7P6PUve5NoXRZXT14MQMAt5xiMGx3xM/mNBaZpZC8C/RE+MPWCqTSAtc5juAAPTtZsg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 243da1f6-f5cb-418e-8f3f-08dbdf605155 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:18.0132 (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: LpBVgcyPPL4cr0RTAdRve6jKiAmMghjUorbXkoM56mj6/kD6Bko1BLfWC3N24jN2mEjWJDqi1ePA1Qk7CUf1ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=993 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: jZCAT1H48AqVn9uLZ5zo1mUPYnGS__wo X-Proofpoint-ORIG-GUID: jZCAT1H48AqVn9uLZ5zo1mUPYnGS__wo 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 c11503c7..bc203893 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2648,7 +2648,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 Nov 7 07:07:11 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: 13447957 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 17216C4167B for ; Tue, 7 Nov 2023 07:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232666AbjKGHIb (ORCPT ); Tue, 7 Nov 2023 02:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbjKGHIa (ORCPT ); Tue, 7 Nov 2023 02:08:30 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A2311A for ; Mon, 6 Nov 2023 23:08:27 -0800 (PST) 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 3A72OhNo015138 for ; Tue, 7 Nov 2023 07:08:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=Im6oY5BkS8neg+YsVJD76Mu6g/v6qmcLL2OpnGCQqSPKaKMDBCFRX8LOwk8k7MeJ/wjv aR2iw6HSovqqjyWLa+8YHK3XCJ9PVcrX5+B1N5eq+MWhkjIlhtIf6RIoW39GDr2zGOT6 9hmo7M491L1yCUjKJ1dtHTk4MQSOBpKN+w2ht8DRnancNuvcrGLvxw3RUigkVXya1oiS E+yS8hdtnGJp+xYAWLdBr5Nhbbe+j2GVbWUVQ9TDosXs7yD2pL7ePQom5mek2a8hivtI pEn5bWwjB0DM2hv6xTG4lE9lY2iR6knRKnV6ikkteGaVPlOplab44m4nwibYdDpIXcVQ Ug== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub576v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:27 +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 3A76hKAS023587 for ; Tue, 7 Nov 2023 07:08:26 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63cd4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHueMKBk40i+Ij6Z1moXdVBAh9OsHfkXvT6TZTsaaxAu0zIqYpySbKOEAOYZLs1IYGBFkuftU/88iJRNEKSp5GKIvw7Tj3eWif2JR4QJEiUXWb/dJXgz4cUi0VIx3zxjOcERHITdPfZQ0AB9SCvdkA6noTbPdnn2KjAPcsJKpiBe0/Suj6hn3q2HW0uGAS7crOjIukcIQK+cv2o4NidwasqPVURia3nTDmOwX9WhuZX1+bXIdln1Nkp1xPrLvTEDv1ygkR10ceTUX2Yx5i7OomiXpHFApB+Et5v3oySQV6KP/fOFnILhR15J/U/4zJvgaKJZRqPFygiJaiunG7Ot9w== 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=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=W0jBk0zmVAsKsEggO3vu6Q6WBqn+xoDLRtMRbbcnv50+zzHCI2XScZUgMiK+3/mhXz9lWZrLDyxgc3qePQyFKmyx6OuZzM9L/vgi7wzNb93UrP35UptiMKVaRVnyk1gR0UTH8Khaeok01oFRgmNHTW8aM7S4QjrSD3HDdM48WMC1IFfTkiVorEnCN0D8rQoU5yX/sv16bwJF1FV+FS/Hf9Y0MwDNq4yBjsnv5EUDNW3gULe4VP/fpphc7VujNJvin3DSuXyndZL/gjTTsUWKC6IIkm6qNiwpwk6LR1zoQZuINtMoOAm7b1OFJzzdc6vuyzElTfDB5mrzUCJOe9xuMA== 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=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=F9K6ym0qUAZo9+7bQ40kv3peGgQ44j7h7Raco7BMqdQ6l0bB1dYvZViYtt1xykHVUHN5ffHOFQy6AzIaUYiqm0yL1ti4+U1V21CLNrRWeTtX1hbf+WsijpjAUb/FnwsSFCxeSANcVTj0RECOyb015DAN86u7eFTXy3BdIb139lQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:23 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:23 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 10/21] metadump: Define metadump v2 ondisk format structures and macros Date: Tue, 7 Nov 2023 12:37:11 +0530 Message-Id: <20231107070722.748636-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:196::14) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f7260e3-c349-4ca3-e033-08dbdf605490 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZApblFiej1HaWMTgkYY1cLLAAXstBpsbQt6Y8NwLbA7l1X2YANEdpktFiCjiNhFS67bqve0xMxWBCb+3b1xqSXYIHRTwvj5a0QSvyqhjBa3WMZz6f4HpyMN+YpKP4Sd6f7ZNK0cJc9HxM3WAwPkPMdl933b7/t/qDR/1U8GFUakyGq+F1AiTeHcg09YrImA9EPOhqc0n8BnsjV1otra1kqiksm/EdYACglqSj/tqOdrE4gR6QtX/GtxVIrkgJvqQE4xqB/90p1hQ1Z3haXbRoPMgAPXPzRagbeaDJ5HiAvqIaQlj1sIK7RhNKLMwYlIPo7wBlgfPoJmjlzlgXYV1SCBpdFRU6NSvblBqETSgH6kxD09+gyZd6R3pg1cci251Cnh5iQ93C6Pw4jYJ0u0lOYPS2zC5EcAPzHhswoMff5IXCMaUIIz0/UNORTsdUjArOxl//KNDDBc4O8/7VFfxOI1hgJlAFfsZUhYueHJpHaHQUmivseuXMEaOeZVCwLh7xhgfnMOdXlGgncDv/xFmocN7NqFy5IEkhCtzi3bw2rriIQmRiIDFQecma0N2DbkoLUGziGnWB2gQgZL1ZqzmYXPngJ478MFXxrNiuM6ziv5STE3YaMqTVmsokILW4wG3 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002)(66899024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MMgSSe3vx0MuOGzAosuO5RChadGG8b7s20spis5zuUsaIc5NfOLEXNpPpM01eCBIpWMNjEjYY/LrjmYBTdtWR4YlwnYnlIVAmHDhY/b+nFTB/R0n6bEv1+UbG1kUphCuEa5g1QidCCEFvNzNSQO19DBVCfrceJtzfypCALzrM8IV4pj67UG6FhhKz0C+9gMobkl3vauBKC6KUOYDbX/Mxs8XwVwx83aLhyR9qAB5TgcvnGXkBeYxZGTahdG91SjWAUSylAKn0u/Otebe5h/rn+uUccwWfm4+PfhxKDF1WzPQAEtk3Y6AQxtUPX3Okeeb/kSJQaEpPDsdvJykeiYygZhoJyNvyYjTMWjzc1WBfRKSYUecojDQWkw3RfeEvB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+y89/TWdNCsXICGsB4MHkGlpQr/KRuc+HZjlbJDnNDliNIS3pp5jyqO66H9VoOkfmnEzbr/NO8/eMHUZ4nYiQ9RCzyuNrO/hB5edtj2ccbaHVcxJUIik8ym2o2LzgSWYbiOIs1iRRjfDsz7qzxQrekvQ6aujmVHp9Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: n2PAT2TTfO+Fryz2jTId1bK6evjDwvD9lb4Pn0aEZLIY+BXibIB0hmqnmJQuOGcXkGIIRxpbITKSou3PQkdJPAWPwSdfCn/V2oLIPvnNmluJT5Wy63nL2tiQfDHoBudqwowPNw/36DOFVEZryBjAOTC9PYvSy2ph1Q6zuxpUPwXYu8SBGOB13DIQeV4exN8oIBqK8Y3aITJw8vydwmCh6TGQuyPPvCMpnn04D4gaJOnwww5w4DXLd5qj+MpRTD6YZeB51DnWzKkBP2vUGzAKUZPBhC7WSpmX2DTRN+LFfOx1B446xzD13SDUXAl+1nXAdav+wQLiICWN+v9gswzkBGQfKZMlW7wzQxbi1pvOApTQMY8Oyo2Hi0jPEDuT8W6Ho/5plcLz1ufY9fBSPXTlV0cuoL8Vb5tUBAxCBZCNFhAhRkosELE/AIjf6SQNA9e8IMLsX8LgmCWqSsiR7B5nsVZsnVU5cHzqPV1o/L3BWsEfyYqjVU+A3ytnB9laHT6ANact8oCHkDZrmQOYq5f2lh0y6Lecssp4jbUVok7DJRhWpDMO7zZrJFLISa2muM3fRNPKPw/niZoAP6/ofAv6q0qFBFs/yQ3LA6NQm8+QYHLO1JKDPGgQmPcIyP1CwoqhcHC1B0MbjyLrNZm7ATyAHCmi59brHc2Cy+0jDPCupcyaBwBq+j2hxcaIMQWGWcSaBlOf7lfH4nmJHnk7pebug9RWtcnwzXXHN37OU/w5u8LEUkP120iVxVlfJ02lxBS4SLa1u+NYaQYhRV2ET3s5LA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f7260e3-c349-4ca3-e033-08dbdf605490 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:23.2486 (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: ol8/ROMFtcJUUO4das5SwlXrN+3wyrZgBRB/DLMf4BiKh2R2hd7aqGABHKBJOXITChgzWgoIFHZShvfFxUbj+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: gT3ZRnvHCrVPxt1jOjGF772FONwx-jtb X-Proofpoint-ORIG-GUID: gT3ZRnvHCrVPxt1jOjGF772FONwx-jtb 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- include/xfs_metadump.h | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index a4dca25c..e9c3dcb8 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,70 @@ 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; + +/* + * User-supplied directory entry and extended attribute names have been + * obscured, and extended attribute values are zeroed to protect privacy. + */ +#define XFS_MD2_COMPAT_OBFUSCATED (1 << 0) + +/* Full blocks have been dumped. */ +#define XFS_MD2_COMPAT_FULLBLOCKS (1 << 1) + +/* Log was dirty. */ +#define XFS_MD2_COMPAT_DIRTYLOG (1 << 2) + +/* Dump contains external log contents. */ +#define XFS_MD2_COMPAT_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 Nov 7 07:07:12 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: 13447961 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 2B46BC4332F for ; Tue, 7 Nov 2023 07:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233550AbjKGHJB (ORCPT ); Tue, 7 Nov 2023 02:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233518AbjKGHI7 (ORCPT ); Tue, 7 Nov 2023 02:08:59 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2824FFC for ; Mon, 6 Nov 2023 23:08:57 -0800 (PST) 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 3A72NlOm031854 for ; Tue, 7 Nov 2023 07:08:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=qfWqxZrIBPs0VnI7Lkk+afuz6HqevyfWtE4gtToFdp9gZMZaJdZBKzq9kpum8Gm6QGV6 avliIi9ybyxLy9ok7gcsrmnYJJjmRQCJpC6Au5/g5TYEW24QZHml2vbZ0pD4Odm1rsvH VAtnuVlEcR2IRPzbxqPVHuSUwZYL2DyJRW+xtNi79/OVG2J06s6CnGsTvSDWfPMUkT58 IJfaHiJfXiZOg/NnX45nXG0SXc6Mr94p42/dUO+85TXswgXj3aMaZTSMq6t5mZpABhij NL++6KVdm+17PHwamnMkX7wmc0rZatdVw2O7yXGahUkBz85USVSuaTVkbA4R+8EoCK1P VQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u679tm2ku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:56 +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 3A76PYvv030550 for ; Tue, 7 Nov 2023 07:08:54 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NhoG4ScGs0KQ+Xz5M9rmn0qnQIUTugQ+eX9MBkhlocm63PO1sys2vxbfBxfCK7v3WlMQ36TY/0AuUU9lS3FI7Uf6FjefQ4q5xyAyp9PbFGi/A6IMxRt4otir/mLEpmkWgp0ugq3Y8zHQEH2NI6w96E9jJt95aqOME6jS68M8WwBOLjdJ6LHSOY20NQAiza6dAR8sQ9/gicszD7OTtYfY+6uX9pGBXjYbvUX2N7aI2q5jve/TI8DhtHwTnsfi/Dmo4yuzL09QpTfEawNorpzX9gKWI+gWNTKjOSSnAdutMmw8cbbKVM/HxzlhcRk0XNRPQxp6+/8zxA9YVtl6lAyewQ== 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=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=DXLPt60ry4/aXCHKmsJCT3KfP1g5NB5EHbZPYA0UMX+bHmrYWff9nPjdppmw0LdwEvokmLIGz8swVoQax6GFzD9lDedzDkD3FBTvLBq+1O4stYdW/ee+q8in/HCVtjTxiW9on0nbrENiYt1L+9lKX2q2lrKfuOZ/gLEFJKp28M+mtaHK8ZnPJZXNMQiP6q4DIP+95Pvm2j8t5R9+oN/J20WgPbEGrHNLoX6Bfd4HOPlQhcr/kIqRMVxifgkWVqY6XbZ1L6gRALAW7M6icoc91LeROBtXjiZLQftkOBjrXkI2dm3iNIqX6jLl8WUoXx+69WDVcNGsHtCRVmjM5IJgBw== 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=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=REzJFha0OjSRMM1vEP/5YYCma4GqntO34ZgWc75fod+0UVtP6Rlk05ML4AnWrHngAHvsBAalBFo4G6K2snCGx5bJYOZlRrM+oEx4rQsPjLDqRQ/udIVeGq460KUTPtBJL8i5hQOIU3VK2o/FZ4g9KUTGwErFiEP1jeKSn90rfBs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:28 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:28 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 11/21] metadump: Define metadump ops for v2 format Date: Tue, 7 Nov 2023 12:37:12 +0530 Message-Id: <20231107070722.748636-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0169.jpnprd01.prod.outlook.com (2603:1096:400:2b2::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: 762680cf-b302-482a-97c9-08dbdf605771 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JL/8/K51/+HoPSpeEaT6AAUD1RE+NrHScWm0lAEo/rMPf2gKJSD0AVkPEzYwgBnKGZvEDWY9yT3d87/rAlalUDoO1VVIBDSqMtpgWKEHV4fJsk6guD8Y2/wT62rRsqeA4gWOvgAxzzhGzOoWbpcc1u+TsWV4QD2bb4PeCx7xtG8EUNCcM0ezunwuvHotNzSfzZJQfQWcCI0/0KVBJqLXkTsZ3In5Qe21FY3ewCtT8iks2E6dNLg+d6KiEfqonuhrlu6Srj3yBN2C4K6eW4iHJW+h+0RPTupsBbgisl9ZYNtph46xxepN8O57ogMLern5B0vD06DWrFqs8W3HtPcRar8XMs61TqUvnY/BBB2r/axT5D99aaiTfnh+X3qO235AUFqpgnYBc0TOJB1jXaOgt97W2ynhxIx0fD+Jte6k5rFRne5oWrPE4+ZN8kHtXbVAVKCsmdhSHvXGJp8kPMkVpcW165wMWDxSinBSIPSSIrfYulxEp2Hb7vI/kiMIcek/4qjlvIZsfhdLrslwRcNFiIZKo+O+91clNDceLiTHhXf8I9tU9ey9GvnhKCAM3/K243IT8FqVMqdL+t7xO5zOeVw1Wzl3So2hRXjBlbTBRpc7TNoTSHgbPZHxzYQiO7Wo 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PqYqEPpMcpyHauH9eRv7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QeJduAS8qB3Q+zxcUwdx/JdkjuxySlyLom2UH//liTbyWNi0GE0BBNOu/QFVKQ4+fUMJ+4zITkZH+HWRhPcF0fhuR+BV/bjHTmA3NriQjuouQptAbnDj4kgiPvTmdLFH4dSsa1XBl//oElfaczyDV+xvLdzygZqGLPNiYpx2aDqrTZkO2ROrDe1Qz1yLpGLo9Cv0eEW4Ow8bs8Y8WZBelfS0vwevkyLMl9EUqbR7ssojwkHhUCf3Y/HG7TyUg/Vrr3IGNiBCYfXokwgpbXHoXajLWGJp8AKUs+LjC819V/E80bzcb6TvB21fKUx1Dg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 762680cf-b302-482a-97c9-08dbdf605771 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:28.0806 (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: jx2xZKclcD9zS7xNw81688uaz4sE6/51/acJsSJ98KHiHf0g3UUYSV9bzpQc4Q1Pl6ksd37VjxpUtSCBI343Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: PKkXcgUw73T2ZVJOa6u0mIk0ZPsYcJn_ X-Proofpoint-GUID: PKkXcgUw73T2ZVJOa6u0mIk0ZPsYcJn_ 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. Reviewed-by: Darrick J. Wong 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 bc203893..81023cf1 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2736,6 +2736,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 = cpu_to_be32(2); + + if (metadump.obfuscate) + compat_flags |= XFS_MD2_COMPAT_OBFUSCATED; + if (!metadump.zero_stale_data) + compat_flags |= XFS_MD2_COMPAT_FULLBLOCKS; + if (metadump.dirty_log) + compat_flags |= XFS_MD2_COMPAT_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, + const 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, @@ -2872,7 +2936,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) @@ -2896,7 +2963,7 @@ metadump_f( exitcode = !copy_log(); /* write the remaining index */ - if (!exitcode) + if (!exitcode && metadump.mdops->finish_dump) exitcode = metadump.mdops->finish_dump() < 0; if (metadump.progress_since_warning) @@ -2916,7 +2983,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 Nov 7 07:07:13 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: 13447963 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 DF201C4167B for ; Tue, 7 Nov 2023 07:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233518AbjKGHJE (ORCPT ); Tue, 7 Nov 2023 02:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233556AbjKGHJD (ORCPT ); Tue, 7 Nov 2023 02:09:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749EFFC for ; Mon, 6 Nov 2023 23:09:00 -0800 (PST) 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 3A72No0J031402 for ; Tue, 7 Nov 2023 07:08:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=WpcNPS75OCYwksZvhCWJOerISOQ2TNx3wpDRgjgbMmp86N4xJfrfgugNZ5/SMjcEfNgf QSBAUtPd2Aa9mr1+ymrHvI/OfH86R9/wHrGOh/5MBEXwQCA2nxz9hNt2kTBSdpAq5E6Z crAUED0d1lHJwN8vsMW09tsOd5isE1U61DrQCRoKhvmQ37pAYrV6z9pWeqq5wqBI4Xbd fyojAz2Z58G4G+DGxgiNstn7EsK6SDRXosrlOvlXsxxl3Ro4lCyWDyBRAbyspSrP7jE4 QxbaJacZKhMJWNpzZAUj16yYrMjUBtD1mO5rd0n1bVV2KCUSl48ZfWgDUERwoBb4Z2HC ew== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdw9wj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:59 +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 3A76PYwB030550 for ; Tue, 7 Nov 2023 07:08:58 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cu/0fd2ZSKUPe4OC7n3Ww22CE80df1XcRRLoUZVZhH4qY6R2aAOhqoXCzN4xGNYRz6N5X8Bf5T2NGQeMYi9mXqdnqlFvRUOjxQCZYQ8TJkx7KjMHOU3BZ3kQZD9i8CfYpkj3K7uXNuR8BIhLrcsG8ycWE0PMBZ1xoWxu9jbj5zRB4LEy42OH40XEfmnRxW687p67KesRpXccBUF02Yiks2wpbOAI4gAHvU2CKQIg6YWsagnitiQij+SLf3Z/xLxj+b3DnuZSVISqsmvax1z6FgFQj/lGtIcb3C0eYam3cibIpS5bHG2UJIiVIzaRFlPG+AqBk17ADw9b2O6mYSeK6A== 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=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=ZvUkXIDCwkcAq8RCueYvv/oP0+s57Gqg56/kzQS5KqRxo0JCdixoDRcdLaQwHGbAgwRsDBMyOSbOBu+Rh7uDMZO2Lp/TXOLl/cI2O8oTiup+NdWgO4M7SEk7P+rFJj+Yv1AiVuFxHAM7bwGYDOPn8I/1/qizLGS+VUVfW3oqlhvbKRPmGOzbST2lq3zG2AmwkEsFu6W6EvC+8McP8BWNuHjIJ/4UveYB7cQ9RZ4i7QuZbAyyJk5IfIkmD0ZPVkDI79McYPbnqJQdq27dB+uFEGkHIBwNHbTkxMY9b7MUZdbYReylTnMZRF/gZyQQnrUCr8Elnxwt07XtE64EBX8ZEA== 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=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=zY5oBzKdv4Qxz4e5v2NS2st33TMkW0qaiTjCUZ/0TyRT3d+J/GjmxpixCGJkruaz/nae1Rg+jNe8IY65JchUQZXpzaFTaDW+A3lZPciPNZLIuPu5XYetT1uJXHZo9vj83DA3uLUzE5zOgN5rLExfMsbaOq78VqviPRIzbaprrI8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:32 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:32 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 12/21] xfs_db: Add support to read from external log device Date: Tue, 7 Nov 2023 12:37:13 +0530 Message-Id: <20231107070722.748636-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0171.jpnprd01.prod.outlook.com (2603:1096:400:2b2::17) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: a71ac75b-ec2c-48be-19ef-08dbdf6059db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rJ+rNLUBtuPg8Bs4YWAdT4AE+iSmBGNdMIUoM/CJTFPi1tLh4EPNWzGBS86ixVy1qMQKwIp79k4HeeUPmCJEoFT8Ka8vTDemb6Gf0yFu0r1TvOX1AnIPBzB4YvQ30NU63/V9NciYWDLdM8yL0mhrM4EMFr3QCuNvxfh1JeHzcmEgcNJjzxmnswkTJAOtl20uJcr9o8vxjVVIV6sGkEGNriGXMlM4VvmEXpKgAI17gLH1bx4Licfu9iyv6gNMEAiOCFXVN/g4EB1mXEElqizuJ4VMPgyNFmQa4W3R11YaDckKeRTjdNduXVQhX2gIvTweu0RwXxqIP8cZRJPWRJcht2Irm5zp8cqhdqUsQdks1ynMEbIt0NVnrYo3wnCqSq0iHymiI7euV6SadLFInASVsAcM7MN11NKK4oQafNDFnVeXgLJsfCfNpnvn9r5+ZmA45QEpyfbXTvtN0a6rH1Bge3j6dVFKFxA04Oo63DImM02pMACD8f4qm1GjY5JNa5KSAwvltj+VsHN7UJhj1Ybb6k0/5nstOZ+W7hvZXuV2IRUEvmvXEHyPD7YwTRzMIXRKfYhuHgKmXKLN02Io9PBrs4QoWYTZL5HY9g6M9TPivhfZP3MMa4rm2YOpHbR2RPlz 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aOPgDnGjdx5ZHn8ClLOmIs/GWHb6siJNcMJ6gnk3+cKOLcx5nnUUcptKTLnsQxVeIBu7SF9ol24W/Euwpr6fScpw2iFQv8rMl+/wOocKvcOWYWxcY/nEhL841gTvAUu8R7ihvWAkjq2Ezd2/MgaiUsuhHZAsbUfsmf9VVGmppONX9rU6zbsi15iQJMH9jHa6qD+DJl3RFlLgumCJk3/rnevdecfKrRNOzqnWZsnadKhMrkoup2piEG3dx9wxPPr44aW8SumLimlXJasGJNyMyFsbSXbqHHuKQ2suRW99zua+oDNJKcVyUOW3U/oll+96PjovBJAoSeAJGLEgGmQfAv/r+DhZVe0ajV4KwfGv4sG7GUNmwF/JZSSvg1Q58Niwlj4t/SJmXI3DitiNXJ9leuU25ShuPEgsfdYA4BrApEIvQ0tnxzd6wyGMJ4t1f9fXj17XA/cOdEZ3idp0cqKUFoXD2i91cST0Ra1jSAUsVFTjHYPLJcH1y8XIJtSumSc5ud+2rtzQ/r5cUCdCEgo/kujm8WwVzBYsJEYj7lKdnsbH8Q0/M6ywtzeLoCANGd/UFoa3isVJv5lZc7keVKpGZCbNVkziebPE77Q/6NUaNcFxQph+SnS4uHw9JKIu2Z8aLY1nVQWaLmZJGh5VbW1W8a076xlZIUULjdNlj1bqBzrL6NknXnivODe8j2IElQNzC9j0eENXqIx/B3N4dvbpQ8SYwJW/3LMMErVzdb15N1xH0iLmvHRk0IxvdJJtmPeizI/KCnOrsTamHjoGO+vU8vE5PluubCKlMWy4QIEv8FWSUo/W5DF1lyP2dQiL186owB9l+8vZ1pP7gtQiwIckgdXjHQ8dkc6COdNH1M5VQONnrr8pttgfXyNtiAlGaFofjTvuT9ZlVAA15Cq4R5bEtMSTSQB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+RmzYYF0Ygg5V5rQMM9GU8ZWKlxzQoBl0ON4DwTqLqtT9gPIh9KsuaAV6Ce9LXYh14Bxtpqtm3NMuYH9CnwmQ8Djd7AhAJFe3azBFOPSEvLH8vgS4elYqWK+sNEeBeyuzcUbV1V/gaFelvTxwjYWYETSkWviUu26w+8h3wIYssJYCtznAQz2lRMzSiReYpw/q7aBlFzeWUL8fBwBpMDEHg+QSe5CumQfqx639InR41wvg8XiDhQsBTAldgJ+/eNQPghm+Ozo1dzKzkLW/JMHyHg4Vjdxhod1o2Cefnj4h6arKfc8MOTbNSIbov7RZx3AF3YIrLiUvT4nhU3c3pl1F3cU0S95rwq5Iuj4PRT+bz2/QQried5CfySOyMtACRgSxcTc+ZoRsMMXTiH9XqSAN/ONTrzG1hWBQmgaSa/8y+Ur2aVSO6zDZCCWyXsoKBb5RGEEt6ArN4ia3v1k09rZwRLNJ5T5DjSU3CJcw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a71ac75b-ec2c-48be-19ef-08dbdf6059db X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:32.8645 (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: LVlzkkbn6+u0o74i5s240bDydfTKK78ggvSl03tliCti7lBCvx9cKKYKBcIejZ83OzWtyVjxqc3qySljv/I1Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: _76o4rKNBL6tFiBVol6LGyhm8LyojNqV X-Proofpoint-GUID: _76o4rKNBL6tFiBVol6LGyhm8LyojNqV 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/io.c | 56 +++++++++++++++++++++------- db/io.h | 2 + db/metadump.c | 81 +++++++++++++++++++++++++++++++++++------ db/xfs_metadump.sh | 3 +- man/man8/xfs_metadump.8 | 14 +++++++ 5 files changed, 131 insertions(+), 25 deletions(-) diff --git a/db/io.c b/db/io.c index 3d257236..5ccfe3b5 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,35 @@ 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) +{ + if (mp->m_logdev_targp->bt_bdev == mp->m_ddev_targp->bt_bdev) { + fprintf(stderr, "no external log specified\n"); + exitcode = 1; + return; + } + + __set_cur(mp->m_logdev_targp, type, blknum, len, ring_flag, bbmap); +} + + void set_iocur_type( const typ_t *type) 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 81023cf1..f9c82148 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -38,7 +38,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 { @@ -75,6 +75,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 */ @@ -108,6 +109,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); } @@ -2589,8 +2591,20 @@ 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); + if (metadump.external_log) { + ASSERT(mp->m_sb.sb_logstart == 0); + 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); + } else { + ASSERT(mp->m_sb.sb_logstart != 0); + 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); + } + if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); @@ -2751,6 +2765,8 @@ init_metadump_v2(void) compat_flags |= XFS_MD2_COMPAT_FULLBLOCKS; if (metadump.dirty_log) compat_flags |= XFS_MD2_COMPAT_DIRTYLOG; + if (metadump.external_log) + compat_flags |= XFS_MD2_COMPAT_EXTERNALLOG; xmh.xmh_compat_flags = cpu_to_be32(compat_flags); @@ -2811,6 +2827,7 @@ metadump_f( int outfd = -1; int ret; char *p; + bool version_opt_set = false; exitcode = 1; @@ -2822,6 +2839,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", @@ -2839,7 +2857,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; @@ -2863,6 +2881,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; @@ -2877,12 +2906,42 @@ 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 1; + } + + /* + * 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], - XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), - mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); + if (metadump.external_log) { + ASSERT(mp->m_sb.sb_logstart == 0); + 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); + } else { + ASSERT(mp->m_sb.sb_logstart != 0); + 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); + } + if (iocur_top->data) { /* best effort */ struct xlog log; @@ -2958,8 +3017,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 Nov 7 07:07:14 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: 13447962 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 3EDE4C4332F for ; Tue, 7 Nov 2023 07:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233567AbjKGHJE (ORCPT ); Tue, 7 Nov 2023 02:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233518AbjKGHJD (ORCPT ); Tue, 7 Nov 2023 02:09:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7D811A for ; Mon, 6 Nov 2023 23:09:00 -0800 (PST) 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 3A72NkpO005334 for ; Tue, 7 Nov 2023 07:09:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Eo2H4ZdqcZj1h9U9KJV5dXdRK4RG40qHiLn0E+r57ns=; b=267yZrXpJF3qjHIfh0Y8QqQXjmGFI4T0sdmcpehWExsMnsnDJUyeuiWkN+eU2HpEBpbG 4cncoSDIVjhHaf5gwVM6cC+Qy6NE/PJSJmmVY0ClGnrSE67nVjRpksGmWj7CQZug72ig 1NasaeFzBoRMBkSCRXuLNxrDDNwKx0ciuYQKkVZRiBODfLU9VTyFDCEcMtISCLTURsDD xDP0gNAuxJA0myymdM/uvS8gtc+2OT3miUDAeKwl9Z3mcQY5gfAROfSaEMyheennc0tI fORX6FtTTNzO5aRJ6Wzkduglg8V6/5qWrvBEat7UqSxti7LAOCYvYbfEP6i6BYzDMUor 6g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5e0dwae7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:59 +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 3A76PYwD030550 for ; Tue, 7 Nov 2023 07:08:59 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IAF250eVi8usqV1LAScaS2k1g+6dFbMIlOAq31WufylK16cxYYhaF4f6nTNnvUC40FJwnxvrJjhL1iDFS3iS1JH7WvUY9+51aFov/abQ8LA+6Sz1/W+wDBuwkl1xFJczZbvsO58PKTyeiJQrmg/t2tLm7nopJei9o/vgQVdsYMMFv5Tq8mdxKqGdbN+1LqrsP6OZnu0oNgfKYJHEDKE1ML+OAShtBM2rbEIBnOLqk8+vPlE1XMRUMzwbKJgSns4ZOwsbSyxah8arVLFDNXRAseyKDtTPF8dJ/O/0WoQtbkQKPiHb3zFfzeADaY9G3UQHBuCYSdRijNYuDyPv1bgYkw== 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=Eo2H4ZdqcZj1h9U9KJV5dXdRK4RG40qHiLn0E+r57ns=; b=crZ0fX8QVs0litzyT3Zar5TU5/JWxs2/s2ZWigfLIZAv4uK7Px1hp7Tl0fTFnLO+pXt89hSYFlcrqnkPwEobvLWEizO4QLm/RaZOmRg25R++OD+o0mFdAGxCsyEczA6Lh9L2//pC5ecdoKuePEEtUxpjvKaS9afHunJEc3gzvdJm1RU4t9qENITEqFiVp2N9PyAn3IJoAkB2+XWxc/Oyvyawn6VDvGfgk6uWPLCy0LsCaCgC/GA2hKIjYjTN4b7kI1lw86fltjJ0IZOnrceWkAYMR9Tv7+ywovG7iPXT7LTcTH+E3mUsQ13xaqR8cIVqOzoD0OKb+uot+l0yvLlyPw== 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=Eo2H4ZdqcZj1h9U9KJV5dXdRK4RG40qHiLn0E+r57ns=; b=qIRUSUPozAbdaapucJdOqw54G7vtoLA1vw+iNjz9YlQ74oqpebM0O6BTFGv3kI3B6rWWopBeCKLq1K5M5Q3Cy7TW7XWr0+jqxStgVXZXD96pYfSMdA0lZeVSSj4B5qO8AghyKUTG9STu8LyJ+tOUH54R0EQ3sEKRzmcd0l0x8Sc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:37 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:37 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 13/21] mdrestore: Declare boolean variables with bool type Date: Tue, 7 Nov 2023 12:37:14 +0530 Message-Id: <20231107070722.748636-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0287.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f84dc10-b006-4fd0-4212-08dbdf605d2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OFMi+6+ESi5QTRaCaXJuzV5WTrZD1VYBp4cNazAqV1hwI6wma249dpi7ssMV96VtfOsvc8ved5Ij7SiJ1wd+zJFG8RjnjWudrTZoNb8Pefn0gABopretO2eCMy7n9ghu+EdTX7UHDu2ZidNzBicIGiOdIvCkieGFvJ894afh1azqQQaEbCInJ39h2O5vf229Mhp/0KS3MEB5vV+uwl+oP04B+Zbd7caFnEoyQCyQKs2rxsA4hPVnWFj7upnsGdBz6lTS03EPBw6qh/U/ay5Ap4zVHyPVNng7m9ebebl3qrpgGmRFvuhghWGLM5UYAvJ1PgkFgo3QQcpU+8ZAYsHOSr1HJrvQcaUoc2P2JgsNKwi2ikGLxshHCUKU5M7I2NuIPZRtq876ZhesCWZSkx9S/72LtcXOec3IZWn8e+D7UXkdQHeqtadHGyVwic5D27RGytxzNsHJmQIISit/bgUphjkQBJ5RuTSXlmc/u53p0cq2vYJ69kzZW9tb8RnUxptDoSqM3v32nNt8SlMsX2BmM92wiMHTVOAPknWEI5of7A+RoEJOqjQH/KaGWaFDy1/aOoQh6lIJgeBwKisojwTJjnfA34FS7pECOMQ+rv8rgVYjtZ2HG43X4o63OsB6a4oF 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NzO9t9wlHL5aB5hDfLOQvpYPK2Vb6AnWpDGoD5HYWajdZMkOFVMTBbi6u5jduKlqHhGdqZJZWKswKw9rrXg/lX+5TDdk2T3hrtmpICmFJvP7y6rL0dJGcjUFe4Q8vKVgL2onMa/QWjLX6O58D5S1WW5o+vPTz+bztiafbTu0ptz1bzGHZ2ChKAE+PLh1V9wjPC1SoIibafXFbw9aTdcPkcTLYs2Gc8IN3OisWmPwetlE4eTKfOdAqK4feFrxMfGeW0ObIrmonUAZV9BAh4/Oo0HnTJ0aX/hcXqOcLWStS59tT/jT0Pb/oBf8CEuDlF76htGVDiSrn78xrVCXYMw2lOLn2iW9WxINICDma4V3pFdzPcYXnYabnRVsZL600FmUbarTdXaZnxC58GfSt20+amF8pCFX0YqoYbUu5g+CV2ucXdYonqPTKUg8jdEqjcQP9BYT1z5y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aXblw8KhVJtlJCS9P7XKvvks3nQdC30qvbv9HlO92rS1YVsoZTHIfuD56Fjx3nVAI5OLw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: IpL6Rq6iOshUDqwbV1qdzDjBBs8/8yPPcbJXVakLQwwBncAei2h7FPjgDf6rRFr4LrOjpLkmXXjzYZTubBVse4EQ8oW0IKkmjMkxLZ/85pGCKlMZKEwk0itcLC9xB/pRil8e0atVIky+BQIdc+xFDRe+jRFPKKeWr3n70y6NcacZ1oV0yvDzDmhSOAUBr3cAH4PpvYOdcy10D4ydD6Qbfi0Xco5DOCPEa1Nurq3txTIJriffeitB5YzEO9+pvK1rpNJYPhg9TLiamA/lLA765ha2v84l4So41ycbSg9yQrfRh7CpGNwN2Qoop9XUqEUdLkvwRtgb9P/ZLRq5HYK99APduRzrcCz52jhtRRWRP9Rnk4he+qVwbPalfZhs8JnnXhAgLcqvfxX7pIpFpEncV/Roa1mdy83YN6n7w4NXm20QTTKbot2AHadh8qtP67vGC1Wo8eckCgFc6sGnbTcsbpUqHPx1OVVqNcideqrcL+m+3xayYwqlc6Yn/rFIjHXVmMrGpDzMZwseZF4egP3yMPYveMZmkkS0LC2k6oR1mDiH+s5AmQ36vz3jPZW+ZuwAt1AbSGUREM+J8xIfP3Hx6+QMpKmiyxafekS/b6WMbEU+yrv+h9KiRnVptIj9rSySIqQPGkmFL+u1Y3v6HKNB04nN8AdvysEJ60yq7LaoxuvvrvUxFyIWx7lXZxFTSSd/lKbJuhAScZiOXxJDHAGGc+V3aKZVFOgs0d641QISlzzlJcLxEUjIIsn/OGzWSgI6A9waR2VyBXCOyqj3Evd+eA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f84dc10-b006-4fd0-4212-08dbdf605d2e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:37.8156 (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: M9863hgPIG3CWJwYt9L3wVXhNczovsPpc3i4IG+w60HWJ+0eNprRXJscj56sf3Us3CJe/bsGf30KGGzZxzWEiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: V5Je5XI94P_fB5Ej13zaci6a8uTuAXXC X-Proofpoint-ORIG-GUID: V5Je5XI94P_fB5Ej13zaci6a8uTuAXXC Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- 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 Nov 7 07:07:15 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: 13447966 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 D2075C4167B for ; Tue, 7 Nov 2023 07:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233575AbjKGHJI (ORCPT ); Tue, 7 Nov 2023 02:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233584AbjKGHJH (ORCPT ); Tue, 7 Nov 2023 02:09:07 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6460F11C for ; Mon, 6 Nov 2023 23:09:04 -0800 (PST) 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 3A72NnqD031636 for ; Tue, 7 Nov 2023 07:09:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=L7f3ZKtXUhRBswEzHa2tsOZ52uFUEV4YsW3z6LXL8GU=; b=csTdrH6tCuHH6XsUzltOQLkspdwiX5mtSBL1flybw+TSodSRjR7fG/BfZjZ7xRqrpRqe ohAuPCkWPYFz1kPQZKVLokTtetckTy6EC0pLoV4/iz9PiLdnlIB95g/H52qcZ5yhEXF8 s3SFqAlntvDLUV/GGj0peF64au711H+M/nciDz5Ul/YqT/ymgEw+Rq65uq9P6tunuL/z /prs615L1mMeq99CH2RxV6YnMUuCLqZ6V7wwUTXKa9yRF2fXpxuD2UifacHEsYc3AnFm xIzIAa8JQqJdr/+BTMqHrhP9XxYBHyRaHjmG8A1GpS3nbLPhCOdTeS0gldFkAXdIfseG Bw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cx159r1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:03 +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 3A76PYwE030550 for ; Tue, 7 Nov 2023 07:08:59 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:08:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rafdp+ics2WGT+yUYdy4ggcnUWBz+i+MFJdEnpQg7erAv+Jb+VRdBjmKdjSTB4+PXEBNhCGaReQnOLjodfGjsxRsTov0jtGt7x64EObzhfSCQr0gIF+q4u2eTxsPgwf+EodbmJTEGii3ByfHHpey509DT749lcszoq9hH86eCtfWia1pObS6pSeCy+OBZzX+oHXdCpeaDASZWqXhTCf5n2BvEKaZOCTztQPM/Qg9po22oZ6Op1muNtjOAzlVOWvDPQE4fUaQGX8QVRdAUrZ6NVTAcCii/n7kR31KeQCgQbhZcGgXpYibgs1stEFIy1Hlv3U+OIXnXbZHsyuHLApzMw== 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=L7f3ZKtXUhRBswEzHa2tsOZ52uFUEV4YsW3z6LXL8GU=; b=hFSfzs7GhtRb6lymb/tO06Ha75sVQaJVAftUj+dgsBgvgCbjfZxQa8gTdqqedR5/BEytgS7sT6OTI7L6gr8mXyCTKl929akDT9G4Cc2zgLXZP5HY+xsPChlVDlq58U9fR3U2YFeMyDubklWDkT1EYbISx5SIa0lxE4zfHkyxyWWN1mALwq9fRfR+LxFpGwr2nCs95ogtbc1MkRdqXnbLMcFtp6Sn+1wO9NYQ1tcSQ/NEgcd5DZNafn4wtuu1k1O9cQePR5o3S/GGPzvHWSxHM05uV9WoMfbd2WKwtwYwgAqOPF8m/ju6G8iTtunnxceXD7a0J3JOwanYPTUhAhH7Xw== 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=L7f3ZKtXUhRBswEzHa2tsOZ52uFUEV4YsW3z6LXL8GU=; b=cT+7gTLKpqKYEyLa6QfSUNBx5TQ/2nSWQu8Q5vUbb9yIctlSlOCTOXZM9szISKYMf6tbX/yNdgAZv2SNqGrYqlqHQw/G6bwqfAVwOUzg+pn5WEFLJFoba0vlb8nWXABCpUH55MH2GsYeeGSrbMQc0hY2aTEm9NPDh/KqVm9Vifo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:43 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:43 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 14/21] mdrestore: Define and use struct mdrestore Date: Tue, 7 Nov 2023 12:37:15 +0530 Message-Id: <20231107070722.748636-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0294.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::6) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: fb176e87-afbf-47b8-1b10-08dbdf606092 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pr5Hb+yZmolFlnDLer0WlGz5WOP+jdQw0HfJuoZeh/qdeRG04upYb87lBNmC91wsCIKQ9DVsDkUJyCa0kA2wg+Uoc7iJOnKNSD3SjaqrcPe0Cw3DvFSQ6TdXz4Bv+kR7QVxCfxOhdWoGl0ET9Yl6esoXXSzeqPm6DdQMC4wxATAIXUOwiiFYSBYnSYWDbPFaDYyFE7Iwlwr+y2gANTPEgfmwlEOPGgt4xmDr/YeMv0eVmc853U3FyGryoGP4mZny9nQZ21UPuE0kedqmgk56QUU/xZwGUmgAYTxgzd1SqQqeoOmIKMXBm8B/iCl6MmBDkiz0124ganRXupLDatjwX8aCfjRfUBQWP/at8EaASZIkRN2JZNYcAHMfE5/X6VYbOZN9sBtC+Xm+IV7yySvu+e+Z/4vG5zhwASxlZVJj6BYtBywdVZbS+sc4Hd89nQV6lC2gQtp5ElRjcsSZ3zrhtdI9VYBdlE6gezof+HZsfwogOu0T1GDigl+8wAgjwpsojywIWLOUeAiLPXoUxzfQAQJWLwXIGaqpdiptp4CqMxd5BdQnA+qVTn6ESPkqfeQtKdB4XenFauVEYiNKk18+NRFSlfBCn/k56AV/li47+74vg/Nhy6zWihAeaWOeF/90 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1/6f/fBmgaf3OsPM/xOs655X8nzlTEFrWXU/wsml5xC0IxDzcWtGZjExO6XsIb9gHwNS8JPls2dw5hrlizNTHqrHAClwUqVTfw1+vVxghZa/xC/3DV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zuXoTHnTgAvazMK4AfnyByebqB3QeOZisc0A6xU1nww+n+L1ETwFhvJa6/2oeUmj7e+RBVNncv9+DSBUbrWQD9m3H5iYwteRFP8Gb4ukhknpEAzsfJy7/gObO6u94z3f0gz/XuSnvETPV64Uc0Ph3iEhEZVoU6x4OrRcpI4dqwC5VqTTF1HCRwvzN+X7Wi2zq4fz38X1w31CDZiT+oCeANrtpbATuGcrPishCEjnNl49AM1MrQxi60Y3Sx6+R+QpvFBLLTocV1w/CtTCeroC/86q0V3hgCPFnKw079ej6BHcobO5oLDJNpB2thiEuwvie8GReasAeNZcv32m3GqyeIBKVSbv/vguFPw4vyFmjJbVzzs7Nh9C4gFNacKE97Hh2klmccdeQZ5t2Hp4dCfy7l1Rdsw4m4Gib5eNACNXMqLKpUpIGYopociqjd+1Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rF0eo73I1MBuTCjnWix2bLDJc7DFkArxRAkI0P7TEDqmfT+x8f33fUoWiSen1JWAvhaoHGLBTTjOpxngI5f+zWDjAgS3IUQd7g5gCkmo8fmnWpBVc61HgoFnWlTy7j71p534V7Jc1AJE9OwbVgok+1zqDFhDMnEZT9BT8155/2E7lAnTIi9ilcIVic6c7mXYjwQaNQMsNzg7v7prDzMAhWXb8wnBRdNkn2jog37Zq1RW1OSvJ8PM7mV/b6YO2NHIiFry1uByy1KVnp+2JEB2B2Gom7CTBs/5+wvxkC1FagwUFfXLQq89ZNEiesQnZNmuzd6LwUIFILzUxpoacKt1ATqtnUEgVE/5F2BqnnWih0maaaaTQFEHnKSFibPt5gnNe0g1yoUlYUTXvLyYApP7/oWvVO9DY3rIBj0LSfBFRP0m02n+QNTzpeP8X81FwztNr/qQ+Nf1auvUs9JqyC/4ej9Smj1K3KgcLt94ZWhoN+cInEqc4LwYp7px0Fzb52G0weY6bWVd714AGj5TDfd8SBpjd+c6tB/UT/YcZY26QR/Cbo+QF30BfgVN4PDhCN+wkT3WyyWphqrH4GByMFukij3Vf9xWdk4msD7utx1iZHil4HQX2Bg/StQ8m1sj/kG28UtEhp92jaSBNS5JPcADqdJ4Oaobzgsm8VLgsQ4yjWrni56QbZLEM00d9oPwPj9GyQysUiwmMzLPSJ/z6IX2dMFPZXFgL3l8iJYFf39D28iznHyMhAmxz3Uk3ifUGIqx7DYDUqVer1nqIlCWNplbfg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb176e87-afbf-47b8-1b10-08dbdf606092 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:43.3936 (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: nbRT+oWkMt4BsogE+3UCciV2VUPNM8O3BViI/PZ4nFf5myPTwrnAY8C22hGlKvoXhSVe4bC3RN9luZ7uMFPlZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: JYCY76TTdccgr_ajTfj-nDl-q8W2mb2q X-Proofpoint-ORIG-GUID: JYCY76TTdccgr_ajTfj-nDl-q8W2mb2q 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- 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..97cb4e35 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 Nov 7 07:07:16 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: 13447967 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 D02A7C4332F for ; Tue, 7 Nov 2023 07:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233585AbjKGHJL (ORCPT ); Tue, 7 Nov 2023 02:09:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233584AbjKGHJK (ORCPT ); Tue, 7 Nov 2023 02:09:10 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D4611A for ; Mon, 6 Nov 2023 23:09:08 -0800 (PST) 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 3A72NmP9031897 for ; Tue, 7 Nov 2023 07:09:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=bQupO75Zvy0ifEPUPUOBCixJ8Lj5K4EIaTt5b0MTbAs=; b=cwG/vqe5SsLERMCyC3Kt+Fd4NymYx26DEqRbhbJyJCCEGjsXd/8WBScMIVBift/XR0Bi NQR2bJoIDp1o0Khr3XZdb+8HCNStduQiMge2gGwfnJUMyZ/yT4fD5x5nDhp22UCL9R53 mrYdxXowDzroc4qZe345lXKR+tRifTDq7bWmCNUop/pV+DZK84zV/IQenIFJvXwYFnSG ov8fU7+anXqHM1GVFjs9aQaXeH3c4CtGvAF4BRpoWrqTktDxzTmDdUEucnzySypCgLxb z1h3wPyeDvi+MT8njs60QSSvKMcqwc0h/ebmdWtiLoPUPFrGt+wKr8J7EsYAXIyTxDas Jg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u679tm2mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09: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 3A76PYwF030550 for ; Tue, 7 Nov 2023 07:09:00 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ml73lyqGn0Gj+LMytw/1WwlVDVE9B79f9Cua8r/T/Y6POxHL2Db/6piNowuXRLv6bikPyASiemh8vy7S7th3IHNbrHmB1/x1pGYPGDRym548L/On1Nxow7441ErITg9E3yeqsEnMpaI/0LokP5r9DDfmRjwxNhVqzJqSW5IOUWeotUwsbLWrT0BU46YeHn70MeDPs/lC4Jp02LE4S/SIjUqzMPFgQ9E5/28GiipzyUXogIOuxGBhw/+j/Xiy4RDhRsaJXfRvEDpV0TjQgbQVNLuJsfb02jTdTNMjP8vAXgPZhjDe93CA3p2h+C6Ib8h2CZqA1fczR4EFStocRke+nQ== 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=bQupO75Zvy0ifEPUPUOBCixJ8Lj5K4EIaTt5b0MTbAs=; b=OP0uZ3TTuVLAqrMrCSiyi1hqLiGFKFw/x8nWIzgpfKJsbARUbZxr6JSPoOBii4nyfaGJ6jDzRmwJh3rKUcZQv8kcc1Yeu3bt7mOUbs/lTYZFNwB1udyxc2IXPmNrkvPT2wYpdiS0n9NBkqscHUUtsgHkgiXPmDZtF0ENsVUuXzgnmzKWZG6rf5F3Y7pl0rPx6SmShFnKnNhHPEO51EMQdED98EiqutYHOE5llGBnuE9pURHlarWoKvGkgTPE7bB8fP9sJ/oVMXZq7twBlaRdYtry1oCUyL2iwQTBhTsHgjgraxAiyVuIJ67WcZSJbV3U+SYFK+p/2BGpSDJ1MVqzhw== 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=bQupO75Zvy0ifEPUPUOBCixJ8Lj5K4EIaTt5b0MTbAs=; b=W/EXQntiZA1/fMtcruEincej4bgfOTs/0HA35EFunJpk4hfvQK4qn1yNsKlPjU8+d/IR8LTFED5X5xS9VZsa9NWD6L12vDYP7qIS4EWBvxkipBC7Z+mafufFuezcfXFb4jOjcDrUogpVXk7So8SGG2dD67iMS7EIMrDO//BD5Ns= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:48 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:48 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 15/21] mdrestore: Detect metadump v1 magic before reading the header Date: Tue, 7 Nov 2023 12:37:16 +0530 Message-Id: <20231107070722.748636-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0025.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::12) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: ddf88b00-4aed-4a01-20b8-08dbdf606381 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SMJyqh02NBvYJRzWSyNoO6eemeleIX0L1F+GtAoQz+zoCN/FB1OMWGcMz3VeDrPHgH/NATByPjAyJP0Dqyo7iW2uBa+Ki9HRCA+2CZyVCKuCUOaWn2P+wcmACbfpBxtrGl6NSBDjHaHrw3VsrlkQzrnJHfrhi96lpecZ9S06VP5T4B1LxTmPKHfHREhTTB0w3fEZJXn1pAMWmOxXzKkUIe2VtiHK4JsDluafSBImSF313o9GZ5Od67Y1FPKc3nwNyfFXjKsr2MZsP3y7aewpeBUZdJKCE7lE1Lc+pW+ncZMrN6VCnJrv4og4ol3V4DSjYIZGU89Aux5hj4xClp46jb2cnW7IpHe5oNFqdGn5QVx38yZr2DeKtIUfV5ZOabOAp31gJS0uJtXpWohvCHxjxtTFtvKAfUNuASemRkUFLtNcBDntECOuboJMFEPWfNvP+QK4pH6xpkt6MBQatwpey8A17tjJCqJuFkbUNQHwngQEKctQu89JXn7okkHIFAgQXsB7tbFOqKjc/zegi/TWJOCLKma7zq47DijsO3RY9P0UQWVt9uCODSv52laoN9q0 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DnMAaf26qf+kwL//LWPnKbsgK+q4dBBrvF4PXw+gOOjS9F7YuiRdKVDLxD0DqekVi4S6A7gwhAnzZZuTEnDm+UAlraOUIyehqAozP2Jd5NMvpf1c0QuYszl35vjUQDDoT5adQWNo0963hQIiqm7DdvVtvr7b1+ojIr3W8Zx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JiL0+p2VurBMaamsN6o2x51nMXLJ1bRyMuO5L5jH+QbYM0qylxmeeW/FS/5dnW0Qk/kXNbhbOWgg867FLi6g0hm5nr63zX+V01N5n9IHjaEFzcibrHkFfiM/nQGK5QgsUvuZl/dwVmRm5arMX9IrjftMUoCFv0qzvjuep7BHiCHUHMq6dEhL/rgI9N0Ssw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddf88b00-4aed-4a01-20b8-08dbdf606381 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:48.4908 (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: zB98I0dYIvV1ivNjLwuYMbc5CWk093EdqObExBC7YRrsCiDvCv7BhD7v4nta0Y6Rcy9b5YbfjKOJ2gwTo6sZow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: qinfoibxUCLSbEdM9HwmJKxI65x9QUHt X-Proofpoint-GUID: qinfoibxUCLSbEdM9HwmJKxI65x9QUHt 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 97cb4e35..ffa8274f 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,21 @@ 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 Nov 7 07:07:17 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: 13447965 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 8AEE5C4332F for ; Tue, 7 Nov 2023 07:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233576AbjKGHJH (ORCPT ); Tue, 7 Nov 2023 02:09:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233556AbjKGHJG (ORCPT ); Tue, 7 Nov 2023 02:09:06 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3AC6FC for ; Mon, 6 Nov 2023 23:09:02 -0800 (PST) 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 3A72NnTU031384 for ; Tue, 7 Nov 2023 07:09:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=oMYSwpTbcnKMfqusIbqftLcUyMkWZSUqS0mhc/7zXTjYItaQ4GJrLGHD4N9xteGvBY+P tOhvT/n0bAQhmtNkc14ZtJbG0CGnD8N9uDCwThbAWNP/YDLfm++Hwgy8rvwdTnbqSu0s gUERmlVhEiHCtDWrEjIUHsxFxAiEkAEOG22A3uWTRRrSfu7DGBzQpKThNKDk/pC0Ru9h Jjib9RqTy6FervPpDr8dO8hGPcqNvcwbyT/YcbdrnbLcFObkI/0ddcajyB2aA+5x1Zy2 vq/shpzU23YRdUvU9dwBGaa4mECdDUDzh1WTyDOtChWOxnXi/JeD6b2CKSXjKIWCLdlI 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 3u5ccdw9xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:01 +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 3A76PYwI030550 for ; Tue, 7 Nov 2023 07:09:01 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=foeEhIwm0V/tcZbrRWnWe47A5xVsLNxSsCB7wKYfvwE9b39qgGVEPizMa1xNVzu3PPWSwDYSBYyjpKIQmUk8YJEZvR+lOZOb32AEtTzTUqYQ2mW0H9uqLGurdBlhV2Nq5kV6FT1CeTIHdSDuCrutVVyyU5zyrCGl09vwENN3PsCE9z7VsjcC+mwd4gfft3Lpz+yTtHhU1t/sSwO/Ms4pMkxcxD70rLLn1E1s1YBNgmwwiUS/e9eOEjq8m5702YbB6oB0Y09RWYVM3+CKi/wDmFZNRHL+SvimKQ0+Hb0K2FLRk4jOJ5EDSKYBVmWpe3YtPG8tVRqR8dt2EZOT9cP63g== 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=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=LpXkCUWtFG9aRoyPljsIGiRjkR0H0rbUCrV+Lt0vjs4fkvXIiPd28Ky1Pyh1cLTvEOfzwtzbFuC48b+6sYgrCs7iJJ7TXQNdWSN/e/XuA5VPfADuC/ghF2bNaYPPfSHC7Y0jbtQZVJ6yb6nymZ0bqTf40gdlAfPDxW1AR5r1Py+Ir5Y/SLWy7lxxSS+Comcrm6uWd7DjJIWnQa/U0XTLi551wzPHgfdiu4linY/q6iJd5tERiXrLkJfxl15p2hVuR0sjQ2UYNEV84GgX+xO8OAM7105Z8Y+wk/JYiPZXj++CoxVNnM7Jl265+zTwxW23ox+CNma1BUB3eL6hNXpw6g== 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=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=gtFAGkr/8OYi+c8ZQ018YttLAl2MgWCwHcBzdLp05UIbKMLh6sfnkJVimnTW5s2sxbpyHmJRjd8yBe1Nw1etjIxbz+cgdE/qZs9Ne2yMS0jBTF6rmarHIdEB8tAucFQ/z65XsfgYMyGe42o90rxBUQHEXz9hg06lcFJRE8ZLtV4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:54 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:54 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 16/21] mdrestore: Add open_device(), read_header() and show_info() functions Date: Tue, 7 Nov 2023 12:37:17 +0530 Message-Id: <20231107070722.748636-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR04CA0005.apcprd04.prod.outlook.com (2603:1096:4:197::16) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: 2659e2a6-28fd-4ad4-d280-08dbdf60671b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lnJHFUn/meodeAND+RrPs3i4mFoOIC7a8sO24qMBMB/TaBE5h1fM/iA9Coy+o/xHARnKDRKQMPmfVu9rz1rn+yJpIYN8R+Vk7Ep2gvRH4K1h5YKPQWMmqSSJYMKLnEIN50MuCu3Hktg6uFjN+GJ8wk5u4vvH9aoJ/XhlXvE8WOfGsnVwUuefJEIcvENBknDt2MYpY+uCi+i8QVKOjQyw3aEcE1PW2/5iIYJ0Urodi9763iUcen8lVsv8lptW1pUpwC/sTgL9LasNonPGKHQwrkQug7KBO9/W1EfmZjle3KRdaBTM0ffy1OXXGknoa3wywbGZefo8O7McJMsoM4np+j6kEic3PfHs31kWCz0fdpKKh9qqKafH1BwKU/jRqbvmTvSwRws+0kGwcuiC1vbKmhkzezlXKwrBpJGCbpO24incZDLixyB2OlF9jx5E/P9u259Tvlft/3xf7QOiXmiHKU09nZw5pKM4HzRqFAzBg8DaWi4NeIpwVP10IS/Fi6jV/I0lJjt8x+eENRs5myGQkio5M3UUI4tk/Obl1UUfFRpxVqA+qKpIp9IkY8N1Zr//bQt6MRXgYjHDBVU6D64qz1ZGLwtTtLEfZ8AIyv5Ml+XLnitKOQSNLNl43qs3HdJ2 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IOhIXhbHWD9bU20fsWeoiHttXe3KNEv/QV8xQaa6C1zFOV8VEWiu4i9hs4uEZMtJ7JKT+DO1g28iGo9ejFV6wkmEwBn0skpRU0mTNErd9m3oVwOktGHZ2zzSDyOGH1L222iwxn3rhxBRnPvwDVG6RHJxUHt0sogka9GwiK3FORfToU+jgREqceMx5luTQTun+pjeVgOMZjq635sNCaR+KgQN/06W98paXUFOhCeeI0rqOslXBkPqNLUS/CzFOky4UfoClDnDgScAOB5CJyHGdKmGHKfnvs7b0jiM8ZLZE0xgsiT3eA735kNK9QpIsfa8257mX0VfBuO+cgi4H6M+ylL65ANs9NrlruMmgpVlNLGbR5tlYiPuwWAsBA9dCyE9EeBb+3bnUKcGOdveKJ3klhQfUq/IQGeBEPoxgEKKKDWS8OujDHFpnIbcsnyu0OzvIXMU2/B2NAiqMsON/+BtmyAHnOIM8qDb8ruv6vsUS3yjIW4LiIi5Jtz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gkQdp+BL4zyxBauNxFf/dbTYWVarHUybJ+lA5rO566A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: wKt4Fxb1kVTuQNKrbDnL4+xn3NipxOwXYqrvE+dSZ1B34pacnNwNqthv37qRS8oRruRvz1apJs9S7Y/eUsz8bzXGofI+s78ycAkgO0uShWkkQ7ImJeFZnxOL+M+f0xCOT3EBG5CVOmCthNxYe4d+p5/LWLqRJ5ZpTfCAtJjS9dfOcG/G0KDM4gMmZ2iCh2A2nfuPgg+Lkk0qktILqFb3TgD+CIzK4gTsE957Rqy34Skpe6Tk403YPOhItOjjvOYNrdqDK3NqAl3hi8gA6VcZq2Hw5t8lziE2Ap9YkBHQ7btuEr/SwKiz/Wn335B08+Xv7+0Sn0N5W/WGG5tA78QTXCrfnhpBWJBImpUr4NPJitoHhdm/J9S0yeK0En2VodYDnm6HZzAJs4hwBFaMpPrIq3EJkcLrw0H8IkGZFORVYqaHhy1SNEwk96Zumvh5J+Adbg0sOB1BZD+mwgLKETsTaaPz/IJztQ+n+ctiWHb8Ae0hdHzBIfdGG5b2z6Gxh3UyMibyScEzR3sOSyelbpCVY5n1cshEvxgcDOhQOR85tOPlv5AsYlg74vWpGaHJrdjaBMzbYc9U6cm1MEoipmaX/FymmGbpvWbypiNB78UvGU7fVEyPjmIGhfKFmwKv3YqF/kOcXBsdNthcicVkHMuBWQJyxtifUk1T7uxBf4sxGrGjWYTHsa2uwhyLNTgkngJQp5KR2D/NjTGk432RZCgjGp+Mh4jRhKxAQxD+4qOaF0jlycBoIiIFnavuFO2LT/wJk45MTp7MoxdURQECI1ADIQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2659e2a6-28fd-4ad4-d280-08dbdf60671b X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:54.5441 (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: x7RLJ9XSoGuKMDA7Zx3wIW144951jY4pD1tkov9d9IfmlR8JqwQQcv7j9h4qzYEibgTuV6UwYyOpJLXAQtN4pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: Rr4uF-1b2a_j4XoEKz5VrUdx9IdTRLPH X-Proofpoint-GUID: Rr4uF-1b2a_j4XoEKz5VrUdx9IdTRLPH 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 141 +++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 57 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index ffa8274f..d67a0629 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,71 @@ 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 if (platform_check_ismounted(path, NULL, &statbuf, 0)) { + /* + * check to make sure a filesystem isn't mounted on the device + */ + 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 +115,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 +145,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 +176,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 +186,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 +199,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 +210,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 +220,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 +237,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 +250,6 @@ usage(void) exit(1); } -extern int platform_check_ismounted(char *, char *, struct stat *, int); - int main( int argc, @@ -195,9 +258,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 +292,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,11 +312,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"); @@ -263,16 +320,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); @@ -281,30 +329,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 Nov 7 07:07:18 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: 13447964 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 20A15C4167D for ; Tue, 7 Nov 2023 07:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233556AbjKGHJI (ORCPT ); Tue, 7 Nov 2023 02:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233575AbjKGHJG (ORCPT ); Tue, 7 Nov 2023 02:09:06 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A82FB11A for ; Mon, 6 Nov 2023 23:09:03 -0800 (PST) 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 3A72NoSN031388 for ; Tue, 7 Nov 2023 07:09:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=R+OIMSXaSSdWpaclGhG9JzqsC/R7PmckAA2Vt05yIeg=; b=LEJGrljqk5r08IxAVkJlJDepLeD46RF/MRlmuz2dLNVYANIL+UvkQZMQHd1fg09K+YDE uS52SlSTn/tzzW4YVnP6mfPqQF/5opOhQGYVv007dDtmrp+c4xqNBCRwyQUHt5rR+tik dnPSBpsd/4Qa+XLFu/hZO11ld26XcWvFkW+uHuHb72xDYq9vgEE6tUfhaVD2TtcVSRz1 T4TFciFOtOILvh25mJat/QQjMYgwgoeNZyrOdNGdOSsLuVMEvVIy5wRaCm7kepsg4hxX EdpwDT/K0g3XEZ0MIYJEplJ4Z92VPUExp15gZoryPOTzVLlxRm8x6/+AlQ41g3NiLDSJ dg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdw9xg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:02 +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 3A76PYwL030550 for ; Tue, 7 Nov 2023 07:09:01 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63fev-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+L27LMjxdM6XhQcSR9uVUSUsQPpfdKNoN8CWE8xchzTZtsWzG9l7c7jM3eNfsJHMRdLmdavO5kGJt8iqb3F5ldSjQI8cqtPpUrKJ4eSQM5LhhgwWh+Ev3sbreH6aiwpZyE2k/7yDwfRz4Y/Glt1rKGR8xd7xQ+SO35DPYGI4lvB0btA07NkwMwi0Se0P+oU0+K2RA0oBvAOmBF/CkJEDAJuCeuEJ+X1JRHOGBytQpj+dnvY9pDgn+t8quNd3v2g63HMES6p6EFJe8vxiPUgFCBua8OGnxBZuVKAdnxLxwNkC1bVFfa7UdP1UiMTW186HS9ZNzbFHk+38s/ZElYN/g== 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=R+OIMSXaSSdWpaclGhG9JzqsC/R7PmckAA2Vt05yIeg=; b=kmCTmNodFkgnDCu5XJAFTOb9DPmc0fcwSPSqe+xx8Oiwmceq2RF2+oD4x3vrJxrl1XDnvBKNiuLABP0EAzrCCS7jhh2aDBwS1HX5C3ZuDbVphCh/GI0vzHkURi9RkeULUEElbxT9DeEw1AU8px8LiVQUf/3TxAB1JFz9C0//aFC6KYSrsLpNpAgjGiOBjoZILqJpYwbGmtUdOPYfRdrk9Je3SwnKlmj+yYSPUaXTVgEPgueec5oRRIxG5Z4e0gJaBR+tN2fGIx68BKE+/uWNxsqDa7aIUgijfZ5QD+wWYHMEMV7RWFmoKamjwsKMPE8mRrrPHOHDH8sDg5rSj7zTYA== 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=R+OIMSXaSSdWpaclGhG9JzqsC/R7PmckAA2Vt05yIeg=; b=NuJT93Dydv9M3U3Kb3dcPHDayB2UXAUOMUnhjBHG+gyLgCPQYETe/cLzNmZY68l8MSsumfzqw04CSErdinAqLYiH7YVtOmFQdbTgRY7ALm+RkegTcoUgS6vBKCrGnRx5wYrLM42kLpOHiKvJK1ZNB8yYrsduqlQST2t9K3ls+x4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4770.namprd10.prod.outlook.com (2603:10b6:303:96::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 7 Nov 2023 07:08:59 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:08:59 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 17/21] mdrestore: Replace metadump header pointer argument with a union pointer Date: Tue, 7 Nov 2023 12:37:18 +0530 Message-Id: <20231107070722.748636-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0020.apcprd02.prod.outlook.com (2603:1096:4:1f4::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4770:EE_ X-MS-Office365-Filtering-Correlation-Id: a74b9ddb-9679-474a-7370-08dbdf606a08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wezHch0pMwgK329To1AekKAtFLMzW1HX/YUVczXqPUd/yreabFbuLJJces2+7pyHiSOwaue7s+fTFfR3yX+aulnRSlHAJU4UkD5I1JZlXWRr9jNZN/lvxfE5fAk0mG0JMwjy6/XvY6KXrzm/RoPiUUJyL44j5zV1o6p5puO3+6g61ExopiytSvUncHzkZsRgUeZsoOMIDxE51uQext0IRELGj7JO4bOuTj0zpxwcs8wFA5AjGeZZ6UEb1fq5zPTaVVboTRTeHElmgvfntVTWh9djXop5IDgV+SZFLXtOQMZcUauMvRyYS3kOnOmqXa4R0gAfoRt+jVJolUBqB+oV4BL9JEUJZnplpRkCxbgHMzca0Q+IqZNMXE4N2hvJdnyG05qKdGXhPWV6JnFXz1y4jh7guBjsLA6IJfEqTwZLWhrei2r7qK9wzQDmsJQsflmnl6156+MLvWaa23uUOosB8iaF6HH6Mic2hLgRDq2gLWn5bz0l0uTMJPcfEyThKQbzkVfGtCoEGjQIlF7UvssWtn3o5UsPuMne6IVen1MkqPuKGMztMXtB6C+YdNy011jKCix2Enu7P6v00/tHIYPSiHlIcv6p0eaMIm4um+mXmbaZJaBhp59ExVFtRTZ97tQ4 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:(13230031)(396003)(346002)(39860400002)(366004)(376002)(136003)(230922051799003)(230173577357003)(230273577357003)(186009)(1800799009)(64100799003)(451199024)(6486002)(478600001)(6666004)(66946007)(66556008)(66476007)(6916009)(316002)(26005)(1076003)(2616005)(6506007)(6512007)(8676002)(8936002)(5660300002)(2906002)(41300700001)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1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ek9M0c8ef03Xu2Xkjou3d0dlqseIUVdeydfGYFP3eZnW8tiYwjm66PDMc+BAnatGILmZoOfIG+hcrzgIOo0QTIfndPfHYMPr4FgU8ddiWA0PDAy/TQzxkxPOZtDyojBm7jTg34PvzUccna+kFW/kHN0RaXqapbGLafghiewO4ZP9oI4O4mh8PB5XywsOdwQOH1npDUij30SqvH98OA0PwqizjmYWym2ziduz6tF6dqQth/ERADVHCt10GYKaM+jizCZO/q+eik3if8nwrifDpVDnVYZuUngIZSUq886nCLWJ7Z09JPR9L28vkDZnawySRt5omWI1A9j5hYAgc9jgwYpmrl4Tl+nPuoEaxLIuQM7lMs+ebnf5TX9oUZRxzGpcA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a74b9ddb-9679-474a-7370-08dbdf606a08 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:08:59.4601 (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: hzswx0z0+RD3hDW63Gpfv3tUykFrf6zUHa+45QNJx98WMwb+Tc/Pwc6DmwsKRyD+BdaXhnTpaj8kKlVYqQswOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4770 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-ORIG-GUID: -0zDRNirYN3mBN2qE7d5JWtw5Q_69thw X-Proofpoint-GUID: -0zDRNirYN3mBN2qE7d5JWtw5Q_69thw 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 "union mdrestore_headers *". Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 66 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index d67a0629..40de0d1e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -8,6 +8,11 @@ #include "xfs_metadump.h" #include +union mdrestore_headers { + __be32 magic; + struct xfs_metablock v1; +}; + static struct mdrestore { bool show_progress; bool show_info; @@ -78,27 +83,25 @@ open_device( static void read_header( - struct xfs_metablock *mb, + union mdrestore_headers *h, 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) + if (fread((uint8_t *)&(h->v1.mb_count), + sizeof(h->v1) - sizeof(h->magic), 1, md_fp) != 1) fatal("error reading from metadump file\n"); } static void show_info( - struct xfs_metablock *mb, + union mdrestore_headers *h, const char *md_file) { - if (mb->mb_info & XFS_METADUMP_INFO_FLAGS) { + if (h->v1.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"); + h->v1.mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", + h->v1.mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", + h->v1.mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); } else { printf("%s: no informational flags present\n", md_file); } @@ -116,10 +119,10 @@ show_info( */ static void restore( + union mdrestore_headers *h, 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 */ __be64 *block_index; @@ -131,14 +134,14 @@ restore( xfs_sb_t sb; int64_t bytes_read; - block_size = 1 << mbp->mb_blocklog; + block_size = 1 << h->v1.mb_blocklog; max_indices = (block_size - sizeof(xfs_metablock_t)) / sizeof(__be64); metablock = (xfs_metablock_t *)calloc(max_indices + 1, block_size); if (metablock == NULL) fatal("memory allocation failure\n"); - mb_count = be16_to_cpu(mbp->mb_count); + mb_count = be16_to_cpu(h->v1.mb_count); if (mb_count == 0 || mb_count > max_indices) fatal("bad block count: %u\n", mb_count); @@ -152,8 +155,7 @@ restore( if (block_index[0] != 0) fatal("first block is not the primary superblock\n"); - - if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, md_fp) != 1) + if (fread(block_buffer, mb_count << h->v1.mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); @@ -200,7 +202,7 @@ restore( for (cur_index = 0; cur_index < mb_count; cur_index++) { if (pwrite(ddev_fd, &block_buffer[cur_index << - mbp->mb_blocklog], block_size, + h->v1.mb_blocklog], block_size, be64_to_cpu(block_index[cur_index]) << BBSHIFT) < 0) fatal("error writing block %llu: %s\n", @@ -219,11 +221,11 @@ restore( if (mb_count > max_indices) fatal("bad block count: %u\n", mb_count); - if (fread(block_buffer, mb_count << mbp->mb_blocklog, + if (fread(block_buffer, mb_count << h->v1.mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); - bytes_read += block_size + (mb_count << mbp->mb_blocklog); + bytes_read += block_size + (mb_count << h->v1.mb_blocklog); } if (mdrestore.progress_since_warning) @@ -252,15 +254,14 @@ usage(void) int main( - int argc, - char **argv) + int argc, + char **argv) { - FILE *src_f; - int dst_fd; - int c; - bool is_target_file; - uint32_t magic; - struct xfs_metablock mb; + union mdrestore_headers headers; + FILE *src_f; + int dst_fd; + int c; + bool is_target_file; mdrestore.show_progress = false; mdrestore.show_info = false; @@ -307,20 +308,21 @@ main( fatal("cannot open source dump file\n"); } - if (fread(&magic, sizeof(magic), 1, src_f) != 1) + if (fread(&headers.magic, sizeof(headers.magic), 1, src_f) != 1) fatal("Unable to read metadump magic from metadump file\n"); - switch (be32_to_cpu(magic)) { + switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: - read_header(&mb, src_f); break; default: fatal("specified file is not a metadata dump\n"); break; } + read_header(&headers, src_f); + if (mdrestore.show_info) { - show_info(&mb, argv[optind]); + show_info(&headers, argv[optind]); if (argc - optind == 1) exit(0); @@ -331,7 +333,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(&headers, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Tue Nov 7 07:07:19 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: 13447968 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 594EDC4167B for ; Tue, 7 Nov 2023 07:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233586AbjKGHJN (ORCPT ); Tue, 7 Nov 2023 02:09:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233584AbjKGHJM (ORCPT ); Tue, 7 Nov 2023 02:09:12 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A7211C for ; Mon, 6 Nov 2023 23:09:09 -0800 (PST) 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 3A72NoKu031640 for ; Tue, 7 Nov 2023 07:09:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=yuUbVJdFw+H8H16hakY3mw8W8115W9Nt7DeDCcpLW14=; b=KUcThev5T2PokcGwKAg3XP9HSQNHBXsXGM+P8u1A54HrHnRA9d5gbLSqP6owafsNw9y+ qOmw1wukDs/e7a5ihjr9zjLVGxxk0NJyriu5ur5J6jy2jgxnNgdRNowbLZ/tUE94XvBW rIXgtKw7TCQgJuuqUrbVRQKX07tlU2kdFtm/KUxmoa2Ev60YdlHRHFFQXWJ0Sy5iK1Dp Uzdd1SX57EEOl6JwqlWSmWGROIrkyZmAjs0Sb9DJDUsOWS6CbGXxN8bFnrqw8esHdUvz N6AUk1iEGQUusmvXC1lreNucWiY5TWdcwA6ywbWxDkzSfrR78N5Q88Q2yNyV/ZtbbIXE Kw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cx159rm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09: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 3A75xKn0024790 for ; Tue, 7 Nov 2023 07:09:07 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2169.outbound.protection.outlook.com [104.47.73.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1m5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hvk4cILkVlkJCR1QZv7WqG89jQEhzw/ChWwnDuh8RApHHbvsg06ylXL9B2DjDt3uayvHAL177+zsxMC/0bIkvacrzny5nycX+Mx6M8TM58gg6rYozIYQqYHG1QzdqAOiBk3LXe+KqsqA6jr1nVmeeiDdXkLawae4+xZG821kdg4Eh6YyVuZc3bPwHBDyAmxRl4tEE1LZxZKwLKwT8s1tdK4xI66rvbahgHb8eydq+CDrcrBmHB1qsHW6ThzDN6PQy7rhP5ayI8e5XaIBTk+o0A2hiiGhq2XFs1VEieCvFKdquqb1hNEjDHhtl2u9LbnZ5GBVS7skfng+La239k7nrg== 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=yuUbVJdFw+H8H16hakY3mw8W8115W9Nt7DeDCcpLW14=; b=Rs78suiCkfiCMoQVfLhdzpiVw+LC3FA6XckAtLmr/bz5mF1cqgQvgD7Z60CMobCFIQ4jXQm23KE9q5KpXWCFYa561PQgRK8YRyE9qg2a/s7iJk1uIPAhaZDPm9RlwEeSZkOTAbRXRgtQR33x3ngIolldnveND4b4Vw6lMTF/3jH42R3TX/ytedCynh30YZxyzWMRC/kyjPE3F+sq4+vFWymomka2As04du16vpFJOMVr3cwZgaoHXVF78PKR5Q15In+YxinoL78NPw5Kp333JhBK+y0baSmVZx9ACxKX7uIqwXdrCqqwu0AZ4/ClTUIzW4PHAIsZgohaf5YNY1ZOpw== 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=yuUbVJdFw+H8H16hakY3mw8W8115W9Nt7DeDCcpLW14=; b=o3Z0GYgMBkkwEiVW5ynwg5ikfzZOBISwWZ2Amde6MhgMoeyYD5drXI+l8HRwzTCrtub9sSxZlPOEiLWaUqYMeX0NwuiN9urvmbJQVcXWacJmNIMLDyWLj9CQSd+fAgwbv2vzu0JMkRK7BHoOmzhbHOSAB+v/jkBGu9p4RB8CcRg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4616.namprd10.prod.outlook.com (2603:10b6:510:34::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Tue, 7 Nov 2023 07:09:05 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:09:05 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 18/21] mdrestore: Introduce mdrestore v1 operations Date: Tue, 7 Nov 2023 12:37:19 +0530 Message-Id: <20231107070722.748636-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4616:EE_ X-MS-Office365-Filtering-Correlation-Id: a0902609-e86d-4b3f-36f6-08dbdf606d97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mx/d43cC/Bo+PIPJLGnobdxuznFFG1jajGPfJ80KXhy97Ziigb5K31IpciGFb6eak1meJNX4EEYwOLjbjD9EkTQJ3piycRun36FKDof5NH642SwIKHI2gyKqJxWQdC41ebPn4+yfTRVhVDTYcg4tVooyrNX1jaEkohP12n08SGqlLLOqF42QpqWP546e+3ltS+c2cePF4Bo1IKAGtqwHfkdBk+9b5PMCFBn7DFqH6Djez+dR6+ikMQJe/SGRPcHlPmOPAunTJSaalPINiKbtUM2l70i300eRIXPpUppS+mB/ATl8MLKi2Xbeccf8sfe21yozOge5+/xB/C9AagkFx9lhlOXxVve9xvjc5dF/hR1beQoxPrwngzuqmsifv5ajdhVqMp3l25JjrCdy1nLfhiqcJRVWvAXDrulgXcYNxMC3W4vSaDl/d22+URow3t+b4DWArSejusbSF4B3BSW3tow+iAF3BTtsCWZnHJw4wEwVTIQAaNs3376VoiLexKd5XypKFR+olR/RQZ1h7/ujw+FLyydXzsz9xjRF2+gCJmPHukvH6K8kEawynzH87h3VayNf26ne724iJ3qZMG8UcUpr0Vr2d+86I4X9My/DTYehgewssKwahIISgtwLdamW 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:(13230031)(346002)(376002)(366004)(136003)(39860400002)(396003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2616005)(41300700001)(6512007)(1076003)(8676002)(26005)(478600001)(6486002)(8936002)(5660300002)(36756003)(86362001)(2906002)(66946007)(66556008)(6916009)(316002)(66476007)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yody4murA+nPbuI9fz7f6sMEwOzabILcy437tD0TfvEU+sxXOfu2vwlfsXIUVyQdcZ4k8kii7muUSS37DQVX2axhdiT0eHNYPsiR6BOl3/RSyWR/HARoR/qQE0JLSebkLsL4u5aK7uvC1K8whQYzDnY1w4FcDgcXLyHc/S6WYMEAQQ/kf2Od2+EmwdRZEkZNJjxe5q/n9UZONNlnbHO6FjUTRBuOhoeakJ1SAnAEx4TtC3jvZD7hH1NKCfU1mvfzCzYzxfWxSPIqvxtLXIf4ceY/HDQN6N4f2+ImrdLuvz08EtFP6ZR1amuTLpRjl0TXaOyHtfSwByEXf2w1Y0tiXqB+6Lnmw+AQAgzzpEB9cvrDTHjsn6ifFH7yT46cTkpChzKS/xabmm8SeCrZzu8o9PKg1/jABEhQiUIbe3Nwx8n0dRh82m40Fjz77/8FbpD6/6BtIn5MEaVW+FZn8zLwrX+wtfBYdBYwT2qGnZJhLIgN8KjVlBrPRYqT3ql21aSnsGbCQ6wF47KVuI/fAwQq369TEW18sBAAZbcaPyNhy2bodVK5wQWvOF652kkD0HKKSm6IyV/i9cn73MUdUoFbdocBUg62vLObEZmq/A8X3rJUIVywyPF9iTTOO4FDZoinE9tBYzd2JPQ5HUdOQh2kaejOh39iVSz91IZIxqw1IaAB3A03LSQC0IkLo+Nz1U26Gfp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wAbiaLLHyWdKRHihmMLus9bP5JMLoR072iEctRqITrgw+Aj4ucuv+k39XJZeD3vyETaQ0jOR9meHdFs4YAce9RwgQhXeC1Ik25NnYtg4xwiJV9eJZb3wLpiKFQX+T6fiIvNKdq4q09u5rSh3YAPFwo/6DzUdUt/YU5Hajz+wNbHiRh+6G/UYYCDmrtICdWexPHL3yJYxr7B2qRwXjGLkPmaRBQ3pubhKi5+WNngPJS38nK3DziH6IWqbstmXh6ypttALl6i+YeUnL0gur82SJAw0ADT4qW7xu5tUBKqFZtrV/+aZ4B2lgiW/RpPyeS2UegGLJkcDH1FqQiTwSLVESPDWiiAV3UfJbKYPNur6u72RO5AT+4AKaAmZXTm/jCbcm3QsfFg7sX0GqzF8uDO0gdhGnqiTTDkylZ9BokM73EHsQP+ao6mpdEY4Lq7z53gyl9wqmPyFUYNVgabiP1zDgl8o4GcgF2pKbMQ7s9SUXuQCxoJlpDd8+FqZGEzJFDlol7Ygs8Ks8plG1Zqg5Yc8hAuJ/bMA49tlHwZal83AZbTslnuoXjJge8wzzKBuSn8/hdMcYjtOM6021BgygdAraORJvGh3TCXYmhWqkWqJm9J2RgCY5/8czSih9oNk9oGVeGkLWj1eA3hCD3OjJbghdRgrQ406VWGp8BtIUFDkpYFbMVmTncmRLQ02IQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0902609-e86d-4b3f-36f6-08dbdf606d97 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:09:05.4121 (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: PoQiTiLAwcozZU1q+LUoV2KrJofn4n16YIaKuHZfcl9o+vRHElxCzvo6Ym3qM6yD0Sf5J9sdH95vj1sV7tUDUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4616 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: wwnGtUWxkBbpyHB1qXqlsmDFle4gPDi8 X-Proofpoint-ORIG-GUID: wwnGtUWxkBbpyHB1qXqlsmDFle4gPDi8 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 40de0d1e..b247a4bf 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -13,10 +13,18 @@ union mdrestore_headers { struct xfs_metablock v1; }; +struct mdrestore_ops { + void (*read_header)(union mdrestore_headers *header, FILE *md_fp); + void (*show_info)(union mdrestore_headers *header, const char *md_file); + void (*restore)(union mdrestore_headers *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 @@ -82,7 +90,7 @@ open_device( } static void -read_header( +read_header_v1( union mdrestore_headers *h, FILE *md_fp) { @@ -92,7 +100,7 @@ read_header( } static void -show_info( +show_info_v1( union mdrestore_headers *h, const char *md_file) { @@ -107,22 +115,12 @@ 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( union mdrestore_headers *h, FILE *md_fp, int ddev_fd, - int is_target_file) + bool is_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ __be64 *block_index; @@ -245,6 +243,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) { @@ -294,9 +298,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; @@ -313,16 +317,17 @@ main( switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: + mdrestore.mdrops = &mdrestore_ops_v1; break; default: fatal("specified file is not a metadata dump\n"); break; } - read_header(&headers, src_f); + mdrestore.mdrops->read_header(&headers, src_f); if (mdrestore.show_info) { - show_info(&headers, argv[optind]); + mdrestore.mdrops->show_info(&headers, argv[optind]); if (argc - optind == 1) exit(0); @@ -333,7 +338,7 @@ main( /* check and open target */ dst_fd = open_device(argv[optind], &is_target_file); - restore(&headers, src_f, dst_fd, is_target_file); + mdrestore.mdrops->restore(&headers, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Tue Nov 7 07:07:20 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: 13447970 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 39FB3C4167D for ; Tue, 7 Nov 2023 07:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232365AbjKGHJ1 (ORCPT ); Tue, 7 Nov 2023 02:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbjKGHJZ (ORCPT ); Tue, 7 Nov 2023 02:09:25 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 417BC11D for ; Mon, 6 Nov 2023 23:09:23 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A72OWIu021822 for ; Tue, 7 Nov 2023 07:09:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Utm5Lvcd+DgY9K4VopJp4jyGdtSR30ppD5dN5Gzx6HY=; b=c05fgVMCQoylVBeVtWWeYbYsfxH3/LIZPvaVS1pW23I6UBSAJj/5+1XO3r1C1Nxc41t9 6f9Z+aDDbmp0kVcWrEgtRn1dLB8t3jV/sXDVnZkufIiEZosTrZZdo2InLjhKEt4pSXjR p/NP1sSkRPK8BvRuVyGhsDc1yBTD0MYt5e0xjZJ0prxx+9e4qS+l5RC/Ru2pIH9e686i vw/raWEtOMjhxC7/9DLI2vqoOBroe1Oj/9RJhEDQj5/fwnatqqzpSyTaEw+ZtFsq0yAc E24r3ErSoZTPG7PX5qmy/x+zM2yUuTgcq+bSmhSL3BH0SpvR9XhgCrXeWDu2mpTtCXBU AA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5egvd8ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:22 +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 3A76AfEx020819 for ; Tue, 7 Nov 2023 07:09:12 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdd1x3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLi6TJX03ewzxjLCnYhceh/BIuVsUNagizzNsaE2Ag3X9m3ojr7pp4eoSpLT24islGvu6Nfq6dXWjl6BJHcPoZZDE1HPffyELAwS/EdmgvGUp7cZ71TqzPJCdSs6xiHYoNg8XFzejs92Kq6UavYkTHrMbEs3w0EZCHVQbqv/28o0beqLThhKvx+OcAPsNE8FZTx6g8vFHV/O9ZnuF5ckOJhMjBD9z4TCnR75OIfobHZSmf9+QZ9xZ59iaaXHL5zsjUN24qVmrSJM0ZFAyEMsy+OWV6sik48H3tujPLmftkgYNMx/QRoMoIxItAgcAjGVGFwZ49+AeMilIP8fO7kCAw== 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=Utm5Lvcd+DgY9K4VopJp4jyGdtSR30ppD5dN5Gzx6HY=; b=AG+U9i1TkncdLuIUieq4Vum9wrB2pvL9gxaHY1Q84+QgY65mY/cns5V8BbrSPVpejhoJmt0AA7seQREsqFqFhjZx2QLOFq3hnJzqThR23s9yMmMoeVWblcQo/KaeDiluoVvQ0x6k97JtJjhO6OCz8O6ZeO+M0GY9AQf5UFvGOyYVCnja04VPZAWSvyQ67it7JXXGG54+NZ36t0CG6y9FjvCxazyKPOAGuj9IbRRAw7NuNLxq2ieNiDDfSuZeV69jJEFaqnzsRa/kWYdzdEPtahzQupsHeOk0yeBbrDRYYGyu6qyvFs5wKCMTuI+0O7s1epTRv+nG9bO36+hVSzsoWQ== 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=Utm5Lvcd+DgY9K4VopJp4jyGdtSR30ppD5dN5Gzx6HY=; b=TbWPd05Xhd37lYAFYkUZEQyzKo3pnvSwEaxPK8CwkB+dHyXNOrnkX1VAu0EeqLR8HtNan0lsJP00yFT3smHyWi1v0JEfMUhZ8kM3PhIn0OlvUN9zfloR3UX2vwwvbxn7ooqVoABLnekgjnzQYjvwpCUOS1Tmp14XWDKVu8rFcMI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4616.namprd10.prod.outlook.com (2603:10b6:510:34::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Tue, 7 Nov 2023 07:09:11 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:09:11 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 19/21] mdrestore: Extract target device size verification into a function Date: Tue, 7 Nov 2023 12:37:20 +0530 Message-Id: <20231107070722.748636-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0042.apcprd01.prod.exchangelabs.com (2603:1096:4:193::23) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4616:EE_ X-MS-Office365-Filtering-Correlation-Id: 43a49e1d-119d-4504-7280-08dbdf60711c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qYCcaUQwibljWfkEd9us5twYa27Ih/WHLd47G4WY7Bglhf1pfFjbQWiwy/MVMJCBRYCd5U3cw09lHa0YF5q0oNXkN1s1VK7Kri9Dr0Fi6M0MVctu2H2O21VUxM18RJivPCGMbUyhNFeMfGulHIzgAUD82N4Iw1FWmvZouL/LkoI3Ishu1KIsjiguzza+cXDRRlBIyUBG5Zjv/j7hmHIBmVTG9DmDYChb0nfLqrEErJHsBMJpSr9snTxRIhdV7ruPQeNwCANf7Kv38r0wcVglOpJpoYRs0ACtFPZQbfRX3uv7+/z2l/ayQezbdlBqN118fF60KjUPIheLuPmTqNXDn5c9FjWftMRf6GW//LWhS/STl3/f2iWoM/PkOZm48nqtQ8LTvpq80iOoXyrEOu2taDGe83Q4Vpd69yM0thZkrRD0fWNirsoftdml+majwItJZ+hstCUSNMsGc7TKdd2y9DuiVanjwuFIPNvY6cXmq/fLOmWwj6dJIttEhsys1cwxQ4F4wV2p/T6z/ezgbi0msOn6AKIPpFfFOrcCUk2OseS6ja7plDqHMVTqfsijbi9Crff8PZ3pUm9W/KDi8w09SqDPXcQ+GWCH/3XLRUi3sg3D8kozUQI2+5PMiVfzEQml 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:(13230031)(346002)(376002)(366004)(136003)(39860400002)(396003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2616005)(41300700001)(6512007)(1076003)(8676002)(26005)(478600001)(6486002)(8936002)(5660300002)(36756003)(86362001)(2906002)(15650500001)(66946007)(66556008)(6916009)(316002)(66476007)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8S3ZgsXxfffAK6lAYlWDodyVESdqu3IkJjPy9CNDRiWCefZWm2t31OFlK0PgU4frX+mcFKp7AeikwX/kxsVu4Kpcr1k+f0q3MODylwXaH2hT5C73MeSrU2/iKjq2QbrkaTbD7ZiJFGhmR/si89jwt3Xogyn48AXo9jAUkDeee6qcRlsg4v9zzW295EJYl7Wfsg9DuQ8brbiMFCoCHFi4d/CfrFblHzPR1CbOlJZL2gJyWEwlfR/u6Ux95Hqa+QzL8A+RDu81IyfOFK9XXvXsEUmoW6vsBte4p1W2I+8ZlcV2yXLfGLsgq/vPt+dLISoBq+wOdMJt2U5RMdS9q2DR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-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43a49e1d-119d-4504-7280-08dbdf60711c X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:09:11.3603 (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: 7gGH7rf2rudpST8AHNnIcu35rpLi8q47QAugNUjXO3yqm0Kqi9KUECzQ6EPuVtpqTSl6NHfvRzIiWlcSmCt1+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4616 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: 7XQV6db35m4XxiZgNlQs2wQf_cvQxYky X-Proofpoint-ORIG-GUID: 7XQV6db35m4XxiZgNlQs2wQf_cvQxYky 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 b247a4bf..0fdbfce7 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -89,6 +89,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( union mdrestore_headers *h, @@ -173,23 +197,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 Nov 7 07:07:21 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: 13447969 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 524A3C4332F for ; Tue, 7 Nov 2023 07:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbjKGHJ0 (ORCPT ); Tue, 7 Nov 2023 02:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232365AbjKGHJZ (ORCPT ); Tue, 7 Nov 2023 02:09:25 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF29B11C for ; Mon, 6 Nov 2023 23:09:21 -0800 (PST) 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 3A72O4CH019476 for ; Tue, 7 Nov 2023 07:09:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=sqOwC+RyZFn89xG5KtO7LiO9XIHVEfyYm4Pil0jpylKnqVdt3ayACJQZuqO9uZ4yrhu5 ETde7GpmksG5rwHz/3p/w4CM/2t3jCfYvDkX7NcnhPHRXJLVgm4e15u/p2wtg2z8FQLN W67lkAzQ/43UMrqpKfi6kxMcTCFc0feu5B7mapDIXLpxI+HeHC//RC+ldkQ9zgErb3bC wFX2VHtNoNJPe0hzWOT5DAnIfFQbWsNLEgXcNW1aJV1Jsv688GXBeLyyZZjE+ywHZQwg wuC0c4txauOvfc6Ypf0OJomHzXjdekgFG5B7LJUjxG5DtGW7i7DTFIRm7BjOEqeLaEkE wg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcda2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:21 +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 3A763nu6038284 for ; Tue, 7 Nov 2023 07:09:19 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdda54r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0dMsr4DcEQK31+Ot8ma2MNED98A4gQZEZV+WwCRWVmOryTaerWZ0P/CH4lhEUniduL9XQyWpBWvm/hQGlz1xb26Ytdnlc29mLW3EJOnlE4Bn5ZJoG2+Vv8RPrKVL/0f7QYnd5DLaD3JcAz3a1sPEBETJZp2+U9ag25l97klp9Ye6XqPTmeQ7JZg4JkGUzMjEZbuv7JJYJNao8LjzLdKb9qbr5PyarMaYwIdjUU9J/6eoD6Bap4mLHyAFDOuXxAcmlB0KDBBfE5yoGTomy/c217WfwP+bYnu7XArL0dY+1zSPr07pw4bqaYZiQfYcCcBwWHZtuSdCfljp6L5+Szb2g== 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=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=Ala8hHWVe9RtFTIj6vzd300Qv0F9JR3c/SwLO8MnDVGuDgxFxrVDn7s2joPkG0MtWRLCLrLjt/xEO/vSav28VY1QO2wgpQMZmHilmLxecvZofKN0HVisbZOQUn08Uucw+I7Jhq4suVMoqqfiZi5iwTY4LUf01u1PI0W+mhQ8+tOzh/gZkHxuI7/DEW1KM9P2DyZvqxNxxk/6bqmEJiCl/xAkFpd8SWxaFhnPIqVi83tteiKD+OwzW7u2bT7U832OaYvcBhSHUuiRyvphpLqkFI+OTMHV707HHaadN7YFBQKFhVUW7LjsLgQt0BJ2JGnRPdkEQKdRGyspXjfxG3ZuSw== 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=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=iiTLvUfe8I7mtWLPOnFQ5ralib/vfwbZJLnrjkC2XoD5SS2lwuXzP/SYJhj0SoeGaPKxL8WGCWOmUq5h8urx/cTGAXNuFqCqwuZJC1QjNAmI9Qb5dAp6+qwgwbuiXk648mJ52I/1W4jR6tPSTPBm5RwnRHqOWr8Rl8LSMFCFbDw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4616.namprd10.prod.outlook.com (2603:10b6:510:34::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Tue, 7 Nov 2023 07:09:17 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:09:17 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 20/21] mdrestore: Define mdrestore ops for v2 format Date: Tue, 7 Nov 2023 12:37:21 +0530 Message-Id: <20231107070722.748636-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0037.apcprd01.prod.exchangelabs.com (2603:1096:4:193::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4616:EE_ X-MS-Office365-Filtering-Correlation-Id: f14e2fa9-a5b1-4d75-6de8-08dbdf6074c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UC6LCcpmLWz3InhO2kUwAk4Rukjq/BE6wp2Siejczzg48k1SOQTGRFcQGy6AeNTTj2YeCOGGKxvzRZxA0006edZOQPfuHg9ACQbxJiwK6iQJvHICUkm4Os6zuBMUIO7xDrDN1RNvGrd6cQE88Qkxi+stDR/wQmxvXf6RviKcIvkbSMzoMcy36V6vXKqYV7EChKdW4P11TXMsIK8uzwdmS1oRVWAG0KQTwn99poZIsMkp26MTsZfWutEdNWCCqIqICyBcQ3DzJhL+A+cBgMCHb8C2hQn0UeUFg0VN7TORYnLKXHM2++zGscCA/8QEG+LaVVUI5loPFJeauSXMbMVBafXWeHqP+NkjJvdNks81JDf2LvlTqZqWqwf7kWEmZV+kMxV2MTUL52DE5y3zupkFK0fNcYTjZnmT4MjciPJ8/97J3hb62swvdkYJFtzgJoXpq/ijqQO8RSnhShFLgK/khp7kO3sGM0ThGzdDXV98Ctqsc8hkIiDCzE4qfCKnL2YvMTaDObAQ2SsVujAGL7eCp3caFZS3RtCgaLYr56myu5pAb/8XmA0kBIZx4XnDe8MOvRPcnDaUK21EUl7cglJTNVF7UMUwn6S4ThHFt1aWU1H7820xvhr0VqeNLeWGdF2x 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:(13230031)(346002)(376002)(366004)(136003)(39860400002)(396003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2616005)(41300700001)(6512007)(1076003)(8676002)(26005)(478600001)(6486002)(8936002)(5660300002)(36756003)(86362001)(2906002)(66946007)(66556008)(6916009)(316002)(66476007)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0GqEfq+PiU7sfwCcwHUNFdqnqmTv8mGGTG60Hw0clWeCnYwJqtOsRV8/BeK4a1KNlXguv3t/pXUGb9OWSFt80pQDdTgD5F570dEeqyYFg7vTtFT7qgMFHYVVnHXMLud8hub7Qzp5ouiy+NoR5NlwpfdgmURk9RC7JC5dOQ4Fk6LE5Oj2sOakxv329qZTK098jhz6pBSeZSO4x9VbS059QrgIKs7MRjSB+A6VzL+7dmKPmnIm5N0wNPyhp9Y9nDpaxwAv11n8/eDvuIL8bTMtANytZzrrHTONVmmRkDsiV2Q/PTXX3Gj/Ns9b6bGgbmtmDAf5M+Rs+Fb9dzVodWJ73BOyKvEsRt1uQQ0hvSImZQ0F1VlYvEPGD/oDCHLTrVV2Szoc15s5G8uTOH9zPUHebWEsXwxB8nU6NSbeY6jKGoiyH/JzEPuyvJtmurBeA+q3Xbeur6vP1iZAMHWxuGMGtRIpZazDh5jMwoWKKDLHBmd1gWDtomgn0dl5cyfoPiNBeZ77zV0GK/bOhlejFpYykJ8sG+KhK5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== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Qou9m0mSnRQ/vcPT4V56v42pMtGpw5OPdRh+xp1kWHBCMyttKsu1l546VQQl+L850UsSAZ6jIHY4SQs7+YmeKmn7bIa2RXVejKujxq/+38z3bLG8/I15vBKcvEMJHDFAiMIXhE3oifdlvrP/UO7ONw96QQCe3Y5fCYmuxl1HoiAGD1fI38xhrTYOyf8t+ujwWVzJhBm4l0reVaJ+eBEf2HeMePbmI0G75SAhCNTAPx4L7v0/FbXhAju0blq0Hj1mZcV+SU5uRZsud8pgMRfDdvkfAc7BiQ+5w8y3T/3tIfI5kdKIhrBDLHyHR67Kkiih7RvD/rGPgYTBEwrSQnzN8XAqA3zq/cHnNUjX74FSWDhE83HdCuHX7Bokr2lQmbNBr/08GIlC5yELZm4g0sZ+e3TpXQ7KZ8ofXhGSXhx2V+HYHyGLdlZp2c29ZpvBGqYrG+YcJcgiqScMPRQQAZqgWcPpKMW+JuymP8l+jV1vzBOKg4faEePr7/0SOxljil8uztks+8QkvVBkoZghRiSJFgQ3prbR5g8u4Hcc7srlx2jGeC8lVTCxjJXhx5GlWgchgMhm0Uv6GwctT9bbrjLO+Um9j2KG525tyxEoYdByrlpW7FItF+18UGOQMeJp5HLKoYa1EkyQYNKk2JBzaaTpBt+aa/GMd84vD4uQ4nkKNVyrD3XVtXNrUgok2e9eEV3Y/pI6Ma5Gsf+6b0WzhpINJx/HE2Y8yD4Ml/PTYsIpg6o8AUMCxBzfltZOXDfDIsN7QGPXB36QJrtSyuYy5b9Zyw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f14e2fa9-a5b1-4d75-6de8-08dbdf6074c5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:09:17.4757 (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: Xi1cuuxS9Azm9C6TM9IHgBOXqgbmPQau9BlBuBIqaYT1IhYWiJTfILZV2u3sa/9CataYnJiXdguoSA7XwrzeUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4616 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: IrPfgt-xz9y63P1nOEpQ7aKWZcUki3RK X-Proofpoint-ORIG-GUID: IrPfgt-xz9y63P1nOEpQ7aKWZcUki3RK Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to restore metadump stored in v2 format. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 240 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 228 insertions(+), 12 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 0fdbfce7..105a2f9e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -9,15 +9,17 @@ #include union mdrestore_headers { - __be32 magic; - struct xfs_metablock v1; + __be32 magic; + struct xfs_metablock v1; + struct xfs_metadump_header v2; }; struct mdrestore_ops { void (*read_header)(union mdrestore_headers *header, FILE *md_fp); void (*show_info)(union mdrestore_headers *header, const char *md_file); void (*restore)(union mdrestore_headers *header, FILE *md_fp, - int ddev_fd, bool is_target_file); + int ddev_fd, bool is_data_target_file, int logdev_fd, + bool is_log_target_file); }; static struct mdrestore { @@ -25,6 +27,7 @@ static struct mdrestore { bool show_progress; bool show_info; bool progress_since_warning; + bool external_log; } mdrestore; static void @@ -144,7 +147,9 @@ restore_v1( union mdrestore_headers *h, FILE *md_fp, int ddev_fd, - bool is_target_file) + bool is_data_target_file, + int logdev_fd, + bool is_log_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ __be64 *block_index; @@ -197,7 +202,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; @@ -258,6 +263,199 @@ static struct mdrestore_ops mdrestore_ops_v1 = { .restore = restore_v1, }; +static void +read_header_v2( + union mdrestore_headers *h, + FILE *md_fp) +{ + bool want_external_log; + + if (fread((uint8_t *)&(h->v2) + sizeof(h->v2.xmh_magic), + sizeof(h->v2) - sizeof(h->v2.xmh_magic), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + if (h->v2.xmh_incompat_flags != 0) + fatal("Metadump header has unknown incompat flags set"); + + if (h->v2.xmh_reserved != 0) + fatal("Metadump header's reserved field has a non-zero value"); + + want_external_log = !!(be32_to_cpu(h->v2.xmh_incompat_flags) & + XFS_MD2_COMPAT_EXTERNALLOG); + + if (want_external_log && !mdrestore.external_log) + fatal("External Log device is required\n"); +} + +static void +show_info_v2( + union mdrestore_headers *h, + const char *md_file) +{ + uint32_t compat_flags; + + compat_flags = be32_to_cpu(h->v2.xmh_compat_flags); + + printf("%s: %sobfuscated, %s log, external log contents are %sdumped, %s metadata blocks,\n", + md_file, + compat_flags & XFS_MD2_COMPAT_OBFUSCATED ? "":"not ", + compat_flags & XFS_MD2_COMPAT_DIRTYLOG ? "dirty":"clean", + compat_flags & XFS_MD2_COMPAT_EXTERNALLOG ? "":"not ", + compat_flags & XFS_MD2_COMPAT_FULLBLOCKS ? "full":"zeroed"); +} + +#define MDR_IO_BUF_SIZE (8 * 1024 * 1024) + +static void +restore_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( + union mdrestore_headers *h, + 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 || + (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) != + XME_ADDR_DATA_DEVICE) + 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)); + + restore_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) { @@ -270,15 +468,19 @@ main( int argc, char **argv) { - union mdrestore_headers headers; + union mdrestore_headers headers; FILE *src_f; - int dst_fd; + char *logdev = NULL; + int data_dev_fd; + int log_dev_fd; int c; - bool is_target_file; + 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]); @@ -328,6 +530,11 @@ main( case XFS_MD_MAGIC_V1: 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; @@ -344,12 +551,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(&headers, src_f, data_dev_fd, + is_data_dev_file, log_dev_fd, is_log_dev_file); - mdrestore.mdrops->restore(&headers, 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 Nov 7 07:07:22 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: 13447971 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 ED8E6C4167B for ; Tue, 7 Nov 2023 07:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233584AbjKGHJ2 (ORCPT ); Tue, 7 Nov 2023 02:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbjKGHJ1 (ORCPT ); Tue, 7 Nov 2023 02:09:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415D411A for ; Mon, 6 Nov 2023 23:09:25 -0800 (PST) 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 3A72O4CI019476 for ; Tue, 7 Nov 2023 07:09:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=aT3xEat0EPPy+OzNeMXaoH+ik1wN0Duv6b2rtzAixvyjWnQpR9SEWvRFGBfXPs0mjie7 jThb8Y/JzYO7Zkq7eZn7c6kHFhX9C2z0wdkwq2Ju8Bt4/dfflCZfPp4+lkAoCdnqRbrR vHikezaVfv/wNjpddtjbc0j5R12RM+8v5enTGiJFVoR9LtPDFE6O4Wv7XarhcyoBsJ7t fJKrq+XvnMtnc7V8pZ5kV20Z8oE7pVwiDURLUFXIDxMIee5oL5vCxVXMemfjPaDQ7Vs9 F+OK9qG7an4T2KIgENPeX0/8wvI3x1rO09fWueZHoNPlxoQ6cF1fpJ503wg9YgD0s/n6 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 3u5cvcda2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:24 +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 3A76TLq3030408 for ; Tue, 7 Nov 2023 07:09:24 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2100.outbound.protection.outlook.com [104.47.70.100]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd63gfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 07 Nov 2023 07:09:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AemJM02ADozTO6XaZTtjWbGYslJEEBKfH9hyxpiRs0DhjI3wKyCt/mOQMNU1fO37LzyaYpyjwkATdU+OU4Un4/4Qaq0vhoPza/ONGSTR+bgLP2yL1BikABCoL/uqyy0jsyWa1HZa4ndlQYD/wUkHIEmd+MLVsn+FlsCmNWQlqcPhlq2AZfE9zzGSiWifaIY7T0easVjIv+Vm0ZGe+ofAa4+O9BsL8Sc4b7n8ebH/AbFICAYCnkX9YHbiHdwGbPBupedT/GE2chblcluQ7K1o87D2ocPqmbBb+rab93dg/Cos2BoO2eK+BTAafBBcDrqB7WLcLK2wejNNgsspZdzU4w== 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=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=LACWzl06kyJweY/6RkCbwxDfjFY0dnQ3jEw2VMVT3YnPbTxynvINNvs1briGOFP9vINYkZsnH/pOU4XvCRbVgDrOWoRRqs7ageoguRgSc0IJu0RJ406Q1zKahEj1ZoKc+1mqVU4Ctun0SNdbthXI6f7PzNx9gNMMcmxE7IjI86rCxonfkkxysTAIboyjqrnHefGN9zayAqn47f6v8MFW0wWjNiRml0rfMoZbeeuR4of+ApGEvuraKPShaKvPVcLjvU8CkE/hsQ4nDa8t7p5/2NxNoEhsZQHW7kDF/LvapGPiIWWHMqUgdK/NjvPHDddLNtC4xLRBxWVW1WEpvwCN3A== 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=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=dEEvc4NeRdOeRUAB5thJNTJ/SHqEQjktUoagaBaNU2gYfp0VX0J9XDx+RCln3CYSRPCrOJYmdNKn981jXyAqZ+jt3WotjlMkd0l8hTjxnaL+XLrYiyyl5lHiAY+EY4gU6xyZ8uO17Uy5AKPBV7OBivmR6yVr4hWiyo5V62wliIA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4616.namprd10.prod.outlook.com (2603:10b6:510:34::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Tue, 7 Nov 2023 07:09:22 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Tue, 7 Nov 2023 07:09:22 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Subject: [PATCH V5 21/21] mdrestore: Add support for passing log device as an argument Date: Tue, 7 Nov 2023 12:37:22 +0530 Message-Id: <20231107070722.748636-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231107070722.748636-1-chandan.babu@oracle.com> References: <20231107070722.748636-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0044.apcprd02.prod.outlook.com (2603:1096:4:1f6::6) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4616:EE_ X-MS-Office365-Filtering-Correlation-Id: bde2fe78-26b3-485a-6223-08dbdf607782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8r+qT6OiyUt+aArO+Qpn46E1haqSAxu84Q8z1v8eNGSnFddMx19KdmTCV3RTMY+SKaDdGRPLswOcuSpGTwB/9IDboeXjJlw8gndmkgA3c7o097/Cd/+zzENmmn02X3kHeYVtQHt+K89Mw8MvCFTm8DR1fzs1zYzSlK4DPeKKR9yapD6rsQZLJv8EXZegQFrdycCt1O77uAihRXo2AyDd+vh3eWu0lWcivz9MMlKw0INpQlathsISiqOx/+8Wl3/6YJAvs3w7PTRBZPgLL+AVaFk0EuzcQGJZl66dSwm0677ybQ/yizhZlHbV4Kfrgq9SZl6h87G5omaVoFEZsX6UWFWTULSqZ5MrgVK0tqZ0NXVHQeJXmZ1jGFFSobStFVPB7pVthNWpScThaGSbY8cH/JZEbhXhjKs0RfGmOoyxXWtscfDX/gu1iDoNJseSb8j7FQlKEmg+G20CiDK5olrVhJV1cuW9agLzL0/kv6mwhFIDSWe44mRNethlM1BTcHuODenTCGN/Z6x5NpHpgFa4wF184QoRRguJXuLnIBADOLEKcVKm93o/NO5O/u0ldr6laSXGEYOBIvAA/NBnm/eThKLnX5w9arHecHFITl3WBjp6Gn/kAN316n8ENqwApFbN 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:(13230031)(346002)(376002)(366004)(136003)(39860400002)(396003)(230273577357003)(230173577357003)(230922051799003)(1800799009)(64100799003)(186009)(451199024)(2616005)(41300700001)(6512007)(1076003)(8676002)(26005)(478600001)(6486002)(8936002)(5660300002)(36756003)(86362001)(2906002)(66946007)(66556008)(6916009)(316002)(66476007)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E83BoWOHaH/NvOMas1piKu7Pm+CwIoJK/16+8hqKBSJNChUL+3pM/DWAf0KuYOkjNlsrwuwEDy7mn9ReeK7OM1u2gsyiXt0CRvLEPhy4bw3kPJySrvwBTVFM4sXXJmN9SfCf4mK/VMRwGKN0AhfGlTLxUutUMMU5s3shhw81yjn0+8aoiiiS68CLTMXLa/gS2RscLDmze6pJYRdMfVp5WCkbzTEz3qwbr/ydkB30wurDcWXe3onnnqGDYIi2aMoQsSEq14Lj8tIkPCb/iI0VCeRjLrR/LN+J/dvTnuL4lRRBhA+OttsmpgohucR0PeJfsE8Decrn1xlrH2YcLsGjwR8wI2PXJo8TeP0RrOgjwy6BymKvavRVS/+sHIeTDJqXAMdOMi77eW86z6A8FDm4uJn4biQaGa0aNv4GWshr8zT7EsXuHGuxZ1FSwHsssNLH+xPhXScgx4gJMPtFWrpNLxcQAmXJPP5BfEtHLqygQmtclcPOiyt/7L99gCbtOLKnhMaryAR/1S5jCSHRkARr3NQOho3pkalD4jJK9H1+LIlZGAofVe1fu8LXU6j+L23QWrKJe4q9IcQsiS2I3VI7gusmDS2n+gkBNo+wzs5+hOrDsPB+k9UhCc5IYAyqXBhGfRO7jhNWnW4jlQAUP7jtpnIfsrlUbuCq5ez33VtSFSX0OK0uK7u6ZRWVrb+ql+Hs+oCfOjUEBbk/AXCL61JE/9qsS/fXdGCwhBKC8QUAm5YzxeKvhi6IEBuZgAT0k593J4WEtvLyV0iymvHornxbikvJVqXcG3oFSE4veOJKFuEGTZPO2N2nacbR34EwnoLMqXxPnN5dHG+poSbucSFsqY2SWRaA5ifS68OUDB2mW36LeeBS5+AE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6k4WSWYDdKZz0ZUFvyuScAeCV3DF01+7ymcIHAiz+Sy/IZQ9IGMz/snqtM6IIFeUK063ceO8NvR1RnORYhp6SDj4+0Nx4Ys3w3HjZ8cNfopiLaaEcQMir6rZsEprQEbUYG5CdADtcC0wrzvuimjj4s54VR4pt4+ySGe3AOGBsB/n72Mumk6RgVGZ8J6I43Z1QIEgQRfSsqIR2lD/dPpFVBI/uHopr5wGLz6plhNMCiPSbsm5PwSZO3aKBR0GAftn/Rx+Dbw7ft9kE/uwcR3yoP5+TWi2H5uBG68k6aSI2dp88Tqkh5Xqw6gon4B065JF6hafFcOXS6HHLVjSguubINO40fqj3qoabwgvrh12UEiIHpJ1vyle7gO2uBWcmxIn8/t9l16iR2pd8qEqGo/+EZNSymL9q+os0Gjh3TfKdFkEQqnASBuU4URZOS+vN7HRQIQ3xYe8vbo8yU0aaIvJYYKHC1U/OsQ2wtqMjIEgI0Qtg7A5dliwz5nwCenVWJtDGsldRkFAPQZTmnA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bde2fe78-26b3-485a-6223-08dbdf607782 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 07:09:22.0701 (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: gJrec2MA/e8+7ht5qcVQKhutR5soXDF6YMm5lz/jEJWcAuDI3YYt2MnBupGrvcRxabk8kOKOV/M4r+YxGFXBCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4616 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_15,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311070058 X-Proofpoint-GUID: yrvjNF-FqvQx1yZkOz1m_MaqIsInGG-_ X-Proofpoint-ORIG-GUID: yrvjNF-FqvQx1yZkOz1m_MaqIsInGG-_ 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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- 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 105a2f9e..2de177c6 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -459,7 +459,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); } @@ -484,7 +485,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; @@ -492,6 +493,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); @@ -528,6 +533,8 @@ main( switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: + if (logdev != NULL) + usage(); mdrestore.mdrops = &mdrestore_ops_v1; break;