From patchwork Mon Jul 24 04:35: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: 13323418 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 1F48AEB64DD for ; Mon, 24 Jul 2023 04:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjGXEge (ORCPT ); Mon, 24 Jul 2023 00:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjGXEgd (ORCPT ); Mon, 24 Jul 2023 00:36:33 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74F501A1 for ; Sun, 23 Jul 2023 21:36:32 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMWMor014874; Mon, 24 Jul 2023 04:36:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=KtHETe8WwNkODnPOzBR0jxQqULzrv1kP8B+eDQyw965a0CfwzBnd4M+gVFiVwON0ak3B DY6W5bAL90eBMrcS5Xvi9GHKYcPxriymhgpVsiAbJRkot6c8OxeF9edpICjOBZxJeYXK NhWV0s20DYztQE6Oo/Wmruh8IJ3YtMJyhI3eUam4iaUZTblvmZmtfhb9cudgv8SPuV/H D00CysoRRqm9dFCTTNe8c/m4rPMfqDMiQqEnTcBn0Bq0Lfc/GSr9VU8AP5TnT5UwZ4eG 1fAacd5E6ullJrsJPKHy2Pp/bsXwHrUEPgp+ENna8xjq63yi6wDsCm4LuuNBHdYAB5bY oA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05w3huuj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36: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 36O1PPTI035600; Mon, 24 Jul 2023 04:36:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x77m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bUPRLJ8y62TjNjx3c0URQ5JcV7MV5+savth6Hd/M22otvRgRdapG/hJvoGPV53eERpIk39Q/yeEH8TZn3bSsbZbBFjHB7N3GiSpBTL86eRA41Cf/t5vdvJE1WyLgOhX+sIb/0N+d6VENJpXtmhFbbVh+YxPfJQ6slhAwWzRGGdJ3VPAv5DsPF7XVEm8VRgB+EV6Ul5xr7gXtsWB3Zkx3ckP19HheT3CTtiWMRTVwSx7hrJ+Agsz4Q/ntj177Bq52g005GA5Mm7g0bKkZqj6SalnYUZegZ2t9ZK3rVAQOSWloexgDeX6TuEQibNqERHcNsmkwvtFQAYAPJ7yhDVpcoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=m09YwLYsOg/C5AlKML9EAjNpmo9nf3wH4kcpFw07OQsBrfRx1XTWA4GxKnf3Jpvq2jb2i1vpHfp8s1RRC/viEeCQM+5bFIzDZlkHnEjuF3AokdadxO0PhflJmsulAuOtkux1FTWnT4+ncf7Dy94q54z4ATfvxQazrQFW0yGbiktmgdWc6e1B9VzaZs+Y5q3eWVdeYE62Gy9TfDsIfTaQ9fky/sD+MJyiWI+3uwbrAyzXP6IQQFmbFjOKggkiqdSrLQwWaoYUSEOeW8k6FfMmQSZyVw7HQd+hd2EmnL+A6MIoAphTDVbbV35Sx3Aln7euAudPoJ2esSBCbcnnZhMoYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6ONOo55tdf3ee+BxrYEgkRmZAzZhTN+QPS0HdmE5hsw=; b=n20fwRFQJz+b7kzkQXPLyaVL3hY9MCpbFd1ZSDNJnuy0Qvg2ujC43+GrMZaCKUOEMV5EmO/g6nCTUUvXf1QOBvLtrOdQBLVCbYNQDO4a4q5dKeYu97GQqNZZZgi1UMJUMySy6GpkXD3cAGCqD6sZ48V6msqP9FpJITJCVRrpGg0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:23 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:23 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 01/23] metadump: Use boolean values true/false instead of 1/0 Date: Mon, 24 Jul 2023 10:05:05 +0530 Message-Id: <20230724043527.238600-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0076.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b3::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: c824d5d6-00bd-407d-70cb-08db8bff88b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Njfn6nuR7VaWnPwOYE1Oz3NC9DwUiY0iYOhAkI2n6gKvun85MrIKK6iADlsYvcecLjywfCpYh/JVmZkpMsfRCpo7lrh+yjCPtQqZYKx+xxtEEomPyhoVjp3DkbbiE1mgIPewXyvVuoJXduHaTZhjr2TOtkZV4gzeMjvi7yUL4azYChhyJFwJZQPs4TaMGxJTDs2SDfEt7Gp+wA4/tZQME/5Y00aHFrAoXFk/dCwS1jJ+3uOx6QMHsz5NA/dNJ2cKaaR2XlPbLqRNrOK7WWc5DkyAoPMMhdOnNh4+usyOxGoMi+vu8Z8/FH2NarHhp5FnKrQrjHsI8Ol0EcTWJ57Ku75I0Iq9DQm0PjCNIkA5t1GAszSpwy+623cCR54H73WbneSj0InKB2it3KW/oX8sn6dXuR8lHoUHt9Nq1jRvkQQ8fyimCA0VRIKN46YlWJMbb8nDpk5Pvh9d4kDzoD0xcjvX4/qmZIB9Sdv8BHPxHFxkJZKzrjHI2/D+RhItxTl1Kv9mClGPpuS8iEKowZmOL9Oiv8EQIN9jSgojFj31RtBld43ah8qP2SNHrennh6ba X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bb7y101h6f6sEih7FuWmfhKaBsqF9fEEF5x0vKHlRDBFa2rj0gYwoobodyAj5eM5nXRL90Xd7XahuaarbUFDI0aK75fiE902bxFgxauwq2CoTeLV+aIyen3CYZVreLsUoXqEqO2BQkxCz7luVJgBuUIbc9Ecj/k+prYNQFflHt0pdMkbnWMPN2knZSwvTS/b+ZSK6ZlUQ9y+Y41ZXOE/N6O3ZBSa5C9yHnDchM0DsbyHFsX2N2FNoIVrqr+ZPWZ6iPfYpnVkGkLfcCMiJUk+as1DxPuctedNteSghaeN78AweP4MfAmLApfwvbiOASGUww5St2C0KVmPlJOWK4VS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1rDq3B15SXJcXqL4Qj+arW1Uh0qeHCLvLO9fJtH4shzDipGJotRv6fEQisIBFUIqGjGpuxWj3fwXOkwz6li94pS/4jRXtzqErkM4CbsCxq3ayMJn0JUWaNcl4k5CpdEGEaXNJ1bTBY0Ginst9R/GOL8OuoZd38ESUroKFRPZak+sowEPN2gCgozkIH/3QX2u X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: VpImXAHYN7s49WmhaA5cP/ml6HCdI07vRs+CoPucAhkacTICI8jpqtCGb3z+Wxf/MRiTNqLK0eMd/Ygk4A1obMvfBzDljbu+hZcJtSBxu35LMGqG3AEkAeKYQJgyK/Vre6aLhPiJLYY5RVZXos1iDNb/LCcJdJVeNclUQof0M5vTcBMaH2d6NmdJBk97grF9wCEh4TsmXMgLv7Yo/Myv3fOd/xlg9OgY4oSZJJxGTVFbrLPAkf3LuTxUtCxieIqJrcgmSQUYD14USjQyOI1WacB2VKbzUIPRMu+dNuiiMCAqvj415lfDhJl801HrZeKDf6TM4+VtjTSeAwsijEUQnf8KCjEVgqFyugUlzB6SYX4ffEjs4Z+YLWDrA5oT5OUA8k3uGBCYNT4asfTnx1+93s1Ubc4HwuP3aTsgyYMbg67dCwnqcfmErBTUQ12hkkp1NP8WnXdWO8IaaOXLWoSdqRYeEvFVgE+bex4v/mxuJ7dlCMQjuV56Z4IKZw2WjtjZFroGlqUKNyz0cJoF4GJpqhlwReEcJWgm55BLZ/tbf1uErJu3DkmYE/iMYHzCBS8roplLjvjkLA70bhVkmefO7VU49Zmd4ooGl7GEnGpXucKekbIIegxpifsOmptDe32w7EaJMw+aXFRxpYxlgETlFmP7cCp88L4OHBbfUH6VR6RpL7RY3kmham8RVDff2YjlQTCF1zIijc6Zpj8AfR5uTglZLZHKV2NXPcAtB9ZhWCj6xJB6Efdia/xrz84MPwPa7xF6nFIvlWCAOCgW1y9xkK1fo4gLpa3npZdB5Ceihgo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c824d5d6-00bd-407d-70cb-08db8bff88b7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:23.1693 (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: XAPCHZAH1FP7d4g6MuIK0bQXNV5GRV/zT89OPUAZ0ZghyllidSp4dm5d1rm7qYYkRi7QPiliD/CmyofGlVwFdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-GUID: 1VQA-h6hA_N5roZLGWy5WJEAeNYVYtzl X-Proofpoint-ORIG-GUID: 1VQA-h6hA_N5roZLGWy5WJEAeNYVYtzl Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 27d1df43..6bcfd5bb 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2421,12 +2421,12 @@ process_inode( case S_IFDIR: rval = process_inode_data(dip, TYP_DIR2); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFLNK: rval = process_inode_data(dip, TYP_SYMLINK); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFREG: rval = process_inode_data(dip, TYP_DATA); @@ -2436,7 +2436,7 @@ process_inode( case S_IFBLK: case S_IFSOCK: process_dev_inode(dip); - need_new_crc = 1; + need_new_crc = true; break; default: break; @@ -2450,7 +2450,7 @@ process_inode( attr_data.remote_val_count = 0; switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: - need_new_crc = 1; + need_new_crc = true; if (obfuscate || zero_stale_data) process_sf_attr(dip); break; @@ -2469,7 +2469,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ if (zero_stale_data) - need_new_crc = 1; + need_new_crc = true; if (crc_was_ok && need_new_crc) libxfs_dinode_calc_crc(mp, dip); From patchwork Mon Jul 24 04:35: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: 13323419 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 AE6A7EB64DD for ; Mon, 24 Jul 2023 04:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjGXEgi (ORCPT ); Mon, 24 Jul 2023 00:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEgh (ORCPT ); Mon, 24 Jul 2023 00:36:37 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225BD1A1 for ; Sun, 23 Jul 2023 21:36:36 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NNjJVs015795; Mon, 24 Jul 2023 04:36:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=E3VJifj3h1HlWIaromhXnHwGijkMCYmZgYrZWVnJzw+nMYR+WSxzXfEmqW3EC/xxyVuK dZDmgGqr0QV1Iopw+LiP/c4s7ofPU4jHQF8JdnVnXk5pZ4ieWAztJmJxAPdCn4tJpKML iu7MvGGuGHKOQ+dmqIO8hv/s+slP5RUbEW0ZqDGIz98FU0YdHDoyD4wnnWPPbqJP+NR5 EXBUz4fJmmf3vRyrkMRFfXOfAT+Uz15aC4ETUWAKRYTQR1oc5U2LaCfxqMvQh6JDcbqJ y4+7+cqRFtEZOWYf77CzGF/is14t5XeZaJCtGEWZ+2eIa1SBDg2jIuTIJILhBTT5pmNF Vg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s06qtstrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:32 +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 36O20q0C028691; Mon, 24 Jul 2023 04:36:32 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j35xh3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aj88UYN0OI/62O1UZ/GrZ0L0cjHTpMPk0A3WiNHjCnzuesRwWObInUpoRtr/K/jSCAj/1KeVU/i3Kl5bgQHrf1nFQ4Q8dhRwHCm7ro1529fZPSMIX7Kr+1uHh9ImsR3/Mz1GN1twvtnJhtG0BtRsAuOBfrdxyjwA+ukJO4gWe0H4alNW+Lint49Ceif/mTgc36+XzolR+UyflE7VvrIqtX/g4ttvvSELxx6wYTVxwFucp0ZwKk/OWU07dejuxoZPcXPyHtmSpmMAIHx/r2cPoOwB8KR1lXMFdSZ4LwAPPj/bQc5wQ3d9Tpqkw3cZiW0pkoxT/4SmGkiIT/msUjAMrQ== 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=BEq35Z0nRgb4oBB7d2a6IoaAH3spf9+ziU+gYV+vQQRMkbReH7Gv3LF2M4CU6pXhJQmHGhGgD+S55zoGpVyLGT/VsbFsTI1OYU+012kCLQROGNKi7MTPmaq6Yoa32X/d34KVrVcA43ql7W956eTym2gOI+AFgr/M0kggzLCdkyRlaMJmQPj5X+VDhUa53TAvHvioAFBoSqLP40BMNTaejhpVsWAWJLtJr1CUz7af2Cfnh34gYcmuEuhoI5clmOm4D9LqHMZtiKCvULvLxtYN/bgXcQooc7L+jIao3yjh7ta4VUoVXCh1YUKkeAvQ6aBuABRhYkmh0wd2BDatY+71OQ== 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=xiE2s9sSgexkKtkUCgARbEZ5XV0MNoeor0qkfbEGh7XkS5A9lOjHKgtr7NE1RfKXu4ESJ0pYmW5hHccSpbno084VwRC0243u/AFj5A/o/HZKisb0OttqgJNEUPHr8LQjNrjw2gipzTBtyR2qofPUlTfRGGfEF7NIk2Rl7Utb4NU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:30 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:30 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 02/23] mdrestore: Fix logic used to check if target device is large enough Date: Mon, 24 Jul 2023 10:05:06 +0530 Message-Id: <20230724043527.238600-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0039.jpnprd01.prod.outlook.com (2603:1096:400:17f::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_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 180bd9da-4793-4df9-41a1-08db8bff8d0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CUq/bLXVcvVBPkCtxbnTdID3cUCbuAFT5uky9Du3eRtlZwFbRPsrD2A04tEZtpmxr2hNrxj89IjhLXQEYAB2xlZ662pa0J/wfA5PbPB9c7azzU8dDWX0i6MNav65sHMIbWmDJihhq1wH4RXRM2ylWpk+qmDhGK6eUtN5EkbcFr7EkNNihOzr4VOZjtwhImJ+OguSJn+IpQE1JPom9XQYwzd3rDzhkMqBePBSrOYV9eOYJ1dLNMsnP8fsFdTpqhhuinvgV3czhRYL0JQfFT2q9FUVOt5T4OnJMifN9ze1rCJf8TqkdA4PlHdSIqpVnXwtiKanWBqhx38Fzp+MnTvDdUwdEnF6PnVLSBNVJqlsRBBSMZ8YWdcWEsRVitg8C1W0fIVaJO+X0EAdK0i7o7Cf09UdJ4t9D8gCBAJbUhzvDlvjlR4e4mwWDjAo08ng32vj+IY6iMkn9o1uadaz+1i+8LdMlKPRkRo53ljOqy4POXwFrCscvGbYoo9SYj7dB8qoeUh3kQ43WX3fbaNMhdaDiXyuUMDrEaEELom4kUEJhgD7TVRYphnzbe7QHTEVeVHJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(4744005)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YfEX31MuQ+6X5HDA2MSepRYtBPom+Vz2vOeKHDwr1FIDnB2yP4wtQolA+1hjwq/d9aJytasm9IctXlVpABcDDjANJ9tD7uhB2w3qic4+gT0/OvcbHX+tionUiG5KuRmvLv0N7TUE11bDfegJ3GFp4apkRbkUpfkA0bNFPvDCuEuFt68bjIfLnQv0SF8JZnJDspK8Rwyk0W1jRm7kVz9UfyvZ0uGnURy90G54GI200gdhZH8AodkhYaS82dkkTRsFLxVZ1/d7L4D2eNFqslbMkSBlA/3s4DEkYuJImiB7pserKnydKI0ZIN6heDuZjTTypMNnYkkJDFZGC0qj6RtskqLTKVrBEJjfqDv8/dIoCDiTq50sWLaJSVcHJeFNeFLt+0PlX0jfsj0nlItj1OMK7EmeW3nY49NYt3MyvlH9pYOmB2BmFKmYIYiI3qjidOW/M5jarhBdJpciTjWSbuvUt8S85TCTit8Fi2jT118on4xzs2bq1juJ1DAak8TE2Y1SzK3kWZpdfKOo/yijbaqctF4JwZqr0PHNX9bJdPOM8MrGhdWdssdDffbDKHu+EmI6LSeu1Qb6A37dF0+6gIYSNyOwliDsDPaaR7Rb+P7KxZIVhUTV9ASIKCmzrr8iyVJ0dBE8ikemnCK1e8reAASexNOaOkeCjIJwZh0o2ewL1AZgXnek7FSYM9Vk0fuxfXAq9hyxM8G3KHOo/xLtYcSUW9Jhzqs6pTxqkK1siA/Y1rStlFMOz5zZ3+M3tuLZt10aA0IYBNX5KI5YTSXvPiVCURf3V2D3vEQuZqsLKwtpUTmMQZ6EF4JxaObpaIPfsQ0vtUyv3IZlZnyyQtrB+AvidbhIOtov5X7/WBnEUs+W0TSMqwkXQI4a7hXLO+GEss83IcGfcN6Ermv4BNcO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Dg9zGLbWDmpwOZkaphEFk6kXDkPFRJflhXJBez9ie6e4kvnzL5b6Kh2C44He61oJrO/LRoNJDp3rKJjp7k1IW9PUuc9FcHA8E4HtjSCV1u4YRv8GX0KgoGji3bOnHeYUUsiopGcAAzLKQGf0naN6eovGt9MOqyLQwD6RlVfduu3R7uOEfsTYle0cUVPVgXVj5GO2MjY4EYMlZzPaswVbnUq987uEgQ/SLi8gXBscTBXlXpMd1yQN3Ws7PtPm+X2kieW1Sf2Kezw3S/NrzBY5kNaO4HCEUos0yJZjrRhpfSxapwk0BUtGziRRQ22+XkDUFgVyPj5hAej92AA22YI5el/WPA2fSSQvHhcwH3EvdE2M6JL8dFhPFrNVu45C3+aK7AXFoEC54G66ekXLsW0XzMeqBpx2Tfxw2aU1QWduL1bI5M9SfmpPHebILJxZn2x9SrYLrGcnkyvBH0SCgu5AP7g0eAOYbxc/z3enQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 180bd9da-4793-4df9-41a1-08db8bff8d0e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:30.3261 (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: wHcFStxUY4XuO8S2dPI0enRyAH3hKffISmDqjJ+1nAXsqPIwAy2cj+UJYkN86SflyntH69V6bP2KshKnVQNF9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=973 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: 5uKAuLiGAeExCFMRHUKtVe3b89Vd3DkZ X-Proofpoint-GUID: 5uKAuLiGAeExCFMRHUKtVe3b89Vd3DkZ 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 Mon Jul 24 04:35: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: 13323420 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 BD8B1EB64DD for ; Mon, 24 Jul 2023 04:36:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjGXEgp (ORCPT ); Mon, 24 Jul 2023 00:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEgo (ORCPT ); Mon, 24 Jul 2023 00:36:44 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96B21A1 for ; Sun, 23 Jul 2023 21:36:43 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NKlNkB003163; Mon, 24 Jul 2023 04:36:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=5sF550dpaQoiszjKP4QVc8CaDyyVb7656y+9Wv50MQg=; b=sU8qQhWKdjCpEVYiX1CFZ5C0iozxpxwlG1Pyu49Tm6krVRzCDGkVjTmc306ozIGxQtWS dp+pVxVoUTicWezvUHxzQhHmMi+uovxVeZi1nrYdEDrZ108rLxleWCDA7YGGo5uUg+OE QJqkTQYRLUK/SvJrFoQwQxQmTtXBWX2VY3rvgiUqzk17U+cksZNxSgHe2Ac6K3OHGfZP ps6Nzw7XNKKaxeeYcK5k6EYElJhyW5P6yzlc+jQWxQy6AgdALpENuQYqJ6htEUJ65BsY D+rtuiqlazMWEzTOqwMYyMToUFVQUlvsxnd9VFY8Cbyqq2V9cWi1Txx+5qy+JppootzP UA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s070astey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:41 +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 36O4CAEE027586; Mon, 24 Jul 2023 04:36:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96bkb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lc5AhecrkaByXzYfz8IMoXotONWyQeIvwPQaiyoB4pKMq/KtCdbyE+L3NzxukFXdpOrIB05NX1MJXhPW17fgGYZS00VWq/sFO9UVCV2whp9Cndr8+ZHAOYUUAhHQov4Z9v+BwzapGhoztEPQs4OoFU6i6C0/dRNNrbz4rodjyNA3Cr4vR3eTy2KIXqj8JLLycCaU/EORyKOHAiwi//WV34zsPHzHAt2SVGJx0QQKQd8dvHP9jXSwLrBn03T7jRtYRrHkuv8bf+KcFLnuZld/Qps4xq9wiVFCimTKwLEZ9yRL6CMVHsq6ib+2boWHpFcIIoxkAhEetRGVz78B+p3kNw== 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=5sF550dpaQoiszjKP4QVc8CaDyyVb7656y+9Wv50MQg=; b=gFedKz8GunQbpoEAVD/icajRSOKk9+tgDN/GzNgYSPbPHdxvJPhu3xeq+/4VjQJpvFgD16wPnrAHvsV+G5SAKQvOcBvhs7Pwie7UoLXhJTV+HUhBx1MG10vvRLzoEDB0a2uQbfEu9iVEuBxpMN+n6K3QUGvuoPFLf9hRxWQSi0l93eCn+1y1FkrTrgxPWoT9AhxkmQN6QlnHw/o3Rg6qa82TZ+KppnZ5PKaw2BL8Sm97E/qXh+tB8tTcCK3uGMhsrfNVmQZn+vX/9t/JHVPe5tm26fXdxPiBu5gR+BvWcX0KPZje43g759lsQ68zX3LXYqfkv/u5U6CjD5debx7VYg== 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=5sF550dpaQoiszjKP4QVc8CaDyyVb7656y+9Wv50MQg=; b=vQ9GGSAGCAYtHkF8j2KITDf2FxgrHOM4XB+mXH7WQopOmunutoa2DeCT0QqrEDyTrGzC1TwzgtYJ/TxTM6UVmjxQJBQAzkYLLudpL1SJNBTsPj+PU5tIrZvIHnt83ZwVCSUnHVKJSV/sDm6B9os2iq2A7D+CMWsSx6vBUF8BsKs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:38 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:37 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 03/23] metadump: Declare boolean variables with bool type Date: Mon, 24 Jul 2023 10:05:07 +0530 Message-Id: <20230724043527.238600-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP301CA0022.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:381::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_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: bb5cedcd-ac0c-48c9-7a95-08db8bff9129 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJujVvmVnC2Ax8GY7NSqs5qzlKxUdFwhnvkzn65LQBPSpwq7eI+IsbZzOwHHrNZUHN/cLBRzWgjYq+iDFj00Apsr1/NNilKZ0ZumgMV+BLEICIuHJ4ERp7UuBYqBy1OQEHKMgOxjIhZevledoukEsjCV0Orn8KakoJ3IA3sUvHSzP7qtzxBjRFfOsuXNvhDkA4r2BNnA163i1H+f6oOyWnjvfUrwqSlf4WQ205yMxahnvUYD4h0lOPxw6M4ykKx8jCZL8/cGcIwntxO2TvcOc62arGgI5RYbyIPEM6WrkcKM6gyV0DJ7h2OFfZ13WuvQTZ0A3QVSJXXzgRwvIraykN/gopnrAl0Ge+OyNlQSjT96mtCUPx/FMrhj0Z+nDhJjFU4EUFOQ9qeVqUTfsjRjIhcAbHC3CSX51P6THrV7IVBWDM+Dpc9Pgi9d4PjOPXSHeJZvYA+pWZcCe0u0xZSQKG9iF7A0nJZO98z0xEZUcahNPtFG/1NXmshIiA1gc4AnPmrVjMv1dfcOBWhTt55mNPQZjhVsM2YsC5Cd5BSoymEHNoR9vWGI8c/w7FR2PazR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oS2J3I019tbmY/tZOGUhjcZSPBP4O7q5oOcWmI7IJzKjYflw7KaY0HuuqUoC2MNowMg1EIDFM/YmwQTXCFpMXAxMvkRkAJmHZ71EdfjsGMo710aKA9kDmbG3a3c/PlYHY2M7IiFBYMMCZQSPgHUA3M0j6hIXq9UTwv1p8Z8GYWAqRHlxT6Dj2Nhzf/idvghLWCMTRfA8VQP8v4dAd87bO/eZbtb8bk6Puj/rU9Em00dqsQPRR0wWSUM965GCc2C08WRjFijhyL1HqJ+z2sluR4C1DdUyr455fKm/hgAaoe2MALHXtPIUfMv3xC9W+kdBxz+5Az7j9+MBkgFxjqoyRNFO/uSRVM6buSxreSD40MIhBY4+GOmvDctQAlxAHwKeO5WISw/Z2qA7kovPPU59o2k3TsXhgmphCKkVPK5cOlyIn4bicJDFrDK4CX0o5PwQKSzmVRpMN0xGeOkPM0k9gIkoYzvWZWEOFqpnUn16Fxr3RhJUPVlOzOPf3hrZm4BKoGRYjrjxDPTthq9xSOM2iBrXIEwIhkSRdnG8NaPc1Mw0a4UQYiHzHihaF872AdcfmDIpjVPqg+NtYLsUNtshm/VaurbC1ExdMuISVuN4/NqoRr7L5L2YuHyWsKw1KfIUf33hDe2rEuvQrA2q96BZUNqZFTpSoayYuPl0ImY1mDRzUzrFZ5GFTwFEadUEr6YG+XBvikSXYFfpFzfK5Km0yI+ppDTSei4QGCVK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+S1gWc8rqh49Ihym/QL+649Udxfjo3qSz+pspmcrZ7bZ9Ty4N5utXTzTPduVKflY8NrabYhz9qBGYsEImrjYdjoes4v1hvbHtr55hhxFlD0L3GgJ9yl63oO3UhVp3EO6cvtbQ4wgEmIwr1m4jXnf5aZGLh9zMuelNiYdXV105Doauq1I91TEu1IAXUURqToVLDNFsqXKu+j1LV8T7DYK7GjHQaQTPg575Q3bLhNUS+Ou1Au2njAdluXZB6ZtAQlc5+OZRYcrKTH4S/OnaFFgjU2CwVzB+6ta22T0dUSIUhL8cCx2hGvGvbkncFuwX4eUwRxPOSX04biCvq0LephV2JlanY3XmeyhRYC6s5RtAhTZaoMsAvsQB/WgMfp1IdIEnYkH9wwlZM2mWm7JUWCM04tMvTQ/1E9HjWNTTl2RT8o1c7iJo3IANloQCsodEvaRILT/qqbsyAr2RqOGmXPgGEC3zBiVj3FPz0ojBu5J7PdWAMEg39t4VXXBHOL4YBdUCfdwEGD4MU4VXi+O3KeFP9e4xRj5EWwJMDkGFL24WEAqc3a/LBeKVOiOGfGzM0bOAJjhiV4KFdJgYsp0t0WeTJ0F7gtG6jHLwwXUbDGQULLV7ReJpaKDLaXy/acgF7gDO+mimQHKiIaQqAmtBfqA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb5cedcd-ac0c-48c9-7a95-08db8bff9129 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:37.6920 (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: OlugSwi2sc+79ZTGmK/KBEPYKz832e4XOu3EgLawYjnL5M94tj3ajLjIqfopwd9RY/mua+0/OLTFR4mRBJIUqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-GUID: FsWe_UT5-7pjIRbCgXte-C4Zlzc4d2mK X-Proofpoint-ORIG-GUID: FsWe_UT5-7pjIRbCgXte-C4Zlzc4d2mK 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 6bcfd5bb..8b33fbfb 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -51,13 +51,13 @@ static int cur_index; static xfs_ino_t cur_ino; -static int show_progress = 0; -static int stop_on_read_error = 0; +static bool show_progress = false; +static bool stop_on_read_error = false; static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static int obfuscate = 1; -static int zero_stale_data = 1; -static int show_warnings = 0; -static int progress_since_warning = 0; +static bool obfuscate = true; +static bool zero_stale_data = true; +static bool show_warnings = false; +static bool progress_since_warning = false; static bool stdout_metadump; void @@ -100,7 +100,7 @@ print_warning(const char *fmt, ...) fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", progname, buf); - progress_since_warning = 0; + progress_since_warning = false; } static void @@ -121,7 +121,7 @@ print_progress(const char *fmt, ...) f = stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = 1; + progress_since_warning = true; } /* @@ -2979,9 +2979,9 @@ metadump_f( char *p; exitcode = 1; - show_progress = 0; - show_warnings = 0; - stop_on_read_error = 0; + show_progress = false; + show_warnings = false; + stop_on_read_error = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -3002,13 +3002,13 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = 0; + zero_stale_data = false; break; case 'e': - stop_on_read_error = 1; + stop_on_read_error = true; break; case 'g': - show_progress = 1; + show_progress = true; break; case 'm': max_extent_size = (int)strtol(optarg, &p, 0); @@ -3019,10 +3019,10 @@ metadump_f( } break; case 'o': - obfuscate = 0; + obfuscate = false; break; case 'w': - show_warnings = 1; + show_warnings = true; break; default: print_warning("bad option for metadump command"); From patchwork Mon Jul 24 04:35: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: 13323422 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 B4865EB64DD for ; Mon, 24 Jul 2023 04:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbjGXEhA (ORCPT ); Mon, 24 Jul 2023 00:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEg7 (ORCPT ); Mon, 24 Jul 2023 00:36:59 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4DC41A2 for ; Sun, 23 Jul 2023 21:36:55 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NNaI0c025548; Mon, 24 Jul 2023 04:36:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=jaydoIx5euRqH98rEQ8yCOLTTyuuHGOKyMbmUexC760=; b=WRtEDt//5mYrTsB0puqAU8NZ8tCMfT1M86coTw/zLZTZxI/UbDKk8FO9en1tc9NTY6vs spjjD4u+1wt2cApPelAeLawnHBtxGqeRLNLUqLYfnFgJZdg0MNJUgwPM2fwuo9mvMQCs d/qM4SBGCZcAfNIc0i9SnDjEWaDDPaU0bIKRDGfjq9RSXA7clCm0IoeCMUSR1WYeEcby M67RDIqG7A2rPDsrilvEDdGuJi42XIU7RJ47rwgX9yab7WqNcHZDH7dVs38ZPpjYE9j8 HHBx45jx7Whv1F/3aRsqaG2r3fZpR5vNiRUhEeztSXX+71K4LHz8KhyA0TKNWMKGVAEw OA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s061c1vdu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:49 +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 36O440S5029092; Mon, 24 Jul 2023 04:36:48 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96j07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oI5Fp9VBODivknxQnMOyyVnSv0Mtoc7VJk/EXEp6/1jTDydThDLyj6IYUWwLytF4Yj8YGWcV0+665sClYwki3fOBc4XWDyRmWypY8LHrs+Ds4rone6LH0PbMlbGKarqh8qKXct7EWC9B+1Hg0dHrYnPEt+p7oiXGJysl5tyeKJjrVkW9dmfTw3VNtNlJSIu+RxU5AblfM5aVYUOsz881dxbnYthSuml1hnKGLV3nYeeRsNrLCDOOWvbTMhLfCJ8ogL7L6GqduuJK/dR8s/mzTolVWq4Gq71ozhRpOczJHNyeS+bgimCdyD3BQoMlvdvWqtwDy6PrwmXRdEUWwD84+w== 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=jaydoIx5euRqH98rEQ8yCOLTTyuuHGOKyMbmUexC760=; b=bu6/kR32mcyVmWm+kcoCIGLszgJ8ibs+RWZDE9+gOi5Hfh1hNrc0Te6OqvBk8pc4uO8RL4XAvi1dGP0b3J+Mo6ctrl2b2Sj+dSpsA3b/6O/jOsGbDN3WTSFb1u7JE+b/qto9pCtGpGzUh6FtlN/3Z5hJ4j9bWSdjavuQ4udy2f3Uzfq30sgg0p3DApz63OY8wL+FT9cPvEbtlPM8JWDVxRLKEbOA8YMOFi/cLhVrIyPUD/l6t5idlarHKsQ8NIZalL1SSrWhZoZHY7I0898hLf1fWIIKaLpUzXduxEzaFZ9la/ILIyhRzWcEQ5vb2KwmA4TF4lktGvbpfUpEuxIQXw== 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=jaydoIx5euRqH98rEQ8yCOLTTyuuHGOKyMbmUexC760=; b=CXJB2g8j0t04D76nsg2SOcjXQmUczNs2u/Wequ/+PG+6fbJGbbWDHtw22lW7MnWKOQtlJwGuT3syTVsvjzSzDp+iGNJ7+AEVPmP6YD5nuucOyJOMnMRrsrRqZ098X07cQfAe4NhGtaioQ3N3xiru5RORt8tPBJD7wFCH2ZVzjZw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:45 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:45 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org, Carlos Maiolino Subject: [PATCH V3 04/23] metadump: Define and use struct metadump Date: Mon, 24 Jul 2023 10:05:08 +0530 Message-Id: <20230724043527.238600-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0049.jpnprd01.prod.outlook.com (2603:1096:400:17f::20) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e57ba72-3d4c-402b-bf7a-08db8bff9595 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LLafUln9UCTxwAY2xCu6/fxQW40+Cp/BkhoXTWaZBj3l064swjY2BSHBci4UPTjzKcxp5FqbjaM8FTclHdpT+G+tTtyxvhE6Oj9xukdM/9W/TQ1ZGvZ9K1X2Z2R7gcrRuzcJYB6ffA/ravioDOO7GdqIbEFqU4mgr0UdehUNYrVGL4kC7V3As8o/fHCQGzc7rGYeJJ6IqKnL0E5gWrj1IbQ2KIcLpHk6VgjQnLILsyPWuB4SYY3yPf1yXlCxuNuRm3YlASfczKeGBlAqIQ2AQD1p48XaQELnba/Jq3gAucEyvj+AqYFl0MDrhd94p1BjNrJKz/bKFm9/1K/cNqV2bD/790sVGAc4NynD64yoagBohxxHrlf+qKgKlIRM2m/xoxipTp6JB9NytzoGPc3XAefj5iaY2K8IxNENvC9ldfOHhHyNtV6BWvgHJaGIfMmpAi6T+uP5GVBvBWewSUEU7PqudrRn8IfW9eQSqGd//za2qr7au3KJkXINPpxawksERtAIFFobqqJLg454NliG8ccdG819sN5a71VLLdMwEC3dlJ4qHG1+LKPMT0g8Cmam X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(54906003)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(30864003)(41300700001)(8936002)(8676002)(5660300002)(316002)(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WjCZlGYyUSqJq/+WdyQb2uYw7kI44cBC7ja/ZHGVbKq3dJubwRoUXQg1Z7clQ/02a2N+4vs+tU2K6EA3YgtL7ros8hTbhpNF7eNLKEHDUgHoBmf9+KK/nFJULzExQcafXg7CIcV1U8f2AQzZW1rXBsBhBd/Yg7J6UzXupFlFzfSnayX6ebcY86GMJZSDY1Uhs9aZLroVV2x25sfYFc9cryuGV+z7QVQAqqHMZI++dPfuVKF8xcRc6rpglq5KnQat8FNvtq8SAi7S3RMDq5qi9+r2NmCGDoB3KDA2++/eQufvFx77qU1gz1taIr2jhY6nU2oLYAJSzrYcMR9NUWvHguxAFq82Yd3BVNliUlIkdziCCIUAQxd0fJ/G5/yh6oc4ZPk8RytW3hS5g0LCdSi5atdOUwXnvdxN4BMKopVhr4ie6L6BGCK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e57ba72-3d4c-402b-bf7a-08db8bff9595 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:44.9575 (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: /ybVpBYAxZTNgWIXkEGpcNlSUN2WMUgiv8zKww25Jc9cv/9CT8E9UOTTJbB9oiv3RdC2Ik7gPF8NURfPyMiEEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: 8UBWOPj_NEnTqkMgzIxx1-Fkms0aMKLZ X-Proofpoint-GUID: 8UBWOPj_NEnTqkMgzIxx1-Fkms0aMKLZ 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 8b33fbfb..c24947ec 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -40,25 +40,27 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; -static FILE *outf; /* metadump file */ - -static xfs_metablock_t *metablock; /* header + index + buffers */ -static __be64 *block_index; -static char *block_buffer; - -static int num_indices; -static int cur_index; - -static xfs_ino_t cur_ino; - -static bool show_progress = false; -static bool stop_on_read_error = false; -static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static bool obfuscate = true; -static bool zero_stale_data = true; -static bool show_warnings = false; -static bool progress_since_warning = false; -static bool stdout_metadump; +static struct metadump { + int version; + bool show_progress; + bool stop_on_read_error; + int max_extent_size; + bool show_warnings; + bool obfuscate; + bool zero_stale_data; + bool progress_since_warning; + bool dirty_log; + bool stdout_metadump; + xfs_ino_t cur_ino; + /* Metadump file */ + FILE *outf; + /* header + index + buffers */ + struct xfs_metablock *metablock; + __be64 *block_index; + char *block_buffer; + int num_indices; + int cur_index; +} metadump; void metadump_init(void) @@ -98,9 +100,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 @@ -118,10 +121,10 @@ print_progress(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - f = stdout_metadump ? stderr : stdout; + f = metadump.stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = true; + metadump.progress_since_warning = true; } /* @@ -136,17 +139,19 @@ print_progress(const char *fmt, ...) static int write_index(void) { + struct xfs_metablock *metablock = metadump.metablock; /* * write index block and following data blocks (streaming) */ - metablock->mb_count = cpu_to_be16(cur_index); - if (fwrite(metablock, (cur_index + 1) << BBSHIFT, 1, outf) != 1) { + metablock->mb_count = cpu_to_be16(metadump.cur_index); + if (fwrite(metablock, (metadump.cur_index + 1) << BBSHIFT, 1, + metadump.outf) != 1) { print_warning("error writing to target file"); return -1; } - memset(block_index, 0, num_indices * sizeof(__be64)); - cur_index = 0; + memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); + metadump.cur_index = 0; return 0; } @@ -163,9 +168,10 @@ write_buf_segment( int ret; for (i = 0; i < len; i++, off++, data += BBSIZE) { - block_index[cur_index] = cpu_to_be64(off); - memcpy(&block_buffer[cur_index << BBSHIFT], data, BBSIZE); - if (++cur_index == num_indices) { + metadump.block_index[metadump.cur_index] = cpu_to_be64(off); + memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], + data, BBSIZE); + if (++metadump.cur_index == metadump.num_indices) { ret = write_index(); if (ret) return -EIO; @@ -388,11 +394,11 @@ scan_btree( if (iocur_top->data == NULL) { print_warning("cannot read %s block %u/%u", typtab[btype].name, agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { zero_btree_block(iocur_top->data, btype); iocur_top->need_crc = 1; } @@ -446,7 +452,7 @@ scanfunc_freesp( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_alloc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -455,7 +461,7 @@ scanfunc_freesp( pp = XFS_ALLOC_PTR_ADDR(mp, block, 1, mp->m_alloc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -482,13 +488,13 @@ copy_free_bno_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in bnobt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in bnobt root " "in agf %u", levels, agno); return 1; @@ -510,13 +516,13 @@ copy_free_cnt_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in cntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in cntbt root " "in agf %u", levels, agno); return 1; @@ -543,7 +549,7 @@ scanfunc_rmapbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_rmap_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -552,7 +558,7 @@ scanfunc_rmapbt( pp = XFS_RMAP_PTR_ADDR(block, 1, mp->m_rmap_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -582,13 +588,13 @@ copy_rmap_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in rmapbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_rmap_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in rmapbt root " "in agf %u", levels, agno); return 1; @@ -615,7 +621,7 @@ scanfunc_refcntbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_refc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -624,7 +630,7 @@ scanfunc_refcntbt( pp = XFS_REFCOUNT_PTR_ADDR(block, 1, mp->m_refc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -654,13 +660,13 @@ copy_refcount_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in refcntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_refc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in refcntbt root " "in agf %u", levels, agno); return 1; @@ -785,7 +791,8 @@ in_lost_found( /* Record the "lost+found" inode if we haven't done so already */ ASSERT(ino != 0); - if (!orphanage_ino && is_orphanage_dir(mp, cur_ino, namelen, name)) + if (!orphanage_ino && is_orphanage_dir(mp, metadump.cur_ino, namelen, + name)) orphanage_ino = ino; /* We don't obfuscate the "lost+found" directory itself */ @@ -795,7 +802,7 @@ in_lost_found( /* Most files aren't in "lost+found" at all */ - if (cur_ino != orphanage_ino) + if (metadump.cur_ino != orphanage_ino) return 0; /* @@ -1219,7 +1226,7 @@ generate_obfuscated_name( print_warning("duplicate name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); return; } @@ -1229,7 +1236,7 @@ generate_obfuscated_name( print_warning("unable to record name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); } static void @@ -1245,9 +1252,9 @@ process_sf_dir( ino_dir_size = be64_to_cpu(dip->di_size); if (ino_dir_size > XFS_DFORK_DSIZE(dip, mp)) { ino_dir_size = XFS_DFORK_DSIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size in dir inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } sfep = xfs_dir2_sf_firstentry(sfp); @@ -1261,9 +1268,9 @@ process_sf_dir( int namelen = sfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length entry in dir inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - @@ -1271,16 +1278,17 @@ process_sf_dir( } else if ((char *)sfep - (char *)sfp + libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen) > ino_dir_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("entry length in dir inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - (char *)sfp); } - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name( libxfs_dir2_sf_get_ino(mp, sfp, sfep), namelen, &sfep->name[0]); @@ -1290,7 +1298,8 @@ process_sf_dir( } /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) memset(sfep, 0, XFS_DFORK_DSIZE(dip, mp) - ino_dir_size); } @@ -1346,18 +1355,18 @@ process_sf_symlink( len = be64_to_cpu(dip->di_size); if (len > XFS_DFORK_DSIZE(dip, mp)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size (%d) in symlink inode %llu", - len, (long long)cur_ino); + len, (long long)metadump.cur_ino); len = XFS_DFORK_DSIZE(dip, mp); } buf = (char *)XFS_DFORK_DPTR(dip); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(buf, len); /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) + if (metadump.zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) memset(&buf[len], 0, XFS_DFORK_DSIZE(dip, mp) - len); } @@ -1382,9 +1391,9 @@ process_sf_attr( ino_attr_size = be16_to_cpu(asfp->hdr.totsize); if (ino_attr_size > XFS_DFORK_ASIZE(dip, mp)) { ino_attr_size = XFS_DFORK_ASIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr size in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } asfep = &asfp->list[0]; @@ -1394,19 +1403,20 @@ process_sf_attr( int namelen = asfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length attr entry in inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); break; } else if ((char *)asfep - (char *)asfp + xfs_attr_sf_entsize(asfep) > ino_attr_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("attr entry length in inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, asfep->namelen, &asfep->nameval[0]); memset(&asfep->nameval[asfep->namelen], 'v', @@ -1418,7 +1428,8 @@ process_sf_attr( } /* zero stale data in rest of space in attr fork, if any */ - if (zero_stale_data && (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) memset(asfep, 0, XFS_DFORK_ASIZE(dip, mp) - ino_attr_size); } @@ -1429,7 +1440,7 @@ process_dir_free_block( struct xfs_dir2_free *free; struct xfs_dir3_icfree_hdr freehdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; free = (struct xfs_dir2_free *)block; @@ -1451,10 +1462,10 @@ process_dir_free_block( break; } default: - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid magic in dir inode %llu " "free block", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); break; } } @@ -1466,7 +1477,7 @@ process_dir_leaf_block( struct xfs_dir2_leaf *leaf; struct xfs_dir3_icleaf_hdr leafhdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; /* Yes, this works for dir2 & dir3. Difference is padding. */ @@ -1549,10 +1560,10 @@ process_dir_data_block( } if (be32_to_cpu(datahdr->magic) != wantmagic) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid magic in dir inode %llu block %ld", - (unsigned long long)cur_ino, (long)offset); + (unsigned long long)metadump.cur_ino, (long)offset); return; } @@ -1572,10 +1583,10 @@ process_dir_data_block( if (dir_offset + free_length > end_of_data || !free_length || (free_length & (XFS_DIR2_DATA_ALIGN - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir free space in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) != @@ -1588,7 +1599,7 @@ process_dir_data_block( * actually at a variable offset, so zeroing &dup->tag * is zeroing the free space in between */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { int zlen = free_length - sizeof(xfs_dir2_data_unused_t); @@ -1606,23 +1617,23 @@ process_dir_data_block( if (dir_offset + length > end_of_data || ptr + length > endptr) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir entry name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) != dir_offset) return; - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name(be64_to_cpu(dep->inumber), dep->namelen, &dep->name[0]); dir_offset += length; ptr += length; /* Zero the unused space after name, up to the tag */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* 1 byte for ftype; don't bother with conditional */ int zlen = (char *)libxfs_dir2_data_entry_tag_p(mp, dep) - @@ -1658,7 +1669,7 @@ process_symlink_block( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } link = iocur_top->data; @@ -1666,10 +1677,10 @@ process_symlink_block( if (xfs_has_crc((mp))) link += sizeof(struct xfs_dsymlink_hdr); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(link, XFS_SYMLINK_BUF_SPACE(mp, mp->m_sb.sb_blocksize)); - if (zero_stale_data) { + if (metadump.zero_stale_data) { size_t linklen, zlen; linklen = strlen(link); @@ -1736,7 +1747,8 @@ process_attr_block( if ((be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC) && (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR3_LEAF_MAGIC)) { for (i = 0; i < attr_data.remote_val_count; i++) { - if (obfuscate && attr_data.remote_vals[i] == offset) + if (metadump.obfuscate && + attr_data.remote_vals[i] == offset) /* Macros to handle both attr and attr3 */ memset(block + (bs - XFS_ATTR3_RMT_BUF_SPACE(mp, bs)), @@ -1753,9 +1765,9 @@ process_attr_block( nentries * sizeof(xfs_attr_leaf_entry_t) + xfs_attr3_leaf_hdr_size(leaf) > XFS_ATTR3_RMT_BUF_SPACE(mp, bs)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr count in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } @@ -1770,22 +1782,22 @@ process_attr_block( first_name = xfs_attr3_leaf_name(leaf, i); if (be16_to_cpu(entry->nameidx) > mp->m_sb.sb_blocksize) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr nameidx in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } if (entry->flags & XFS_ATTR_LOCAL) { local = xfs_attr3_leaf_name_local(leaf, i); if (local->namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "zero length for attr name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, local->namelen, &local->nameval[0]); memset(&local->nameval[local->namelen], 'v', @@ -1797,18 +1809,18 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_local(nlen, vlen) - (sizeof(xfs_attr_leaf_name_local_t) - 1 + nlen + vlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&local->nameval[nlen + vlen], 0, zlen); } else { remote = xfs_attr3_leaf_name_remote(leaf, i); if (remote->namelen == 0 || remote->valueblk == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr entry in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, remote->namelen, &remote->name[0]); add_remote_vals(be32_to_cpu(remote->valueblk), @@ -1819,13 +1831,13 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_remote(nlen) - (sizeof(xfs_attr_leaf_name_remote_t) - 1 + nlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&remote->name[nlen], 0, zlen); } } /* Zero from end of entries array to the first name/val */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { struct xfs_attr_leaf_entry *entries; entries = xfs_attr3_leaf_entryp(leaf); @@ -1858,16 +1870,16 @@ process_single_fsb_objects( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; /* Zero unused part of interior nodes */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { xfs_da_intnode_t *node = iocur_top->data; int magic = be16_to_cpu(node->hdr.info.magic); @@ -1978,12 +1990,12 @@ process_multi_fsb_dir( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; dp = iocur_top->data; @@ -2075,25 +2087,27 @@ process_bmbt_reclist( * one is found, stop processing remaining extents */ if (i > 0 && op + cp > o) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %d in %s ino %llu " "starts at %llu, previous extent " "ended at %llu", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, o, op + cp - 1); break; } - if (c > max_extent_size) { + if (c > metadump.max_extent_size) { /* * since we are only processing non-data extents, * large numbers of blocks in a metadata extent is * extremely rare and more than likely to be corrupt. */ - if (show_warnings) + if (metadump.show_warnings) print_warning("suspicious count %u in bmap " "extent %d in %s ino %llu", c, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } @@ -2104,19 +2118,21 @@ process_bmbt_reclist( agbno = XFS_FSB_TO_AGBNO(mp, s); if (!valid_bno(agno, agbno)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number %u/%u " "(%llu) in bmap extent %d in %s ino " "%llu", agno, agbno, s, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } if (!valid_bno(agno, agbno + c - 1)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %i in %s inode %llu " "overflows AG (end is %u/%u)", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, agno, agbno + c - 1); break; } @@ -2152,7 +2168,7 @@ scanfunc_bmap( if (level == 0) { if (nrecs > mp->m_bmap_dmxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s " "block %u/%u", nrecs, typtab[btype].name, agno, agbno); @@ -2163,7 +2179,7 @@ scanfunc_bmap( } if (nrecs > mp->m_bmap_dmxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", nrecs, typtab[btype].name, agno, agbno); return 1; @@ -2178,7 +2194,7 @@ scanfunc_bmap( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", ag, bno, typtab[btype].name, agno, agbno); @@ -2213,10 +2229,10 @@ process_btinode( nrecs = be16_to_cpu(dib->bb_numrecs); if (level > XFS_BM_MAXLEVELS(mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inode %lld %s " - "root", level, (long long)cur_ino, - typtab[btype].name); + "root", level, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } @@ -2227,16 +2243,16 @@ process_btinode( maxrecs = libxfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip, mp, whichfork), 0); if (nrecs > maxrecs) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in inode %lld %s " - "root", nrecs, (long long)cur_ino, - typtab[btype].name); + "root", nrecs, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } pp = XFS_BMDR_PTR_ADDR(dib, 1, maxrecs); - if (zero_stale_data) { + if (metadump.zero_stale_data) { char *top; /* Unused btree key space */ @@ -2257,11 +2273,11 @@ process_btinode( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " - "in inode %llu %s root", ag, - bno, (long long)cur_ino, - typtab[btype].name); + "in inode %llu %s root", ag, bno, + (long long)metadump.cur_ino, + typtab[btype].name); continue; } @@ -2288,14 +2304,16 @@ process_exinode( whichfork); used = nex * sizeof(xfs_bmbt_rec_t); if (nex > max_nex || used > XFS_DFORK_SIZE(dip, mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad number of extents %llu in inode %lld", - (unsigned long long)nex, (long long)cur_ino); + (unsigned long long)nex, + (long long)metadump.cur_ino); return 1; } /* Zero unused data fork past used extents */ - if (zero_stale_data && (used < XFS_DFORK_SIZE(dip, mp, whichfork))) + if (metadump.zero_stale_data && + (used < XFS_DFORK_SIZE(dip, mp, whichfork))) memset(XFS_DFORK_PTR(dip, whichfork) + used, 0, XFS_DFORK_SIZE(dip, mp, whichfork) - used); @@ -2311,7 +2329,7 @@ process_inode_data( { switch (dip->di_format) { case XFS_DINODE_FMT_LOCAL: - if (!(obfuscate || zero_stale_data)) + if (!(metadump.obfuscate || metadump.zero_stale_data)) break; /* @@ -2323,7 +2341,7 @@ process_inode_data( print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", XFS_DFORK_DSIZE(dip, mp), - (long long)cur_ino); + (long long)metadump.cur_ino); break; } @@ -2355,9 +2373,9 @@ process_dev_inode( struct xfs_dinode *dip) { if (xfs_dfork_data_extents(dip)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("inode %llu has unexpected extents", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); return; } @@ -2369,11 +2387,11 @@ process_dev_inode( if (XFS_DFORK_DSIZE(dip, mp) > XFS_LITINO(mp)) { print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", - XFS_DFORK_DSIZE(dip, mp), (long long)cur_ino); + XFS_DFORK_DSIZE(dip, mp), (long long)metadump.cur_ino); return; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { unsigned int size = sizeof(xfs_dev_t); memset(XFS_DFORK_DPTR(dip) + size, 0, @@ -2399,17 +2417,17 @@ process_inode( bool crc_was_ok = false; /* no recalc by default */ bool need_new_crc = false; - cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); + metadump.cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); /* we only care about crc recalculation if we will modify the inode. */ - if (obfuscate || zero_stale_data) { + if (metadump.obfuscate || metadump.zero_stale_data) { crc_was_ok = libxfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, offsetof(struct xfs_dinode, di_crc)); } if (free_inode) { - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* Zero all of the inode literal area */ memset(XFS_DFORK_DPTR(dip), 0, XFS_LITINO(mp)); } @@ -2451,7 +2469,8 @@ process_inode( switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: need_new_crc = true; - if (obfuscate || zero_stale_data) + if (metadump.obfuscate || + metadump.zero_stale_data) process_sf_attr(dip); break; @@ -2468,7 +2487,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ - if (zero_stale_data) + if (metadump.zero_stale_data) need_new_crc = true; if (crc_was_ok && need_new_crc) @@ -2528,7 +2547,7 @@ copy_inode_chunk( if (agino == 0 || agino == NULLAGINO || !valid_bno(agno, agbno) || !valid_bno(agno, XFS_AGINO_TO_AGBNO(mp, agino + XFS_INODES_PER_CHUNK - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad inode number %llu (%u/%u)", XFS_AGINO_TO_INO(mp, agno, agino), agno, agino); return 1; @@ -2544,7 +2563,7 @@ copy_inode_chunk( (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt != 0 && agbno % mp->m_sb.sb_inoalignmt != 0)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("badly aligned inode (start = %llu)", XFS_AGINO_TO_INO(mp, agno, agino)); return 1; @@ -2561,7 +2580,7 @@ copy_inode_chunk( if (iocur_top->data == NULL) { print_warning("cannot read inode block %u/%u", agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } @@ -2587,7 +2606,7 @@ next_bp: ioff += inodes_per_buf; } - if (show_progress) + if (metadump.show_progress) print_progress("Copied %u of %u inodes (%u of %u AGs)", inodes_copied, mp->m_sb.sb_icount, agno, mp->m_sb.sb_agcount); @@ -2617,7 +2636,7 @@ scanfunc_ino( if (level == 0) { if (numrecs > igeo->inobt_mxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s " "block %u/%u", numrecs, typtab[btype].name, agno, agbno); @@ -2640,7 +2659,7 @@ scanfunc_ino( } if (numrecs > igeo->inobt_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); numrecs = igeo->inobt_mxr[1]; @@ -2649,7 +2668,7 @@ scanfunc_ino( pp = XFS_INOBT_PTR_ADDR(mp, block, 1, igeo->inobt_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -2677,13 +2696,13 @@ copy_inodes( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in inobt " "root in agi %u", root, agno); return 1; } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inobt root " "in agi %u", levels, agno); return 1; @@ -2697,7 +2716,7 @@ copy_inodes( levels = be32_to_cpu(agi->agi_free_level); if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in " "finobt root in agi %u", root, agno); @@ -2705,7 +2724,7 @@ copy_inodes( } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in finobt " "root in agi %u", levels, agno); return 1; @@ -2736,11 +2755,11 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (!iocur_top->data) { print_warning("cannot read superblock for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { /* Replace any filesystem label with "L's" */ - if (obfuscate) { + if (metadump.obfuscate) { struct xfs_sb *sb = iocur_top->data; memset(sb->sb_fname, 'L', min(strlen(sb->sb_fname), sizeof(sb->sb_fname))); @@ -2758,7 +2777,7 @@ scan_ag( agf = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agf block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2773,7 +2792,7 @@ scan_ag( agi = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agi block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2787,10 +2806,10 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (iocur_top->data == NULL) { print_warning("cannot read agfl block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { - if (agf && zero_stale_data) { + if (agf && metadump.zero_stale_data) { /* Zero out unused bits of agfl */ int i; __be32 *agfl_bno; @@ -2813,7 +2832,7 @@ scan_ag( /* copy AG free space btrees */ if (agf) { - if (show_progress) + if (metadump.show_progress) print_progress("Copying free space trees of AG %u", agno); if (!copy_free_bno_btree(agno, agf)) @@ -2859,7 +2878,7 @@ copy_ino( if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || offset >= mp->m_sb.sb_inopblock) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid %s inode number (%lld)", typtab[itype].name, (long long)ino); return 1; @@ -2871,12 +2890,12 @@ copy_ino( if (iocur_top->data == NULL) { print_warning("cannot read %s inode %lld", typtab[itype].name, (long long)ino); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } off_cur(offset << mp->m_sb.sb_inodelog, mp->m_sb.sb_inodesize); - cur_ino = ino; + metadump.cur_ino = ino; rval = process_inode_data(iocur_top->data, itype); pop_out: pop_cur(); @@ -2912,7 +2931,7 @@ copy_log(void) int logversion; int cycle = XLOG_INIT_CYCLE; - if (show_progress) + if (metadump.show_progress) print_progress("Copying log"); push_cur(); @@ -2921,11 +2940,11 @@ copy_log(void) if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); - return !stop_on_read_error; + return !metadump.stop_on_read_error; } /* If not obfuscating or zeroing, just copy the log as it is */ - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto done; dirty = xlog_is_dirty(mp, &log, &x, 0); @@ -2933,7 +2952,7 @@ copy_log(void) switch (dirty) { case 0: /* clear out a clean log */ - if (show_progress) + if (metadump.show_progress) print_progress("Zeroing clean log"); logstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); @@ -2948,7 +2967,7 @@ copy_log(void) break; case 1: /* keep the dirty log */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Warning: log recovery of an obfuscated metadata image can leak " "unobfuscated metadata and/or cause image corruption. If possible, " @@ -2956,7 +2975,7 @@ _("Warning: log recovery of an obfuscated metadata image can leak " break; case -1: /* log detection error */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Could not discern log; image will contain unobfuscated metadata in log.")); break; @@ -2979,9 +2998,15 @@ metadump_f( char *p; exitcode = 1; - show_progress = false; - show_warnings = false; - stop_on_read_error = false; + + metadump.version = 1; + metadump.show_progress = false; + metadump.stop_on_read_error = false; + metadump.max_extent_size = DEFAULT_MAX_EXT_SIZE; + metadump.show_warnings = false; + metadump.obfuscate = true; + metadump.zero_stale_data = true; + metadump.dirty_log = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -3002,27 +3027,29 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = false; + metadump.zero_stale_data = false; break; case 'e': - stop_on_read_error = true; + metadump.stop_on_read_error = true; break; case 'g': - show_progress = true; + metadump.show_progress = true; break; case 'm': - max_extent_size = (int)strtol(optarg, &p, 0); - if (*p != '\0' || max_extent_size <= 0) { + metadump.max_extent_size = + (int)strtol(optarg, &p, 0); + if (*p != '\0' || + metadump.max_extent_size <= 0) { print_warning("bad max extent size %s", optarg); return 0; } break; case 'o': - obfuscate = false; + metadump.obfuscate = false; break; case 'w': - show_warnings = true; + metadump.show_warnings = true; break; default: print_warning("bad option for metadump command"); @@ -3035,21 +3062,6 @@ metadump_f( return 0; } - metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); - if (metablock == NULL) { - print_warning("memory allocation failure"); - return 0; - } - metablock->mb_blocklog = BBSHIFT; - metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); - - /* Set flags about state of metadump */ - metablock->mb_info = XFS_METADUMP_INFO_FLAGS; - if (obfuscate) - metablock->mb_info |= XFS_METADUMP_OBFUSCATED; - if (!zero_stale_data) - metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; - /* If we'll copy the log, see if the log is dirty */ if (mp->m_sb.sb_logstart) { push_cur(); @@ -3060,34 +3072,52 @@ metadump_f( struct xlog log; if (xlog_is_dirty(mp, &log, &x, 0)) - metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + metadump.dirty_log = true; } pop_cur(); } - block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t)); - block_buffer = (char *)metablock + BBSIZE; - num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64); + metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); + if (metadump.metablock == NULL) { + print_warning("memory allocation failure"); + return -1; + } + metadump.metablock->mb_blocklog = BBSHIFT; + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + + /* Set flags about state of metadump */ + metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; + if (metadump.obfuscate) + metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; + if (!metadump.zero_stale_data) + metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; + if (metadump.dirty_log) + metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + + metadump.block_index = (__be64 *)((char *)metadump.metablock + + sizeof(xfs_metablock_t)); + metadump.block_buffer = (char *)metadump.metablock + BBSIZE; + metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / + sizeof(__be64); /* * A metadump block can hold at most num_indices of BBSIZE sectors; * do not try to dump a filesystem with a sector size which does not * fit within num_indices (i.e. within a single metablock). */ - if (mp->m_sb.sb_sectsize > num_indices * BBSIZE) { + if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { print_warning("Cannot dump filesystem with sector size %u", mp->m_sb.sb_sectsize); - free(metablock); + free(metadump.metablock); return 0; } - cur_index = 0; start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { if (isatty(fileno(stdout))) { print_warning("cannot write to a terminal"); - free(metablock); + free(metadump.metablock); return 0; } /* @@ -3111,17 +3141,17 @@ metadump_f( close(outfd); goto out; } - outf = fdopen(outfd, "a"); - if (outf == NULL) { + metadump.outf = fdopen(outfd, "a"); + if (metadump.outf == NULL) { fprintf(stderr, "cannot create dump stream\n"); dup2(outfd, STDOUT_FILENO); close(outfd); goto out; } - stdout_metadump = true; + metadump.stdout_metadump = true; } else { - outf = fopen(argv[optind], "wb"); - if (outf == NULL) { + metadump.outf = fopen(argv[optind], "wb"); + if (metadump.outf == NULL) { print_warning("cannot create dump file"); goto out; } @@ -3148,24 +3178,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 Mon Jul 24 04:35: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: 13323421 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 46452C0015E for ; Mon, 24 Jul 2023 04:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjGXEg7 (ORCPT ); Mon, 24 Jul 2023 00:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjGXEg6 (ORCPT ); Mon, 24 Jul 2023 00:36:58 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B841A1 for ; Sun, 23 Jul 2023 21:36:57 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMfvPQ015477; Mon, 24 Jul 2023 04:36:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=AOrjB1JhGn+GoPVPYI/JEwYnShJMyRp6zWRqRfOxdzE=; b=iubVYD5iWNhkpItudj2jjcG5czB5t8zBvFuOYBqQOrRLOWvJuFaxjM+wIEk09nQE0pHb COhojuzsf7C9dbIyncg53Z0Cv6UZ62v9m/sJ6dJW5NZeTNJPWoWSFOCaUB2DOxFES1HB d7AYvfwf8+P67T/Hco7MPSccnh8Ezor87xGzOY+0Ku7ipIOYUEycwjuSLM66WJdJ2Qsk 1U0pzNRLy2AX6aQL3WRlv+YrPdSc7F7PYqWme3igK7jc5rHg+l2mtRX3VzI3N9A45mh0 NCaii2njO929QGu85sI82z6rMA743wkXZSOLT7o1Y20APmb4LwaX+bJhJ3jfKo1D1App cw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s070astf6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:55 +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 36O440S7029092; Mon, 24 Jul 2023 04:36:54 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96j2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:36:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=caBrHB3isj9r9ofpuB1zkd12dMx6Eyqk6knwM+K50uIlEDczhhh9+NktTKkXfKynAkqp2B3UFC0iNGt2vk+D6bygD5YDuS5oYIuJjlI0NJmjVGO4ye0gbZFZU8zCPm1WGLnRjH0adyUryCeWKmpcmcFvPO1e68l6qau4nJK7B7LI9NZGXFsJQe9DhWP8DKRJVEUikJxhj6bxxSOrWYWr04q5g99b/V9DHMbg59j6YUuZKkAJze388HykTaaCFANXLaQZBWcQ75z+EtzD5X/qB8RXYFWp1jlhtiJyPZblM9C/1dUyp2vFn2QdGopidCwyA4/o7f/fM1d3eZ+nRohzHQ== 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=AOrjB1JhGn+GoPVPYI/JEwYnShJMyRp6zWRqRfOxdzE=; b=GKMwuqaemCotipp6JV6YMJe+C75l+0TW2GzkpoZQG0rCRIqgb8/2i5U5RK3PukpgAWOwznApO2sDYPuxGix/PD6O6OLtHRNZWzpTHTjDlSV9mDVSWzKZ0qesqxJHzqoMCt4h+1+rk60YUrI5O6GaF5NsiVUpZIb/xE/2kwQgeS/S0FVo+rlO6u+LhXFURyZEA+uGnu9Z46bABVtrVl7E3NT1pxpdhYSDICYIP+Mvp7pgzfTYhh7GqadAP6EMqTQkZlJQE5OC9ZsiRFfKiuj0P2OKyuNg7JdBmb5YsPT4Ncrt6cVYWSIle99VCy4kEd8v65nXe7mwUqwB2mDRVooHBA== 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=AOrjB1JhGn+GoPVPYI/JEwYnShJMyRp6zWRqRfOxdzE=; b=TrjBYiPDwzfGC1nBJpzducl2vycOjmk3qFBBhSSC9CbatP1e0Hh/QB8P09vCiuUfU5xIf1JdZ/ZRZOqV3k0qR8hSo6Hzzzr7sAuxW2rOLMXI2Xwnvcwl1nwpODhfDpS4ThJVjwCObifoltpK1glFj+iBNAaG7POnEcdsTItP2Sg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:52 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:51 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 05/23] metadump: Add initialization and release functions Date: Mon, 24 Jul 2023 10:05:09 +0530 Message-Id: <20230724043527.238600-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0047.jpnprd01.prod.outlook.com (2603:1096:400:17f::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_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 66c9fc97-c2af-488c-42f6-08db8bff99de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1t1uVoTRifD5gBEXOvh+F7w5S2HnNW9yMpBJXzpKH4QWtru5LVBnfBB9w+MEMITTNPL6Z6ypsEYdkRMvIT2ifPoR77pp6ZxlfKBr+Akly7akh14DpR5O3X6NirDMAAvZ7hkd36IyumYirtl0KZEIB99rgNMqoOGPIjaiEz4sQBQoFkoh1FkNqOIt58Yc0ul24Vufg0rTrGoWtyCeLMEkDDpKwg2zNDoRlig01wO+M8K9pGnF2tvMf2LS3fsz+WhaGfcVb9p4euvBhk6U/WyEPvU0kCbCv2/QFVvtEzrY07NEfa9x61n5Sy+aD0sOnGp3Jn/g1Nj3sKf3RfOmcwXcUCwJLr/s9IJJAW7PCkPa7dh5+5j9GQTSLRncj+GACup3c8nQZOfAa8EpmVC8M0mz5Rtixxd44BJhhwL0L6gLJQuwKrVjAJqXktwD4FMtQ/iSdhWiKsRDNwWgQwgujd4wVbHQifHfagEs/42Ced3LOcqYIGGmeFyDVH0yttxflJsYEMZYR5vDP8pwU+b1FIineV/BG00LWhUaQlmdFrmJIOSZYXotTCYufAHKhkrXXXWP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2huJHlkI6oTvMpMOyetq6RTV5cNRzfcB6ar+R05N0quWBSQxMFZQ0wXjtBk+kKc7bg8xUhVDAODE7TT7jCO2Lgf5pOCCPWjtl32n8kxNh1sJxPA71lf66hbEfgcE5XextxxMs+d97YFxVw1GTPohxtWOtBJMdfYNn4dFc5nRKd64rUG2m48tLn633Bxsh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rcPvxPck3FGa7ULRq2n/Mz9R/EYfd6jvQgtIRKnj70Ig9qB4VigYrLS7MJA08XvRYeNYmBumJWrObZ+98EwSWUSAHg1NfoCFhz6/WolSemroqIyL4LRBRI32z4LiVOuHYuQeacjvcaLMY3obO95m4i+qv4TKVUOZGgnm8wuWNRbb+wlFZtMpJou7KTKXwM+RSvum/2eUFoJrcjwmlG3nY07bedZkJ54b5SQ61PXot6CswQPxVp3mxFiI2I7iF8lr8H/To+dHsYDeLJdtuXzKT4RHpaPtTWTEayRY3j2v/6zcCbFDST2QxjgsQ8Jw4EG4a0XBbPstcpJ X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9Z3iH55+qX98kbgBQM/TQZuz1hBdBEfbaupt6GGVDTDtwPGSetmn0nmXFGUHMtq+N6oWVuxh9CqUtVd2x9pCE4xTDm8Ly06M7D0/dniSR92D2RZCwXNygGJ++C61ElIpA5UCa6RRefYWR43b77C1qGxzgxeqPIyOSmgidGLIUNTVcrmhnYzPKca0qZPLIDPf9diUi9EZUeCOMho+iB0kbYJuQYUD/7VW57vceecVTqPBf02DNFdM1026TMmh6po91iQkwxv1mAHS0zUsQQpBosCAu7PN3aqf6azlGH8yebX+WuMC2ldsRDhqsO4Uvtgrx199dQSjojY2PVQKJQ3GEUbh5a3C2TW8ywEScho/0UJOKBX9TDchbT3DK+lMd+fn93vpQhbrC1XEnUsmkVEaNp1ZDG30nh8AlH+lCMTr4foc25g/99rQsy0ttXvSjhgFR8mzGZx4GmAf5kMdY4YF7njYqPtcym6/y+fAcdCS/taqfhyR56IJhtQ00PTtkMXxMDioz6ftKejgIt8QTlFsMcJaCGXpFycUBdKPheIzbHvl6bFqD6mGx3mAqoRGjilc/EhcI/qH9j9SyYXdlZlAM5c8Ds3xKpXiiUguzgdSMCL4oMh4LALLHE2ssiK1Rmmisrln6pqIH+gzJzYyoCdaXHq6vudgnCXiaylYefi9A3jzOkTzRGdjA9G+GPLxLp0BYW4gt5a+O16atHdSIJdWLNFJXpobg6c8CQrcclPx9dsDY3b3otOBKlyLryJe/Frd3SK2RELb2G9i6nJiRvsKeF1zP92ilavk2D6+T4eh4TY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66c9fc97-c2af-488c-42f6-08db8bff99de X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:51.9474 (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: QrXoDfaFf/PmVVEGk79P2HZ3Y5iUemNIJSt/t2iStcD7v2SEtwkZBH3IrljEvu8T19VQF5UC2w/IEfPoGJjQ2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=851 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-GUID: EqsoTc8t4064ZEzJKiUEW3Pu0vhIlpUs X-Proofpoint-ORIG-GUID: EqsoTc8t4064ZEzJKiUEW3Pu0vhIlpUs 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 c24947ec..8bc97a6c 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2985,6 +2985,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, @@ -3077,48 +3125,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 @@ -3195,7 +3211,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metadump.metablock); + release_metadump(); return 0; } From patchwork Mon Jul 24 04:35: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: 13323423 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 74411EB64DD for ; Mon, 24 Jul 2023 04:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbjGXEhK (ORCPT ); Mon, 24 Jul 2023 00:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEhJ (ORCPT ); Mon, 24 Jul 2023 00:37:09 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431FD1A2 for ; Sun, 23 Jul 2023 21:37:08 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMRLFH003455; Mon, 24 Jul 2023 04:37:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=M1Fykt9drEa1+zTcVi1eSPiP+NLoBkqrG8TxDFiEwz4=; b=c/uIrYu8li+YrxwKIIWbJmtqu9GJ9S+s7kR1KFRgOCR0FPRisQQXGFWepgQ6E5Hn6w9M ZH9xS/2y7hbYBAHtUXaZBK3s4Trneux1rlRRN88Y4sb3HMuawR7269J81xV7RuUez+Ht aS9VLSU47YZpghO3xdH7QEm7XlP72lqQ+MFm3S9scPVCAVb30HFcQzbLl9MsxXYQmIlN Htut81wUoumhaoDKGsWfQZz5trjc0GQnlMa9IA/fc8xeKPvGP/3kG2SqsCqcC4Fd1aCS IXZjOyqtocAcV7IALNpm4Mvvyc0yyS5fKtaYtcZcLoEEn3QJhlsm2e36/61cn7EQkhxB lQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s061c1ve8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:03 +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 36O0sJi9028878; Mon, 24 Jul 2023 04:37:01 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j35xx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cx4oNqnsyzfRydiLXZ83oagII9uBfx0CIifGjnHiIV5E8vratFk+OgopccFpbTsyAGTnXOMoE/ayPjUVDjOk0Lr7SIXJPzcKmlmzGXFBTi88rXfoqq9pjwxn8ZZeQqx4xFBWddwfO6xMYhaJ9qbCpmysxCgh9o7NBHl14FTwgILSnmo/ftFrGYTog/m/6mhGYoO5cQwBQFvkGcYf1QfdbPJE7KuwAGOVYqVxQcngXvvLuSu6m3v/QfstRemaeM9EkJd2xoK5SnAB8m0nvtFE/vSilASNKg7dEkrV3olYPe0Ng6aMMh0lhTWKvqggX3kxUl6tjVO4MT7/9dqDkyCaOg== 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=M1Fykt9drEa1+zTcVi1eSPiP+NLoBkqrG8TxDFiEwz4=; b=Bj2zxgn92B2xa10n0FPfQBhjDnTHzQEApWV75PFU0Hsz1rFFBShJNetm8k+QVFvhCKlxhKhGHE9pqkrB8w7g0UO2x9fN1It3dFT0sUL5Mg8hYutB80EmJuIa1gWrklPFt1ePlIdSSsCAw5szngLHw3e6sYB+88tD4D/CDHZT6maG0UtntnrAll1YFUbgZ9M5lnkw/Tpdve8Jbn0AKbwOTQ8gadct9HMYsrZuFyxZHxWmutV6ac/inVoy+7ikqOaj+d2EbPPFfDJxZ7seyHzmVOxejzEaj5smvLJzsZV+NhKHXnDUOsxLmA4A3RxoHS98WzDy27/G2oQ13JpYTrlq3A== 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=M1Fykt9drEa1+zTcVi1eSPiP+NLoBkqrG8TxDFiEwz4=; b=DRbw7qFbX+K68ulkU/uj55XgVsyAOu9cB7CbPlXo6ukBUEALAq8yL5F+OqKXGiB5YYoG8OKH5VS2nUbKhiUs1z1t8ue5d9Dj2mJsN0kibfQLB50Ax+aeISu0XkwUphloq9eOj2Fhyy7xrvK4zlcq9iz/a3cTKKJGihBdtORAucc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:36:59 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:36:59 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 06/23] metadump: Postpone invocation of init_metadump() Date: Mon, 24 Jul 2023 10:05:10 +0530 Message-Id: <20230724043527.238600-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0227.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c7::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_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f3e3fa-f371-45c6-aeae-08db8bff9e51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N3vTBPM+Rn7X8+dMZvC5CBT/wDWHQV4ugvmDsvj5DIShE+o9f/HiNk2zJV9cvSkxXV3yS0obw0DSo1lluD8v47xEq/cN29r8XOdjPN6hnxEWLqiNx+lAXa16INtchJWwSzObIaUTIO6rZk5jI2PywTmsOH5CwRK4h3e5laF/vEMc3nk3YFXzEJcGOqS/jH4NjrdNWc9KDmrXKUhykRpLUlO8jQAsZ2xXcVRgFa3mhLrRhlLMcQyUtv8arDNNDal7KfKoziM6RDgjD0pJ+tgAkEoKmi/SIbiqQE6ETlQu3GcKsVRC3QMWLIqug5b6NJhpjODTS5IlkX2OwsW2M4mcmpXtJmt0BdoGhqzpSanj2DrZhdh1qFNj0MFUbv5wT2SecP49PSDVWj8wvNM4J/5wc2VJTC0ayhIf71PSeXAHBr6C4kg4xtZICNdoKePhvB8rcChoQ24bER4w1y9QJrc2QkX5ZVb7gBlHN2j0WbH2QRQAeiGbf3e89mDTQCpjhmWCih/xN22r68w4IXqEyxjOqUFKru/99xvWVIUeZUBdwKbF1dxneOo5jhkN+deJocKU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d6OGt3uZk/ZMKipt+dTawPTla3VGaVxgSCaxJpk87lOfnSI5UT//2sMoeRaSkeA8QluBM1CYtReF1KJ78PWTRqR4eL6VPCz8XMNHYVyCsNJgYMeLNUW2Aiz/QrrGASk7XtRky+Gd2sTZ6JYGsiShHl09xCQS/mM00BJmDful91tM+TIcK3Mt7Q2RJ/+/eOl5GPKljCc/fOgKgvNYtADwucWLZthbBb1p2BKM0Wm5IjeC8Fvko7ZQ81RboGHZKRq8NOl0bwd3wzjvpbHj01mysjea50LTAhU4EkgIz+SyH+/qjRWQrOZ2x7/txmhijRcETTG+uKQ5tEDKzPJrrs2+ehN6vr0Ej8BaAWGNiuTNWzhA7i6kpk4Wk13+eRhTyMwAgJK+4e03nMWlldhihwiEQddEd6Uc4iFWWJ/3f6N2scM3U2s0tW9UijtsT7aMIxhzrcv73zt1yOjkm137oqOAeuKZrsSXSZLBzxcDbmL1Xy4YT/fcYOwlhrTz96h5BIwFyJUbmnLAxjwe6DON8zx6O6NaT1RCI0xfMYvKuFxxIMxs9LRw7KlL6ZpFOmn8Ccr0wQ+WgOXAl8FqOyHXCCk0OB5QJII2uvRuR2/mRSxkml9qdCxD0tXH/Nz2w6FttxOAqrlP18GmWu9njWQIA5fG1vFG5/5bqJFxJN7VKX7tamluJ0RdIn1GHWVNpu+o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fzAAwwTUs0PEWSQ+gm5v7LzbuyFxLAc1Su/hM+IP8PD1jPhNNaHGhZ8uQzY4aLb2fuRqhXkBEGJFzUBlmJytWYJBYZtCrUa1/rVs5RMtjrUD//LGeyg45IdPKTEDjmib6HXL9y6fRPTIT3YFMQSE9muslV6wK9dqO76GQgBq8rlP++/2TLsLJO8YnvE0T+M81d86gCZXmQZky6FTAnuGlD1aS6K4KeBehKwLhCVOgGqxDZU9elTVAMVsifD845nGOOYRphQAXSpVdn3mW8RYYOliaP4aeF3BIXONW4INX/w0vAC5hLUVh8mnLXSULJjxE9ZgEMwqeIXkMBTzkj6S3BUM1fXKPPDfZSA1xCx+Km+Tv05ZwzKp0g2P2VJAO+L0gN1fhSiaw4s5aYPhHROqHAV+wj1/9SepmpmPqggWQU2sQP8cW01IYbdskM9r4XQ9hNl1BkP4j9CcDKmmTuyMoriE3VvGb1ix6aO8mm5DkzOj1Sh06bwQIPY2ehoZWhpgI8Im3K10/XpmMIWiVelCUmIcOVosxCefzgDCahkkXuAShdF5Q95hAwzIxMakWwBBYQpq3kwQZapvvvma095RT6vQ8EkJxS2n/3PnlWQevdPSc4XOMZ4lSwsM2y6EHhEp4mz0l8dMEP79a/TCjXyHMFfxFGOb1iASYT2tKcUs78DaxHgRqjigRTew+u7PZ0wA3XiydLfX33uN1+v/Ipn0KCO/JijA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f3e3fa-f371-45c6-aeae-08db8bff9e51 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:36:59.4050 (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: OgPyjB7MA99Xstum0OBA0t0lgIywsN2e/opA/6rLpHQEVXCeGGKGYUooza1Y6p4iSqEL7N6WvljdveIYYRzSQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: A8hZcU_zH-KCg_GkMe4-ff7qGY7HO3_q X-Proofpoint-GUID: A8hZcU_zH-KCg_GkMe4-ff7qGY7HO3_q 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 8bc97a6c..aa30483b 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -3125,10 +3125,6 @@ metadump_f( pop_cur(); } - ret = init_metadump(); - if (ret) - return 0; - start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { @@ -3173,6 +3169,10 @@ metadump_f( } } + ret = init_metadump(); + if (ret) + goto out; + exitcode = 0; for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { @@ -3210,8 +3210,9 @@ metadump_f( /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); -out: + release_metadump(); +out: return 0; } From patchwork Mon Jul 24 04:35: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: 13323424 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 9C40AC001DE for ; Mon, 24 Jul 2023 04:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbjGXEhN (ORCPT ); Mon, 24 Jul 2023 00:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEhL (ORCPT ); Mon, 24 Jul 2023 00:37:11 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941FD1A1 for ; Sun, 23 Jul 2023 21:37:10 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMbAbn009717; Mon, 24 Jul 2023 04:37:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=gPFiyvYDKJuasOfkr+VvVb83W7GBnnHtVP9oyYOqt60=; b=lGPn353YWxrjdW5Ez5V8pwc6XYvKUxRYRV5ql1xc9kb/ukjDzgNbyTfqTi6tlLZBz25A qRTcouz2iNYtnmT2nHHQIOxU18BWG+YlADK6x8Ym/cpEinCrKUgSh8R2wDG/AXU8YSsk LzrH/kz0v4y7uGJS58vdUFha+X810+75GTeMnfDdzl6lTu8za0jcjpmD1UNvXEQeZr5D fRohgOZPtI6+oy/s69+wUZk5IXAUnYNNLVs2pfBEDyjMH3am5VWKCgwn/qX53a/RzHX1 NnmqUu7664EeXoRcKtbagRnuBFGvhchDfKzAQoCN7gaLh5YAo4bQNV/5kD+dkMqKEbS9 8g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s070astfn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:08 +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 36O4Xb4p003751; Mon, 24 Jul 2023 04:37:08 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x8tf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxOez5XEV+N1DxjP0diqtbogXzRa+dai3JWr9uS1b1u8cF4fFifUpffOkX63kuug5YUCUQG3PuC2bbm1ZJq8BueWKBaE7uU04FboWzVKx4+MzRtUxZi5MPGDtGmlltH25tPQxPdenK5GW3f3YWoUsYdfNbI/7YdU62W0eHXS0MZ45uhrnUpkTtk7D4oFJ8zsq3CA6cNnH/1Ne8zw9wo5o2SYs3wiKdWFTa9Ae7kse2UGHDIEAinX/zxwWj2w+OWFnBVzmo9w+ISXnveBdRSIUIgw5e20DnTQ7HqUJfEWscAUvPBUOwNViLHHFR6IDQVdMZSqmxvoGxt3WccKd38qMA== 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=gPFiyvYDKJuasOfkr+VvVb83W7GBnnHtVP9oyYOqt60=; b=a/mspOuWaBkqcHU1xUCs26PkBgBC4RDJBQrJs85o6Swf84l7ZgDEgoFqnS8aRhneDqdzPCuon9yIt/QXrFd6/SmMwjXHRovML+l82b+j6FFXu1+nWWolguVfBneU0WTN6Nk99+DN5IVl5v8zlU01JlTOQeT9i8c9pdAg/jgmwyUEk7rm+v33Kksd+LclnR3nyGkfmsyixR7C8b23iXeZkNwuzeLEU7IbTzSSPlJ0daDu0Zo2e1wKLH8+cxmpP3WhsB3ntFjTU/VMcwNzdkg2E7xHnw55eByc2zPxks+pW6lFf34LTV2gIa3KhqkKbzr++LocsAneCFmtABxyQH/Z2w== 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=gPFiyvYDKJuasOfkr+VvVb83W7GBnnHtVP9oyYOqt60=; b=ylWkjuyLVPrjRhAR0IVp/ubrQIta9ZJ2l4mNVCP3PXKNuEXMe/4FRLuzp1RAR9m0zkTmcqLXPX5rnElo3J4lmm5DOgkrwpI/pb/uGRW8Rx5775JPX8fihCAbLBavjoNvn/ucG1TVpiJMjXSqxthNDAA0CIx2oANrRgivmrHzsDk= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:06 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:05 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 07/23] metadump: Introduce struct metadump_ops Date: Mon, 24 Jul 2023 10:05:11 +0530 Message-Id: <20230724043527.238600-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0008.jpnprd01.prod.outlook.com (2603:1096:400:a9::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: fd4fb3cb-a19a-49bb-141a-08db8bffa236 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IqQQRhIQWE4NPkdDkhz3+TneOanqVv2TBG5S9C+6upVzbYBNa+nqbGM+71deCOPwARYiSqlG42YlPMeIOc/wSr6E9xy6NcuF7gLJPz0jrAVLMMgxOwPv0IElYxuq4hb7X+KZK1h06duru52FPv43AMQ6sk9b3jKzhu4SGPsjAOkuJKEZ0mHrKrAakFpUThcToEp8vsjM/jCJDcuYk4y6IutFivvF85lXwF28PmJR0E5dz+FPGKHCHxRg39IzhPzhOr1vIlJvKwd/qIUKeqykc4li5S2g+6oZX5fGQsVIlmn16rr2LgRWygqHYioeKM1sEnsN9OTa6THB9MR/0GSuahyqR3cKILjYQ7/XVdb2eNAL5lQ3+UH6kE/XiGb0Qz6T4FyrUxrVMXwNUMKcH/oKpjdTpnp+0R8ZIECJueX3Db/v3x9BPieeGUGLLJRbRDY0mGzPePyJdUYLWxq0M/F5NnmAKBJxd2rRZjGY//anXjJa2A3feerwaj3KNxt0tgI5AfVHEbgaEBCUD9Jljkz2mHm4I213vug53iQy4XqWHAyFwB+/tftJ3GBUJEQLSEBf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pUzmrkeLHSDoYjSogBJpT6nXlMTctk64z95MRpua1AsJlcVdiLqn55XFsCZxTEIQr1SQiqnf/e1b+TP7zlOhabTG3ZFz4O43dvec+LRJVODFcG11+USK6QT8yxGUQfYdpfnAlr1SJkxmi9AliW4Vjs3xxLODlvs/olNHfzwTyOin14ExhP12iMj4EjuJGZ4wjvhcdWThunozH4e34clV0dPxLqT4FzDSExxzdA+iqvq67naNLHq1WU9y7jOgttuU2jU5lDO9qfOsJT//H2RgHbexImgKHLzAjQAwUpQJhjHagnGQh7ewr9AyovLYPZAWRogKOMZZCfvPWQAYdlOMHBPA3JPIJK7lX0w9eLk0eS7oHt+JtjpBEkZsIPJz2uVMIkMwsHM8/w0isZnHm0YWHEylKOrCN7x5Wl3EhA7yjPpNq7btUKYkkiXJZVg39AQJP/ULV+o5NkL5YiqGQe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cZQKf9qBipWyVHnlTMhvYekuqQM1oO2phcRAPHmZnNITmvdlMi0/1OIdqhUi3fM6vLBzNG5ObYxNe1GYyDA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: NyD4YoWcDfs5vz8k4Af9hv3Wa5ijKelJs5fhhCX9JYoSlhZdm0JA9/XAs1627B/EZJ6Xgco6ItmytSdgd/UHBwHkO9lCp1I18s6KbogYqthc+oSB2S4IEwxwNmRkuErcGkzA9sBmdsvE3DSKB252P6KcAgEfheOXabEGmRkJjjJT2qjlqoorNSV9WyxHlcAUyRRQp7jydPXygEf4khw2BeU2dSgKei8O79op306H5CPLXPxXTbgJDlgluaERf+goE1Zo6yPJjiDvsqwimGrT4S0TUgUKzrwhZoOfl26U/ZmAGEaVTB8drFsTgvWaN4yicSYXYx2V7hmRIyK9pfTXuayu4HyjLVpfNYi40XRq5vRTUThRtWTi3HoH+O+n0qyS49edBQx96qWf3iLd2Xkm8PUuMgTd4zgKvXXSA3m5zaeYq3UQQDDqdJEwMxZ/1wBNP0YZT2JEFOUtXsMa4FDgg9D6A2uXxMTGwPiUcvr8fUWqgiU2W8euywFEr8kmqzMfurYk4ZUAIgyunGoLtQ1T6W6kvYPelvV4PDpdkZ74v+fXcPREEvCau1Owa1oJL5QwhYgN/GZG+PvM7Hu7LXB5p9GH99LWPPQZIIwTKnWqIlfE9onxguYjmOILZDOpzew1BZwRX7zNoGTiokmRqUmBvNDJUKWbyxCWfGWCYgwiu/8FZDyqQ+q1PpQCkVlLr6km3nY00Dd3nAklhYr4UrIR27tE4pce/VxAcWP9PYTP8ADOL7eL+brOznk5Le91lnyVg6kb8FYpATTxvEXNFXCw6kk1nQ7F3Cp+WVMl1Mc+icc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd4fb3cb-a19a-49bb-141a-08db8bffa236 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:05.9270 (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: qCTqisAJKb7mDTwJYcavM5xKGMV2gteCQo/LbOAp/PlYKScLC90V65dcSrOGAMbzXDg3XMf1g5xQj8zaUv1HCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-GUID: Y7L8C-hX6qUrCjCVvZ7EVTum0OgGDyey X-Proofpoint-ORIG-GUID: Y7L8C-hX6qUrCjCVvZ7EVTum0OgGDyey 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 aa30483b..a138453f 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -40,6 +40,30 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; +struct metadump_ops { + /* + * Initialize Metadump. This may perform actions such as + * 1. Allocating memory for structures required for dumping the + * metadata. + * 2. Writing a header to the beginning of the metadump file. + */ + int (*init)(void); + /* + * Write metadata to the metadump file along with the required ancillary + * data. @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; @@ -54,6 +78,7 @@ static struct metadump { xfs_ino_t cur_ino; /* Metadump file */ FILE *outf; + struct metadump_ops *mdops; /* header + index + buffers */ struct xfs_metablock *metablock; __be64 *block_index; From patchwork Mon Jul 24 04:35: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: 13323425 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 B27DAEB64DD for ; Mon, 24 Jul 2023 04:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229903AbjGXEhV (ORCPT ); Mon, 24 Jul 2023 00:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjGXEhT (ORCPT ); Mon, 24 Jul 2023 00:37:19 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721211A1 for ; Sun, 23 Jul 2023 21:37:18 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36N3n4SO023604; Mon, 24 Jul 2023 04:37:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=r6e7J2/jI0qDysiNTwNPel04H4atctawZMY6LKbo2BQ=; b=XxsyDIFg9DeTMbO367PNQpPOJqNPU/y+arFs4tOwUzfEXLrrrusWF6qWzMa2JCMfvvIx AQJsFXrR8fHX1rWO3zZAJ7cYpEopfZq2z2IwhC3hTYqvqed54s37lw3LBE5Xgn3pzDEy e1gSNiiCgFBT+uaTy66LPeM5ksY8DbogkZVUXc6Iq3vh92yK5iPmEcBdqsip7fHA2jul LE9vbqNJZTM6CRKMpRFm2bRN615O/McPhs3DOR2e7bWYZqp4w58tpTe6h8UNv5ELtlhT 2bTtKMiUgyH0NRhmwAwvcrSKgpX2uPR4mR5QrIOdCPf9MITN0TbzaiDL/TW5lj3i9lTm 0g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s075d1u1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:15 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36O4Plg6040850; Mon, 24 Jul 2023 04:37:14 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j3e9r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C5weA0TIAjmz1o6IEj9lWwRCBQqN3+gy19fk60RbqsK795xpSTmYg7n5CXfMrYq/8rJpJdm+s2STs2ZApA+wG4KTWi0QtgPWqoeFZpHXAdZhjr9wH2sbS0yLltHc/oP9kA7Fh03A/79LA4GWU+xqMi7BPoqRkF/lyFVmtc7cCDqtLmZ+97zaULuVC/ODzxvEwWbvF6S/bC/00+3Y+efcbMS1U9s2rokT7RIp7wHux7+JAkJq+G6I6WLpsqocl0JB4ujuPXMKuw1BdEoOcosaO5yv6FaC9uFKb+8unT1HS1UNPTIiFn65FxMaQ4BFMs3HdynIHDDup4RktwrNyHmzuw== 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=r6e7J2/jI0qDysiNTwNPel04H4atctawZMY6LKbo2BQ=; b=IkXpKfzBzdDw5qQq+E5AVaQ7Mr2m3qlOXN4MB7ib3U+WoPEimC/zzkrUqU2d416ub5E8xO7gqHtMsZt8ebgzERKeS61rr8/Ldu88GWVCs+MrAxFLr99cHNPAO+QPrPAc9s5EW59aR53a/7a8iAe3V7AArEhiQmazMeLnxrtFKX+MiKpvtliv3onVabGkZF6PC+CBtY6tG3RuDljegEhDlPosPWNC5Ayzba1+PS6Tui2QzG3wz6Dl5/9Jp4sI0RKxc5qg40UbZL5F8d0by5AWTZJPXWekh4L55FTM6i5yyldjkxOO0pPF8UdqSjlJdNKWTjDBIHYw9drQxk28qj31pA== 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=r6e7J2/jI0qDysiNTwNPel04H4atctawZMY6LKbo2BQ=; b=oMJy+piC3wS6ABGmGqaE5CDJzb25qjYYy2fe+lz95qZnekTop8MrJMwGKoq1RZ2l2WyfSbHk3mkC4kAOjVxoc5h4V3cR2M2GljtU1h5R9wJCAuVHcXZACby+rexQLCu4BALLxeRHFszhUXa8FfGVjoUj72uLoNm0e8DR87bA2kA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:12 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:12 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 08/23] metadump: Introduce metadump v1 operations Date: Mon, 24 Jul 2023 10:05:12 +0530 Message-Id: <20230724043527.238600-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWPR01CA0016.jpnprd01.prod.outlook.com (2603:1096:400:a9::21) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: d214f1ce-16f3-4233-8e93-08db8bffa60e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lzAWlm70sUpaktA+G9lk4V7gjvwpAdZwRCzaEfmCyH2VC6SkqImX0016BJdl0DmmE4RtwImx5/G6XViDv5fi+Y+L+Ohg/HbBiCbSzti/Y4JGB+V8iwQ1bnriMvogLOtNN+CwTKLi6RvO8r0P1Liji3JXlupOkFMzczjnWeiQgXDk7vOA7LtfQMhI+STGtLk626y5KMs+biEd7PBfVLgfhyyHAx7oh0AsCeH/IOSrIUiZ1rZc+wQ5UjL7hVKeVlIZ3IPL9qAgZT/cu2wNpkSr7jrJghRddL+ZZZ1B8SkGzT9rp95UaU6+WnRfyHjmVaiWhy4fjeKn4RCRCrWIKNmnP4PwtXsHYW5aLFyXNSSNbPZ6sbeAB2hc2pXZfGpJx7sfKcGfEHgbVThF59a13nboinSvEk+o8ZJDeGw07dGHQXCE5phHyIAlL+APTyP77UOl8hnXlqXDo9AscY66j0IIfKXfn6Lpq1c3exbCxXV9DXFvSdvlbZekiKoTwpdciyCj+Pki1TCOhPYyGsbeOXTmimPvZHfd4zAxn5UmkjsMvvbn+aXm8szWdIYrh6clqSFT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rrlxZ4CiN0xZR0OphMlfK/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wVTJTxCshT4lK1b76sMgxAgQMqXDoyu2V79PemIAteJ8ththT0IL6loQeUvIPQ8QTNr3LwJUyXtTNNcqPPWfDZJFn7PQuU2I4q5xAVcAxOGABtyZYZKnTR67WVr9TPaumCN/8Z5YDYceXrG3I9Pnbc8zEAZGKM29jjtwyonMwuf91r34/dAsotisuVSFI4TSW+LuQTlCVLDFApPs/DZJPZBmRkTzfor/eCueadgmMaTNFLcXBKLSLyuw3d9prwSPNm7vhfE3vXtsu8CU3ctCYGOJn8JHXHi4Ox/keg1iXW3XbK5xeREQltcKzQrkFQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d214f1ce-16f3-4233-8e93-08db8bffa60e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:12.3867 (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: vXD62p7VWkFyCZwjCRIm1fbWIc8d3JeyajRfyxjY2YKVwRUvRgx2JuO4tks7Mj7orAtX6vQjwJzxhawTPl70Aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: 7oe6AmEas_gjlgCz_eLf5w4eJs4IXdZP X-Proofpoint-GUID: 7oe6AmEas_gjlgCz_eLf5w4eJs4IXdZP Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with writing metadump to disk into a new function. It also renames metadump initialization, write and release functions to reflect the fact that they work with v1 metadump files. The metadump initialization, write and release functions are now invoked via metadump_ops->init(), metadump_ops->write() and metadump_ops->release() respectively. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 124 +++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index a138453f..c26a49ad 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -152,59 +152,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 @@ -241,15 +188,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; @@ -3011,7 +2960,7 @@ done: } static int -init_metadump(void) +init_metadump_v1(void) { metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); if (metadump.metablock == NULL) { @@ -3052,12 +3001,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, @@ -3194,7 +3192,9 @@ metadump_f( } } - ret = init_metadump(); + metadump.mdops = &metadump1_ops; + + ret = metadump.mdops->init(); if (ret) goto out; @@ -3217,7 +3217,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); @@ -3236,7 +3236,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - release_metadump(); + metadump.mdops->release(); out: return 0; From patchwork Mon Jul 24 04:35: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: 13323426 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 26547EB64DD for ; Mon, 24 Jul 2023 04:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbjGXEh1 (ORCPT ); Mon, 24 Jul 2023 00:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbjGXEhZ (ORCPT ); Mon, 24 Jul 2023 00:37:25 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15A01A1 for ; Sun, 23 Jul 2023 21:37:24 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NNNCQg001492; Mon, 24 Jul 2023 04:37:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=WxQ3rU/98LcQN8BGtfGwuT/w/tKOVbV7UOfxEVvh8xs=; b=gUfcg5yCmL2xga5JbOAFSByZxjjOUZoDTrO+XvjXZvFnkpLAdOY9zn3urH4RA47798K7 /tYLyKVrIHXrwvPvzJaUGMND2cKa0Zx/JJXKTSwroqBp3bIap0N7MR5HWgdv5idBGnS3 WRxW4+xG6udkPycn1cSXIEYqLVjcUl+Ljl+MvCCefDA3vr/MXDbmBNIik/FHFvFOfu0M xy4Pe7AEOIxxdE7XyISCJXcepy2XEcCWvIpSVG9LnV2VGixUzYKEpedSonIX3gj3SEd4 6yDZUUK7uQrIiXjXc/mJmwjKuR+OknIwcXYxBtdIwP1jc/TtcVxLrNkRxhgN//KZpU+l kA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s075d1u1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:21 +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 36O1WUcq027608; Mon, 24 Jul 2023 04:37:20 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96c5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cyxa2Id0+0Fl2khikbWl0WhqTzOJetBcd7I2vAgPcLcaQHker2fuQHLwuG1Jci9fvgs9LNabFSXIPRdCfHzxiz4TcAqmMw4CZGAQ+NkUVb8scyxvsPhyLDz3F+jQltHiAgMjiUhL59Iw/CWCzuZb1Ly+u2I3PWxIez8qO9it3y7JHsJ1ZgJ35BhwWOrYO9T+mkhw66Yiu3i+UeN7lho7RZJJJ9+i0zFrIVNUucoKvDkCJ6kJXl+fhnuhLab431emZGG25NTPwk1MLJ1IbX2bJi7jsdpDWokvvF9eCxEmJqxitOwFw731hbug1771fc223q5gWLsGi/g5Yy8Y1NIGPQ== 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=WxQ3rU/98LcQN8BGtfGwuT/w/tKOVbV7UOfxEVvh8xs=; b=k7JR7kDDMU7HmcIHnz31lScEkMtHwj/M+RPbzy2DYWODZCaCxYRUmAQ9b0kFrWnqlp0zFRakd5IoNEpl56ZSPFhQvbZg4zOPHVrm5MeQhpCAtufJQKClR5DqikmbCyXHEqVOLauxTpsmoi7haytvIr8nGi6oHhb2PQcMqeWwIMDUcMMc0jMTd1KufjKDWBErrO5qpW5O4CuJ+1ObuDhgSzPoREUpPmd/pqpXcwAf6mm0V2JaATI4K6AnMdKmTVHmMJLjDq+4cb13wvysK72/OSpKdYpoK3YJk9yikFp6d/Ew2OffkE6OzRY7dnEugjU46eiK564VypieFAf7wgY3Vg== 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=WxQ3rU/98LcQN8BGtfGwuT/w/tKOVbV7UOfxEVvh8xs=; b=QfIl5ECB3zifsDE1cz0IfUycpX6tHO56Tdtpr8PTtCir/eNU0d1RXylV0n72R2VwDPWlhDUKv9RkeMygAOBt3v0Zu+qWcRsQ71urTcP0SH2Sun2cyUxbW/uS20U8gH5fReXmggYKVkUsB9p+ahgjWbr4KWIsTzJrmFk6QTV3qCo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:18 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 09/23] metadump: Rename XFS_MD_MAGIC to XFS_MD_MAGIC_V1 Date: Mon, 24 Jul 2023 10:05:13 +0530 Message-Id: <20230724043527.238600-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYWP286CA0027.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::11) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: ebb0e592-3e2a-4ac7-f726-08db8bffa9d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FMEloGnDGqDHQ2BW/PLtWU+Wl1XEkqkdf7Gb6pxekiKTQZDGw3gFTiU60EJWLv2WDkRaRBJJ5TyViZbZjGdDmbBv3Za4f0hOzX4qZ0HMbYjQ2hnmX0i8dYJC/4Dbb7vfIHqemz7w2OPY9+yZwVbBYVgZz0kY0hTf2vpBp5xER59tzrVJgBCA8FKD5FzgfwJPsVbWqlEEe2Kh7PYqOth1HWIt+eRqV2WpyD3bA/OT6HXKRECidmMPZB/O8uFeaK+8bf2kGWDenQbchd2u8QAe3/EzCmSD8RnnuuSyBIyAXidYXFhVXcv4A8YkR+xQhtYyoPkNrBYh6mNWFusDKtUAtE/IKpnc2gPaAmjf1/yGZvk1NP10m7zAabfQPIGb++ikOtPA54v6qzCRsPVy/9qlTRxt3oNchV9pJARHqY2Biu5my6+C9y/wXc14vhpfNiSZ1O+5GXnFFpij+N2rKtZMfwrT/Bmek2U89E4rUfuRrl+aiT8x8+4mlPhU0L8JQc5qEvcubSXZ4u02SKwNts1svQaBOD17c2nyfu2kwPuaT3SyVzTiaEZk3s087KRHExi9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fXpOdKaP/vaWEwUgatM7xhQ3Jgo7yk93DFpA9DS+8QI9TooH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qgpNLJYFzBw9js15M5ZDHLo73e2USc4yvvRP0X/4TnY9dBhcklppFPomAbAdYeFO7kSaU7w89F5jntAa7yEOhheOsNG29LBZV8X1pmG6LMO+V+gKMUNAys+hLPD1O8d5HUOhwlT4jRmCdNufJCVMj6o31QQRsui4ZLChed4l2VC/hRz1tYrE3XvVCTkKdHRyoq3y1hWlMMWYpcWO08zOL0oGcnDMuqaZaKMcu72J5q7SERk/VDna0YFoqn3EpO2E/uTKMi7GRaToEjPZXGrf/gIYUlLZAyXpbXvmTPuC4otvC4CCKp2RGNa0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebb0e592-3e2a-4ac7-f726-08db8bffa9d3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:18.7418 (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: Mu48TuQSHUPFibv8ZLmbfBgzlQNlXRDqk3fxKHgYS/6Xuf8bNOi0O78rY5EYEOqKnzu8oc7T0kwowY5Bl9IkQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: U7vJUcxUqcOSz5xALMGfWu8AS7rmhAYB X-Proofpoint-GUID: U7vJUcxUqcOSz5xALMGfWu8AS7rmhAYB 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 c26a49ad..7f4f0f07 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2968,7 +2968,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 Mon Jul 24 04:35: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: 13323427 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 9B2A7EB64DD for ; Mon, 24 Jul 2023 04:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjGXEhe (ORCPT ); Mon, 24 Jul 2023 00:37:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjGXEhc (ORCPT ); Mon, 24 Jul 2023 00:37:32 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38B31A1 for ; Sun, 23 Jul 2023 21:37:31 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMan1D018630; Mon, 24 Jul 2023 04:37:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=5KL2dSRBJcX6W/k04xfgLvJGNrMRIWN2CaQHACXy2V0=; b=c57HzYu6QoAkxGJJ6wae76KNExjxS1+wCyWCpHFm4YLN6Bcj03HP+Rtevfsve4yXb5Oc j0IpSOb9Gte41ZiktyhKCQYh4NprNnz+TlBddW4sMWbsb9n6oQjbGIEGqInre+Je3nQy cvwqD/xfji9Vg4LJjCRDVpefuj+P1fqCN514tXUc5vbqsDU0YdkXR0Yflb1cF9qG8QdA BAPXS9ZXQbpW4iaG8iIPJCzOnQiuYP7AZHaHDTkc0Sh7a4YrxsXVZ2ChAH5NbsmRkYsG HfGJG3VaiRX8+U+zt8UjEIr2Z0poifP/dL1Mdap6kABWOk/InkJSxO1Dxdzot7kRssmX mw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s07nuhsmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:28 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36O0i39O003916; Mon, 24 Jul 2023 04:37:28 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x90j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kDQ9nAUfAT8HGec8BwdlstIbRmMfj6j72wD4iIJlL9Qmf9fxAlEX3l4UUC303HIqdklRNSw3msP+yPRiKxYMWQbdFZvtLJVqNPyEW88mTLimt3rINuai0xjHnVyqiRRw4Z5Chi3SN9X35sYfFEN+XbqhGyAGPHeAPnwnaDPBgBhs2Ke+yVKxPinWxXf4gI0ZuuH2PEnijKF6ZREqtR6qSOxBTbGVG1gFMEsYO3HTfRxe2N4K639zg2dlUF7s2Nf2BYj8s23VsEi8EqBmc5QwPEnqNjB9qRz7wFvn8ctF4yZga+hefJy7VqvCeFgwtk3+udbyiHkNIVx81+Pxh0tmaw== 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=5KL2dSRBJcX6W/k04xfgLvJGNrMRIWN2CaQHACXy2V0=; b=cYK8slRIqCICH09VzMFMArC7eMZLCuY3DoJI6QFpX768SmdisdGLC+WJrwqR8+NwZLFGPgteUC6AEErvauhtwd+z6b9ciiULH6Ol739XQtN9jeV4LawzyNrNiSNLLhKSt2v3e+v261uWupCE48CNau81o5BVw8QrwypXE1skVEIEk57Z1hoPNCOFtMTKcaRj0deKxJzSMyCkcs2v4jecyszuhNig5C1GrgFfCOYOqI2r2mYrb+mn24hee+GRFZ2nj7dClANXakJrozDroou2fHtb9NH11fSYxw1E9NO1aUtuUIwq8xZ3OQxUpfBcf7wiY2i6cCMV/SVABEptoIV9MA== 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=5KL2dSRBJcX6W/k04xfgLvJGNrMRIWN2CaQHACXy2V0=; b=JyqhhgeTcfrC1fEn0aSY52H4uxNclMCzMxxpLzBTcdNoLEh/Mei0GvoK/v4h/WF8YIV69JnkGK3Ok9jyHzyjAMANnWfrsPIiDdgbufnnHl/wqRrr19hDx6H2YTac74gWbwtdyy37ZCDGhBTfyvFndHNtXDmRLlEFlxUGtxQWBRc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:25 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:25 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 10/23] metadump: Define metadump v2 ondisk format structures and macros Date: Mon, 24 Jul 2023 10:05:14 +0530 Message-Id: <20230724043527.238600-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0165.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:383::11) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: a0f3d952-bb05-4df8-dfbb-08db8bffadff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7X7ZV/GyLtHydX2KMTH/vil4WCTSlMYKwhewKISagM7ByUW3mhh6vD6nYLHdZ1nwj52oxpCkJR4SkqAQhVWNJiQasRRTbnugg/AXJhMf9dQZGdlEC3U5SC1Z+9aIzsY63k1B3cjcSY9+WCF89fbVWlpssXWxdUXSWiEX976DxMHXqD92QpWtdoog5N4Krh7tyO4MTan1jTEFl9NN98vhI7G/QBT724jjifv+W9w+6sTIRKOd78YyGaVfyDC/gvpF+2TJB1FNglxiN9lMHE2RsWA3LYNGD99sEb7n2B7NqWYAVMD8BgQsc+8k6Wcaad7f9fH9lZc6cQCQ5AsKfirGE/zqxsXNNlYLu5hXe+NmUKFqj+5wjdO7F1s4kHPz9jRSLEmTK2d0J8NoxR3UCXPUGqQ+oodWOKZj6BIcgwV/i1SAj2hJHhTLas+nO+VhQ4yhFZyDGsh9s/pVh4TkXnp/PJ9TZtY2WU1+gmykC9SKhmB3TFLR2wcrZyIPYFiKQTN+LurTnDfuxD7QeCRjapZXaiFhthiXccmz7wbvyT0vkVzNb1NdWDfq0UA2bx1RL8Rv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002)(66899021);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5o6wUYEXbNdzo+23rcAdUxdb0P7venUUWmkWlOrd0OxjaaQRJ127teAyXSjhJeKgtsji0xhSwNIaoXpi2iNDYOfPxpUeVIGI7qpJtOFumT6NChKzMRTR3M5N4j76ZyQ/2uWmNByPHkUymspSUXByWptp7QiFwHl8yxXs4R1OxTdNo96TiVd5jnK++4xQjZIZRwuLPnx2QVDZHPxHZ1pMCzSKmIJJCMJyk0Q7efikZxbfJk7R2zN4aqqg4W9TfnC5BFYyihHmTxAA4eysApZAYSQWBXcEZSa8OkMAKT/8m4Tv3SbXEhbqFx/vPunl0c6te/+VH75C4K9JEO370JjXJbix6kunL7SOamXzOaPatpQuOg3qqIsuiFt64xtVgY3Qvsv4tu+H+5LLNIx3qHM4odo2he5O3MS2XehS7GFDScDBjEFWTpLMuB7748Dt9jXPJxMD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3X2S82SaFEP0E/bdtcsgoGJA1oivHpt0QEySnlPNWZaQXWOk/b1GjVpTAmCHhdJJ8on1nmTuexMJpWkr1AIcCnkXJDZuuA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: bn+hp1gZgju4NVTMIJEpCnkOyW3Y9hzE63CNEHQ3vfV0jv0bcyKMeEoPz+v/FvSSbNBhzzZNaIZYcP81dCrBY54jM2bZrxcEBfh39+9CYCSM57dqmanrgFpictNuBs18470ebt8xsD3C10N0Ww/m3bFCZP6lk2vvMX2rmYN4TPLuEqEDu+h54SBBhQPLPmdaxjez9I2706BeRcx2vWdVOsAYTCkSXx3Qb5U29BNqbR1S2MKUj7pxsQEgvjwcOLCf1f2do7klVbolqDOOZkVqOJLNmlRf1m+v5i34RSXUUTOKqInu6to17K7VMfZkvNAIaftwIbsZ77NtRq165uUKQSbtkJBMVvnVlty+7pc/IaCKBB/Sc6t71IuoXPH9K378UPcq4eoDHhl6vdYEJ6s6wlHvHMfQXyZFZ2/4eLorD267gPIjvd1mbwG7XTHK9oWjHjZgQTSD8kIyQ3LrajQ6aHwCwhZxiLk9PQha2+2BJijmVZO2F6ok3CrOJZ5myxmQhytS6vQTNFh5xnMLtK2NMTEfVvbrh6VC6U7c7tBGCfevTvWn/n8EgawkFQrUSzNTph1xYlHLekyFZ2rf31u+xlU16ENRlgj4gC6HUkGCRAE3wTGNMLVzkjUWDM4Gixt3nob4L+YMfeh7RO+SiXAVo7BkPNOEHsJGtmpVoPIMrdcMWHMJ0IxWjBhyavTjlJWd/D0vNsTPqKSkrDu4utEJ85S+oEv1h2Kvh+UesyHkcwYrkPvpJUbjv74LFi0JvhJxiLEiw7XVkkFl3oDHgQiDWalxGlfXczs7oEkfVib6Mic= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0f3d952-bb05-4df8-dfbb-08db8bffadff X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:25.7133 (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: EJQ/kYw3A7YqGCheQ8l1jBlAfyTc3fXm9912amTop6fzYJrcjvSfxDnJu7HZjrX2i9gyVhJ8K6CBOamrAZWIoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: mgslu71VCDcuIggtbO34-Fos84d5wYtC X-Proofpoint-GUID: mgslu71VCDcuIggtbO34-Fos84d5wYtC Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The corresponding metadump file's disk layout is as shown below, |------------------------------| | struct xfs_metadump_header | |------------------------------| | struct xfs_meta_extent 0 | | Extent 0's data | | struct xfs_meta_extent 1 | | Extent 1's data | | ... | | struct xfs_meta_extent (n-1) | | Extent (n-1)'s data | |------------------------------| The "struct xfs_metadump_header" is followed by alternating series of "struct xfs_meta_extent" and the extent itself. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- include/xfs_metadump.h | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index a4dca25c..50175ef0 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_INCOMPAT_OBFUSCATED (1 << 0) + +/* Full blocks have been dumped. */ +#define XFS_MD2_INCOMPAT_FULLBLOCKS (1 << 1) + +/* Log was dirty. */ +#define XFS_MD2_INCOMPAT_DIRTYLOG (1 << 2) + +/* Dump contains external log contents. */ +#define XFS_MD2_INCOMPAT_EXTERNALLOG (1 << 3) + +struct xfs_meta_extent { + /* + * Lowest 54 bits are used to store 512 byte addresses. + * Next 2 bits is used for indicating the device. + * 00 - Data device + * 01 - External log + */ + __be64 xme_addr; + /* In units of 512 byte blocks */ + __be32 xme_len; +} __packed; + +#define XME_ADDR_DEVICE_SHIFT 54 + +#define XME_ADDR_DADDR_MASK ((1ULL << XME_ADDR_DEVICE_SHIFT) - 1) + +/* Extent was copied from the data device */ +#define XME_ADDR_DATA_DEVICE (0ULL << XME_ADDR_DEVICE_SHIFT) +/* Extent was copied from the log device */ +#define XME_ADDR_LOG_DEVICE (1ULL << XME_ADDR_DEVICE_SHIFT) + +#define XME_ADDR_DEVICE_MASK (3ULL << XME_ADDR_DEVICE_SHIFT) + #endif /* _XFS_METADUMP_H_ */ From patchwork Mon Jul 24 04:35: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: 13323428 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 EAF5AEB64DD for ; Mon, 24 Jul 2023 04:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229548AbjGXEhk (ORCPT ); Mon, 24 Jul 2023 00:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjGXEhj (ORCPT ); Mon, 24 Jul 2023 00:37:39 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C441A1 for ; Sun, 23 Jul 2023 21:37:38 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMWNo4001972; Mon, 24 Jul 2023 04:37:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=By86vlQ/X4kg1XvfAL8vVwvDmHQQ5vV/ZDYs0A1YsnE=; b=Fg7pVd7b7eisx2LTt9vjirDQEIuMTLyXT6W9/rLCG8q+qGdhP9xR/pyxBGPsWYCw5DZE 194u1vKACYo8QMoY7rjDdnIuiRwE1RW5k+ra+8awd6xO6hZjOxDgL0ngFqo3RS66YlR5 JT6LKjdJ6NhWbs+fV1BSW1lK433scilPDyw7u5CecvqEqfQw6ZoFwKY18cMxhl0lUOio r7ioTWseO0KoJD8NCtn+u0MTFlGhkBLf/6zZb2YGI3fyIwAy59ad2t9lhXzM5Lk4PWBb 7B7sjjKii0h2I+2SrPpyp18LY1HwCf20V3fEDRs84iTZBCqKuqt+TetP9Xvyo+Whp12U +w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s070astg2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:36 +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 36O196dU027551; Mon, 24 Jul 2023 04:37:35 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96cam-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LagbaeoadG05doxojjPtBh9JevJTCbF2JMaHcMSOgcn1vPELKfpEmV9hLrpdJH2f1+QOa/I974zeshVKJcvKIg/NrmKxQrMuQHlxr+czf2wOrEqvq4SaAloHN6TEilez+BMKP4kLNUHOmvwsRo89irtUlmUAtS2gUlQNOv783NVUylxChIW5yTv7KX6zArkw0bB8nVjyUswUq6OlBc5FA89R3xaL7E1XesS4FRCMHZdMIgciLdpFcwhs5MiGaedTsGblxkBOE2kg3mk6uM4CdCZC1J53Xm2T/MtUHzilCcjZKFL+WAYKFSKD+GAezOG4+zJMquzmo6bQyi19d1jShg== 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=By86vlQ/X4kg1XvfAL8vVwvDmHQQ5vV/ZDYs0A1YsnE=; b=BYz0CutLTV/aKx1+LH/cmCjYjM83hFmYsh/V8J8AGiJCjuHrNyxrcwmGrvyAwzQxNUZNvOgvxBz5aTI80SkjyLHaETUCoL3rI+VKnE0xA9wNk8/yy176rs+6P/6oZNW67c6sRQ5Uu0Mp7CSaIfwuMf1Et+j+CeIAky0bIm2Yb4mDaL7g89LceVDGDP99LOPLllNmR5rP1ruIavAaeDnY+s/qmlE1mxM269A1mO0EoQRwd08lNzzuopW8wkXaSqVTeAe0/C91QXgSP5GQZjfV29w9XP5zNUmUrIx9kfaIFbaF9TiXqrANjIDsAdltKhdwcTbPgC9TxThOv4kNmiIrQQ== 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=By86vlQ/X4kg1XvfAL8vVwvDmHQQ5vV/ZDYs0A1YsnE=; b=VE78pq1yIZsbwor7dMo9siInXiriQvgSV7y0/IqbGHt79V9Jw/ivb0agfglzX39HpV8pXrcmXldfYtc2VsTFY/h7+Q0WJLd9kmINjuieFV4LPHmO3WsiKRD4djuYhOtxzaxqTFY9nbDUZbgStubgfZckh1qAc746aCuJU5YqKAA= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:33 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:33 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 11/23] metadump: Define metadump ops for v2 format Date: Mon, 24 Jul 2023 10:05:15 +0530 Message-Id: <20230724043527.238600-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYAPR01CA0185.jpnprd01.prod.outlook.com (2603:1096:404:ba::29) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 7982df21-75d8-441f-fe0d-08db8bffb264 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VOChuNfUPLRofTeqMJPZ8jz1KeR128NerIa17P0kAMV+/ow84wP/kYewP77nTMGqAuqNStBUevk1jRmJhR692V6A70/AwWDalz+xzpUWimE6GU40zpXVSd9I+kDIjzU3C1c74bh45JPRIUappFp7IR2zSsA7Z0inCOKbzTwxuZm8DocFs4IPKSaZx40ZOizO22SYok1+M9FmFq9tbbFYsuNfTLquNPQ6pOEb84dHvDNJcvZyvNWKN+zgXDtidaGNS2qgHu8OtWwVlhpul3w/Hbp/F++xviuRR+H2lyIJrVM46zXmELCcsuZ2U5n13h/qmyWxf2fD3uhvV6mXMBf3RZmGEk13cu3ZKpTm0kFGC/WGRt1iz+1fBPUFZOGg1JBpKbvY6ierwuOESZugA6AQJHvxP7893WTfco1Y5pyOHuWuA36B09ZIOX7Df9/83OjPw0g9FrnB1teOslBbQbA66iGqNKMb75Or+D0xvplMM0tc+pP5z9ortEGAxWv+kPnMOtyMxEqpaOLeojQcGNyWgXlkWPf6EA94kdVqlnppR0etld35btyrlhsBr9C0z2NM X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hlZSpcixe9WEqu0JdSSfHfj/bpPrYJB/I3/XqfwLjNYejeFgGdrq1Vuyry7cUN+fco5/2+jdMK+3Y9zCs5970dQzp0ztLL21fW5TeQjUftYBTlHMNKD8mTZgJxwQv4XXf8sx0Z3FQOSt+fxeX620+BMoAvfNeefGVinOFmpIisGyXh+VWJYusOI9YLwQNdKnZ/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NNQJjfoAnt/8r/r5sVrp5R6rfTfCpnYgvGsI0viMfkHOeBSPG/QohtaFDLazccDCd0oXp2U8itD4Mo0PKGIH+Hp2eWVJzalQT+qIYhVH/I3zHXwTLrbQA55l9Oo9HEqZG8bHTGMSBDLYkn0bEX47ohVuzV++C8kwuVI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7982df21-75d8-441f-fe0d-08db8bffb264 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:33.0786 (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: Zt4ugYS4Q+kZAo/toYndot61nQb6Rn6iYT2ZznXFpfKmenbG4TAy+yeWFqaL1iFSIlAnRmWGEXV5ILVqNq20PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-GUID: DWpSigOl-kiUS0eVeQS7qGI3nDnKCyTQ X-Proofpoint-ORIG-GUID: DWpSigOl-kiUS0eVeQS7qGI3nDnKCyTQ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to dump metadata from an XFS filesystem in newly introduced v2 format. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 7f4f0f07..9b4ed70d 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -3056,6 +3056,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_INCOMPAT_OBFUSCATED; + if (!metadump.zero_stale_data) + compat_flags |= XFS_MD2_INCOMPAT_FULLBLOCKS; + if (metadump.dirty_log) + compat_flags |= XFS_MD2_INCOMPAT_DIRTYLOG; + + xmh.xmh_compat_flags = cpu_to_be32(compat_flags); + + if (fwrite(&xmh, sizeof(xmh), 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -1; + } + + return 0; +} + +static int +write_metadump_v2( + enum typnm type, + 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, @@ -3192,7 +3256,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) @@ -3216,7 +3283,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) @@ -3236,7 +3303,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 Mon Jul 24 04:35: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: 13323429 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 292C8EB64DD for ; Mon, 24 Jul 2023 04:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjGXEht (ORCPT ); Mon, 24 Jul 2023 00:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjGXEhr (ORCPT ); Mon, 24 Jul 2023 00:37:47 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A453F122 for ; Sun, 23 Jul 2023 21:37:46 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NNnXb6018552; Mon, 24 Jul 2023 04:37:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=aS7aNBYCuCoCy9DN+ETg4jVMG9CziEaLI/hvKubgldo=; b=CprH75KrtBB2KhdLfWmFCMgc4dLwdsrQBOm/wd75fLeEUqolMSmGhF0UnZFba9J2exov 4icNsifC9DI0O1SVQzocfu3y+A78oiyUpAVyPLGKueMXJMSUNrCly24SvJWV46qaIkZZ v4BCAwlvrGS/+Qza7crm4NoDZ1corKC8Ek8QFfFeZC+O85zJMknnoSrENlaCyz63lA8A gh2Wrm9BohlcdhgVq4Q66HnTZu0vfnj81Db7GdDPp7UdcxtrroctfWxQQgkPe+eJ5Ft4 om+zl2SInJLPI0Hs5D2JZxLZOKSwFDQqqeqY+8uACyxozWNFI50gvTOeFcubxbVxyXwF xA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s075d1u1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:42 +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 36O440SG029092; Mon, 24 Jul 2023 04:37:42 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96jjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kp+fAw+dReMhHJWpSEW8LMkh7wX0w8+WNqqHFsiUOcZYybKXP7+y4dXa18s6CgkBSP8ohqRn9ytj0gbxlyyPFkugnUXzFZ8fCBHZifiKvOM9uwOj+fNgrFrnlKXFYnyCgc/U/UdnhBR7WKyAh2hwmrIYi51TN6jrG/tKTLFBiRgylHb77/3zxTIcKctyAmDkRt92x6c6iDogmXuEsz8pkyB0YEP6TkySZpmilvR/IM3gsEUEf2JaPhy7FW50U/cNUzgiF57RjEbc2H68hgJQOsSNh1Kxy6xWXZKD48coiFNBRFPnRFq9ic/qI7T8v4wfr+ZhfOIFaGjYj9leyYA7JA== 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=aS7aNBYCuCoCy9DN+ETg4jVMG9CziEaLI/hvKubgldo=; b=PLHZtjBvMUx8liT4co4XTmrXydSNho7cYTss+7k4pppJms54wj++u1/pF8p4C0eal6prY4ewYLHJp8U/lgUFxwXb0Hf5GXxxS2acaw1N7KaH9/3z6+vUiiFDAEzZRc4myqAhpZxf7pK557v9v60mAx0+eI3HX8K8JdZm5KBcWYfRJi4jGL/Whw0DXvAcAjmfw994xTLZKIz0NzlTQXA7S8h4APNpaqKB7ZrP9AsalklG4ebrWif20T2lUtrtvZUsAFB4EnSZSsjujIgvWEUHZH/xQ43A08d+ekVoFuvqN5n533AAbpBabxm5zcSbvs50Xr54sPWiL6U/XsBKGW8XqQ== 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=aS7aNBYCuCoCy9DN+ETg4jVMG9CziEaLI/hvKubgldo=; b=MBrhnv+mmAVfeMAlisggYioz20ZI66x5V6tvZUKo9cqb6Vpx4q+2YHIU9bn6azGAMZeWxpYuET1G/m3Usz58BcWfCt8It0347jKg3YcJVGwt9Bcmg7sXul7SJL7skiyP5WBLVSzoFjJUMLeQ+TQbV4njbXgJgQny6zi2v4D81ag= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by PH0PR10MB4774.namprd10.prod.outlook.com (2603:10b6:510:3b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:40 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:40 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 12/23] xfs_db: Add support to read from external log device Date: Mon, 24 Jul 2023 10:05:16 +0530 Message-Id: <20230724043527.238600-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0016.jpnprd01.prod.outlook.com (2603:1096:405::28) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|PH0PR10MB4774:EE_ X-MS-Office365-Filtering-Correlation-Id: 46142786-2573-4a05-38a7-08db8bffb680 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TPG4MEguzD2G9yazJCDHjZuqeJTIYRLNImyYVsEBFTynK6u5C0uhKF55hB9YaSkI1UhDEXHxTvVJaKugcOS1tVkc9gVDi5mtevHmbxzTw5PwU7KhyAst3/QhMLoaOKG87V8rnYN4DHrmuO/fTR7nspeWMVx32nx0nJaeMU/9PVta0EyH8dLEdLLPKXKtNjm6Zx503jeTPu9P09y2J90TKcveZglUb575KCRuGksifcpo2DvF4uZOcWtwgAbrg006WkkvBcuulr47X0iOOIHgT7Qv9gOiS7CUzEK3+ZUf8WfQqswx9TNbOOi+wrfsXqzDishtR+iQlJPe+y0f7Mxs25sAanXIiwqsMD+7+rsF/KKm7d8432iFM+JonelYiVs+PDjrJU1G96w33ZDvm7jdaCEIo+/0oilzocIk9SU1vFCvkWEJSLey3k0yGBfrOrszKFFB+eR4c1WfowjNjtsBOwDgD1L2YrtXQ8JFvCD2negvZFHBpt2+/rI8VV1zccmAuNUhRhtpLzIhQArtHHgD7cZWCnmbY6SACkksoz8v1UCw0zAnmDeuO66xgLAUiCM8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vJL/V7J0VIp9yB+UkwAy3xqsXXP/qEUZsBmx1xL0exppU3Za3HB2IBkdTsZjuVWyBMauiy67Qjqhe5tSQ0GlYXXsabdcYhjDc1NW5UrTMlYZ01SaqTzamg+ptmcoi/hMEXnnYiMB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YYUMS42aSfJK4oZkPIA2f83+B2fjM12gjIgD4dXImq/RcZVyb47sb1cYN2BjT3RQAs9SXOWv/YMKcLquvqmZ55xsEuvPZwiDdmwBWN0uJOxrA4wcknyEuHLluN8FGNkdG88FVRcya2TO6ZtMYFBhL5+z85cRoDNqglRveHSvG2PphFkFj7XnkaSnOLBQSWMIKvKItiG5v8rv1IrYx9JSyrs/NtpQeU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46142786-2573-4a05-38a7-08db8bffb680 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:39.9857 (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: SRZ9tG0TaBHZtquxOi6GyQq2dWGGPJWniKKMzdgh49N7h9qo/7zuj1pRRAam12D/tz/Vp0174VNlW8jJJQTeNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4774 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: dHNRbtUjZ0IIeiQZhhx6psjibckvo6Rr X-Proofpoint-GUID: dHNRbtUjZ0IIeiQZhhx6psjibckvo6Rr Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit introduces a new function set_log_cur() allowing xfs_db to read from an external log device. This is required by a future commit which will add the ability to dump metadata from external log devices. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/io.c | 56 +++++++++++++++++++++++++++++++++++++++++++------------- db/io.h | 2 ++ 2 files changed, 45 insertions(+), 13 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); From patchwork Mon Jul 24 04:35: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: 13323430 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 59AF6EB64DD for ; Mon, 24 Jul 2023 04:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjGXEh4 (ORCPT ); Mon, 24 Jul 2023 00:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbjGXEhz (ORCPT ); Mon, 24 Jul 2023 00:37:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A3981A5 for ; Sun, 23 Jul 2023 21:37:53 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36O2jvwG026582; Mon, 24 Jul 2023 04:37:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=H66qGbjV70ou8FWBBgOpLIkBPi9qfcwQl+qUFzfsv6Q=; b=DMxPBpiqX2t2iEsPqby2Ww/8rzERqvVt4mLyV/LOyiZ/4Us0epdl4J5z+JOtulX0mBBv 6EC/NCF1mv2aUEvOYFxp6E18hdZUVHmeEQaUvptQAWjFNDREfV0SD6RkAXYV0a7wW6xZ mZ1M4YiIWsVYgN4U0zviGRJbciugsC5SzYKoCNgXa6IcxQn/WuCRbap5A64rLI2F/wxQ CtURkeAhEKabex5LpuGRDQTNxoIS8JrZVbdnk8hPY3ecRNkAeEeA1cMTAdwbIVbl6By5 7OMlv9PfZQ1oX51AGOYmaVFnPLnBvfObrxMowf7eUWGJdK4mhJWa/gb4Rmh9NmyUhp66 Kg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05hdsv9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:50 +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 36O26NSY028227; Mon, 24 Jul 2023 04:37:49 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96cfr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RcDf6SvR3gPCpm/byPY5gH4x6GktfFTcN0Eb56qUWCmgjrC8JxJCrH4yVp4Ojsk8E/+7cI5UXh91pGv/Sk9xsBQd83mNbfRy7GU0yRSn+2YB5ue5hYVLKP05pMXPr8xlmQ8k0Ny4Ir/jVp+eX7W1IhGnCikHE5EST2UhF+QCZCMRV6VlLpg/8WGCPDO4dnikO9J7SZ/X3Vx5tYZKepcR+kmOdiCxfgQtGoTpN8O/A/OLSLYJAEyiQvd/VqJ4cU7rUCuxQuDNPJhZ1HiWIl13PtADmll+7vpLeyyGq0rapcAxMiCYTpbYM4Zo6zOJluAKTk/AbpjVnJ81cRdMJUAgIA== 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=H66qGbjV70ou8FWBBgOpLIkBPi9qfcwQl+qUFzfsv6Q=; b=MRrXyeuiJ7zRHwMQqBwopJpZ+GHGz2wiehsWSS2Uv9fOXpnBS/lHN7TnZbawL1UoU7ReVWFE3mYyRSij/dwrh1UPJTHXq8TcFUP/+BcAevYZbHvrjoC6L2TN5pXaIIPh5K731P0HndF3h3u0trL+izG3k4F15VFYUSSYpHLSZcnBkfXsvsGRSf7EN5jZLTtjB9DWjB4W35c+9dGdbF9aTQlQ4eLRnNH6TiOVedVw/xHV8cDwGvrn4ZZ7I1ekBzT6AEQdC482aFh8Iq8lIX1UeiTeyi8EjrlrHRysLjQN0TPCMUbhesqW5qDE/yciNhAm7tk/N6Q/RpbbgOUe5y0adg== 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=H66qGbjV70ou8FWBBgOpLIkBPi9qfcwQl+qUFzfsv6Q=; b=kohilrwY+fw8ye0+5ahqYuMNRTJEIGHU+dxdLRNEn2z4/JvFlPU+KPJB1FWFIFmLJuynrTP9nk5z5bjmT/npLAQStN/Fs/Af0PjEgnOV+U6AAiJzhnGy50r6WO541hhlYTNwyFMtAfzji7yoBXjO6hR6FifEyZyKUqUPKEM03hc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:47 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:46 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 13/23] metadump: Add support for passing version option Date: Mon, 24 Jul 2023 10:05:17 +0530 Message-Id: <20230724043527.238600-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCP286CA0337.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38e::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: a48ebea6-3651-43c3-d512-08db8bffba7e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R32Hwi5XqOlJilJYh8jd8Nj0+UMsWP7P6bBsB+MGHTyoe+7B7kIgEKVukKLuRoXPxagu8zdqN49P+uGbq14SeXxYGekjUX3fH7Z93fiPEGCDSgpzN1SsuxCadc5nsmT4sAXqk7ZFPtiQ80wGrEfrZfDOmgDcYgQxt9Z7sFxC4+Xhsnom4l23ct+0rimGqIBdvwN+2CiAGKQM69DIEuQDpqX5aOKGlCA43D54kvDr/cVdjEMBMQjmkMMMqOeVRB4kTRFUtNRpea3bgUwTbgWz1YMU4aJIc9bTQ/mg8JjHYJfHJZNIyG4wnfMB+7SaTjD93zdi7iZXXFLY73e+nbTL8bP8uoVpL6iiE6LU7BxJc9n3ATAmKzY09oAbycTfoD5U1ragY0uxpZEF3ruh7+LLOxrkK3HMJuxf2tcc94Q060xFkpzV0RnQIbPeyUByK4VtqpyFDk2prspG0dFKtkTQ3y3fz4nCRha3Huc90zNSdYIWTRgH8RRZxqTSZGaa+wo4lYFuhlznT83oWLvBQnOCZV6/v9eENfhC0PZLqRNLK6nb48U84xLZ5PxXomjxmT1R X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiS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v1xVPPzwvceEgJrAVK6l1hgPn5qgN+NPFUejHc+E54j219PqA3GpaWixHxvSiKyc28u8/nBq7vVMD7hmdNXSmHPllzFbMw8w6rW7akKXlE2CCxsfelXhd+Sl2YMeZB2PNz0Gu5HahXQHK/ZGABCe5k76KyhsbFMl5dJyuWQIiXDmU/hRT1pC+ihyY+rXZLK5t4MmTZwdCW0vyE4jkU9l5ji17d2J6hnxlulgXbc468SB3YqhIwjCBoQ7aOq+cLnknmd3kqSrs8BADD9DKh5Yx31QcwP3dXhaxsipXlc1vAwPlRy7pVRHGdWg7gM+Ej2XNjB96zz0pQ1J560VGYrkt/Rj7t8zUpKB3FS4o8+O9E6XJU2L+O635NPAZPNHbx7vsYXNmFyAGJcJ18fhK7VRiEevE4a3+yZPs//UgrMkcQS+TJclCA+/a4NBKiHETUt8TMVTszN7sOOqGVaPAStaqSjdg9URulrON0JBa/CXU2c0nOvJAsbW0DL/LL4QQcB7M4bu1GERY+hSvH0MPvB6APiT9PyEjak/CeqtjDOd4vtzRww== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: WAl/TDnvz6j428MhOnGiMb6DwSe4wszp1XoVZLRjybS9vBZhS1sgA5DXVg1LhbFATYexu7SpGcJJTr5yJ5VoPIXSAOC/5TbUEPon2vMBKKOEgwrAMk8f22QrT2g9wD441UUbUuN4ZGdsAO6jIc6ItSJOgAFTIdN9gzbBS99B6Mm+245xILY4uPFQvOWd/gw56Zzx717YVniGqEcqd3QNfF/1pt7eY0ObQ5HSdOhF5DOH7kLu3xsdItFAzCfs9cm+TPhFkSyNCz51U4XBGAfLySV5/uqiNZFRGOLp2yyz7I1fW973dOns1KJRkdG+lax9FpByGelsbSriqMsOXqM0Xz9gENpj/YXsBZ7JhQstBFNFqIuWhWczlOy/oaCItSfpCBm3SASeHExxguLHI2YfSwU+RQmwsV0wmRNAilsWwkm8t2JFs5rEuEMjehMIID5Uho0PzP5Lr5KZ2HeUhTucxPm0knBJf0PbYrzpzZUH6bofOLuENhcF9ht7PI0ZwpE8dgQI7/4+CKXjmH9xZs43BbRFY/dMinOWlH17Pee/BuJvn2M7AIP6fQUJLiHObzpxFd9Ih3mopYLv0SePFZjdMPd7Ib+d/iJBPEjeAQkcKua54L/yMPL4c5CBl+jogBnasQr5P9aA6Zq5MXh/4sIuD9KjAUM6y0/XuqRAXn9RhBMB9DO1uwUtkD9WKAHMVRFhQKb6b0zvF+WDo5yAkErmqZsT67KuqesWfIWlgF6B8s02uvMykTjDXVtM3oJoi8aKajqNbu478dcKGeFY8kPPJej6NJBKrihAySn5bDWrZMQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a48ebea6-3651-43c3-d512-08db8bffba7e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:46.7004 (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: cL7vNaJ/qu2i+IzaX03xRU/FWZ1MXVSmY1sk8KnAj+m5JfzUD/6xMimUwpNTc1yM20+ah1xUjzBKJLjjpKX21g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: terID1S7hMVJXVXstKO0_1ha-_l8WTvt X-Proofpoint-GUID: terID1S7hMVJXVXstKO0_1ha-_l8WTvt Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The new option allows the user to explicitly specify the version of metadump to use. However, we will default to using the v1 format. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- db/metadump.c | 81 +++++++++++++++++++++++++++++++++++------ db/xfs_metadump.sh | 3 +- man/man8/xfs_metadump.8 | 14 +++++++ 3 files changed, 86 insertions(+), 12 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 9b4ed70d..9fe9fe65 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -37,7 +37,7 @@ static void metadump_help(void); static const cmdinfo_t metadump_cmd = { "metadump", NULL, metadump_f, 0, -1, 0, - N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), + N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] [-v 1|2] filename"), N_("dump metadata to a file"), metadump_help }; struct metadump_ops { @@ -74,6 +74,7 @@ static struct metadump { bool zero_stale_data; bool progress_since_warning; bool dirty_log; + bool external_log; bool stdout_metadump; xfs_ino_t cur_ino; /* Metadump file */ @@ -107,6 +108,7 @@ metadump_help(void) " -g -- Display dump progress\n" " -m -- Specify max extent size in blocks to copy (default = %d blocks)\n" " -o -- Don't obfuscate names and extended attributes\n" +" -v -- Metadump version to be used\n" " -w -- Show warnings of bad metadata information\n" "\n"), DEFAULT_MAX_EXT_SIZE); } @@ -2909,8 +2911,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"); @@ -3071,6 +3085,8 @@ init_metadump_v2(void) compat_flags |= XFS_MD2_INCOMPAT_FULLBLOCKS; if (metadump.dirty_log) compat_flags |= XFS_MD2_INCOMPAT_DIRTYLOG; + if (metadump.external_log) + compat_flags |= XFS_MD2_INCOMPAT_EXTERNALLOG; xmh.xmh_compat_flags = cpu_to_be32(compat_flags); @@ -3131,6 +3147,7 @@ metadump_f( int outfd = -1; int ret; char *p; + bool version_opt_set = false; exitcode = 1; @@ -3142,6 +3159,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", @@ -3159,7 +3177,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; @@ -3183,6 +3201,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; @@ -3197,12 +3226,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 -ENODEV; + } + + /* + * If we'll copy the log, see if the log is dirty. + * + * Metadump v1 does not support dumping the contents of an external + * log. Hence we skip the dirty log check. + */ + if (!(metadump.version == 1 && metadump.external_log)) { push_cur(); - set_cur(&typtab[TYP_LOG], - 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; @@ -3278,8 +3337,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 Mon Jul 24 04:35: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: 13323431 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 B9A12C0015E for ; Mon, 24 Jul 2023 04:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjGXEiJ (ORCPT ); Mon, 24 Jul 2023 00:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjGXEiI (ORCPT ); Mon, 24 Jul 2023 00:38:08 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5713EE54 for ; Sun, 23 Jul 2023 21:38:00 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMM2uF006375; Mon, 24 Jul 2023 04:37:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Eo2H4ZdqcZj1h9U9KJV5dXdRK4RG40qHiLn0E+r57ns=; b=Mlw/5u+pld3Zt5MLocYT8jQ+TWdTuRwF0Fitw+qIPtiwTioXYFCtNDWZ8oetCXAMq3we 5CfArUODzjlfE9B446dZtREsXXKwrpyt0RBCVVbrTRCdtCmuaItEmvtXslPqUTFbPl75 aBViU6HBYtG8Hii2Q7D6iRFi1O8h5V40NsxgDqCVGcBN+cTCUCAgDhudGgpPzaVZwBGJ w26WxofJrjrwEhtxanZa7s5H6SWBzyECTIOjL8xBesMbwWeIzWah29JSjz/A/DFss7Ot +w/jO+RFxamswQzXeqvSeFCq2YsCSGUSr4Fx/5JXY0U93cNSwqV+jSAeXG5z82p/tOQH Lg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s075d1u28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:57 +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 36O1LJh9028655; Mon, 24 Jul 2023 04:37:56 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j35yfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:37:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jn6tBvTNbGK7OpeQ2mNHDVmuHnYGkVMWt4627S06Mx3w9P0rTgvGN3VJiSQrNn4pFnQ63DtBQBPy1ceEO6CNEJysu+zBjQuFbBQAZSb3u9V9Xiumj9qFReVC/rkYmxz0jkWWmqsDM4yJmwTHNotdkcj/d5Tzw+IguAb0P+uff0Q9dMAfKj0ihkabbBDaoDhbvDzQJpv0JN/ktqqbaybDNvoQkai0B5RsUwXlONFfMdDGi3XZyMTlTYzBOZrzAQs9mZGfBECoGS+FXrwI2y88dNyZsKc7puRTMNt16NghZZjRp6z2yLjvVxV3VQ0pcBDQ4WcKaeAxcnaMiFs/6Z0iZg== 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=d+c6+Kh964952y3mpx5+d6dcbL7z0Q2IsrPZEfAQ+cfbMHo1IZGe07tjJfYW+viSqWG6EW2Ar/r4SXnQedMqaiTpyJ/fYcY4Ek6alGf7pa7AvVDqqSw6u87sJ93otJGKh0GWA4X4b/QM+aJE/1dqmMnRjk2AYu88ZZuCE3+CqSATkMaLYelP5+ykOvmB1WPJu+/M5v0U2ytw73QgKg8WARahD0ktZq9D0aVV6tHo5CCyj5OJfkjwC7p4wnw0fAJWbBbCQd/Z2VzwAsnUSbLpbnMYaPiXIufU97iw7kBcSwtznQOyrpVtkTMWYAZayOrTHeWrSIwyeXy8PssWJFJJoQ== 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=CHxyfwhh2OfYbVqTEUwggtyn2KzG+VYm835hq9cjsEAQhT93IOeeeo1PH1eWtS7K/VsR4qsquUKj7UxP5GYIHcn7YBCluVq6e2y0clpxaT0dadh1hVbCNuEOcsJ/TYW5Q6Wp2SPI4Hk5LTnW+TBPWvTfJwTPnsVSGkUqHRCVcaQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:37:54 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:37:54 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 14/23] mdrestore: Declare boolean variables with bool type Date: Mon, 24 Jul 2023 10:05:18 +0530 Message-Id: <20230724043527.238600-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SGBP274CA0008.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::20) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: e8ed66af-3f9f-4bc2-0519-08db8bffbef7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WJJdOglSYPUt/a8H2eMkMprHSPtFnQnwL/BFmUfZAvi5spEU3JE5cfFC6j6mfsPXRSJK0j4wLa1QEAUrBKNnoN4ApXB4Y1ZFUDGP9qCZGYv8Emt3KZFIZxf0LYbZZ8/UG6IGuJCD6gaaSauyv16R2+NH16MUbyjOr+pAXeyqxxFRAH8Q472eiYtweNBmB+XzGt7Pq9SrN6n7vYGGzk27eVDC2iavomo7s+3nFarw35KL3I6JXrDT97J0kDMC9FOJMxgwwk0nGz6Hw7QwTV6fT+5gwDA7BqRa1jvTZHIFQKBtmXtXVJQK9+oiT7Q/RozdZMHn6MbU+rdFmF7ycABSY2VtR1x6xGABDwJtkNJjHjHfTAq0PmcVx747xqACdioVqkv0Z2IH68nIV6Rv6aiFB0O0UzreP1KWconpJf8VV6WSz6IbDO1rKY102M1Q77kOTe8vEGeo0V/x3ZYG+2zgCjNXrLX7IQ1hh3TinoG/fXEb2pYHUARuzB93aZ2Uug1d4TEs77AqvwzCE9DoRtJ+tg1Ysk/DfX+GVpzXWO3pto7JM2xJryo2syesX+VsLXZ+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L/d7EFgFuEOIsuoSwNcQen4Rw7Y0BhM10JBHlpKxbKGPQU4eMlMwetJ38/GQ1mgt0Gt/bc89JhNAWzfpkj74Wf9/+gz9DE34N+6psVRUesx5P/VaaJaKr54GnGJEN3ly5gkc/2ecLpdwYRlIumIcuX7bdhZAg/vz3tOhjGB8AHk6evMjzxN6k9Tja5XXgziddt4Rdv0b0lp5BawfvI17XakXav0vCD0ipj0PM8h5/NZ1IaXI7I0Zuy9aIJHcxMyl9SM+QzN9l0VBC+7c+hq+RJpvG3a3Kw+/fu6Ttv2EnXx/qymz65oIBI23X970TvQKFICORfFu743VGqssltoGwR+G36cNdWpiYnueKs1R8nSEuPe495r2aG6VKXe8nHwpLxYrbvPhySQZ0vcEIgL359sOT1TF+bnRqD6Sz1MLT/ndTSlKh5HfBefb/YxHV40IJA26YEAF91ZAgF7bx1Z4nS0JtGcSAakOQ2jd8k0G2RO2k/tEeKHuOAvSxsYi4mvb0C6x7FAzUrFoievr5DjdC0BViOMI//8HXVlRdycHpQLH1UrWvcGrt0op7SPRqjvN48WQX3R+S+DmHda5iFRWDrbcf73HKBNpXGYqoXmDYVwxm+uD0Iy1/MTS5rCal4zTfb8UqLK/fd3GEV7giWSnZQfkVMuKrqY1NnYK0k1tLte5ez8zOtpjI2GMOwH63v0fh++InkpCIYHwCwWN2U3s6Bw05oE7j/+vct9hfm7vuOrK5j9TC1R+sHKKFPzPK9oTZeGjfjnt9cf3NARoH472COOHG9AXNKf/DkKs3BmeJ+AioFFvivKEFj3TyzliyLs3svCNlJgDERMQjxmDPoYR4lFI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TiF8/NKO4I6fkX40xFai4yqfWwRltuOKJmTgt/hP6R9R6UnC7WARZ+4LRYI9zug14vYBYigDKaTMhVSLN/tdAcJmGQKtjq9qlTFp8CMPy4wouDTzlUn6+HFWUnza9MH1m36QnCqwz56qBVo1gYHnBK+4Cwt1YFziwZvFDLNYAnaoGtzOXxXW0D1ieB06N/afTTWc0JCij2CdXfCmglVdPLHo2T22ywRrxysTXOjWF3mQeLhvAHExDKXVhcIg5irsE71h5HoJNpJzwGd6hRNiMtXqlLvX9L3fTrdP84x8WgvD9UtdPjTJRhuVxjWO2BGSE7PX8+HwTr/A3JXzY4dzb2LetPxaEaHxzurDhpVFtUyPeIh6iX3tFuhGKnNrihM8LVopBIe147G6nDDgCLMpg7qjNjMwl2CpvaYbXGXyERh+Lw3pUaNP5/wIiqkzM2nllBiNqvrR0PmdVFHDoxvBLA1aAd77JgQcm01bh5agk48eX01n0sQa2PUAuEYvNXtipuaXxNH3dKjTA8fJWCn+1K0p/Sz5qd3mcKI6rt7bR1rMUfAqAqFChg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8ed66af-3f9f-4bc2-0519-08db8bffbef7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:37:54.2465 (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: YjTL7z7GwiTo8PrHDq/VzEl9Jsc7u73crge/ABxQ80XMcZKeriBItyPVyTYuWE3dNgS6JdKK6zsIeSa27egm/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: ihaJ9Ttr4vAye8ZdzsgELaySKURRNV-V X-Proofpoint-GUID: ihaJ9Ttr4vAye8ZdzsgELaySKURRNV-V 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 Mon Jul 24 04:35: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: 13323432 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 CD202EB64DD for ; Mon, 24 Jul 2023 04:38:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjGXEiO (ORCPT ); Mon, 24 Jul 2023 00:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjGXEiK (ORCPT ); Mon, 24 Jul 2023 00:38:10 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D191E45 for ; Sun, 23 Jul 2023 21:38:08 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMMvMh025317; Mon, 24 Jul 2023 04:38:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=L7f3ZKtXUhRBswEzHa2tsOZ52uFUEV4YsW3z6LXL8GU=; b=cR7dTF2NwPtSbdsyoCSrg9vC95EavuWNOilO1aTiKrXEAfRiyKK3iGb/JhswGXNS3J6J Lgz6SmzsKHXktkjH0p+Vo7UyFqydFGNaGIysFtWBbcRA+dhrb4V+9/k1o+C48GpJ+ceW qq3Q2xwMjnL+rMXfy1Gu4M7SQ5sLbt9dEfQXKLZh6phxIRFTSoa7v4VLROjLyRE7zck7 QallAQmmxLue5V/pNQzuvSKyd/dF0No5LjiNRxLEw7lPVygczzrCJoFMjGhMd3GiA2NH gv8sTCxzWBHoVIQ7vuodr5R13uzXGb/DqxM+XIL9o1XA+edVOQpSX+yHDFk28Kpz1E5Q 4A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s061c1vfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:06 +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 36O20G9x027548; Mon, 24 Jul 2023 04:38:05 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96cmy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JEz9yTPQbpfZyJFlOtG0GWZSymSaR3E7Ynwx66eqgdM2/84AKUciRW9UEyONXErL4lupOzKeV63YIC3nRDSFtPFY7LRCKkZLJUOQgKscUo7DSYQDBCBI778WwjMPngIM8fNZK2GEpVc+yze3de2r3tvyIh0MVgN1l03c3AuVY6cjdM3HlCog40L640ld84VNXM2Jt1Zcz5PMEm8MHlINAm1TkPNe2R099OkVu00o+MoCGsdwjtcVgok6kGie+IQgiEOS5bR/b/aLbMTJ/Ejyd86guTN/AV5BCJ+yhvVd/4vHAzQfPOjHaUSki/4E0KRQ2kh4saYxseZcEiQBsTDrSQ== 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=T6G4bRyiapzbMe+OUDh+drTkVZ8YRCQA2MblTUklWUtKdruqRsSnxqG4Q7mfkCCOiNpbSJQsAsShDCX48Rkz0hyh7qTLgCvqCNlKoSggPs3HJWUJG1keUOAPhY1O1DToH5WLolU+k7s6PYNklKK/GB/0Z3Q45rDs/ClJNwnltBX0uPe7F77LbkPp0pIXk5clmv6F1SUZiMlYTdpjRorafSRq4kJi653EcXx3+FGfrn42CVaOnfrY/hel+SM5q80cv3Vyu8Mh3HI4uk7irGRvYyCKmsGicd5eEbFgL6Jk90G+5XGpgZiN0d5cbBY31MzWYJqGQz/ntE4now/ksy5SVA== 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=Ty39FbXvO70Rx5iU55qyD/CGFmcnWynDUo0kb0dWRwXAuafHrA3jnCy4TlHTlguOlE2kuuWaFT9IQY5uZMyAiszvL/Fw3aHDeor8Lxg2NAFOv0NcOowv1YZ6qmj/i30V/xZ236/umU+BOv1N6xTcZENN3hMfLfw8u3CTNAXi6ss= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:03 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:03 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 15/23] mdrestore: Define and use struct mdrestore Date: Mon, 24 Jul 2023 10:05:19 +0530 Message-Id: <20230724043527.238600-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: c33ee4e6-36f5-4429-472a-08db8bffc44f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LhByItiV1fGlQCtDMog5C8rm6KBkXO1h/BjkLjto3lAiBv6j9YdnRnGgID7A+jnTE1S2Cw0BoVbxnHDXWbynHAL0x/BqVsTVhWb4/nYYfcc0EbFmlclkNZhmilVsKBJA4wYf97wf1GL++0zNnfLcEDL2vW1YhHzL6bw3vHzIEvK1NshaZ+xVNnHokKRru+2au1xgh00Q6C+Y/LONXwwxZ6wSholsDEh933hd5zEgZqhr5H0ULhuBfxw3PyxjrkhdyUUU4El1RtXcomq1koEvbBtkH8cvv7PKRZiVdl5oKZfDqkLfnoVqK5BYUC+QbmhZm2og1qyuhKW/Nxs7dVzt34bdPUg+pDpxYckDt/m3DbcjUhXW+bk1DTuvLm2rxY3w99Bmxb1NvCo3FbGsvueLUX3+U6xajKiKWg/pTpOfeFOzQSjnCg3Kn2R60JcmnOjd/z4Gm8nqmtkrSCXV9BpPq/08YJclxEZmwXX57X+l1VAmC6oQR3XSrKKlrDux5rpkP85SFfZ0xR34oAxiyU80Q6l+aLdld9vQs+tUwPgTtmdqQN56iKCleBzShzeGKvND X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EkqFH+lh/knpARrboZNYzhmUH9mOAn0EcdhhwEkNLpb4RnGAM2tJLLzO0uRIDeitmXV7bYizR7u97s2SQfjOSlFK8/BqKSCGfhB5rt0txfIMaxB2YUW+YAdfF8CP8SsLMzZkGDXKLcJ6pz30CBVkvhL4h9d8gQwKam9qq0X35zRNlBtlRfSYtaCXs/vMmjCRlhQ03tIGXwA1KWUy36NeAm1MXDRLrurawrU4Ux1cItF9Zdmfs806P2DvGMqxf/FPpnoHvTajvOsyUinzdnWpyRzvdNxvbzVe76ezVQS+qes2j2P5TxwyceP0/zhy2tZCol+QiEdYdL/KmEtpSwcct5miWv6O6dc1iwe2ILw2ynf7KmHlswknXzUNDMLcNHzjgr9fqbDCsL/MKR/TgvRiey4dJs04L/gbUoziIyDbfErr+eeW18k4ceXwOJR/snZF5/a9OLFq51NvSsW96oehN8kc59wOsbQZgHSECGLsw9WMu6HI5fjIOYrVvhJmhAHwb1ya5LdaRBBLxnvOVYeAUNPFY78B9n0s4ioa0cfG9cQgSOVl0Y/UKeU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ange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qEu6a7XMubwu2zaNddvSFPF2Qw5SakkQkpy5mJjaeGvfx9WOuyw9P8Q73flw0q2K6No6C6owNrHbmBNDiRFX6+fKCshbEwGDldwZFO5H32CoXf7YrYv0s77l/4yy6ddGWTRYJvtJiu8ofWzktTH8GtaWzcrFEDvMT5uG+3aodftpYqWj2JALw5MT94wwSVLaO05mR/FMGGC08+WxrGymRz8LRJmJwRpM9XL+C5uMAjSh1Rz3BOItz+LVT+pA6yyjUgaB0l7KzKWO/X62C/4jOTgcMVpwGVlFBEnds53HJc+JbcKKigywaLjpKvWzTQWA86BMt6K729XjGF+oDzs9HH8sztklLS025STAoxFIxeM/CFbnWm5At/QOd4vynzgmjmj2V9FUPv71CxuzGfo0iw3bwHYajsyNTBmkWNc2FaZrKPy547eWHWT3AYueTmPYzm9EQPeho7SAe+JB1UQ3vgz2c8j1FlIpMtQ8byIjamTeVrahYbz3AHdWfhm1rY79fh2tXCJ74jSMGYt1xkAvZwvypcJpMZtCRWocqo2fOiWUPbBxtWxJcO6s3J7/XZfVAxSLDUpQo8e17f4mhb/TxeSIAo0w90yRtLJKG9SuRXyrsAIoEkalJYRuq3wexB+2FH++G8r9kEhb4VUlOZUlYJw6vW56GtRrtWQVuM765H/9YQ+niHO0aT3rv+qMcgXrpE0sN3o/+wNeQ8+QrEmrBYL7samLBWKa7j78h+0RV8jNUFIrw9bGEbnG3eOyCHpkl61MLmbNIpdtk14LM9Kwlmb2RBtRAJcRksUreQOSkjs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c33ee4e6-36f5-4429-472a-08db8bffc44f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:03.2599 (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: gu+s1bPD2DulEGyJBv/YvSaQnDwXEvsbTDh0n5EvFMpZVYMbZKnkcYxOklyqb8wAaQVWvd5eNQTVPl8s7NcH9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240041 X-Proofpoint-ORIG-GUID: FQig9GWGBZFHnFglvaeZSxokx5j0yDIf X-Proofpoint-GUID: FQig9GWGBZFHnFglvaeZSxokx5j0yDIf 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 Mon Jul 24 04:35: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: 13323433 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 53CD5EB64DD for ; Mon, 24 Jul 2023 04:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbjGXEid (ORCPT ); Mon, 24 Jul 2023 00:38:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjGXEic (ORCPT ); Mon, 24 Jul 2023 00:38:32 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC36B122 for ; Sun, 23 Jul 2023 21:38:31 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMVe93023475; Mon, 24 Jul 2023 04:38:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=bQupO75Zvy0ifEPUPUOBCixJ8Lj5K4EIaTt5b0MTbAs=; b=PI+4zVp8Y+5j2ubtG1k9L4tcOO3YVJv6N9XwKiKJugi4rwAoDM3wfFjB+uZMYOMMYcMT 2zM19upB+VR/BxoCyKTvT3Q2Bw7vBxKwDjQmkxDwLRpOLAI+oKxyEFvdAurlDBRcYMAs Wf8iAihzK9k1daf4nSLdGgtgy2+UnDJkHG4y5YAkv/oZ65y+eRi71V4WxjPdQFf7o0TL eLV5zIswHS4uVdiBKEPqvjd1v1lciuKdqybCtSLCRjLSk1F8QEwW9LH/u3ch+OwwrV75 Flzz1RQ2Bh75DvqgRarBLch7a3FONxJDmreM+VXUu7GdqqY+3uzVTkAbUh2NK5JAIuUb gg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05hdsv9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:28 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36O1qTRH003866; Mon, 24 Jul 2023 04:38:27 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x9f9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=adpzdKvmCNvJ5T4Y8SkQCCydAD37QO4dKfEcexjvJ62diDm5mIS3o/wv4VqEc0OFXY7lyM3I9dG11vmNZkjBkahFv7KLQGfQ9cevinEUIBfmBQ1M8Jpa+FC7sGXDEHfw2YwVD7ImfxzSfFWPO8EfSt38c4ySONRr2JsLq0QEws0v++v5wd505XMjCXMozTQ2RKFhx5Ofxs5gy8YfrpuptEHmO8KB2By0ZxpkpsI+BAtJtuVhm7kQ/bt/uMi2OEjYT7f2HmuiCE6JT4kJsPHKSKbBXKPe7LN1/Faj87uCDhr6Qz4BvkDfRah5ikHiVnvm6i2q9kNlBv7a1MZ4+H6rbg== 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=CqaaUQ60glc/upvSIHLiIufynYKhrtb8H8p3KlVXjWnMipCXj79zTcQTfIajGbmMVQh+/LrsjV8xG4tr+wY3GqxoyYruK6YWzUWE4FEQOW2Xw/S7CUm/Q1rhk1s+/JiWeEv75bB33EP/jOv134ICIv4BiOSU9bw+1yl9LjzOtTRbVsXaagg6c5qDW6EHs5EA7YIBtkhy2vsENjba/SjYLbMUwpmymXMHNVx2TczOKzwzZBCh2S2l2JNi5uEGp9IINqa5fRf+MzEfcqszQbeU3iPCbuPntj+PfaCFkxpiNaiVtk4cUzH2pLT8A7lHmMi2j6aAbv57+2ls2rxt3LQ+Bg== 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=bQrAQ1HrmiS4KI60DYyHuN9YuuZoUhZTcrYUTrJqs5o0sb1Z0HRd3Xk4F+ZSSryyki/Xl/jEv4zJR/7F8DOto/XJDO8ajk2CTsxClUb3EtSzl0vpnXxHIkVASrWN4aNgBdVmExyhOdRF2gdGiVlKeaEEUSdqQw31+l+k9m1Kwto= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:12 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:12 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 16/23] mdrestore: Detect metadump v1 magic before reading the header Date: Mon, 24 Jul 2023 10:05:20 +0530 Message-Id: <20230724043527.238600-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR04CA0200.apcprd04.prod.outlook.com (2603:1096:4:187::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f858d6-b8a1-4945-625f-08db8bffc9a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GIjFjt/+EeFbRwPwbsoW3t16LbYw1VZi61j7/8XEbeCitBZiyXorUa8vMly4mfg5NEHm+GOo9TpTAjz2ylIPUirgYv2XpaZOxXVyI633/AV3/tlOUpPZzv7KoRL2ujqj2LkeVhVDR8aSvwxBrR6dZ6lopr6ADFuB7WGJMfvVZqrUm/37Sl4Zz6Zhuw6zZh1kOzDvECL5xBBKYoMOmE9POF5hOgeo7YafR/o4RM85CTluT1DLPy/WMkmzgsTpVLOodksxyTNBQlET2xq+oqP9Q0BURGnfaDIyRBQw3lmOd0DUJ4er7jJhQLgz/sv2LR/0eI/ejh6c/CS4IjOslX4rRyvSSD48CXJRPm9GtmVoysF1qefKmv/CVdnY7aXjD0N5MVwzglp10e3tKtLwDh0pyaMoPfH4DUKiewN6gYopx7qmJRa6kxpbG0Us4HgY/im7zbao+wdr2IX9vHlz6JarvUJjjYMU9bSnCPK4vzeqkvE8/p82gccH1hRHjyxRdYa7n4j8xdk5MNXMROimX4Tr1amy6HM/yqCoCTBL/vHdHcxMrhttCkImDzqDC0YLyWPi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZPacmsMQql/QTaJaUx+JWu74RKjiHoM0DbA4CMQfyBs5SflssuLI5gQsBcd4mCVXCgXCs69RqZ288gUApByK6FLHt9U4g4PVJVTWQXKVs+cSiumL0LxnkbII2TDKWHUP4lmHb18jEtUXr2D3uOqWD+Svuvzg7RROKMIrYKCXvU13R82UKsNJNSKK/9v45GQio+BZaphp4BwiagpCgcjRm7m0sSf5OL6oijroCjmMuCkUQhZ6dP7es+ICmgU5GbvM5I8WqkTmWHVEWag6il6l9ZxGXwuAnhmS3mIx+GVoFsa9ODbzkbtjitBGupDkD8WOD0nw3PKoj+IByOk8FGCWepO46a7diBUSb83SoWYT/XOJFI4Bvf5nDMlML3q0DfhV5fAKH7BAxYPPhLntWrvts7YiUqcBgdjcFYhDhZ7gs2IcVEEuskprdaqdLvDIl4Vkm4ue6zbcc9FiswfEQVat09JsjR+ulJg8MdzCioem5invK/eKZgGDwSwSZk3cqgtq5wxnXJbtRKcktBPL+mAjxFQ1GU7mdfrDDQAySDrv56UtXAC74oZxftoQziLjv86gSEodx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-AntiSpam-ExternalHop-MessageData-0: +6/rrl6uQAGouwmsCusK6mzIBujm4OpfrbHMVilDd/OGEO+M7qdsaKa66Gq1ACG+VSLqFFk1X9fnF0LV6AP4p7icVi38gQR1GKUqgciWTTdmyabQPqmcQcOP9st4ggMYi/SUWwTWa1sh3Zpdh1ceipUsUUP8ZJmu49B357ua6T3Z/UlhG7+mSmYfwbskBqAY0FyCglPpCI/npn32uvyzABHxR6VJQBoTtC4EfmZnqx86/WTRtY1rtTYq5SALMuwB2wGOx0DE2SR1vNngExFqWzPhBLEywJtLj6Nf55eTe64qFXzSvHDpqgRq1M7vF+w/Fyxbhu7nPk6ub7qx7dLui+0JnAs6iXPEBIu1VHTY0Wv6JwuyNRcrZre2uA8+6X4lQOu9NdO9NXmWAWExYRtA5uwlCLIOr6+LILRHpvO/xnFZxEQ+U58qizGor45VZZi9xuGdQ2xrBzso5r7tpsmh8Tgpmh1DzODtwRo7/byuo0IPTaUVTkZvhHapAkeK414b2Wnr55OSULQTU8HQdb6T1GqrKh5VBTQLWbyuxNvITIhK+1XyFT9x52tuOLoh/PkWkYd0J2CdyoQchV9zPLlAiYgk5Ffr7Cw0sxzL5KhSWW3rY58XfbnBovXtiMnbeN/iH/QGYLWOv8kb87RyAB3OF6sYe+MBXPYxeNiG8LQMOzgmZw18jngz8f2kP5f/0B3ce40ZewGDsZSZ3Gca4MysRb+ZZOTQ008XfjS/VsV2EkQDLrRG24oWdQfUTfybEbwck2/p+NHoEv1QbuMiIIYJlqaUMhTjt0tStKn1f5cU1Zg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f858d6-b8a1-4945-625f-08db8bffc9a0 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:12.1648 (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: 1jF5mv3uftqrE9k40BGScOao1k4jsAzjSGWrqsSfj1VaoJLeL5haIg33HPMFXhHN/6T1jQdAsGi6P3/77/7fsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: QXsIvsoPAG6OLMuGBc0_5m_l1qSgpNOq X-Proofpoint-GUID: QXsIvsoPAG6OLMuGBc0_5m_l1qSgpNOq 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 Mon Jul 24 04:35: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: 13323434 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 34B20C001DE for ; Mon, 24 Jul 2023 04:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbjGXEif (ORCPT ); Mon, 24 Jul 2023 00:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjGXEid (ORCPT ); Mon, 24 Jul 2023 00:38:33 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964991A3 for ; Sun, 23 Jul 2023 21:38:32 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NNuM9t005467; Mon, 24 Jul 2023 04:38:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Yl3FzTgUJfjrEq7AZEebnnSonrYepmNRkzX95UwiAys=; b=BM6TG0OiIbU6XR9bhsGC47X/Ns8XikfoQ8FPJjQillhNidmhdpHYYwrgDJF9LyQFtgHE GYE5Ket2uHIwDuaSBa3WpCdlnsZyEiYr/mk2bHViEulHfNfbY3s9Y+VrTL+olNgPUpS/ YjTpO0vlqNVPiDGbzWTtuKRZtcD2Vy+DJ8+sJQXGQIe8uL210WWfGH41L6GUl17ynz6F CP9dRvam2sx4D2VeTltrgiZGOhJRLiyUuKPcGsLO6JjVREVE/cGKVIpXtqEkIU6x6vUY C/ZEiJsn1K27vd4w7+fjoTWumsgwYHCnnRtmiZqx9FYJmxLZ1jEgY5Cxlg7j+qRwtX2P gA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05w3huw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:29 +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 36O1qTRI003866; Mon, 24 Jul 2023 04:38:28 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x9f9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRx9dFY9o8ziLUWUYBk5NduygIG4+DN24izNOjq83aqelmEe0YyyWaNZCeJ1RA+S2PLp/uKDke754KwkeC8Ltx/dOP9N+uKTamlyvPi+ndyKqe1bNeyjHpptkne/zPGxc7LDwYrNa8ngioUuRLK1EZ+kZB3gK2fsk5JuXwSS636f4x4FcIN7xei04jIZjHOb0nJOBsC0MIhoo1g3UQQ1VLhsuPs+htZEOzdyuDX9oIUWIrSq6QZh+GyduyQ1hnXWsT6mipiWSHFayrunaMvZSmRgCFTWygAU3f+c5nkx/aQ09WZ4yVQApBW2Bit0u3a6TkAprM7fW5KYO6HCBT/DOQ== 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=Yl3FzTgUJfjrEq7AZEebnnSonrYepmNRkzX95UwiAys=; b=G7LnN7SCu8YWyqQ93d1UXqPm+94nUf25zLi0ynb2/JbY/KYCvbGA/LFPNzPpPRNUWHvqRAQtMTWBGtJzeUDy9ZWYprytvlAs8zEOI8J39jM/Hvh4v1v9Rh/yj/pHbQfcaCh5Trn+X6qSzNQp/jD3Gp0K29yQtA75KCstNxONf93XY8cbemvKcq69MzuY/0Biey9vsFmUOoDxRI7dAciRtrxly3ex1vxjs7o/mGQPfBKcK0cXitzHpiPLwEeOdSpeLacRESvDyWEJuuYag5hQR6zAK4U28sFy0wm9v0jcLNavBoSrOKNlYSgkC9VGjWZdTalMKfCsnr+xDK0NWJZRIw== 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=Yl3FzTgUJfjrEq7AZEebnnSonrYepmNRkzX95UwiAys=; b=IjSd627wkzI/K8BMfu7A29KAmumFtqd+SqyPduwLd5xtgvlhUqgl8TScIDyvcWf7PfAQQs5+wiNHGX1SQ+Njj4upuWDB9e0KAYox9F5Ro/c+diohhGPrAtJV+rNrca0W3Db4Z8bq58FYqLoU+OfPPrhbBU8LrujDdsxVy+PzxAU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:20 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:20 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 17/23] mdrestore: Add open_device(), read_header() and show_info() functions Date: Mon, 24 Jul 2023 10:05:21 +0530 Message-Id: <20230724043527.238600-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0116.apcprd01.prod.exchangelabs.com (2603:1096:4:40::20) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: d454c8f9-ea5f-41a9-5a02-08db8bffcecb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OZzbwlbzbRxkgrNJCRTQHo6XFlRgtRI6tbTwjiaBK1RRjHjOj13JnWaqR9b1bldqGuaCFmlmUtte7QIHi60LXo2KJXrCrU46tS37mdr7bc5qCOg1NS1sdx8Gu41AU4yj/0NIXG05d8DrhnFBjuJWnFEPUsFKCk1a37kxJT20DZpuPSli4gE/p/bvYwbozprQEqwBakOtNuoXyzZNVcRn8sJ9KFRpGo5OwDrQKdmW14onLStl+sWJUfmXLQ0fgL6q28KcCk1uNOnO7zRWoAqXTaUjextgA0Mtt8EQnUqzCJF4b6C6j7OZS/hylwBbW7DKYptd2T7Rf1qxyqWm4owI9qUiiom1JHDr/DxZEReZntSQENdbu+aqT6qw+etHr/BUxX+Z+HicHiIJ+FitL0lHe40wqjMa9uHVc9ald8vAWrMGuI+D9EFOJtXwrnmRl9r3W20PThK92+/fsOM0MPXrR5SZG0w17Bkj339HJ0PHRYfPwPBkqMSBciQ9v7mh1XhB5AdJ1VlHL3aataPyhtge5RRin5up1HJ7t8vMe3y2gUqZAPM1aK+6cgFtCokwe2OQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData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EMIy3td6O2lC4aeUEQw9oqMhQ+RMS9B8/29QumxlJXqJsW/N5YIDUM6kdQZSQ2d0kOKc0kNJe6ahkjUJxevbYMYziqp0DNcazfmIpnPAlCxlXrjgQ7cmqfnNUINuHRlUu3rbmOo2zyku+1VKb+ltOlbDPKfL6v+qTA1mQ1drlHyHyYLugw2S9RmB98WHoTSGsiynBnI72bzoy3cppK7oNF5LKwG/r+3ijJ0mvIqhCSIVZ4V4GB8q0xuyYWeLcVLdwex1LSdPlQFNLerH/1rdaPAy1Zgj4/KEY7mdjEmYoqWHIaO/B5Pk21HYOfpxGkG6cNpRjXDebeDZeEJZT74SB7dez7PEghZmg9TnrlgM7dPxJ3VDmY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d454c8f9-ea5f-41a9-5a02-08db8bffcecb X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:20.8481 (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: AN8rSNnOFBfuB/+ZBZc4auXI39lihtaOUaY5kDYCs6yPb+tkJ0liiq8Ylorf98Mq+OPAzYytR/OJvYkOgrwYsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-GUID: N6ZsO67FMq2PtCFMITIQ9TTO4VhPCo4H X-Proofpoint-ORIG-GUID: N6ZsO67FMq2PtCFMITIQ9TTO4VhPCo4H Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with opening the target device, reading metadump header information and printing information about the metadump into their respective functions. There are no functional changes made by this commit. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- 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 Mon Jul 24 04:35: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: 13323436 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 41D2DC41513 for ; Mon, 24 Jul 2023 04:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjGXEir (ORCPT ); Mon, 24 Jul 2023 00:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjGXEiq (ORCPT ); Mon, 24 Jul 2023 00:38:46 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2831AE for ; Sun, 23 Jul 2023 21:38:43 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36O2jvwI026582; Mon, 24 Jul 2023 04:38:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=0CKwC2CoIEtNnO8MqxKFadtmJShtmE9M1RPyfQK3TOU=; b=tBWJnobMhsW+XAeL681XQOWskSd1PXBriLd8qhTLEdZQncXhgQaXJmFLewT2PXG2IKS2 gFQgJKlLHIQ+E0EZD5L7p7uFfm9SG4XMWQvCcy1OR/g/hEU8pzLEnrP2vlpONskjqMhH tcQ9Tx8jG2N7SjQO6RwD0AXv7XoyVthov78d//MlOnDRhNAsl2lcu+h0Wsn/kMhfx5p+ 4SasdethQBGyCzu5u365C049XTHEx8jCb40Imj08xQSbDhEw28atlNhphDJwEJ+8IhAe KbauwZ7M4b2nrAkjdlkSwzmQEYWXKuJ6W/fEuoP/l0v7lMhryIouP6ca5E421jbTC+Ih BQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05hdsv9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:37 +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 36O1vUJI028903; Mon, 24 Jul 2023 04:38:36 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2169.outbound.protection.outlook.com [104.47.59.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j35ysb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YMHJG4Uf1KfVzh2kjdu7sKz2IoLRWlSDokd6SvSBiwKKd5YR2E+cfiJlML1Sof2pSPc+npvwaUk6V2TzfTIUfdxRvy73HTrOJezLB8e8rzmjc6iHDDVIfprz8X8tps0rZ3GemBVqthwPv6x6mP0B/Ky0X3mi5BPVj62NnXktlwRMxyvCZLv7/pTxI5M0Cf0W+PrgjZbsbOtqsswOOkVm2JZtRITpUWBeEusxDiLlm1O+w+/vmD15OpPCKG9dTsk8301JCEvjIhrMIou5s/DZLVRpllRYPnq3r+lZDN+v2MNeN1Zt5/6Anp83n1m6A4G730ErwatPcDIX8zNXXZQkBQ== 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=0CKwC2CoIEtNnO8MqxKFadtmJShtmE9M1RPyfQK3TOU=; b=Eow5Zu0fn1wd58ZpuHlF941XYR7guApC02Eji3Jxx3daxk2Ml3UgS9ixinAo8TsZnkSsquIe+N3QbwXk4Vzk1l7cq/geFSnSZ5UgItYBU4YjoVnZ9udtsVX70gJdV8TvRzRlsthW0q34PfI6sjtxNeQ9KCpu/HCdCLySWkDX7Xp7QfNOPadXVxxg9Isr8KvJ75cyfnuWSNp0rAmq2v4kjtUNoxXhIXDbkRGLcNR0eLi2fH1TifbfryqJB8cnlRwSWVm9V4q3NLxE5bYejaBmXhDAwNaC3sFpY86lq6PruoI/RYFYWyuVaNUFKoeOo02d40fH/xb8tqpwjMNSo8EsKg== 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=0CKwC2CoIEtNnO8MqxKFadtmJShtmE9M1RPyfQK3TOU=; b=JO/F0H+RDmem6Pn2ZnuIgKLcdFPqC6oPStV4utKCku4qRACjZlGv7JadHIHeeb6TWMM6HQgIIJM6z+AXEHZfX+hRWTMRLu0e9DtoJRy0YFSw98ecbSOU3gGFzISx2dTDoRe2+I50sucpDpzCOwk6UQkdvJCD3/f7cxPSOOKobAw= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:29 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:29 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 18/23] mdrestore: Introduce struct mdrestore_ops Date: Mon, 24 Jul 2023 10:05:22 +0530 Message-Id: <20230724043527.238600-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SGAP274CA0004.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::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_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: 78b2d980-1c50-4c83-b9bf-08db8bffd3ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vGt5USDoNDfzCqAOI9Z6xW6jPvA2K25ghpnufEJW7ZV46R8KC9sGeG8MZqUhGLNhLJAF2gtQ0e+KaQyqOiQ5CN5yjqB+1kDCNamgjRGyQY1ciShooE3ap4l2iPLucGr5k4+b78etASsu3jkOp+bm4uihe6o9jRmSYvEbFaVtI3UKP6hVGsnS4JEBszR1k8qPj5WeYcR+QkcdzVep0OpdYFKflb1/P6lkT5rSVxgh/RBMwokdYpUIJ8edWlnajr+CM5R8AthizJpJEt9/NGkadigG8EkqHd6CTPY3hSutBMCnW0BAQD4KR2T1O9RmREszW8VE3RMFZ8nZ9kHfV/XbLf+q9qAdvqA48lefWeV8HwIBq1/pEJ4wgivxs1g9gCsPFaIH35zHJ+CTf+5P0Irk/+mHi9sZ3cYyqqfv3pkVi6IYn33xy4EJkQIYMwYGGn75YsQlNblDdIyj46k/h/myZe9PUom1Pjh/gdWwlAHf1PAToRnQpiJzLwdekomh1X6Myv1Kch1DjdhUa+M8L0qnqJz0Fza1yNvxv06ePdjeahWQ+uw2AQT0xhWb59s8nAqb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9cBdoCI079euCmq2W8HNLSkiFUjYN0OF5+BgCXsVd5a4uWdEk75EDkVIJkLReAW5EtckKYEK2YbXR2S+Ju9YY664Dwm3+TBq6Hx7TcGtMTum0w+qrJ+9yk5TqMpA/bYfY2inP/gWKVqTn7MgDc57cw3LB8pPQMhqwOo795fLpVayli0WtTYAhWsn4bKznGxMZmJK8Cy2t5U1tTw9zJWBhaOsG8O/CDvHPc3QANj65pwqwaUz5T0PjAPOpSGBIqqMGmKS1skKpNbb/+00ZfSFYaEeZtcmG9+W9y9tSekQMT0Bl3tsuRmRpX5u9STiMZxuMwALv1H5KloupP8OXc/rb4rxJX3RN2ninPdpFgKqg+31lYDJXQoV2krpNW9lb/TEMdhLNZ43Oo4xZP14BU6jv2JmXarRhK9Q5xrN8UnyhOzQP1AurKJzQrPnvyHq+H5DnURYpjbPnQHRq7R8NO4icf6CWmjuN/yTAhHWG1D3mUyarhpww5CP8iqKR/RzGJ5vC8jkbBLpnEvKf/fX+vTEBs0WB8MRXLzKF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change-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ilPL1TSpJW71cgJrrSGTDZGKkSGr067o70cQu9f7S43Iw6gnm0s5lWG4ydPvjanqErVSLv+zP8dXofSfXW7VtanDN2FoU2Aj1ysbW4jhstbcbfcoo4MoxK7tB2YCNXPXw/1OMR13AsZRPZX3H6tAtavEz6tvgVnZyqc+VV8rq6+uHMZoB9hnTC5ChsS4hReQ4wDTSyh+/OPBh+cupRNugSnmZZ/tnF6Wc4i2DBFtKR75u3MhXk2gFCDVw9A2u+xQzvrzc+i1s7KWStp7ftqSArciLlWSfiJRat5F2237xq+lw4xFAtCsHXyDQBJqbOEsGIZiolBdUnkNZtv1Dlk6aTEPuw3zOuYrVJn/Rdx4K6Zzj5Cqyh4trc5WiaRE7YhCNxRcMi6k21zJQdL6wYGCN//48NZUAjOv5+cmlycTnu6AEm1kmx/VHjTLea1p/xCLRvWoWDU3szIBygif2GqFi0phcrkW2FOrzQtEcqaVX3m/3jqBnK3Swwti+GNrNPyWAi1Pb7b9Lg/7E8C/dyHQ9vtN5/8lCTu2LwbGKPIPCtcbsRXOTWdm892PjmDAVzKPoGJFq7Q6tLZr73Zh5N2zj5Hz/3yj0aL15/+B/lisD0jTmwmvLSXWBKBLbc+Wk4WEolV2NG1EutHeiH3YyvMwQe7RVe2q/YKbUlvEHs+GY8Xl3gNWVUw6Nf4RQJpZcjQ8TSfbVYdPjRWVgs+XPKQWZc1e+UtVVRx75/wEyDQWQo4n78YxEzVd1segm45e+/HtJlibuRJkErQwxfFNIAuz3GyHITxCzU/S131OL6hzFYQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78b2d980-1c50-4c83-b9bf-08db8bffd3ba X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:29.1241 (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: li8/1gogj6CmqLPEABy1G3MwaI+HB0rAmZinYMEUZ8smTye8bjQHMd4XBsWSbZvTc6RzQAp2hClUvdfZlJfJsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: NU51y1Aol4m6EE24SWXhaNavxR7yNwf- X-Proofpoint-GUID: NU51y1Aol4m6EE24SWXhaNavxR7yNwf- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We will need two sets of functions to work with two versions of metadump formats. This commit adds the definition for 'struct mdrestore_ops' to hold pointers to version specific mdrestore functions. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index d67a0629..53c5f68e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -8,10 +8,23 @@ #include "xfs_metadump.h" #include +union mdrestore_headers { + __be32 magic; + 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 From patchwork Mon Jul 24 04:35:23 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: 13323435 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 82C1FEB64DD for ; Mon, 24 Jul 2023 04:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbjGXEiq (ORCPT ); Mon, 24 Jul 2023 00:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjGXEio (ORCPT ); Mon, 24 Jul 2023 00:38:44 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 894821AD for ; Sun, 23 Jul 2023 21:38:43 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMRLFN003455; Mon, 24 Jul 2023 04:38:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=qNul3HMxDlJGg3OshNDufhqpzwhhTvYBklGacV/IRvE=; b=IRdAS17fpvgoB8G/Kjp4GETOWrw5bGAq8lB9ckHwXR5LjcBhxra3xZDjiNb5f1nJZJam xY8O6tE7VAAud+IbYGmAdHpNZryGzSsFxdEnZoHycf3CvEuMH68cNKC5BgUvRMU5RHht D1zgbJl18GMde98oNOxqQs0rUCx/BnJta4X5vGNHY1+S4arIAHma1stk4E0/S/Vvk4V7 QoS3GyMv5AKzjaBbrAWC0J5K2obyOT318AjKgPTYPbrH13ihBq1mpg2U79z6TCVtXVms 1t1jF2imAsc6G6yGxwO7/dU/4c6RqjUKc8GKZUWrULn4SvpV0bJ2Y6gkSHq2vGACHdm0 lw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s061c1vfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:41 +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 36O1U6vU029023; Mon, 24 Jul 2023 04:38:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j96k37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GVmJu7cRlldWgC0v6YXXxMZdZEWpOL2ZApBgr83xIiTwBtg33RdMKxcofu8ZTu3uj7lP+xm0GZ1EHsUy5JwmcHxNr69jREAG3Pyp0io0gXQk9KEkX5+GGDsZV5rZI0BdcdBSjFq2GYQU6nh/hhhtmabmQ98QvIuxuhMjtl3i8rY+oSnAISG7ONdySbfHpvrRrJodOsvv/Ss2j8oo15m7RTgWI8w1Zms24+NZHM1HY0e1VpvWqJDbx/ER0TIDLy4OxBnj8/Hot5e60Wkd2vP5Mn7XpyqxCHGqVdaXJ+GZe6mrs3IygLc80F4qzSuk0wqg4oG7i74ohrMkbe5FCssxLQ== 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=qNul3HMxDlJGg3OshNDufhqpzwhhTvYBklGacV/IRvE=; b=OZ7KmPxnfVnlqJzhDEC3nIxwXBPcV2UbdD9TstlAXQMylysCP9RjzLJU2P6TsMpAbPeArXk80dqwItefXr6rL0xvB9XxQjgdrxqcSrLMeHcpNyRbYT2zo4wBZhrFPCg/l8wQ5wLsX8Y6pgwZAKnKiJC/tTgF6jon+PFmDKfoZSG/rz7XWMpn/pygBAzQ3ouaMBrmGx9FKNI3VKfP0HnyjeJRdwez/OzcnnXF+xFmTzN0tcpJCRlPYxys2fhGNi+1xnz8/5S1p4RxE4Qyqf1zaPcpcKLo6Qg8TsATlU+TfX0roK6rSquc74i9OquDkJndufS+4f2VleIPZhWMTNRwfg== 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=qNul3HMxDlJGg3OshNDufhqpzwhhTvYBklGacV/IRvE=; b=xY60z5eoYyt0RMqxq3QjbmF8fxXcy9+H/uz5YCVx0wm36eTyFLYxcCM+zaEcr2ZkD0mpa/wj7OuXlc1/Vq+AR3lxkQqccgW+nSImhdbV7U2OkmcUJfDdUZFHfYA8PoyqjLZytylEUCJK4XpGfK2SsHbhDREL/QSNVNJoGz5PVzE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:37 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:37 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 19/23] mdrestore: Replace metadump header pointer argument with a union pointer Date: Mon, 24 Jul 2023 10:05:23 +0530 Message-Id: <20230724043527.238600-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR04CA0199.apcprd04.prod.outlook.com (2603:1096:4:187::13) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f0dcb2c-75cb-4954-137d-08db8bffd8e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ozJgIfZ4SUWj3UHhqDk4d+hLTOAIguL2yZtECM7pCA7v5Z4mn2oD8jIgvJzkBwnRYwdRhk4h0BCaaQy+bXs2SqzNGXAbGQyYQZ1lfkXTMGQSfYQtwg3P59J3gajF014UrkHOF70NsF3h5tUKW33V/Emc7xUdkYNVY4DACe1qFJglIxyno0un2i7dTZhKTCGR0SuCdkpRADZ+cb/5DKBp0bRui6b+BpdtLwIkTzEDCX1pNpc0bHP+wuc9IVGQWPR3mxAu0o6E6egkJ9n4DM5JLmH0dQouSb4+lsd/Zi2L7H/lCrP07qG4J6j0JNd3Xz57WzmXBd5uYHXNgkXX73dcTn6N39+JDa+1wcYOoal0yjm9Kk18K3kg48TJ9p0D8ldIj/24MfXX2r4ZrUhAJpey1qIHNyjLtiPGFAzQP2Nj+P03ufEJBAmH5ftlXMYsePsev9DhRQSF8tkmaHSI8rAL5IM4hNXIbFi+Em5OFlEEyZe4M9/CvVDalIBKGSuZBV0Xm5qXcmnDhdM6Amj6ADsSzl1ZId1qQbzCDw37qsg/MiayiP+57uA7w6vuv2dUS+2P X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8AclsT2pBhQVqI5+ObopTxaAEsZ+fJFmRKqnRoFNIIfNlZWWsyVx1eL75Nkv1XIqLx8mGfYnbZGZBpIXKUiS79L+m9jya31L6jhDi1WUWCyJk43JurQU7CmTuvRrJ3EBJxe5fQ2MEPfZ7fnkSZDqIekW0Mt6/75IBlCq4mHQ++fHbzd21ZEC8bjMsCNL2Oo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ycZxAw6y2fnFEvPQqvUt/CeubcKU+jCsmkmgMcFth4D/SAWKYj1H1nGAi/1VfYI+J2xyRi3TLGKy1vGKUrjDjq03LzymI5d7oC8KhDhDJG6O3zMDlHO+GvjIWGoypKYTIgTTKHjU6jct2dfGasUH8p8s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f0dcb2c-75cb-4954-137d-08db8bffd8e8 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:37.8055 (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: zq3vUlB/pCTbKkdRUpQ8CXjOJ0KmuDt77+o5Rnjkk1bOB16tuK3uwXPA6AEwrwSQxTylDeT9Bcmnla09exo4Jw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: NcyXzg3xsBU9kWr91ykhJLWRe6_ET9C1 X-Proofpoint-GUID: NcyXzg3xsBU9kWr91ykhJLWRe6_ET9C1 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 *". Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 61 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 53c5f68e..4d1bbf28 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -91,27 +91,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); } @@ -129,10 +127,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; @@ -144,14 +142,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); @@ -165,8 +163,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); @@ -213,7 +210,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", @@ -232,11 +229,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) @@ -265,15 +262,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; @@ -320,20 +316,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); @@ -344,7 +341,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 Mon Jul 24 04:35:24 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: 13323437 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 783D3C0015E for ; Mon, 24 Jul 2023 04:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbjGXEi4 (ORCPT ); Mon, 24 Jul 2023 00:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjGXEiz (ORCPT ); Mon, 24 Jul 2023 00:38:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1069D1A3 for ; Sun, 23 Jul 2023 21:38:54 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMvFpB025014; Mon, 24 Jul 2023 04:38:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=YhWDXRrEH4qfI70nbkbmV9QuDNJBQv+jwm2p+r0Icos=; b=jlZW3g7ZqsfrjZoznqLknaSMeWgfB/6BUAeOoNUELbNL14yoW4eS5Le3/jN2emQGavTD rG15hodbZyxrMzkRykQThBreLBa1I1tBGmYaWDv4cIPlVTYrcr8NYTflKhE0is3j5jcD XohKyinBGqggAfWX2Yv5Pb7S53YRa9H3cCgLcif4w3KKfdu/0os6bYHGhkaKi8cMWUOC Lt2ZuwFWQWXbpRlhmpzL3jTZ633V1JeYuWGCRzhvhRmawqSYKGk5ADsRrLpjVVmEhz3X dWlDgZAFwAwAERW8pVi2w1V9ZqNbtpHHoT0ff0vEMsH8TDVB+K5znPx/k3X0tqzznY/v 3A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05hdsva4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:49 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36O1usn1040849; Mon, 24 Jul 2023 04:38:49 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j3eanp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vogqk0FF/IFRYpF2IlLSSM5piF+YUOzIp7lclFr77FUA+ghoWitC+i3o3Jcnj3r18TeXqdtCJkDqlhc0XMQVkyxGd5iodj5Ku0wE0OP2DOzF9/ut4dw92VNzzrhMLZZ+F58l+qZy4L7REY5yEwaAiYxGpxjVBBHL5a83R7W0h2DToJT31xgp8m5TPm5e+C+PMtI10qsDjnkmD5QGkbKoV7t2VLiwPieSPt0pwOGEumhl7PTyY+VeGvLnOigtaB13IzrM995BZiwtq4cZYG/V1p+JGs7X4clNsCZg22cEYz05oFWx9tfckzD/OQcno+xaqe1swn04O/D6Ev2Th2ZrhQ== 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=YhWDXRrEH4qfI70nbkbmV9QuDNJBQv+jwm2p+r0Icos=; b=n1s/jjm94m1t4SlVTId+YjdmG+VoB+LjiXDJWhdNZFtdlIjKOSVuiIPdE127up1sYk3BuLlWYgkE9/g5l/hJ18DAykLlxDlPIrT3XGz4qRFZYSDeoxOQ7vp44gddVcGwLezWzFq4bincOTV0SLFARru2DGAGe+Dl449PuLZPVNCCpBWGR4UJO8l5WBQNS1EoO05pQw4r4c/xziIRNQVISb9hwrbfO201nLjd/om61QoF0B0WxosaZfoNrwhN60A/5gxSIiRT5O+2iOH5IGnRFYKEj8MNtiMCjBY9j5xcSWj5h7Th4OOquAG7Z13JBNv228C3DwGqFwKe7zDKie1UWA== 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=YhWDXRrEH4qfI70nbkbmV9QuDNJBQv+jwm2p+r0Icos=; b=jhmpmI/IYa54Q1xRXOR5kWoomPChsuTGWSKi+UJ7pbtzKil/P5Wymc9wZsZwii6e/1+tjFYSGoefgo5tNygNXy7IhnDaUAOLg8RNcTIDaRtkHW4BgaZKS0nWS5jWANVMAyYMiEYC02d5jL8xGqUn3z+07c1s+HQdlM9oA4lTZ18= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:46 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:46 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 20/23] mdrestore: Introduce mdrestore v1 operations Date: Mon, 24 Jul 2023 10:05:24 +0530 Message-Id: <20230724043527.238600-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR04CA0213.apcprd04.prod.outlook.com (2603:1096:4:187::11) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: b65500a4-0832-4dba-1fef-08db8bffde07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nulOixjYn6a9fqwTtAlwRj2MvREWvmJE1uXAGKwbF6+/pZoCPqNGrAjkbYXEd2cORP5nugSDgQlns2JWVF8K2qPTjbD2rNVpMyLgg9v7L8rzViAEFzp4hEdwC5xHP/5bXjElC9WEtVufsPA9XZ4cU8kGN0IMRoKsY97+H4Vsq4aSxk94Uorsbc5rvYXoMISpsVEaeC0p74Ah3MoAQdUPL1j2dv68dN0ewfjze1zG/k+ZYQGGCB6r6IvzOLT9ppjdZyz4GmqAKWiIM1vCofc7Z8vwM4VOpZPlAyfW31lMzvTVCENa9YsbygQ/SbKd1gT8VV6DI7qzGR78jyvNRsSLKnbC4AKlEv6Y6Yn3urhMhmHo+rif6COo1lDApcMUkPXLtzHYXS8ZqwDegiriOgkdqbJRHqKNE8qyKh9PFxygUlM4rL8TvVwyVD0FQIaWgsoqUId+4HYDPTGngfDqlAXNS8LKUCtYw47ZKS48KSKM1sxHMIJ4NDhsrip1s3D0fJzc5Se5ZZ0MT2i0SzvVxgXrns5HkhUGrOF8bq9mZkz7bI2+v1s6z+KvyMjdnqUOYLb/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Ant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K4nFMjWxksmqc30wbm4+QP5WAua7kDtzyRXqmnTamt5uwBP48SKZQJOMDLOhT9Y1WknN0WrkdhqH3VxwDeHUkgNkITP7vJ8y+0xQa89y9PZDklGC0e2YRipHHrfIPpBjTzIoAZZu+p6ckbBu2br2Ul7ZlPVVbbdNe92SSSshw3hgvYypRJ+r4xBT06Mm7G5TC1g7FmEsHE3ZW6p6W8jidtP7kzhi1XNXvY8DO7jN+KF/MkxHbU1LhqE146dsrcOmTlzYiICW45BElBJeH9m4+LiyU5mguRjOG3+gMx5IxiCWc0FPAPQAQdJDkJyjixF+GGcyUF/G3h/E+8jhhv+jJqYB7hx9wrdxMW6jjAEKeEhP8UQg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b65500a4-0832-4dba-1fef-08db8bffde07 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:46.3899 (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: WiWmaXDryGKcC01baUNcbNn9vWrwFoq8qaVE/A3ORtwL8IA4z/bOCam2tUWLnR6HFX34Kkps4HQBXVz/iINDTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: kCjEXgRazn8YHn6oSBfdiy1nSJ49zIKR X-Proofpoint-GUID: kCjEXgRazn8YHn6oSBfdiy1nSJ49zIKR 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 | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 4d1bbf28..b247a4bf 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -90,7 +90,7 @@ open_device( } static void -read_header( +read_header_v1( union mdrestore_headers *h, FILE *md_fp) { @@ -100,7 +100,7 @@ read_header( } static void -show_info( +show_info_v1( union mdrestore_headers *h, const char *md_file) { @@ -115,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; @@ -253,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) { @@ -302,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; @@ -321,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); @@ -341,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 Mon Jul 24 04:35:25 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: 13323438 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 8283BC0015E for ; Mon, 24 Jul 2023 04:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229688AbjGXEi7 (ORCPT ); Mon, 24 Jul 2023 00:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjGXEi6 (ORCPT ); Mon, 24 Jul 2023 00:38:58 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F15C1A4 for ; Sun, 23 Jul 2023 21:38:57 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMjSaQ007321; Mon, 24 Jul 2023 04:38:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Utm5Lvcd+DgY9K4VopJp4jyGdtSR30ppD5dN5Gzx6HY=; b=yQxULfrRxSmXLfCyDb3ENcNXj0vjxoG0LvVRvtM315u6j9bVB6v5R/8N/StPZ6hosanM SmP6tO98xzUl2E1GRdPPAzOPTEcKGw+bBRb9BCNlJQlax/Y1eT52Vfg9BxBF645NBZ/0 KPpLe2rrZW5T8uLmbC5BaQdphKdT3Tnc7klO+JsvlIKPscJ0PnA5cdXFDt3mJg2QbmRv Q949TJ5pvIzcNyiJ7PN9UT6xL8WdAGSvkvbSGWUOpxh4GoNTPSmNkcum0Zc5G3RqQ5ow e8h42G/dFQZAzJLh+oAqg4/9IvUH/P5FgsTipfmKQuHblRPhdkDGn9CXuAzStSKX0elm tA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05q1sv8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:55 +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 36O1G8gM035357; Mon, 24 Jul 2023 04:38:54 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x8v6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:38:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ENZDojxP+k4A+F+Q8uZRvAgmFFOuNoCWSAeRrOXQe73Pfb2seE8XuLv/OnQmol8tYoYY+v+nYsrr8YBQF2oRKzv75eqt7BV6q6ukXeqCgMnA0AufYv73A98bHbKO81eH4hfKEzYGN/KU/EyMfKQQJ7epCiA8xfFNwPtIc99u91wYTqQ+m05CNMFzi8ZWooVL+YN0uFAqaGy4wzjus1ueG45bR+OXc9hxnR4R5T15OrgSqC8hEvoPoBp5R8esHsFgmzY/utlvuAvYH9zm714AhwWDeUyQ06+/u7Mmd6XkbTqUSRnP8UNulkgDtFIFDBjTW0cS5jWm6SwGHkRVo0LSFA== 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=kVoJ6AIzPLjf8BfAm4eUteblFkvEURYn2vEFjjDAb7v4W/iB/1XUDUPaYwLXImp9TvUw0FJBYRNLBpL6GmycKMWkgzUjdWpQ+RM/xCv0XYdWqQ/7hH4I7WDiUZO/SP1Zv0FpEyzWzHlzQ/RRj/7dCeONMAEtQWWapBu3eiZhW4+xuawFostgUqI/1kySPUldpAkTM5lwO75M6kDaGkG0rmcd49q3vvzlyEahSKDThD8FWjaWZO2i0Lwf5pczSvTMtgtDrW+TMKij6DRTulfSmntDAtI61aOt6wOg0uwwSB+oKhnLCyYrPme9b5nPa9XloLPnX29kkF2NRW5E2dXWDQ== 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=n/gAlWVbPu9uesOh6BzD1mbS/uWjTWJ4KZDh36f0/F9DkeMVN1EaCYTjoyBldl5lkE/ExtENtkWc3l3yBoZpgyw0MJmHvRgYLhDFVTbgePpzMkMFSFvcuCkFqkqm0T7ArkUxkbXpRLNBdpkYzeotAnFVvDbj0FCKWnNbyPoISa8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:38:52 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:38:52 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 21/23] mdrestore: Extract target device size verification into a function Date: Mon, 24 Jul 2023 10:05:25 +0530 Message-Id: <20230724043527.238600-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: TY2PR02CA0051.apcprd02.prod.outlook.com (2603:1096:404:e2::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ac094ee-db82-4230-0e76-08db8bffe1f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZhhPYm7MjezgMnIH0RFh/BcWgTRCBhqinmyrX1htXbDx91qyP0xdTnAfdfNOHt6lrZHIN7EyPE3tJwEJIE8xHoLzYFMvwydOFJoH+u/qSDoZ86b/wqXZHPv8ODb122kSvTo61V6GZEy+ykg1IV/TQJdSX4brwjZKDF9o9T5LJj3MfHC9odriljaVCXZAvNxgqM91cQnhiGf9Lnl3l4ajMUAdXx/u6ZVJM9UBu+8gbjxFu1fGZwGrSDsMSnT/HkQEo8LdI6puZ4lz5W/tIyOmVDxzAWNIhNiaew6+pH2g8VhyIFuXoj8fUFYVxxPlg/0D9TdgbrwZkm9Gl8DE6gb1FONHC0IiyuxGf0QHTWgk+s8EPV6Zdhl5gjO/ab7t2zQHBrp8Ni3BCdxFM5jlrlSX/GFMR4KZ+hIN3ja/TIPAuhpRfr0rKb+YoGVLrbctrCc5Kc1GpGUErs3j2RwF/tAdjd/KStCaOkBPe6Qo2NauzlYIMdb85dTZ5zpXqXy56bgDw3N+cmtG1Rsd92YCMpRC6WJvfbJKGxetffMDHOU/MWy+83xYbMLO+ayR5rk9qOtF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660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h3tYvydFbAsUp0AhlwLTaGAzdr+Rekwr7oadI66/haZx1k1HylLhIpp/eCtq6RYuVW7umIgzH1dzrJQYEQecVI5r24yOGfD/cE+943uuQLuEFaw1KzjlsIj+yf3ZEI4G2LP07rhHyjx1EP0bqQFUC9W/MMAi8aXhjL5K5Xbqx9Utnq40ajrdmN2QX/hhoi+bShHNW2gHNEbCft/3zkKOksKk/duBVAoBBJiqzqWG7kZByZnT28rUrDYoRYBApzI5fWAvA6WO8I3YZ/S2b5YoMekBXh2VT8P3Nn6vMPdMSv0Pu/pmjQSBNKx+hDOySamoQ0WBPMhQu7Ioq+5mQQcM6/Os2JdCsmtEbIbmuf7Ir3sLFvkqLY/QJQEKB/SbhUjSjxaHvGv8gjRflK6Ci4NUflHEt9jgQzppSRPJZyNuyiua3LJTDIkV+Dn9NQx1V65XeM0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ac094ee-db82-4230-0e76-08db8bffe1f5 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:38:52.9142 (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: T7fiqDamGmKHV7zuh/dJ/uvsTLRU6i75wyhSLd7JrD1dxLOgD++CEmuQ+c7mM0O4s7J7hasowduUyPlKsNZgog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-GUID: 8CZi64IXusEudZPNzDgajGPAWZ5p-VdX X-Proofpoint-ORIG-GUID: 8CZi64IXusEudZPNzDgajGPAWZ5p-VdX 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 Mon Jul 24 04:35:26 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: 13323439 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 D2C8DEB64DD for ; Mon, 24 Jul 2023 04:39:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbjGXEjW (ORCPT ); Mon, 24 Jul 2023 00:39:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjGXEjU (ORCPT ); Mon, 24 Jul 2023 00:39:20 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FABE122 for ; Sun, 23 Jul 2023 21:39:19 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36O2jvwK026582; Mon, 24 Jul 2023 04:39:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=xEWaFAbyHH2V/17Sp6MiDF164eKFDN9GqVYTyJdTgyA=; b=bYUu3q5CB7z/975IytZDWsm9q45lLkTY4Eic273XAxDBpz6nxoux8WX1Cy8MgRKNaryR NqqyuVSBPqRZeR0avn9lN5mqhq+82eFtz/ct5z1ghvuQA/MReIhnhPvIulF4sKSfc9er Dy63SCtVWLNUpFqmwjNwESlBIVmuJdc91pu+9sbD0RBDF0nhLfTPgXU3EnKAHfxLvFY1 ISOtex2IPbj2QhF266lwikIqKnpIRAhQo930R1JDIAgkgsDUzO29HScn+i/b8oOuL2PW z/IVAT0ptcFLTzRRg/Y6wn73Gj39SE/PmwNmx6mJY45y+1tXVUvblH1IUr6AuNIuR7Ld /Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s05hdsva9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:39:16 +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 36O10Yqv035396; Mon, 24 Jul 2023 04:39:02 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2042.outbound.protection.outlook.com [104.47.66.42]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j2x8y2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:39:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JERpOUSctDnsNDPMMnx6RB0IA4ZKa0P8V40eA46R5jUHCq2WyuAWKKJsUe1TF7dYLfzTZwfB+qD4jXIyrTfZl8IaSyBI3t+4jH9i6550isOMuO5JyEfOr+3TB4jloKKsu3sKStSGUtZnDJm7Wg6R4akSN9cHCgehiV1MB9U53j961M6lWi69zMo9zcsSQxZYtXm5sZfjXViM12s2z8dBjF0oqvRPmhohUj6iYES9+DZszIGpBvx0T5gw45x50MxCceVPh+u0LdUTllvkRWa7+4zAPlwVI8WSOvepYcemQQBMiAoaQrC6GPQHIUuKToYbmBT8eVKd51SJnylhvOSYiw== 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=xEWaFAbyHH2V/17Sp6MiDF164eKFDN9GqVYTyJdTgyA=; b=nW/6IezXUZuV7rToRE+oT34/GeBMSq44JoN19OB9sJObUTcNaqp/KUFNnch6UkbwR9GytR9OID6e7H2iHOe0bv2xDrLLX/vAljWJcP8VmsNGdU5mARbjHWEUOEFsoc8Z00ksHq/yMIBE/Ay/QVmxf5uZnCrKU+8TITETyTHdxv2EBr0w5fETTolUZsba50d0lRPqWXlCUo2/2oZA6+Suo/HIOJddXdyEWpBlf2io5S9q3kqKplVOO29QoSxrz/iIO0gs0PljNI925n745ISlj0dx4rc0QUb+GKY480KRmWQHzmJ60+hNP9Ft120Gxk+EP6dnQXjeqYZYEez9fBdWkA== 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=xEWaFAbyHH2V/17Sp6MiDF164eKFDN9GqVYTyJdTgyA=; b=v8pquqOr8fEN+ownejx4mN8az32tpQZg0AnfgyWh/UfUlxfrqOb2U9wSfQJuMwxYl9SnIgXx0jlT0H4lu37tqlASo/y+JCRp26ugR7cSpYfqw19mS0tW/M9tbaaaA8bDbVagZdYxyYKqtTQbRR0haQ5wir4R/t+Fsjf8+ksWdB4= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:39:00 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:39:00 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 22/23] mdrestore: Define mdrestore ops for v2 format Date: Mon, 24 Jul 2023 10:05:26 +0530 Message-Id: <20230724043527.238600-23-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: cbbe88ac-a0e3-481f-3e81-08db8bffe66d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DCChk27fMkGBFoIh2s+QLolAQzAuQ6F7T/DhqRAxzTlIaj41dN3F9iXxYJbPhbrHMOv99xWI3IoblWjLtfctaBrH6UTgTU06/UgD5FDSTU2cK1pQal5XxerddGc2dFtRrHNt/DqgF+N2b3ScxRaM4PQ9j4rtQlbz+T78SSFiZQLhf225bYhI8A4Xd16UY6pcLBTAnLAlNsHhFJ/PLlxC1AD6L9A+qzjnIeMniM0xnfoi8tdlLb/98MGUe1BxBx9Tq+I6aXvQ0vUCdnmqOG6Kgnuxeqh4kzZJkAArtzAGRtaYeldjqN2wo4Cclw2LpboL/aHjYiDEhxb5Oreq3TWkQIwiPVpl+pXPT97tQgOiLjIvjL/8Yxr7WkbITlSLROkSaJs2GrXYPzvqtyNfFt2TS5pCIxFj4NB9jBdHx8pa+FiuwhSJ5cYPhCYECzk638i2bF532AylZgiUASW1v8ZtwP9grWAW3cWd7lLXC6DD4IVPt2vIXl2yCx4o/4WDA6d4QbYd1PAR973PEW6mMjQ7UREDOSVpNYmPlrLd25bAqQjenkv2hIhFy/I3Jep5p9+y X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: km6SKh0vV47Me+etSfj5M/P6EQRFXFcZmHIHZ/cKBc8uH1UEWxkz8wrWQM1BMKkrBYcwe5ua9aH/2rFRca4ol+aOkh1Pmi9Bpj4/fO+eqFvzFjo0fc/ZvJ7ZnW8/PezwdppM/QXggMM7+SeZmXA878X5YvgkyJU5iXbLH1vZkJHisnvTomMtY60vr/OioawDf/WenDivMRGXtx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Lu+UflqLify7mWZvM7sxh/wAifB3x/jB+yv/cD7QpHtjvjvi51unOKwOKyFQBBsvKsLClZ04F4dnva7ADwqsgndLUV6nMxv1GZ0vKartSaWIqNASUka1u/rWx/NTtffdmbM9Kmy0+ZfLe5/Poay9/5c4FaA3YTg32JE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbbe88ac-a0e3-481f-3e81-08db8bffe66d X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:39:00.4993 (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: gjartHdS2JuxH3NrMf4Xf95BOwycLfyPviBzZogQrrphsCaRfXeKK5R+7+xp5Ed0ZzeEYA6idjeTZnDTDGxKbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: OOeDVXJskFbUmPQ5VdWpm664VWex20UH X-Proofpoint-GUID: OOeDVXJskFbUmPQ5VdWpm664VWex20UH Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to restore metadump stored in v2 format. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 234 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 12 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 0fdbfce7..85a61c8b 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,193 @@ 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"); + + want_external_log = !!(be32_to_cpu(h->v2.xmh_incompat_flags) & + XFS_MD2_INCOMPAT_EXTERNALLOG); + + if (want_external_log && !mdrestore.external_log) + fatal("External Log device is required\n"); +} + +static void +show_info_v2( + union mdrestore_headers *h, + const char *md_file) +{ + uint32_t incompat_flags; + + incompat_flags = be32_to_cpu(h->v2.xmh_incompat_flags); + + printf("%s: %sobfuscated, %s log, external log contents are %sdumped, %s metadata blocks,\n", + md_file, + incompat_flags & XFS_MD2_INCOMPAT_OBFUSCATED ? "":"not ", + incompat_flags & XFS_MD2_INCOMPAT_DIRTYLOG ? "dirty":"clean", + incompat_flags & XFS_MD2_INCOMPAT_EXTERNALLOG ? "":"not ", + incompat_flags & XFS_MD2_INCOMPAT_FULLBLOCKS ? "full":"zeroed"); +} + +#define MDR_IO_BUF_SIZE (8 * 1024 * 1024) + +static void +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 +462,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 +524,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 +545,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 Mon Jul 24 04:35:27 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: 13323440 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 AD4BAEB64DD for ; Mon, 24 Jul 2023 04:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjGXEj0 (ORCPT ); Mon, 24 Jul 2023 00:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjGXEjZ (ORCPT ); Mon, 24 Jul 2023 00:39:25 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DB3122 for ; Sun, 23 Jul 2023 21:39:24 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36NMan1J018630; Mon, 24 Jul 2023 04:39:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=SIU9hbnyPKO4rmv2bFc88tWCvlQ563t9f31OOptKbTQ=; b=GWgkis5XrjfsXezZFabaSfzqTYA4qqKuT10Wpqwib+nv07uQ0MBo2o6QpcNuhurZc7HH +pyXi2LZYmIU7ofuMRNaFYYDTuAqydWSlXALFocCus4EOJUf3FvF/utShT+jyi3hP441 tHFiY8exnLdsnjc7jfnDtU5qEszp7Hf+hCa8m8iRIMYkHcMTNXPtOrlSz2pnx2+UtifL 9tBSNtBRX77Wvg4M7sIgQIWxma15iTQoCK6QNWGHy3rzL0m/byGpTAqpbssePZ06eQ+8 41wGkgG/W6XvZAcIm1byp0c8Ie36lOSlGO2tucZSngt3oStLJgI74amQe8/ZJgUDx6id Sw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3s07nuhsp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:39:22 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 36O0r7T6000494; Mon, 24 Jul 2023 04:39:11 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s05j3eaym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jul 2023 04:39:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JJXessMCLMVA+s19MWFuHOgR5spSRW65OXRNyWFv4Cuc2K8R7Cei/4cT1x9oU+Jkka3WeQVWeJqH5/jIZsTiu+MDtSWW9HmSIE0bwT1oOwrOx/hr1T1ZI0CWBpCYwvwZFxpJmQCiVo3FQEOc7Kt38m6Ek2qAia3hO1nFgoWxZoJS8U5yobF7lmOaCN2kxefxC9iFbG8zmezF0mXLelCZTcPn9Qg9ze1vePSXKDYuY8KlMNtMqeGDQ4tRpCv2ldWmanFabRAqsZ2lFNUNaIPQczaOvgOKp9XVjG7MNmSYUAfuBtfiChODTOLWr8uyg8mvkqjZ2UtvFUfXDHn8vwKXoQ== 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=SIU9hbnyPKO4rmv2bFc88tWCvlQ563t9f31OOptKbTQ=; b=ORt8DYrkjzU+oRASd1Pq07p0uY8BFbHWsObDpIOoNBGDz+xcjszuGXGR9F8sXi4NN9gVhHyzABMLDynVd+qWi6rBhsIwq1M05wcpKIdnSVY3ImlCagdLjfMmUVv1baT1n3lNHpfn6TDDtf/VIx8p7I4xItyxN3bOG7kfgei09hZXTVu6YBEYL/LApuGO7kD5RYpAEy4xTSkSoHFXrnz2nyXvutwLvIkxewj+hi7bte/eMUUgJY7fpwMjRgncsJD5mjDulTDb+XGK1XDY+bMLbY11An6dL8l5Q08DkZmUvoGDm8rNc1Yj535l5RjCNq2R0N7XlaJgO9OFl7h34xH4bQ== 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=SIU9hbnyPKO4rmv2bFc88tWCvlQ563t9f31OOptKbTQ=; b=KCpQtxc0gnEJeUJON026g4rqhbTYg3gxT8ssGTuTjVUUrhGuRdO5d4gyt4DmED1LgmLTAKaOW2hX6KMGjSA0219wpUcYjndIYotF4W6uBkzzTdI8mpTJYGrVsVPxB9uG9rGijOjWMGlrEUHhU6XI2l4nM4sOfS1vO44MLrzQqXs= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BLAPR10MB4963.namprd10.prod.outlook.com (2603:10b6:208:326::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 04:39:09 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.031; Mon, 24 Jul 2023 04:39:09 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 23/23] mdrestore: Add support for passing log device as an argument Date: Mon, 24 Jul 2023 10:05:27 +0530 Message-Id: <20230724043527.238600-24-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230724043527.238600-1-chandan.babu@oracle.com> References: <20230724043527.238600-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0035.apcprd02.prod.outlook.com (2603:1096:4:1f6::8) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BLAPR10MB4963:EE_ X-MS-Office365-Filtering-Correlation-Id: 97b2c88b-8969-4659-7d7b-08db8bffebe4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hYBRQtxJli+I+dxxYEXQAZ2j/vYDWATiaFTpstUdrWz6HokdBWKojevQLQuEJIz7hGMcwrApV2aj4YBPDT0Erx4gy0Ee63gT3daqAjizcaWq7p+6Npo2awYtgQJhAhTwK5k/tm8GpFPL5vtNTE0VxnLPAeXFjAxXpUo4foxdu66RmOKvke03+t7BWMnTSap+j1d5Q7CE3wfTFRUm/llj2WCzgF9a5JoqdBOFPbGWK9VMmvxbH1qFrjIUAWv4iJk0NocT32qvGf2/gTULGqe7XG7ylEzgzZ/sgv+H+wB1iadZs57edV5ymPjdQRXGD+DKPqqIGOXmTv66rTVpAIUErJ1rJst2YJnGB/cbyEIE2Uwt1FfaWPxuchZV87tmC1vvsf+6hg3c0cKXh7QUXDNyl4UTvt8WcDOhZIei+09F/9/u1LYf4OjU+Amu4Sqct1NAYZ1gL3iN46QBe336W56WX5fo7UJ/+1NNRJO807u74dAWQCKx7h869194JNBoSw/CabBDxSlq5fHTT1bJIendmcne/PzSi6HIALxdrOUrnys9IWanLrncA+UxY4K4nWtN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(346002)(376002)(39860400002)(136003)(366004)(451199021)(2906002)(66946007)(66556008)(66476007)(4326008)(6916009)(6486002)(6666004)(478600001)(86362001)(6512007)(83380400001)(36756003)(186003)(2616005)(26005)(1076003)(6506007)(38100700002)(41300700001)(8936002)(8676002)(5660300002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3E/ZGdqvZr8ybyhsiBSh+wecVc+ltUwy/hd5j9xoAs7Tt1kzVjldqd6wlT/PBf+PrBFjY/VNQIrU2lrHCZduJ8sYp0lqxwnq4DZzlGB525E1dA/N4zkfxesEK5ttTZqS8VRgUSdFCOOYdmP/FYqGAtqyhAAJ1RFWqYce9bzRnMcMxR+VyJCS41WRogItsSZ+HBi857qihBM7Zo5VxipyvLPgBL3lju7QMMqTkmKg0xQ1AUph2pjd/EHHh85Y10MtiUatxh1imSoYds4g21z6Az+We9q+kI7e1JDrMo8YQGaN7nKqc7WDvEppLilUWiBdV9nFlUgTp+C6F0NfG/aeEFJXP8qemuEvMs8vlVYa13BmjeMZANEBmSTRl1Oxl5fRaor/qjZQGNvDmmChZFPAeNT7JkxaDAwrI7b4vylZ1v2oOwSyYk+63Rxof0OmaZJjHtsackyJzP5cq6mCyyapvmhqxZM66A0kQq12L0JriBnX1lhlGGuG0qdGW9+b7E03JE6L2irDuyQ2D3R+EtYKLvuOOgiMo+zGbb4gCQJ3mNfmFeiMyhkHvgpKjWOykZdHwwyut8dECe20gIfjnXvaQJkW8Gxxpb1xxC6kQiTTqH9+PgVJYac2SE6uyKFDKpg3zNMxxAfpcvlLzv93n6aOTO7+uCHmOOYF8NEXU+SyefrLA8FNEYqEy8TMSgCjyHODJ9KGwRx6ChbuSx5TGv3OvY6hsU4e8+dRwAbkqI9kmccWwopZ9ZQsmRPZ8BmUu3I06qrjnVZFdebhUi3FmM0xpiI7rDM6ejGYkSielJYaiK3QEVIKs9p3aX7f4idKHT6a1At6uakBF8l8e3ojie3pVA9JTxsrrGGByjA3UPBP/yg3i0L0tTyV9lzmgndEJxvahrLZMspT2mwWPVt7f7Ckf5kAt29akFw1pzRPjxwpSN5qRgfQf12okKk9QCMRhvOE48bkYWJiw3GC994at5T/q6EHEAgZDU++blbyjmxJXPvA69skQteD5r/uvUj8S07U2B1CIbmg60axsE4hgfGaaPDE+oKONdU0fH16U49PkGH+PdRGSSWHnC66dRbJkX0OpRA2U0MDacmuFP7N6ZyVtl5MyZo/TeqfvrsshsNc7YffdeO8dO/M09am0Muyo+CT5KyQNEZkzofcUcM+xiXVjTBw6Bns9MUC7F8HZAe4R2+8UhfJRui9+XHkZX8UgzVNvvBp/xaizxCwY3m+I3QdfECwVZ8kaSmbt6yJ34kiKAU52bSVayxEB+LO81mp8452ij2ZU5RfVA0mgNdkuBW9nFZlfM7SojgJc/Pc7Oi6XrMj+CuCho3boopchAVOz4wHD8vLIH33TiDAe6RWxNqLfeOXttF++M8VvtVqYYbOCXtbz1eJQpf3G4k/BrvcSxg3TF8DnCtfk5SzuKJN667FniN0K2U3+Z1tT9ASOqVssj2BypUFgpx5yjmVXO56DHA+qMOLr9UxHRdthQMqy8+bbkyaQK4ql1awk1iUHoc9S1nlUH13EOsMlHZ5A0A8HiHkAK8Z5jcLkPAcz3P5iJ2SAftJnGcOmOdWYLbpwsMS8n5agbW8kFvHKZVBdtM9oY3eb7tIlFgzvXuqSBogzIBISg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: mfAv7tqwhhkrECYEJxz1Txqy/i4UbYE1NbnJh0KtQcWunC5yiflR16+mzF/xKOrAFOtb/BrebzZC35zi9ZKWUJ5lzGGHLZOV+Ac2Uaw/vHHtFDGG019OpuYuXaRA+EF7vupNyKHS4/l1mBWMsPbO7vx2YZReOL4xoHA7SPN8Tfdp3XkB6Adir1KOCs7HUrbNR5PCSN5u6Ydx3vGaC4AR03t0WB1W4JzUggNZGmK8bvMbz07Fugai9Y3eqI44m4is8Q+TBcenAKTxLsflc50a8CIJrjH+Glj5EPPnMmGK1uvO91fq6/bphnXff7K0MoYcyTtOvsEfFg0qeRPZkQ3BD2oTj/3c5jDZGNqs1UEJNAE2efewPCNAJwHr4x4s2mSlHQznoeq4m9fmQ7rf5TRzKfA9zFB9pBbfgxHrod4cGdTj54YorP3GaN2Mt/MW/jKvFWOy15yPLg33EWLU8YA8+JpZrdC/x6EyPNGHhTE/dsc2VkjuHEj0Lq14bvW7InkxUXrQ2hgp4k4JOH0mXCHBXwnGICSD1fN95+ey2Tzg/ND3oFLN6QUZ+T3gGPmncGVCix/6SJS1+HiL4OmeuVPATmmgVDVuKmNAr946v/Hh9qoURt1e5yoMfo0MP6R+Fb+JnpyeBBXivfLixh+/UlEd7hPCUWyNFYS2t18MM2n8dpqVRqnjWqiy2mv+N5c8YGeVd9me7IxvcClQf1CZHY3jMZf0PrfCfQASrqUfono3XPjhf3jGrdS/Zf6C8gJgG1LcNkhWiuyb0CkF1NbzIBcRdUjPCbtoRogFeXGmtfYGLfU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97b2c88b-8969-4659-7d7b-08db8bffebe4 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 04:39:09.6784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JWDkqtlmYeQbKvqxeBQBXkpuN3MwdJGZK/svRxxfCE8dpRbV6ATeOK4CyH4Qg2ZDt1x/8qPXVHtgkuFn/5lEvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4963 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-24_03,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307240042 X-Proofpoint-ORIG-GUID: hgpgd6nBcPmFwldVNQgHIY7PYnVwWacH X-Proofpoint-GUID: hgpgd6nBcPmFwldVNQgHIY7PYnVwWacH 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 85a61c8b..beb23489 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -453,7 +453,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); } @@ -478,7 +479,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; @@ -486,6 +487,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); @@ -522,6 +527,8 @@ main( switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: + if (logdev != NULL) + usage(); mdrestore.mdrops = &mdrestore_ops_v1; break;