From patchwork Mon Nov 6 13:10:34 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: 13446907 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 CAEB3C4332F for ; Mon, 6 Nov 2023 13:11:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbjKFNL3 (ORCPT ); Mon, 6 Nov 2023 08:11:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbjKFNL2 (ORCPT ); Mon, 6 Nov 2023 08:11:28 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4593A9 for ; Mon, 6 Nov 2023 05:11:24 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6Cx41m005748; Mon, 6 Nov 2023 13:11:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=l9Z+i7jfqNvyF5V81lTi1vV25xPaaE/z6jOlkFwlpGJvizv1bmERjqYiA00jmXwVm0EV pTeMu4GaR25If5dtq/uGI1EDmK0jZH8PCJzIf3V6OB8kZh99iR/JxQfWesW3sTIdN9Yo bnoTTZiYBJmLH85REgu4FROh/4QN8zkDWB3JLFe70zxbjO1TAlcbPGY5aYgDH+LBwbvn OGMsrJM+ff/jQVpMVQnBtxPlN3FJmBCy1FaI/0ox84OJWiV/InlhHrChWs9i3xXenqwW xEF66yAPN6QL9bTA71/HUxjaigss2N9HJlSEgQZlxyd09e5dWiLsVLSSJfV0lq6ARY3S Sg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5e0dtw85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:21 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D10Ut030483; Mon, 6 Nov 2023 13:11:20 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4t6kd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j1gsosgMJkHzULd83yp+k9LgsAVzXMi9Oki9+HePIopDCTlH0bDiSMgL/x/qxDKTqdqgYtOhxxGXsPjM7x6zaYR2DTat//ShT7lu4wOpFzW94JlylH7syqvs29EsAIWKhivhFpjDpnb93gR+HgJnt6GEv0/TFQsjZ7BKLhYHG/6IYgXNPjczVm7PCktUY6Kxgyi4GgftHMedeRbRFE/1Tql6neFxepgabqWP5cX85Y8YiGH0td9Hu/Zb03UFYS4S0YLQOl5yevxGxjX5rCUxMsnNWKHWthbgsydnw6veFPd40XGzy3VqsXZQ5Y/TlWXBTr2x9jP0Tn0pb2UquWuipw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=V3L20PSgbaTlh6P+BbXLVlsTFhGOedl+67NO2IQq/PjofAqukzHX6TpleQkhtc+2RbKBv//4vFV8Da2PqY9pWUlH7xSp8nOOQOJ4CZWkTjiKz3TUIq+ZgxwzR++qLSphocMKrALIkW2MAGTjvX174A4rP+O3AE6O307ryj5nur3CmXpa3526VtTrGhksiSv+rVrPUbS78+/8gy1/Nz0vSCVraxeL8dmSoq4uUlXqUcAi5QUeklyYKdrU0VfwHS9MnG2SURskO84Fa0HkM3VzKJrgwOsyPbq8m1fJF4oLRlRNkhd9JuzBjEF1dDUVkm4hA/1PkIHWHBgW5di2pso6yQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ud9rOBOyVZiNwlO+3c+yXzXarz0C350WA136+GBmmNk=; b=qv6TJCeZm0zbdmHdasimxjNgxMuuCaxCiqdYa4sEPOfI0uL/DksAOjwU7drFbC6zlMtUABWafXHPkvWFizA5hPbHMyJYOnzZ60qDyGbkgBxSuFSPTkre8o7Nb1miNKm1MgLlEvhqsqRJLDs2F0SZ87kLdzErZ91GKxWJ4EorNzc= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:17 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 01/21] metadump: Use boolean values true/false instead of 1/0 Date: Mon, 6 Nov 2023 18:40:34 +0530 Message-Id: <20231106131054.143419-2-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR04CA0169.apcprd04.prod.outlook.com (2603:1096:4::31) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: e0625a2d-1e07-4a9c-d907-08dbdec9dc82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 03qPL+o35y0InlSyoMblRf0Sabt9v+302bej7szBMWErdmzienJYETTqtJqtz9X3MXJpscxqSCbJ8We+sYZ1gou5Ao/YuJJk1DBa1yx7/7uM+gubUAOAQz7YIaZ7H4HXkpb6Nw4r4tdvaY9lrdbNTgUFt4DEK4JKgYL3vLL3fXa2ZwOWOyKUJBQ8w4P2rdeEipkULXfEUtMJLDir8cqT/SbuSbRv0gC5vAdprnRdapDPgajAKE6nfieDuMzZLvR9OavzcSyb2M43ZqdKygS5deTyXn+ZS79HQlEG3lPPRnJLXs5B7wxJvOCG8QSi8WT7q1jAggzCQe7ogUUCtmd+cTiV8qBsNwHVhODbflgyOOrAPyDNg9wFlT8KLv9wCPH+oTGRKttyBJWj0OHcrb8BeZuw0lcVSzeYMuUrtLIp5lZrRjz+Fo2Zx+334fIzpPKMG6G9/+EC6K5TiZd8D0sxc7LmI4JAwFgCM+z4devIbuik4rGJAWihAjhFNRKaAZGLkLuZgjxBFBdG+ANtbsYr+XtlrdAuveJ5FcP7k+6UPGPDgyIbk5Q0zqSW7qapFXd2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mgbJ85gCnDFny3WY78FBfQnQ8eWzEQw7wYDykyLAri0cmetnezPRzoC9z626xN9clWR6sGOqDCMSmSc5K4ZNZMagPUc7JdZ47qWhiGX+9rpYNYRKaQpU0KcOaV4i4LSJoF0kqeoCnmU7O+yllHRMH1JIJMGK8EMk7oIvkS9ZlMUPMV/1DtCMK7dVQ3ptflIqcq+2ZhyFyoOPJOfE3eFQhBG0rLX3NCUDj/DP/72O+NPVuznqigq8u7GAuDGIlKgRSvAqHJfl3ELrvYsJ2jVnmXJNnM5njbyQe+v7DUS3HmzoFmLrX4A5Q861zCs7B8xWO5sBPc6BFEGblSrDoMOK5YSim2n0TU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ZS3pQEeVKw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0625a2d-1e07-4a9c-d907-08dbdec9dc82 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:17.5229 (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: vcBkzdpF5oU5fhTAXnVgc47X+VuYdRxTH+oGxc7DWBH2eDCuVxtsRIp+wjweFSSFsRAG9gI6mnZu5teyXcecuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: BpNRIB2EfBt7jI6Avqv7ZTdVePR-Zlxz X-Proofpoint-ORIG-GUID: BpNRIB2EfBt7jI6Avqv7ZTdVePR-Zlxz Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 3545124f..dab14e59 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2101,12 +2101,12 @@ process_inode( case S_IFDIR: rval = process_inode_data(dip, TYP_DIR2); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFLNK: rval = process_inode_data(dip, TYP_SYMLINK); if (dip->di_format == XFS_DINODE_FMT_LOCAL) - need_new_crc = 1; + need_new_crc = true; break; case S_IFREG: rval = process_inode_data(dip, TYP_DATA); @@ -2116,7 +2116,7 @@ process_inode( case S_IFBLK: case S_IFSOCK: process_dev_inode(dip); - need_new_crc = 1; + need_new_crc = true; break; default: break; @@ -2130,7 +2130,7 @@ process_inode( attr_data.remote_val_count = 0; switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: - need_new_crc = 1; + need_new_crc = true; if (obfuscate || zero_stale_data) process_sf_attr(dip); break; @@ -2149,7 +2149,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ if (zero_stale_data) - need_new_crc = 1; + need_new_crc = true; if (crc_was_ok && need_new_crc) libxfs_dinode_calc_crc(mp, dip); From patchwork Mon Nov 6 13:10:35 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: 13446908 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 A3BA8C4167B for ; Mon, 6 Nov 2023 13:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbjKFNLd (ORCPT ); Mon, 6 Nov 2023 08:11:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbjKFNLc (ORCPT ); Mon, 6 Nov 2023 08:11:32 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE67C91 for ; Mon, 6 Nov 2023 05:11:29 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6Cx4Ig005779; Mon, 6 Nov 2023 13:11:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Qx1R60DXnIB3N5o6yMynJzdO/XXQYFPlNasasf4Q6TQ=; b=hLbfoQcMXYz+KyT6cw8UJkM0eNAfpv0B/G2bwXNAYVs7TN+n52riSceAW0s+TFfpzKkI 9H44Jx5PoEc+Tz7ht3DaMiq/TKjSg3UNXmvb79gKVvrga/7LPaIm4i8L3rsdQ+yLYHs9 6c4R436wAg9wuQGan0xxGKorcVB/xooauthrGuDxL2pBSLazJ3//rdJpB62DX9spv71f 0Ui9uXN+0kglR20ZhRqVWo0DBYKsPsljg9jQCTCKe5fgOlHnrF9xtAzB5oDb5Dt6RNUl FuEVdO8czMLufCA/AtbmgHuJyAwFAQrWazLen61TMc4Hqmup/vUNyp6y/xmUK7bu5lSq jw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5e0dtw8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:26 +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 3A6CtXfJ026847; Mon, 6 Nov 2023 13:11:25 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd52825-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M/j9NWB8oT44IcRV9ate5p6FmDFq5ETex25E/Q5SYINCWv2n83ENv975z9uIJwvX9b3GDFAuoBhCHU2OL5s2Os6nz2eckq/zT5xX4fyq+vBp9X1M2l5W7SpVu/5Wtxa5Zu1tOIrvpS7P0MrcM9FekDbKxP/0oRrawLDtMrg//pAGotF9IbfyBhQwGtc7rV3Zc9yV70793c86EWQ6U9Rkt7+U3hrtFNnXmYnVC4GAqCTBQWuwxEhzmacw4luTlUqegvDNxfeag+ofhO+1l/Ym1k6ZyyBYUEVN1duCIu2XFk7ql6Q0xHv9jO/VuIwMqhmg+W2lkeXJyfLjbQ69jqedFw== 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=ap7tyvn9cs8/O/JeXVxE7pZ42Iir+ENw6yABd9t+/eevp3cwzAK3Rz68XYf/o4vSOBRGCrUeTJgSzMNuZX1NWc5YJS1SNjcTzusZ/HpdEycFrJ5kfou0qesnRqr29zD4K+mxztwGXJvgfETpxltD+5pFhUMz4kYa6DCSy8TEjS8LkY06UISswPbQNPV8q8yM+KGW68MnOjbAjiQqc+hCz1POcZ3TrpG4+jz4ZuS1BSK36N79cePCKEB9uwAmgUIMevYmxn+SSrowTOsjzmf6ayA4nDsU4Pj3qdWMAnjgyGBtApV556jqvkgaOIIWrBA2ngbfSfGkyIQYC19r05RDVw== 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=Gj7mTXe+9tR8o9JzjDVlC0oh+Z3hQZ4BZqLBS7gNT8SXBSrBnbjDxE7DxqlUZ3M1O55MfCQACbgnnhY5W7+juG/EvrOVA0JmUGK4/7iSvn1v38BzkzCySN3E2MtMHf30HfQmjCoN4D6umdoZrtO2EkNZKZxVrnEy76jrm7gw2IY= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:23 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:23 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 02/21] mdrestore: Fix logic used to check if target device is large enough Date: Mon, 6 Nov 2023 18:40:35 +0530 Message-Id: <20231106131054.143419-3-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR02CA0090.apcprd02.prod.outlook.com (2603:1096:4:90::30) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 203a6b7e-add4-4893-c395-08dbdec9e018 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eLUoS+0SiJkXBJ0/OW5+ZpUo5BQ6RUjreBeLw2hGOE4fFfprWIcLMTkosq9jimNu6kBH90LZH9v1qPxbIyaClegwoCVX6FkGazAOytw7StibSrFVPKnXGiuKyQx4v9ZILmTkOJ+MB40+ZH2WX8L1eztUXanl2oNwYB2qxxzGylC0ZCVzjY7pzz5//8kqDekl8qiRalKp5JhKArUt074NNCLmoh+oiIAh0CEb0wFmcFKZ2l/BPsFZDrAViKx96xTHePiVWuDIwk5Gq/AYZGYAyjA3Ka0vbYOrCwVmPMIiWRTmE/jGSACmz7Zxpx0fpy5XGFaIYQBfWkM23MG7rFlq7in8Hz8Cobu6mKmJ8o6VjQkmIfky+Q+ILr7cX3qSb7KssWxb0k+tnmbw5nEH7HAQ+Vq6NaeHvRxhgANF3pwHTuB99xhsGSytop/1nYOOU2vTTTeshcoYThv9I7U+k8VoSODG9PA8QKKmBAxoTqNRkBDpzCIHN7XsLVcpwBq7np/lcbfeEVXWiLmb9vkRDzOb1KK7IGIUo48snlt8vhotgQ7DoU94OqkIF3ujk30DnvxB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(4744005)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UpwOemVNV4qe7ejGyA10iRMX9Mt4XZBXvVFzooIfGadPHt0g9udiQWle6ayicVqU3XgC5cjEFqeVYvWp5cdjzackUYX1LaYagQwh+UIVwpKR1uWInII3Vx0J8lr4emKr15+vy9IasjJvpm5Nv46C/EaaPvgFrE8O1Tj2w4euzkDYthxGeG0AiDTm8qOONJSJsZxkCxrLDZR7WNo9H5NlY6/sEEEzII4+GEUkPuzGXlgEbROqG0q5h0g9UW35xDXhV59VaQdMTMdZjYw4hNXVVaPqJ5dVJlRfSTx83wy0Bl/aaRWy8fkBs+BNKpJd6YOZQXwy3KRlmh0ob5zdAd9RXg+VaGjXV0Nb3x+tG3Izqu0d4PwoATqW+5yF9p2lai8QXBPgAMt6pIOQElkKflaqzUe8LwyOlc6zX6nT4/hvVAjka6MGos+ayI2lpYer1TcbHfe4Y2SNgP16swKPkCkv6VQB+bEaTAGSo9b4vvRQGs5ivzvU74PsLci+BUFpkR9bkP2Kq48hl+YvIpk6wVJxnEEBGc2T0V9KHjuVba+eBwJcZzPeM+1uCQh2x0TRikCPsbOMBOmpjx2W8FlH9HO/bzjBjNLLe8tP3ZNNK0zuMZkgQWRxVyVxZ1u4n+ao1ut49BceoARgnL58vrdKxm03ZPo5KlKnXpDQp9IvHrdzmNV2B675DLdR6gEsLzA+Uf3PuuTVlfNC+Ln64/6FYdNz1LDWxf9NW6z2xM0qQ3X9tt+WpGbeh8Km+DTneq09KfSPW559BwKXwKi0YJIfeNqDHwqZ9pMu4xgPaaKGFoYa2KjZLqQ9wvJ2Rvdql7/1r7UGCj4ImB6O3ZUU8GmumD4aUxdZR3AAT0HVFSqD8l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ZTWXSv6t9qijIE60uX7O7whSFM12g0ylcaOw0je/ePcPeCRcvpA+b1ELHHgbI73sHQm3OFcxTXvvR0zRepD5l5RA8ZgeKkIOemzKoTItyCem1xNiZF4uyBDgtTmoUypw/kbMlZ+wkk7fh/AAdwKIba4ry5Le7217nd13/Bfly4O3hWQCDAFVqWahE0sQDLjk9kOjy2LOPzLS5CWdBhGwkvgOn5o3WujT+96Jn9cPCqBE1YRaAf+xNud8UxP8XD5a/99yTCP0CoMq6OGoqq0C6t1F2Cths2j7g6kH7iUXPp8oGi16FGzIkaSAIawmMjsSVlU/poSU3/ds95+4SGJaUlBmXBlbTYq/EYCavoXMIl/Hf7MemRwSmSbZInIPdjyMRCwxrbLGdTgK3DnHQdIogEL2Hw4ftXMHsuh9uTErzl1KYrnfWeINBq9W9KtzbXd+xx/IZrarsWlnSPOYQM6sguYYNKt/5nbWo1nPa64pO9Y35xW+epTvVNh06LyChQbkKe4IB5K49d22+Xg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 203a6b7e-add4-4893-c395-08dbdec9e018 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:23.3646 (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: HQuyRHHMvIJVqDcbSRDCu7nfzBKgjZIsdM9fV8Re37W5P4PUTQyRhm0EXsJCAHv7NXNcKvxgWgnSposbw99G2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=957 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: uNe8egKRULblGdIjYmW2vTUeKuD_HFen X-Proofpoint-ORIG-GUID: uNe8egKRULblGdIjYmW2vTUeKuD_HFen 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 Nov 6 13:10:36 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: 13446909 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 C54B6C4167D for ; Mon, 6 Nov 2023 13:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231921AbjKFNLm (ORCPT ); Mon, 6 Nov 2023 08:11:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232084AbjKFNLl (ORCPT ); Mon, 6 Nov 2023 08:11:41 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0F110B for ; Mon, 6 Nov 2023 05:11:35 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6Cx7XA030861; Mon, 6 Nov 2023 13:11: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=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=rCAE7aiZoefjvXfmb2BVxPwAFfqlbW1yfVTJNh58tnfnoZvGIhEaUQ5NCQBgCneHeUq8 5VTynZgVBL1V/TRndfavEOkjbAfUo6dyEDOWQkHG+E1vJdy4o/bgSgdS2cVWB9MZfs4Z OL8nNYPEAobW9VKigo57lPB3uZOlAkojBmwQjghqtrBudwRPHBAp76DVGkGBb45D0uS2 QcXNgEMteBT02GBuoZAgjSpHNt0fi71FFhnyPbJ+rIhc4WkjcVC+Yw+Drq5GhHvC5IWW 3Gs8dINrXfWIZV5wXDeCAqAQl9x8/iwwguBXig72GSokS9kmK413DLr/pJ8us8MOizvS hw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u679thnxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:32 +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 3A6D0mOb023561; Mon, 6 Nov 2023 13:11:31 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4t8w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cRVQIgjO3MY9coX0yGiiBf/erFAXuK6OuzUh4S7k77+qHO7JOe1N/9U8M3VbTm6IcgMYdjZIUnjKav+nSNYSycXkIXrH3Io3w/A63px2QcApU7zqSxbWuxWo+R6em7wca4jZFPWtXSH3NQJnNigfkMdtilGbc32rgMlI8T6ssL8Qlgr1x0DpWOfUzyvFbt80Wh3jbcTc3NEqfTh8CCfb2xoaaaZAnaZMldI21TTAMG0cAg2XNtgbnsGrJB7v5rTA84JQ+aCrIlp4G1h4nt7JwSFykL+cMQM+rhfoZ0xTeYYyZdHfTUFVDocQ5EHkxEDUK5kCdEdwHNpEhBt5GzVVRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=CeT8um1cKCKwDdnz9RFSv5uP/wDUPLjwV60oNNEKn9BwIoWlL1BOlWWGuzjRn5waHBsDJghJdJ/eY+6cmii0w2sEp3kSM1qgOjkGdCzzeaNjPttGkVxf1gdNoBOGeQzKCUGJzR6bqiGvrOzo6/5a9Xfb9oaiYQH5wh2HFYr4ymeRX7HClOVLaoDy+ZvxiAzmsaWu3PQaDZpsQrjnGBL2uQIE7bEJU6SdfsAzpCY8vr+8i2HqG1Q5DQQOCpm9qW/QXgrBMcjjE8JiU8buexMY+2Sn/4YzcTTxXK4Al/+HoR5zuY+ZOlsZFA+h2ziCkvVN3V4qeSs7cEsbmBwKELYiaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Bsj2yfOcsF4w2J4ksTZVgWd6iYAy3HLZhEy+Rfe/788=; b=HtaFBn5lIgkd/URe359XHRwi6XOqPn0oz26XsqKWMUbUnzzKBc/Rfzruns2VHqP9ukkROgWlecoVreKvOzhk5OaOF2+k6A2ovQOmeXZQOrZqOBV/WCqVyFF3lz6K+/T9yNr3DcV7d+ArkXROi5S7UHSPFxXQ6BBf1f3txuSg66A= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:29 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:29 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 03/21] metadump: Declare boolean variables with bool type Date: Mon, 6 Nov 2023 18:40:36 +0530 Message-Id: <20231106131054.143419-4-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR02CA0041.apcprd02.prod.outlook.com (2603:1096:3:18::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 430954ee-5b00-43d2-b0ea-08dbdec9e370 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ebfOfsjfe5LyhLVAaE/I3zO6rbcwVUIbFgIFY8s8M1UceqJN0ugMJL3ZHc0CTy3W2+x2kxwH7rphWEKH9xcq5AVrKXWyjOh1e6Izcbmpj2VsrvZPHn+Th0Tu3YWkaaz1qvnREYBcB21E9w74Hii7Q9WpAVJZnzpYRDTBhbj3o7wjQq4qPdUbWG5/P/MDZP/rB/gJYb5cHSziNq6WI5GvkYebroJrZ7spDOd9m6JumN3984eYWLwdmbVGeVZjJ5ci3jk5Afc/MQohrugyuBzuawQcZeVqbpKezx/HlNVed6iWfO27WkXci39MlmeX4lN68YtQRpzebsmlkjVKZ/oIg2WVnqP5ZpAOUw7mIWSeThAcnzykYlfhxyk6ns01KmKyzTiKiA7MnHQjlr4y7DlT/6R7eJEYtbm5k5VJj9M6FXgztI8/UerqadlAJcZ+huh4TNGzG/EIdOhUkkviSRex7Q5V4MxiQTx3ZZMfdYp98TBmu6v7IcV13pcKOg0w9OURsRluwmnm3BV9/BBJOfYH58y78HaOqgzNkls3xiaPJYLY5njHxdxIdygzSjLxe1Zm6YoruXX9qNScSRRu8eeIKMuekaefYibXq7uXV2eS2hmbabQIgP2rAqyUQGq7CbyL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PDSp/bpC/BdKdK7dWTZ/xII3Vi+zGMbjit3hA0SzcFbIByaIhhY/ArpIknpdA5eBV5xsMZpZwKGzatueuqH/9urOm0UBakpVVPmOY4Oe9XZN6SgZq7waRD+IxybcsBwvVTs7LosBscqLPCMGg/V0SHdhZcHM9n0rAdl7/4JYcQhbrSU9poTd1mrwAdRI+ZqAgVR1bCN15Zl4YHcdcxp5+NhjD1fBoSpfSqmZC/aNe/Ke4x5luzJX5D4sDiLKB9sbha0rPqxovSrlFvMQNdem0DB1CfvC3QtPGBSttkCl19M1P0/1yWPWJpvBruS6zTAvtPgWtCC0/nvj1VZbsOCJx6eUqmdlclcXv7NT1N/Qa7r75GZ6OQYFcY0nJvawn0VA1lMmP6/jYU1mCeUWTCFBj8KsG5EBCTnPU34mlaG4qnE47usQ7XIQW7OzNFV0VlJ8ZoqIlRRqcC2oFCcvvggddT6t5UISYVyqI6hRfiCx/ZYz7FbNdrqjypJSnI0RhX7t182zl4JrUNXxB/iDoG79mlIJf/XIrtAn4rmgBhrsxIdSBPKK26GYajZ/PRNlZh30K2vO95v6fHTJqvGm21SG4rq+/9AAhm2fXtC9mqUl/t7fX2M9sU9rxBs/zvmL3bHvO6QWZQffzYK7REYfEkczn7tmy0FkSnAiP4y/meOobDp0HgBbo9DYk1sWMk0KG5BQhpxFH+U+Q/xk73upa2FInQoge1+5A2K0ThtyjSYC/hehPlxRD3jP6yUBZkVnPN1Al84YJooidNX5GzOpkxP5a37zLPXYxn2qoEBtK5HdV2cYxjZukUAifieXqYq4jd1Fae5VI88PkTmT1w3bwMNotDbWSwMIzOcxRsAJprbjoBoyspY0S9meWDZB0Ls2TwXSN9f2tr+wc1jUUe6GV7o065ZktonuFJR+pULfZt9VSIgYF58b/RAFOpk3ka2BKsY+4h6cSxmoCAMtYNKrUyehwDpfvySKTpykhs+9gHkBTAx8MoHLhKByNxjux09xZgaQxaRgtLC0Iw+845GzooT/MHWk9jPpzrU1rToYtfsevWAduWzyyH/SHLcURwTLaNlxdG3MN6ghRltZZLPZvOFNj1ZNR0zNDotia+lXvjAyNJprlqCNPpS/hJ77mxMV5e2cLDahdCooWHBQ3P/YF5NobZ2Vdc0TgZ3bnkcP20ZjWFtWcTtrkrBuHnnH3GgE3/JedY40PZmGz8G+pODRrmpStPz9uNMIsQsa+zzMRlM97FYwn2543gIRkhmJnSoMwNX9073ufSnIaNaMfvdAC3wEjN+cSxRuvavhBdjdJuXBms20W07417MsZv9tDbCr8JWAuJGNQttD3cPg8USuVmDESUkPCZSQvhDiGxxYy1r5Z6qnxB6RbgecdRutFX1SxGrDtxr1un/4O+0iWCN3tcvOorr7UoYjoGATtvCTuV+v5NGudDSpL1LcOrZzwudqiLSU+tQ7JPlu55rcZOneLV21Iq8XFj58hPI86nx7zrxBx8x8SRu9PGNcrvtqBqkTDkhiKDc58V46SqAXXnM6tZvD+A1J0zgQ6B8SQf+aXXGA4znYVxHM41gkg+4FSDXv2+L7113HuH+3iuor9tLCmgkwLQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: C1Am2fR8xFjmnGwgcHiy96uQnqj3uZs5RbJyhkX1E/shCvmdSUihXqk2R1WmrJBTgCdYE2NzZtAxhupe86fZ1vNHcPFR7bs33Eh7CNnCTJhM5qAbjBKKkxrQcMbpzRtaUn/FRWDvNExUc8N4VFRTJKT/C3dyuMjrGk/DmGwdUu/8xgXohIesoXbnpKnWvQ8aee5DJDYxW4wGyB4hnEZtd9rc79l8DtAkr8Qlymb9hjiryaKM0KxiXRW8qYLcOLcbdcEepKNeXd+b+CPp2+cs6D1KwUs1bnUth1OntaPev6Il7GfPjE9Jd+PpLMz0SzKMtpcFWsmaWvkbZw1Z8coGyb9jc/FJ0ytQA8aeYc5QKEAOWtpDq5PsPktCOMotH/TdnOjpgJbnDYboyJ7CAmtM41hjmM0rZuRksecnzRnnX3fSO13w2Cz4DzGHLHdzjjTvc4QIAtlR25AZhOWTk6ysak/msMbpad5hm7HvNI+0UE2MyyJ+ooHfPoyCSbLLjGHK6FOCa2SFqmNnWL4X62vkt7ezFPATSKUxXeakB3KTSfkDUOXA8SJSKvXzX3rL26lbpwY3xTaklxWDo9Warz8QY88znzi+zu9TVQsiatYAj1UPxVYBjD83CBXvUgVMG8ommAt91TybVY3sgaHyYOPzeLQSEorlkr5DPOQgKDSCA1DrtN2GlBCncY0aEyij9YtBd5qqIaFdd7ewINZa8n+OGfHKAMW7jaKTTam/aFicf88KgJINf22LbTleJb3YDloevbAqnWVmni4Kz0C34xRECJxDA0gEHx9owQpYU5P1z3k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 430954ee-5b00-43d2-b0ea-08dbdec9e370 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:28.9686 (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: SfBm0CoKVpdeCDLNULDrhNmrgV0gXegNm7jf3DgkeRgY7af9DlbBEs61fTeXZhnWo2Pl615tGYskfa/9iA2grw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: C7WwFRuKQgJuJOsmzLxJpq7fAHBpU0X2 X-Proofpoint-GUID: C7WwFRuKQgJuJOsmzLxJpq7fAHBpU0X2 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index dab14e59..14eda688 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -52,13 +52,13 @@ static int cur_index; static xfs_ino_t cur_ino; -static int show_progress = 0; -static int stop_on_read_error = 0; +static bool show_progress = false; +static bool stop_on_read_error = false; static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static int obfuscate = 1; -static int zero_stale_data = 1; -static int show_warnings = 0; -static int progress_since_warning = 0; +static bool obfuscate = true; +static bool zero_stale_data = true; +static bool show_warnings = false; +static bool progress_since_warning = false; static bool stdout_metadump; void @@ -101,7 +101,7 @@ print_warning(const char *fmt, ...) fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", progname, buf); - progress_since_warning = 0; + progress_since_warning = false; } static void @@ -122,7 +122,7 @@ print_progress(const char *fmt, ...) f = stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = 1; + progress_since_warning = true; } /* @@ -2659,9 +2659,9 @@ metadump_f( char *p; exitcode = 1; - show_progress = 0; - show_warnings = 0; - stop_on_read_error = 0; + show_progress = false; + show_warnings = false; + stop_on_read_error = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -2682,13 +2682,13 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = 0; + zero_stale_data = false; break; case 'e': - stop_on_read_error = 1; + stop_on_read_error = true; break; case 'g': - show_progress = 1; + show_progress = true; break; case 'm': max_extent_size = (int)strtol(optarg, &p, 0); @@ -2699,10 +2699,10 @@ metadump_f( } break; case 'o': - obfuscate = 0; + obfuscate = false; break; case 'w': - show_warnings = 1; + show_warnings = true; break; default: print_warning("bad option for metadump command"); From patchwork Mon Nov 6 13:10:37 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: 13446912 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 4C63CC4167B for ; Mon, 6 Nov 2023 13:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232107AbjKFNL7 (ORCPT ); Mon, 6 Nov 2023 08:11:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232088AbjKFNL6 (ORCPT ); Mon, 6 Nov 2023 08:11:58 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA1CFBD for ; Mon, 6 Nov 2023 05:11:52 -0800 (PST) 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 3A6D27vf011570; Mon, 6 Nov 2023 13:11: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=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=lbMvokUNN9E/m2puOiEciuKZJ5miZAVB/XBtXW/p32MAVNmZ7n1Ba1ll012Q80sLrJDb S8Di7MNkhrAiYhAKKXQaVzKPr9ZDkmHtMVmVAH4N/EPGksVw02FsBaWSfZ5O75ANlRFc DsCDsDaxQt5X1c5kJvPFimqYUsNm5ouRF+Eb8335hnTRGtNQTfR1b+C/pblvubYshkbn fiMAE+mwUG3gLH1R14gMXxr3NQ1RFGk5l/EastZt7Hz5Y/jKG51HN+kaiO2MlWsi9K2p M00MzsQTsipS1N2wOb/ZqEPpJ5gCC9UN9Epq6/I8pUDv/Uv51mNYOHI/IYT8+TwprQJx Rw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cj2u002-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:40 +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 3A6C0kF9020713; Mon, 6 Nov 2023 13:11:39 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdbaacm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HR/kSDyZ+e8B07Qyd+FuULIxQtdvse6u5UXnZmDLF6E8B5JK8AURJopoDkJpFG63+YD6L1ZJGGbmp/kSo9p72a2sVH9VbJfIKs59+UZJ9TYWtTmb/W4eTKHvd+hcgejpepeWSKDgCl7TWTA9W/UWVZXQXoD/laqzKdsJsVVnlo6aLliUZ0ZqE5FXraf6N8rSsjPD6r0vrB0MmV3FkmBfC+AkKLEqm1+nxwttN4YeE97IjUWuaDDxRabjKXVzTyN1NLULr8dYuHf1/CjL3+IRzZkotCsebqdz4Nlo7M51OqVeMeSVGDakv5YI5wVJTnmmixspTToJyXA1miHDO8eETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=X8kGkExtT3ltIJnkIAoqWI/V6HpA+2b92NacwLFaXVUjT07DN0o9TqTCgSeN5n3drNxvXEY1cRrdoKcKBS6yqo/Nywfiqolvm+MIRaXyYA0xGGanfCMG5KvSiAEqQ6PRqUd68yBPZCBSUm0nu0VYohGdFPzwjEfNJkRJA6QPKlxNXjpABalOnLNY4TOkcEdhBM7qyIAHdjhcLWIFx/j1XV7BSBaBk0RLwH12DJ/lUOP0oA9Gtx1UeS0FhehA8xSWS+PpYDf6v8rnTwcHc3lSny6lbQOMm5wLc/Q2tjxpFje36RcCzmUImWl/zB20hEkPFOPcEShtDlOr20fuua7tew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zoketw+P21XNyGSvoAzTndi5fG7d0zFoLTlfC4p8w3o=; b=vwMToabJsdamJWH0y51lkFcpR8PA0ALt111o1CF2BlBGajuhe8N66ohdykPHtK06PMEDeliuStklYw5KUyugEuPUUVX5jtVvHDqOpfOh5H/JDsrVKfDMK8vJSNnIDspit2BS+uEmbBkofikRI/x3bPPL5z9oYAwggNr8Moqzyqg= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:34 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:33 +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 V4 04/21] metadump: Define and use struct metadump Date: Mon, 6 Nov 2023 18:40:37 +0530 Message-Id: <20231106131054.143419-5-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: TYCPR01CA0139.jpnprd01.prod.outlook.com (2603:1096:400:2b7::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: fc0f6ce5-8869-43e8-0777-08dbdec9e630 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hUcua7QUqO2suqC9JGRfAXx2yg2G+CMBZobBcscHjL1L0YexN7K8kijkc+VJDwesqdglvxLxkr31wQLJyN295POfRFH6+4W1YYvRxKi4MbbUyFT1gishX1t0E2zrsv7ewkjUlwuAxUjqNLb1Qz6xOSG0hT5HPuupcg1MISrk/UHCWyq7o4udYJXN77XkTLj9R0Dmy96I//+QU483d2tAYgaiFDL5PMrLMxscDxPgC4MDGAbyZBJqPTs+9czpxLEZHBWe5gBVwXummQAyGM8ask9Y8l8cJspGsKAKfjg+4FVZAGvLxPpOuFCxQ1nGltk9dRow+LM+umIOa37C6RIQqxQNLw36tWW2igKEdKLTG6DaaYhb6ucRtBrvVMsTtEdpo/ZCsfFGMWlkAXxN2IdS/YXgUGbIsXZkgqaUiDzOdQ+t763I48WheNyW0L+uRHDw/f6WYb9ofumzywyMfJbZ6bc4Ro1+TUfs/H2q15Ym6NHSX8hzEbE2i2hwS37GAUNA6t2mvju1e1PqTqIYEu3GUGwIIhXl3iCPhS5O0B2LiDey/7J7A0UIhzXlv0GTZ6+xP5YStNXH6Mv5w6ox2015w7GpsHWLwwAF2aah2C4G23cRnBaUv553zwvEP6yNM7HQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(30864003)(66556008)(66476007)(6916009)(54906003)(66946007)(316002)(6506007)(38100700002)(83380400001)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QUb1cmkAC5VgkouSbZGKfqsL9f/Fdp04em9hNQCsjla//jK4/PQ2O5utNG374faJ0ihY8n1Toj/WJHGM0jfuDc+LzB90nbrdIE4nVHW409yV2QBsXqP1AqiJ7nxFtXTbFvYSgLLnv5COFs1ogUE3eX04fSNeuOkIoMqWFPo0AHyvyMI4QIpEHMZO4OtfB1UMOkc0qVbxXmeqw9V+dDUJwUSraMga7dqiGENOcEwbG3l1S5Z7oZaXhRwF0Yv9+aziGFriJVEAgVTDjHKiq1Maj/OGOSO73f8eECLPSWPmKIaSB9l7ewXmoEgoBkhgCSYVpY82TMSe3xV+Ic2Biutql5DwsJ0HaML2n+ZF56ASxY72N9vTscoKOFf4/zR9LuUXeO5cqXBa6G9BjHn1ENaiJp4tmYjukGgbK+b44+eA2NcqT1QOstZCK9AgjftkAWTC5hjoB4OdpdB4hLyTRDgfKMF/3KNJEbNtKvpqKYA4O8HllpCiwCuO2aWhqwKbMd+EexNjxoaIzd1rQUS4AeT5ppb9s29B1wUzm/Dqz5qneKn+nk0B9Z472TQip1/P1UgsK6/gojmdVMYFWNknICiPVGnXibFh7AMykg9+k460tVcMmQ0Y1d3XmP9i/KHbCjtNiAlCDIkGRUvuXRHTPpIwaw2AYUpzNA/Wxmcw4CGldHM4E8LwyEihmvyvugCI9YAf8Ij/oJwOeF3AA9iL7ygadM7AVF4OMdfb3nwKLQoWqwPRvWcYWw7DHVXLPgfpGEyTGyCw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VoF3vG1kgIcVaeCDF+WkP17jF9eLf0TvnYY2BlYfxy8uIE3lJPEa7ZDly8wreEmuBoQVOAAnOR+2L2o7jj4DoZjLSWLIf7X8cScNY0QL0MMje849HeYHpP6KCJw4rBWA6BECxsysY377MZaxB0EJyc89iplst37KgmNR7fof7bjExgqV6aXb4KRaM5q5VFmw7xd/o3m+ayaJoChSc0wbEIXFGlkaL9bdvX5lxjq8b22WvmoF0VBlUn+ZKzahSxnvvuTS8w5bGzbVcdCjqrnzPmCuMP5g4o/G2I+TTPk3I5n5XJsBGlo5fZMJ8jnNRMfDLg7ucbgzRAxp90Iruf1fRjwYqEdpqoCbZNm0IMY7n7BylVjL6Hl6s3efm9Uz/y0js7GodnBZi728l7cR7/Z3dbG89brg7nU1kdieKOba6QX8LIHlQMHoAkYII3qbKZbYPfqYFpPwGIRHatl8rvJcmkJQ5qYdDd2j0jIDdnn/BwHUP4QLMyPlzicimFjUxREWnGZX5N0c5auivviQrXkUfYbaXVtFLNBu77aMk8ZhgA7DbIYVlOZ7I+Fxy+6C+m/WsSNTauy4ONKGIPhIjzcnxdSWhIK+WgzxY6JdoWlT95Jc497nEzxy0rbwo87ink9LJFi8TpxjaY4ELA4g0vjK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc0f6ce5-8869-43e8-0777-08dbdec9e630 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:33.8755 (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: PcXSnZeyDGTF8Eu+XTskqiHsZoIoAg0pwCoA58dGB+vHdZPI/CORIuWBh0SX9f6Q8IR3t9YnAP8vT+OhG1KCHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: XB9QT-c5icjcNT2c19eH1yHS6fZ26mk7 X-Proofpoint-GUID: XB9QT-c5icjcNT2c19eH1yHS6fZ26mk7 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit collects all state tracking variables in a new "struct metadump" structure. This is done to collect all the global variables in one place rather than having them spread across the file. A new structure member of type "struct metadump_ops *" will be added by a future commit to support the two versions of metadump. Reviewed-by: Carlos Maiolino Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 458 +++++++++++++++++++++++++++----------------------- 1 file changed, 244 insertions(+), 214 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 14eda688..da91000c 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -41,25 +41,27 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; -static FILE *outf; /* metadump file */ - -static xfs_metablock_t *metablock; /* header + index + buffers */ -static __be64 *block_index; -static char *block_buffer; - -static int num_indices; -static int cur_index; - -static xfs_ino_t cur_ino; - -static bool show_progress = false; -static bool stop_on_read_error = false; -static int max_extent_size = DEFAULT_MAX_EXT_SIZE; -static bool obfuscate = true; -static bool zero_stale_data = true; -static bool show_warnings = false; -static bool progress_since_warning = false; -static bool stdout_metadump; +static struct metadump { + int version; + bool show_progress; + bool stop_on_read_error; + int max_extent_size; + bool show_warnings; + bool obfuscate; + bool zero_stale_data; + bool progress_since_warning; + bool dirty_log; + bool stdout_metadump; + xfs_ino_t cur_ino; + /* Metadump file */ + FILE *outf; + /* header + index + buffers */ + struct xfs_metablock *metablock; + __be64 *block_index; + char *block_buffer; + int num_indices; + int cur_index; +} metadump; void metadump_init(void) @@ -99,9 +101,10 @@ print_warning(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - fprintf(stderr, "%s%s: %s\n", progress_since_warning ? "\n" : "", + fprintf(stderr, "%s%s: %s\n", + metadump.progress_since_warning ? "\n" : "", progname, buf); - progress_since_warning = false; + metadump.progress_since_warning = false; } static void @@ -119,10 +122,10 @@ print_progress(const char *fmt, ...) va_end(ap); buf[sizeof(buf)-1] = '\0'; - f = stdout_metadump ? stderr : stdout; + f = metadump.stdout_metadump ? stderr : stdout; fprintf(f, "\r%-59s", buf); fflush(f); - progress_since_warning = true; + metadump.progress_since_warning = true; } /* @@ -137,17 +140,19 @@ print_progress(const char *fmt, ...) static int write_index(void) { + struct xfs_metablock *metablock = metadump.metablock; /* * write index block and following data blocks (streaming) */ - metablock->mb_count = cpu_to_be16(cur_index); - if (fwrite(metablock, (cur_index + 1) << BBSHIFT, 1, outf) != 1) { + metablock->mb_count = cpu_to_be16(metadump.cur_index); + if (fwrite(metablock, (metadump.cur_index + 1) << BBSHIFT, 1, + metadump.outf) != 1) { print_warning("error writing to target file"); return -1; } - memset(block_index, 0, num_indices * sizeof(__be64)); - cur_index = 0; + memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); + metadump.cur_index = 0; return 0; } @@ -164,9 +169,10 @@ write_buf_segment( int ret; for (i = 0; i < len; i++, off++, data += BBSIZE) { - block_index[cur_index] = cpu_to_be64(off); - memcpy(&block_buffer[cur_index << BBSHIFT], data, BBSIZE); - if (++cur_index == num_indices) { + metadump.block_index[metadump.cur_index] = cpu_to_be64(off); + memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], + data, BBSIZE); + if (++metadump.cur_index == metadump.num_indices) { ret = write_index(); if (ret) return -EIO; @@ -389,11 +395,11 @@ scan_btree( if (iocur_top->data == NULL) { print_warning("cannot read %s block %u/%u", typtab[btype].name, agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { zero_btree_block(iocur_top->data, btype); iocur_top->need_crc = 1; } @@ -447,7 +453,7 @@ scanfunc_freesp( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_alloc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -456,7 +462,7 @@ scanfunc_freesp( pp = XFS_ALLOC_PTR_ADDR(mp, block, 1, mp->m_alloc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -483,13 +489,13 @@ copy_free_bno_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in bnobt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in bnobt root " "in agf %u", levels, agno); return 1; @@ -511,13 +517,13 @@ copy_free_cnt_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in cntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_alloc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in cntbt root " "in agf %u", levels, agno); return 1; @@ -544,7 +550,7 @@ scanfunc_rmapbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_rmap_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -553,7 +559,7 @@ scanfunc_rmapbt( pp = XFS_RMAP_PTR_ADDR(block, 1, mp->m_rmap_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -583,13 +589,13 @@ copy_rmap_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in rmapbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_rmap_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in rmapbt root " "in agf %u", levels, agno); return 1; @@ -616,7 +622,7 @@ scanfunc_refcntbt( numrecs = be16_to_cpu(block->bb_numrecs); if (numrecs > mp->m_refc_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); return 1; @@ -625,7 +631,7 @@ scanfunc_refcntbt( pp = XFS_REFCOUNT_PTR_ADDR(block, 1, mp->m_refc_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -655,13 +661,13 @@ copy_refcount_btree( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in refcntbt " "root in agf %u", root, agno); return 1; } if (levels > mp->m_refc_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in refcntbt root " "in agf %u", levels, agno); return 1; @@ -773,7 +779,8 @@ in_lost_found( /* Record the "lost+found" inode if we haven't done so already */ ASSERT(ino != 0); - if (!orphanage_ino && is_orphanage_dir(mp, cur_ino, namelen, name)) + if (!orphanage_ino && is_orphanage_dir(mp, metadump.cur_ino, namelen, + name)) orphanage_ino = ino; /* We don't obfuscate the "lost+found" directory itself */ @@ -783,7 +790,7 @@ in_lost_found( /* Most files aren't in "lost+found" at all */ - if (cur_ino != orphanage_ino) + if (metadump.cur_ino != orphanage_ino) return 0; /* @@ -897,7 +904,7 @@ generate_obfuscated_name( print_warning("duplicate name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); return; } @@ -907,7 +914,7 @@ generate_obfuscated_name( print_warning("unable to record name for inode %llu " "in dir inode %llu\n", (unsigned long long) ino, - (unsigned long long) cur_ino); + (unsigned long long) metadump.cur_ino); } static void @@ -923,9 +930,9 @@ process_sf_dir( ino_dir_size = be64_to_cpu(dip->di_size); if (ino_dir_size > XFS_DFORK_DSIZE(dip, mp)) { ino_dir_size = XFS_DFORK_DSIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size in dir inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } sfep = xfs_dir2_sf_firstentry(sfp); @@ -939,9 +946,9 @@ process_sf_dir( int namelen = sfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length entry in dir inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - @@ -949,16 +956,17 @@ process_sf_dir( } else if ((char *)sfep - (char *)sfp + libxfs_dir2_sf_entsize(mp, sfp, sfep->namelen) > ino_dir_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("entry length in dir inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); if (i != sfp->count - 1) break; namelen = ino_dir_size - ((char *)&sfep->name[0] - (char *)sfp); } - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name( libxfs_dir2_sf_get_ino(mp, sfp, sfep), namelen, &sfep->name[0]); @@ -968,7 +976,8 @@ process_sf_dir( } /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_dir_size < XFS_DFORK_DSIZE(dip, mp))) memset(sfep, 0, XFS_DFORK_DSIZE(dip, mp) - ino_dir_size); } @@ -1026,18 +1035,18 @@ process_sf_symlink( len = be64_to_cpu(dip->di_size); if (len > XFS_DFORK_DSIZE(dip, mp)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid size (%d) in symlink inode %llu", - len, (long long)cur_ino); + len, (long long)metadump.cur_ino); len = XFS_DFORK_DSIZE(dip, mp); } buf = (char *)XFS_DFORK_DPTR(dip); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(buf, len); /* zero stale data in rest of space in data fork, if any */ - if (zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) + if (metadump.zero_stale_data && len < XFS_DFORK_DSIZE(dip, mp)) memset(&buf[len], 0, XFS_DFORK_DSIZE(dip, mp) - len); } @@ -1062,9 +1071,9 @@ process_sf_attr( ino_attr_size = be16_to_cpu(asfp->hdr.totsize); if (ino_attr_size > XFS_DFORK_ASIZE(dip, mp)) { ino_attr_size = XFS_DFORK_ASIZE(dip, mp); - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr size in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); } asfep = &asfp->list[0]; @@ -1074,19 +1083,20 @@ process_sf_attr( int namelen = asfep->namelen; if (namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning("zero length attr entry in inode " - "%llu", (long long)cur_ino); + "%llu", (long long)metadump.cur_ino); break; } else if ((char *)asfep - (char *)asfp + xfs_attr_sf_entsize(asfep) > ino_attr_size) { - if (show_warnings) + if (metadump.show_warnings) print_warning("attr entry length in inode %llu " - "overflows space", (long long)cur_ino); + "overflows space", + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, asfep->namelen, &asfep->nameval[0]); memset(&asfep->nameval[asfep->namelen], 'v', @@ -1098,7 +1108,8 @@ process_sf_attr( } /* zero stale data in rest of space in attr fork, if any */ - if (zero_stale_data && (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) + if (metadump.zero_stale_data && + (ino_attr_size < XFS_DFORK_ASIZE(dip, mp))) memset(asfep, 0, XFS_DFORK_ASIZE(dip, mp) - ino_attr_size); } @@ -1109,7 +1120,7 @@ process_dir_free_block( struct xfs_dir2_free *free; struct xfs_dir3_icfree_hdr freehdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; free = (struct xfs_dir2_free *)block; @@ -1131,10 +1142,10 @@ process_dir_free_block( break; } default: - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid magic in dir inode %llu " "free block", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); break; } } @@ -1146,7 +1157,7 @@ process_dir_leaf_block( struct xfs_dir2_leaf *leaf; struct xfs_dir3_icleaf_hdr leafhdr; - if (!zero_stale_data) + if (!metadump.zero_stale_data) return; /* Yes, this works for dir2 & dir3. Difference is padding. */ @@ -1229,10 +1240,10 @@ process_dir_data_block( } if (be32_to_cpu(datahdr->magic) != wantmagic) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid magic in dir inode %llu block %ld", - (unsigned long long)cur_ino, (long)offset); + (unsigned long long)metadump.cur_ino, (long)offset); return; } @@ -1252,10 +1263,10 @@ process_dir_data_block( if (dir_offset + free_length > end_of_data || !free_length || (free_length & (XFS_DIR2_DATA_ALIGN - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir free space in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) != @@ -1268,7 +1279,7 @@ process_dir_data_block( * actually at a variable offset, so zeroing &dup->tag * is zeroing the free space in between */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { int zlen = free_length - sizeof(xfs_dir2_data_unused_t); @@ -1286,23 +1297,23 @@ process_dir_data_block( if (dir_offset + length > end_of_data || ptr + length > endptr) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid length for dir entry name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } if (be16_to_cpu(*libxfs_dir2_data_entry_tag_p(mp, dep)) != dir_offset) return; - if (obfuscate) + if (metadump.obfuscate) generate_obfuscated_name(be64_to_cpu(dep->inumber), dep->namelen, &dep->name[0]); dir_offset += length; ptr += length; /* Zero the unused space after name, up to the tag */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* 1 byte for ftype; don't bother with conditional */ int zlen = (char *)libxfs_dir2_data_entry_tag_p(mp, dep) - @@ -1338,7 +1349,7 @@ process_symlink_block( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } link = iocur_top->data; @@ -1346,10 +1357,10 @@ process_symlink_block( if (xfs_has_crc((mp))) link += sizeof(struct xfs_dsymlink_hdr); - if (obfuscate) + if (metadump.obfuscate) obfuscate_path_components(link, XFS_SYMLINK_BUF_SPACE(mp, mp->m_sb.sb_blocksize)); - if (zero_stale_data) { + if (metadump.zero_stale_data) { size_t linklen, zlen; linklen = strlen(link); @@ -1416,7 +1427,8 @@ process_attr_block( if ((be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC) && (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR3_LEAF_MAGIC)) { for (i = 0; i < attr_data.remote_val_count; i++) { - if (obfuscate && attr_data.remote_vals[i] == offset) + if (metadump.obfuscate && + attr_data.remote_vals[i] == offset) /* Macros to handle both attr and attr3 */ memset(block + (bs - XFS_ATTR3_RMT_BUF_SPACE(mp, bs)), @@ -1433,9 +1445,9 @@ process_attr_block( nentries * sizeof(xfs_attr_leaf_entry_t) + xfs_attr3_leaf_hdr_size(leaf) > XFS_ATTR3_RMT_BUF_SPACE(mp, bs)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid attr count in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); return; } @@ -1450,22 +1462,22 @@ process_attr_block( first_name = xfs_attr3_leaf_name(leaf, i); if (be16_to_cpu(entry->nameidx) > mp->m_sb.sb_blocksize) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr nameidx in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } if (entry->flags & XFS_ATTR_LOCAL) { local = xfs_attr3_leaf_name_local(leaf, i); if (local->namelen == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "zero length for attr name in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, local->namelen, &local->nameval[0]); memset(&local->nameval[local->namelen], 'v', @@ -1477,18 +1489,18 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_local(nlen, vlen) - (offsetof(struct xfs_attr_leaf_name_local, nameval) + nlen + vlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&local->nameval[nlen + vlen], 0, zlen); } else { remote = xfs_attr3_leaf_name_remote(leaf, i); if (remote->namelen == 0 || remote->valueblk == 0) { - if (show_warnings) + if (metadump.show_warnings) print_warning( "invalid attr entry in inode %llu", - (long long)cur_ino); + (long long)metadump.cur_ino); break; } - if (obfuscate) { + if (metadump.obfuscate) { generate_obfuscated_name(0, remote->namelen, &remote->name[0]); add_remote_vals(be32_to_cpu(remote->valueblk), @@ -1499,13 +1511,13 @@ process_attr_block( zlen = xfs_attr_leaf_entsize_remote(nlen) - (offsetof(struct xfs_attr_leaf_name_remote, name) + nlen); - if (zero_stale_data) + if (metadump.zero_stale_data) memset(&remote->name[nlen], 0, zlen); } } /* Zero from end of entries array to the first name/val */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { struct xfs_attr_leaf_entry *entries; entries = xfs_attr3_leaf_entryp(leaf); @@ -1538,16 +1550,16 @@ process_single_fsb_objects( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; /* Zero unused part of interior nodes */ - if (zero_stale_data) { + if (metadump.zero_stale_data) { xfs_da_intnode_t *node = iocur_top->data; int magic = be16_to_cpu(node->hdr.info.magic); @@ -1658,12 +1670,12 @@ process_multi_fsb_dir( print_warning("cannot read %s block %u/%u (%llu)", typtab[btype].name, agno, agbno, s); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto out_pop; } - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto write; dp = iocur_top->data; @@ -1755,25 +1767,27 @@ process_bmbt_reclist( * one is found, stop processing remaining extents */ if (i > 0 && op + cp > o) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %d in %s ino %llu " "starts at %llu, previous extent " "ended at %llu", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, o, op + cp - 1); break; } - if (c > max_extent_size) { + if (c > metadump.max_extent_size) { /* * since we are only processing non-data extents, * large numbers of blocks in a metadata extent is * extremely rare and more than likely to be corrupt. */ - if (show_warnings) + if (metadump.show_warnings) print_warning("suspicious count %u in bmap " "extent %d in %s ino %llu", c, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } @@ -1784,19 +1798,21 @@ process_bmbt_reclist( agbno = XFS_FSB_TO_AGBNO(mp, s); if (!valid_bno(agno, agbno)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number %u/%u " "(%llu) in bmap extent %d in %s ino " "%llu", agno, agbno, s, i, - typtab[btype].name, (long long)cur_ino); + typtab[btype].name, + (long long)metadump.cur_ino); break; } if (!valid_bno(agno, agbno + c - 1)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bmap extent %i in %s inode %llu " "overflows AG (end is %u/%u)", i, - typtab[btype].name, (long long)cur_ino, + typtab[btype].name, + (long long)metadump.cur_ino, agno, agbno + c - 1); break; } @@ -1832,7 +1848,7 @@ scanfunc_bmap( if (level == 0) { if (nrecs > mp->m_bmap_dmxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s " "block %u/%u", nrecs, typtab[btype].name, agno, agbno); @@ -1843,7 +1859,7 @@ scanfunc_bmap( } if (nrecs > mp->m_bmap_dmxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in %s block %u/%u", nrecs, typtab[btype].name, agno, agbno); return 1; @@ -1858,7 +1874,7 @@ scanfunc_bmap( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", ag, bno, typtab[btype].name, agno, agbno); @@ -1893,10 +1909,10 @@ process_btinode( nrecs = be16_to_cpu(dib->bb_numrecs); if (level > XFS_BM_MAXLEVELS(mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inode %lld %s " - "root", level, (long long)cur_ino, - typtab[btype].name); + "root", level, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } @@ -1907,16 +1923,16 @@ process_btinode( maxrecs = libxfs_bmdr_maxrecs(XFS_DFORK_SIZE(dip, mp, whichfork), 0); if (nrecs > maxrecs) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs (%u) in inode %lld %s " - "root", nrecs, (long long)cur_ino, - typtab[btype].name); + "root", nrecs, (long long)metadump.cur_ino, + typtab[btype].name); return 1; } pp = XFS_BMDR_PTR_ADDR(dib, 1, maxrecs); - if (zero_stale_data) { + if (metadump.zero_stale_data) { char *top; /* Unused btree key space */ @@ -1937,11 +1953,11 @@ process_btinode( if (bno == 0 || bno > mp->m_sb.sb_agblocks || ag > mp->m_sb.sb_agcount) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " - "in inode %llu %s root", ag, - bno, (long long)cur_ino, - typtab[btype].name); + "in inode %llu %s root", ag, bno, + (long long)metadump.cur_ino, + typtab[btype].name); continue; } @@ -1968,14 +1984,16 @@ process_exinode( whichfork); used = nex * sizeof(xfs_bmbt_rec_t); if (nex > max_nex || used > XFS_DFORK_SIZE(dip, mp, whichfork)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad number of extents %llu in inode %lld", - (unsigned long long)nex, (long long)cur_ino); + (unsigned long long)nex, + (long long)metadump.cur_ino); return 1; } /* Zero unused data fork past used extents */ - if (zero_stale_data && (used < XFS_DFORK_SIZE(dip, mp, whichfork))) + if (metadump.zero_stale_data && + (used < XFS_DFORK_SIZE(dip, mp, whichfork))) memset(XFS_DFORK_PTR(dip, whichfork) + used, 0, XFS_DFORK_SIZE(dip, mp, whichfork) - used); @@ -1991,7 +2009,7 @@ process_inode_data( { switch (dip->di_format) { case XFS_DINODE_FMT_LOCAL: - if (!(obfuscate || zero_stale_data)) + if (!(metadump.obfuscate || metadump.zero_stale_data)) break; /* @@ -2003,7 +2021,7 @@ process_inode_data( print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", XFS_DFORK_DSIZE(dip, mp), - (long long)cur_ino); + (long long)metadump.cur_ino); break; } @@ -2035,9 +2053,9 @@ process_dev_inode( struct xfs_dinode *dip) { if (xfs_dfork_data_extents(dip)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("inode %llu has unexpected extents", - (unsigned long long)cur_ino); + (unsigned long long)metadump.cur_ino); return; } @@ -2049,11 +2067,11 @@ process_dev_inode( if (XFS_DFORK_DSIZE(dip, mp) > XFS_LITINO(mp)) { print_warning( "Invalid data fork size (%d) in inode %llu, preserving contents!", - XFS_DFORK_DSIZE(dip, mp), (long long)cur_ino); + XFS_DFORK_DSIZE(dip, mp), (long long)metadump.cur_ino); return; } - if (zero_stale_data) { + if (metadump.zero_stale_data) { unsigned int size = sizeof(xfs_dev_t); memset(XFS_DFORK_DPTR(dip) + size, 0, @@ -2079,17 +2097,17 @@ process_inode( bool crc_was_ok = false; /* no recalc by default */ bool need_new_crc = false; - cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); + metadump.cur_ino = XFS_AGINO_TO_INO(mp, agno, agino); /* we only care about crc recalculation if we will modify the inode. */ - if (obfuscate || zero_stale_data) { + if (metadump.obfuscate || metadump.zero_stale_data) { crc_was_ok = libxfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, offsetof(struct xfs_dinode, di_crc)); } if (free_inode) { - if (zero_stale_data) { + if (metadump.zero_stale_data) { /* Zero all of the inode literal area */ memset(XFS_DFORK_DPTR(dip), 0, XFS_LITINO(mp)); } @@ -2131,7 +2149,8 @@ process_inode( switch (dip->di_aformat) { case XFS_DINODE_FMT_LOCAL: need_new_crc = true; - if (obfuscate || zero_stale_data) + if (metadump.obfuscate || + metadump.zero_stale_data) process_sf_attr(dip); break; @@ -2148,7 +2167,7 @@ process_inode( done: /* Heavy handed but low cost; just do it as a catch-all. */ - if (zero_stale_data) + if (metadump.zero_stale_data) need_new_crc = true; if (crc_was_ok && need_new_crc) @@ -2208,7 +2227,7 @@ copy_inode_chunk( if (agino == 0 || agino == NULLAGINO || !valid_bno(agno, agbno) || !valid_bno(agno, XFS_AGINO_TO_AGBNO(mp, agino + XFS_INODES_PER_CHUNK - 1))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("bad inode number %llu (%u/%u)", XFS_AGINO_TO_INO(mp, agno, agino), agno, agino); return 1; @@ -2224,7 +2243,7 @@ copy_inode_chunk( (xfs_has_align(mp) && mp->m_sb.sb_inoalignmt != 0 && agbno % mp->m_sb.sb_inoalignmt != 0)) { - if (show_warnings) + if (metadump.show_warnings) print_warning("badly aligned inode (start = %llu)", XFS_AGINO_TO_INO(mp, agno, agino)); return 1; @@ -2241,7 +2260,7 @@ copy_inode_chunk( if (iocur_top->data == NULL) { print_warning("cannot read inode block %u/%u", agno, agbno); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } @@ -2267,7 +2286,7 @@ next_bp: ioff += inodes_per_buf; } - if (show_progress) + if (metadump.show_progress) print_progress("Copied %u of %u inodes (%u of %u AGs)", inodes_copied, mp->m_sb.sb_icount, agno, mp->m_sb.sb_agcount); @@ -2297,7 +2316,7 @@ scanfunc_ino( if (level == 0) { if (numrecs > igeo->inobt_mxr[0]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s " "block %u/%u", numrecs, typtab[btype].name, agno, agbno); @@ -2320,7 +2339,7 @@ scanfunc_ino( } if (numrecs > igeo->inobt_mxr[1]) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid numrecs %d in %s block %u/%u", numrecs, typtab[btype].name, agno, agbno); numrecs = igeo->inobt_mxr[1]; @@ -2329,7 +2348,7 @@ scanfunc_ino( pp = XFS_INOBT_PTR_ADDR(mp, block, 1, igeo->inobt_mxr[1]); for (i = 0; i < numrecs; i++) { if (!valid_bno(agno, be32_to_cpu(pp[i]))) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u/%u) " "in %s block %u/%u", agno, be32_to_cpu(pp[i]), @@ -2357,13 +2376,13 @@ copy_inodes( /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in inobt " "root in agi %u", root, agno); return 1; } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in inobt root " "in agi %u", levels, agno); return 1; @@ -2377,7 +2396,7 @@ copy_inodes( levels = be32_to_cpu(agi->agi_free_level); if (root == 0 || root > mp->m_sb.sb_agblocks) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid block number (%u) in " "finobt root in agi %u", root, agno); @@ -2385,7 +2404,7 @@ copy_inodes( } if (levels > M_IGEO(mp)->inobt_maxlevels) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid level (%u) in finobt " "root in agi %u", levels, agno); return 1; @@ -2416,11 +2435,11 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (!iocur_top->data) { print_warning("cannot read superblock for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { /* Replace any filesystem label with "L's" */ - if (obfuscate) { + if (metadump.obfuscate) { struct xfs_sb *sb = iocur_top->data; memset(sb->sb_fname, 'L', min(strlen(sb->sb_fname), sizeof(sb->sb_fname))); @@ -2438,7 +2457,7 @@ scan_ag( agf = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agf block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2453,7 +2472,7 @@ scan_ag( agi = iocur_top->data; if (iocur_top->data == NULL) { print_warning("cannot read agi block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { if (write_buf(iocur_top)) @@ -2467,10 +2486,10 @@ scan_ag( XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL); if (iocur_top->data == NULL) { print_warning("cannot read agfl block for ag %u", agno); - if (stop_on_read_error) + if (metadump.stop_on_read_error) goto pop_out; } else { - if (agf && zero_stale_data) { + if (agf && metadump.zero_stale_data) { /* Zero out unused bits of agfl */ int i; __be32 *agfl_bno; @@ -2493,7 +2512,7 @@ scan_ag( /* copy AG free space btrees */ if (agf) { - if (show_progress) + if (metadump.show_progress) print_progress("Copying free space trees of AG %u", agno); if (!copy_free_bno_btree(agno, agf)) @@ -2539,7 +2558,7 @@ copy_ino( if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks || offset >= mp->m_sb.sb_inopblock) { - if (show_warnings) + if (metadump.show_warnings) print_warning("invalid %s inode number (%lld)", typtab[itype].name, (long long)ino); return 1; @@ -2551,12 +2570,12 @@ copy_ino( if (iocur_top->data == NULL) { print_warning("cannot read %s inode %lld", typtab[itype].name, (long long)ino); - rval = !stop_on_read_error; + rval = !metadump.stop_on_read_error; goto pop_out; } off_cur(offset << mp->m_sb.sb_inodelog, mp->m_sb.sb_inodesize); - cur_ino = ino; + metadump.cur_ino = ino; rval = process_inode_data(iocur_top->data, itype); pop_out: pop_cur(); @@ -2592,7 +2611,7 @@ copy_log(void) int logversion; int cycle = XLOG_INIT_CYCLE; - if (show_progress) + if (metadump.show_progress) print_progress("Copying log"); push_cur(); @@ -2601,11 +2620,11 @@ copy_log(void) if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); - return !stop_on_read_error; + return !metadump.stop_on_read_error; } /* If not obfuscating or zeroing, just copy the log as it is */ - if (!obfuscate && !zero_stale_data) + if (!metadump.obfuscate && !metadump.zero_stale_data) goto done; dirty = xlog_is_dirty(mp, &log, &x, 0); @@ -2613,7 +2632,7 @@ copy_log(void) switch (dirty) { case 0: /* clear out a clean log */ - if (show_progress) + if (metadump.show_progress) print_progress("Zeroing clean log"); logstart = XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart); @@ -2628,7 +2647,7 @@ copy_log(void) break; case 1: /* keep the dirty log */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Warning: log recovery of an obfuscated metadata image can leak " "unobfuscated metadata and/or cause image corruption. If possible, " @@ -2636,7 +2655,7 @@ _("Warning: log recovery of an obfuscated metadata image can leak " break; case -1: /* log detection error */ - if (obfuscate) + if (metadump.obfuscate) print_warning( _("Could not discern log; image will contain unobfuscated metadata in log.")); break; @@ -2659,9 +2678,15 @@ metadump_f( char *p; exitcode = 1; - show_progress = false; - show_warnings = false; - stop_on_read_error = false; + + metadump.version = 1; + metadump.show_progress = false; + metadump.stop_on_read_error = false; + metadump.max_extent_size = DEFAULT_MAX_EXT_SIZE; + metadump.show_warnings = false; + metadump.obfuscate = true; + metadump.zero_stale_data = true; + metadump.dirty_log = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -2682,27 +2707,29 @@ metadump_f( while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { switch (c) { case 'a': - zero_stale_data = false; + metadump.zero_stale_data = false; break; case 'e': - stop_on_read_error = true; + metadump.stop_on_read_error = true; break; case 'g': - show_progress = true; + metadump.show_progress = true; break; case 'm': - max_extent_size = (int)strtol(optarg, &p, 0); - if (*p != '\0' || max_extent_size <= 0) { + metadump.max_extent_size = + (int)strtol(optarg, &p, 0); + if (*p != '\0' || + metadump.max_extent_size <= 0) { print_warning("bad max extent size %s", optarg); return 0; } break; case 'o': - obfuscate = false; + metadump.obfuscate = false; break; case 'w': - show_warnings = true; + metadump.show_warnings = true; break; default: print_warning("bad option for metadump command"); @@ -2715,21 +2742,6 @@ metadump_f( return 0; } - metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); - if (metablock == NULL) { - print_warning("memory allocation failure"); - return 0; - } - metablock->mb_blocklog = BBSHIFT; - metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); - - /* Set flags about state of metadump */ - metablock->mb_info = XFS_METADUMP_INFO_FLAGS; - if (obfuscate) - metablock->mb_info |= XFS_METADUMP_OBFUSCATED; - if (!zero_stale_data) - metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; - /* If we'll copy the log, see if the log is dirty */ if (mp->m_sb.sb_logstart) { push_cur(); @@ -2740,34 +2752,52 @@ metadump_f( struct xlog log; if (xlog_is_dirty(mp, &log, &x, 0)) - metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + metadump.dirty_log = true; } pop_cur(); } - block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t)); - block_buffer = (char *)metablock + BBSIZE; - num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64); + metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); + if (metadump.metablock == NULL) { + print_warning("memory allocation failure"); + return -1; + } + metadump.metablock->mb_blocklog = BBSHIFT; + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + + /* Set flags about state of metadump */ + metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; + if (metadump.obfuscate) + metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; + if (!metadump.zero_stale_data) + metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; + if (metadump.dirty_log) + metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + + metadump.block_index = (__be64 *)((char *)metadump.metablock + + sizeof(xfs_metablock_t)); + metadump.block_buffer = (char *)metadump.metablock + BBSIZE; + metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / + sizeof(__be64); /* * A metadump block can hold at most num_indices of BBSIZE sectors; * do not try to dump a filesystem with a sector size which does not * fit within num_indices (i.e. within a single metablock). */ - if (mp->m_sb.sb_sectsize > num_indices * BBSIZE) { + if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { print_warning("Cannot dump filesystem with sector size %u", mp->m_sb.sb_sectsize); - free(metablock); + free(metadump.metablock); return 0; } - cur_index = 0; start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { if (isatty(fileno(stdout))) { print_warning("cannot write to a terminal"); - free(metablock); + free(metadump.metablock); return 0; } /* @@ -2791,17 +2821,17 @@ metadump_f( close(outfd); goto out; } - outf = fdopen(outfd, "a"); - if (outf == NULL) { + metadump.outf = fdopen(outfd, "a"); + if (metadump.outf == NULL) { fprintf(stderr, "cannot create dump stream\n"); dup2(outfd, STDOUT_FILENO); close(outfd); goto out; } - stdout_metadump = true; + metadump.stdout_metadump = true; } else { - outf = fopen(argv[optind], "wb"); - if (outf == NULL) { + metadump.outf = fopen(argv[optind], "wb"); + if (metadump.outf == NULL) { print_warning("cannot create dump file"); goto out; } @@ -2828,24 +2858,24 @@ metadump_f( if (!exitcode) exitcode = write_index() < 0; - if (progress_since_warning) - fputc('\n', stdout_metadump ? stderr : stdout); + if (metadump.progress_since_warning) + fputc('\n', metadump.stdout_metadump ? stderr : stdout); - if (stdout_metadump) { - fflush(outf); + if (metadump.stdout_metadump) { + fflush(metadump.outf); fflush(stdout); ret = dup2(outfd, STDOUT_FILENO); if (ret < 0) perror("un-redirecting stdout"); - stdout_metadump = false; + metadump.stdout_metadump = false; } - fclose(outf); + fclose(metadump.outf); /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metablock); + free(metadump.metablock); return 0; } From patchwork Mon Nov 6 13:10:38 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: 13446910 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 01163C4167B for ; Mon, 6 Nov 2023 13:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232075AbjKFNLv (ORCPT ); Mon, 6 Nov 2023 08:11:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232076AbjKFNLt (ORCPT ); Mon, 6 Nov 2023 08:11:49 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD27BD for ; Mon, 6 Nov 2023 05:11:46 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1uvk024922; Mon, 6 Nov 2023 13:11:43 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=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=e/BfH027MJ2b9yLXlriq5uDtBV+Z1zv0A9lzLH+Ywmn2ozfQWN4jLgnKYj5tAqCq8TsK bcRj++lYLwryhXKUfnt8C57y1AVPYpx/kvR0Jf1hT5PqfnZtGgLCQ9xLrBEAV2WL4GRC Iwxkq4Qh8+dM8Vm/tMhL5SzI8YljJPCttWNzCdsdBMTKoK97g4xx6t56qm458qIkXNqZ z0gtRbNbnIrnFH7Bgj/EMPPG14xoOx1p2/foPEH2+mcGvc22uIPOBq4JjDbwD2pCfR7k gt6u/wXYf9WwX+OXNuYDO69OoMes5wqGvEVpKjDkd+Um9B1Qo8FUdAlC2ZSHCEIoa2qh IQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdty14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:43 +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 3A6DBAL3023571; Mon, 6 Nov 2023 13:11:42 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4t9gk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EthAy69IiVGXqLusagTxqnAj1kb4KYCbpKi8qnGzz+tG9WmAtZMuxZaEyXbbm7g9bB3OCyZHJHOzXIc/wyCfIl4DXdrur5gqWp4C5s6RoevTrY6/ejG0AGrYp4IiRGVxNTpQTVS+tuLPKd/iitr+W9z5EP0eaBOJUJtWVn9NoPITbO6XHEoke74YwhV9pJvImH9UClJxHOiEflr7RLBnxH9eot9pva3weYbb9FTDzoaCiRLSsz09J3r/pm9AZ5okcwhdIJpZFPHFJ33f6vetmSr+bli+tUD95sOkjzd80Icdvy3VeqQk+0MVDCpbJt6J4tONhP0OX65YGaKXH3URyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=NerS0IEf/T5Gdx95RXbGaMWJj8aCWJ711JMXRgdiICP2fo/2x562wYjVr7cpMbf6FpKFuB7w6DSP4UI+FcJk3QzIzllBi32Wfq7KvX0N/zPwvICik7kdfjbHnkzY0uziBdcSGNKMYmT5K+1geF2Zst5ULp/tbO4/sYfZe2KXGFxIbILx4Wu1KZKRgoqwU+5IyB2WkRos58KYreVgbJEvJpc7+wnN8MpRg/P3UNRGSssknK+8GhClgLIrdqXi8eeyoMl4aYPH4HgE3VR9j4uBXybbJejblky602HwO6PTJxnb+TGYjXHTdm5+ZUimlf1NPqeK5HcMFIqEP5RtGBY56g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LHYflDpEN0btakiKojmMMe9NTsjNlUmSe9C6hc0DdVM=; b=IamkbVS9ylwLKBkLiCtcHLH4IKIggwiRzf+8cc5f+R6xdwjYj+4+hyV8hMHtNejfWlHW/HmQ9E3hAjMXb3OXX1Qy+Eoz5GagS914OUplw0wqJdA6VIj1wtTJYk3ZrcNsuZf494dCzPZES/c3DfOjlISf3qqyLIvXPr0cfmQUbK0= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:39 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:39 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 05/21] metadump: Add initialization and release functions Date: Mon, 6 Nov 2023 18:40:38 +0530 Message-Id: <20231106131054.143419-6-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2P153CA0043.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b621f51-7ce6-4b58-1bd7-08dbdec9e98f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bySrtmyNDHQJi2E2E8xTxp2oAZ/ZMseWkR47vmCYQJLgjl9EpjasSxRCg5co1koUJACIr0ONhwlow4izuLfk/xB34/zSOSDZEyS55Rhpm5119ynVJO3mS3Q4jlnm1FYdAItjROiESeObkHiQST7PIz66I3lyOK4paSC680k0iA9k4FRrOK5h73qcY5RpgSq+/9RXouLhQxVLKR/3T4T9pxNI9ZRbWW6fPVjG9EyOqZzsN3MISNvwGgHSO9pbacJ+Kjb4rRc96ISx6aFEP70Vdb1OzCCs4oFs9dacFHE7QMcrILWdlAd5Pp3CMeqmx4cZcu/8hai/ojtzTRbLEGroWmTSiJk8QgnI34y+jARRCoy7g9UreSlQ5+Ca7myfAwNPYgn0J++pma4AyAmlPPmUpYuxtcR5kh2GdGR8guUlYRVonLsFMVRYl9LZnllBaprkmUW3+TO5yGbLJFZvHFVJttuuvHBeygtZwIisTID/jJQvZOsJ6F9q1eAv9xauOGotH12RQCPGh/oTrWDOSyeP3hVXTGtRwNHFpYEGLgjthxulUAk6M8O1GGPHWRyxopAj4wbUlk7ICViEax/n3wy3I8y2tkDt3+wugT/LcBELYe4ghXMkmmBUpfMWYd3sYesL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /iwAxodK+omjV2/83UaIg9acjLYq2bCVv2da9ppbzrhbAjSJfPh1oO5r5B7f/MqKR+aNYrnxozDsa9+GHMDQzT8d+4IX+XRWEf9PqoEoybbc5KVw+fKVxxjbw8LnOqcqcb5tjAkcyjyUfNig2rYyavuyRABmrMxJG7w/uScGtuxAdclPUhGC49yS4DBF3rIPdM0jYh/54cDr6QTJq4xWseXI0md9uR4FdBygrShQ3OSJUxJLJ7aS9itO2zFElRQCo/TArbmrvhmErQR0WZ7P+WJOIFLe6kk/HRXtvGYCFfKF57Y7nZ2YgjeXHYgtjEr1tFTpCaH/LCFsqqlsIusYxBNbLk8nyyl8H+MMbZo2OqlM+d3yTT8WBP6KqVctaE9Tai84WCp+m7iJk6+7XupGfG99EU0jIOP6+6VZkrPM4mfjKl6jJ0K4cb2b0X+dbMmL1RYlK09orAEDrA8NoohMrINWVZ0r039bbSXPQ3F/GqTHSsygVaZJJQW2fHaCyW5wUOaYV7VYhImqIizHtu6k9MvS7ij5r5va0gj0HgVmi76RyD9b5lqbbA4uY4gsdsU6NssEeYasOCwOLcRNaMfwsUPYNp38HzqhwTIC6/uraZvh9yBuOnegoS2bW0gKwN9BSAowy3b19/8uxr0pEYiHbPzXE87jHuSCLH1I9Fv6zku3dJJZOtvXAhTMR4dGvnb3L3iIGjkNL2+ImdTEWIyKQkWYUes5WigtIJThEst2vvnXFSPyCyLmxD3lFDQBJTPPXSiu8ddqehxMBnBIVoW+G54e+KgH0xvTib+GcJc3KWPMA/N5F7KKH98e5pUwOBgnSu84OrHOPPGjA/09X2l5O+UNxCsL/Txbm+CETsWpov9h2T4uT+OAUBx3ucpei7Z61mog+ZPlRR12u5QbyKFwE6XfrKe/cEvp0HmIi4jKRAPek99NVsKpohtKd3DnJs/HT5V0X8audv3d3P848f2cIFKwy4+M1v0p02LaYcayLHqvH+PcVhoPMS8TG6zC0mRvJ2B+18bKIoHSBsqDh3V2FNnHdl0WPTUD6yyV6IFVottfCdgGWe8QjbSHC2MYrLUCOTFQTZamSdC06bjacpdxLnk6BS1g5VS2Fahux9oJCjhPEMwUQdi5u5WTBev6SYE6znaVapyTMz6EsG2rIuba3/zo3U5hLHdLxlzrt4a4Zr0MH4klWPoLJQTAY5THmwe58WwJpy8Z4nctWEobgrUY7arcsyOQdz4mx56Q82rN3r4gBL0nVgvJfYyoXVI/MBV04Oz6HWomexSoZ5FKeP77l4trH3npWjKeaSpZ4aToomaVsoH4Mp3gx2ju8jPLB7+T2XJZXXtoElZH1KQh2aWiDT/ek9cyW6prxIAsOhV5TUKOk6p8DbEnKXX86JX5FzHLucrJdvzuTT9g6wTk2UbKZOuHGVclrO9qyW0U1qrWR8lVnaEbyga+YNmv1J3B5bG9R4I+MAmIWvLmDJxtPpSXfUcTg3l3CSI0tInRs3xXBNCTrhpSOMj22hZtEBGcvV7/uX/XIMFScIhrbquYsTWJnu1HhQChUZyFtl49UXq+Xe6HHzQllCehx18D2WrvsBmm X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dqdX2LxilNRU//gmq6MuM+52eM9D4Lk9z1W10HOmuRJX/quIS4OA//YtRMQGYbD47o1guSSR37MOrSahiNnOh8j/wcU9o7PDBIvY8FpNfuCspaS/MH+t6WRlWEH4LBAr60HabuSdkLi2085d8uy+bIK7opoeWLsYt/O7QMQAWj+k8MxGMfA//+99OpjB/5Tabp+hCORmqgPCofK7oabLlJI+wqPOlRY1F8nsmGSCTlcCpbN5J0DwacDk5xxNXRAyNNtuDGUCThobwvkSauNqBOcD1jFHyZLrCrAlP6xZ6XJ2Pn7bkNiA32riH/HlTN3locZDp005QLeREduo9xPEbA6yTKlIul68oYo6rHFGLa/ZfhOg0te5WBdwg4G73w3BbPgZ5uQeDGBi/KBFQVLBi8AsAsl4WLk2FLN3QspZfgdVPiNfj6Z0ovWB+nRgY2t3cTvVQQtSULL1WRFbA9cnpipjocW6JFIfqQp51rcDDegFuqgF7XfDsiYShq77x8obIvyzyHm1V7md/4WYtygdWA5nTPI5Yhzk4/tSpLvv5Pdgej5JzeLeKfxXeFW3AhQ4Er9DCDc/yjKJxSlUZJAIQf3uuOJRJ+zL3wPjKdc3f7JS15OD6KpSGgM933xQvjWjMW7fifz9csJu62KvZ3QdNBDXJOzczyZVizQto8uqK4j3XaR0m7Mhq9YuCu87r+qErTYNsrcigyDio0MNrs31r5VxVLPQLJkgfJGiugxOuWLTTgunkBhCNMhSnQOKwvt7UqokDsEb3S3+qK3rWoTaD5X89xDmWHDjWePCdYITqqA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b621f51-7ce6-4b58-1bd7-08dbdec9e98f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:39.4463 (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: 8OjiaFsfFbeeqb7B1RI6Q07Xuoa2xoxtn9fE6PTp17UKojelcfRdWkCytfDJo8VcVa7rcTEnvv6iRIh/o2BYsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=888 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: 9RAFJebbwjjW-sQU9PvWNNsu_jA-xHm9 X-Proofpoint-GUID: 9RAFJebbwjjW-sQU9PvWNNsu_jA-xHm9 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Move metadump initialization and release functionality into corresponding functions. There are no functional changes made in this commit. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 88 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index da91000c..8d921500 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2665,6 +2665,54 @@ done: return !write_buf(iocur_top); } +static int +init_metadump(void) +{ + metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); + if (metadump.metablock == NULL) { + print_warning("memory allocation failure"); + return -1; + } + metadump.metablock->mb_blocklog = BBSHIFT; + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + + /* Set flags about state of metadump */ + metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; + if (metadump.obfuscate) + metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; + if (!metadump.zero_stale_data) + metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; + if (metadump.dirty_log) + metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; + + metadump.block_index = (__be64 *)((char *)metadump.metablock + + sizeof(xfs_metablock_t)); + metadump.block_buffer = (char *)(metadump.metablock) + BBSIZE; + metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / sizeof(__be64); + + /* + * A metadump block can hold at most num_indices of BBSIZE sectors; + * do not try to dump a filesystem with a sector size which does not + * fit within num_indices (i.e. within a single metablock). + */ + if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { + print_warning("Cannot dump filesystem with sector size %u", + mp->m_sb.sb_sectsize); + free(metadump.metablock); + return -1; + } + + metadump.cur_index = 0; + + return 0; +} + +static void +release_metadump(void) +{ + free(metadump.metablock); +} + static int metadump_f( int argc, @@ -2757,48 +2805,16 @@ metadump_f( pop_cur(); } - metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); - if (metadump.metablock == NULL) { - print_warning("memory allocation failure"); - return -1; - } - metadump.metablock->mb_blocklog = BBSHIFT; - metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); - - /* Set flags about state of metadump */ - metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; - if (metadump.obfuscate) - metadump.metablock->mb_info |= XFS_METADUMP_OBFUSCATED; - if (!metadump.zero_stale_data) - metadump.metablock->mb_info |= XFS_METADUMP_FULLBLOCKS; - if (metadump.dirty_log) - metadump.metablock->mb_info |= XFS_METADUMP_DIRTYLOG; - - metadump.block_index = (__be64 *)((char *)metadump.metablock + - sizeof(xfs_metablock_t)); - metadump.block_buffer = (char *)metadump.metablock + BBSIZE; - metadump.num_indices = (BBSIZE - sizeof(xfs_metablock_t)) / - sizeof(__be64); - - /* - * A metadump block can hold at most num_indices of BBSIZE sectors; - * do not try to dump a filesystem with a sector size which does not - * fit within num_indices (i.e. within a single metablock). - */ - if (mp->m_sb.sb_sectsize > metadump.num_indices * BBSIZE) { - print_warning("Cannot dump filesystem with sector size %u", - mp->m_sb.sb_sectsize); - free(metadump.metablock); + ret = init_metadump(); + if (ret) return 0; - } start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { if (isatty(fileno(stdout))) { print_warning("cannot write to a terminal"); - free(metadump.metablock); - return 0; + goto out; } /* * Redirect stdout to stderr for the duration of the @@ -2875,7 +2891,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); out: - free(metadump.metablock); + release_metadump(); return 0; } From patchwork Mon Nov 6 13:10:39 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: 13446911 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 7936DC4332F for ; Mon, 6 Nov 2023 13:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbjKFNLx (ORCPT ); Mon, 6 Nov 2023 08:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231645AbjKFNLw (ORCPT ); Mon, 6 Nov 2023 08:11:52 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A8E6EA for ; Mon, 6 Nov 2023 05:11:50 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D2ADv006802; Mon, 6 Nov 2023 13:11:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=GkfuWiQl4JsuW9gRq8W8KDdMQBrqEIHM7DwZTWe9VXT73dSIm9XU7lXoFdOHOrnlyZxi ZkKAc5QTLWRP3JDc3VjsDwijadKQp67tkwL5sCEsTUTW3Er2BdkDGR7YHsiyBb6DGrbl vor05UTrM+adoRC7fXbZf7tdXt+AI/mNbl7SZ6FL8XN0wxhGXFO7vF4GqZ6ic8Z9E2Ur /CQZX+ISxpUambPcAX0Fa1VNIMF43f1BNBtl72o72ixL/ihYRO716GvwxsHEg5x5swTq GfqaANn85BG9jD2JOGrJXeaN33cPnY4a+XdEVu2NuQEUTr0qDI2XnRpHX62y15eHnFfm wg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcayy5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:47 +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 3A6C1B7L024854; Mon, 6 Nov 2023 13:11:46 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba4c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZuG/WyWVIF3IeqxtdufNYFrYoN4aZ7fyCP6ACbja26ec0X5pvgrCkVeF9AZB30kgSwI5bCqzqQX23dRZmRnSsik95IJHFSZlymxFnuv1ZVZg9r8ReqTwxSy5Y7sFZRNidd4ZaoRSVFLg0f3AtODkJsvUpc1LA2VBDr9X+azdKYB0BSTtDiiR+CRm0Zn26eyNNUlXb3UzPZ/IPZMrqfTqcXz4DJpeL4kzqJajLMdouTJ7D3o9pzsfp2CVsbtZFfBX/YDk4e1Ald2ik4ODN1ntqzop/dT+f2PmNjyeWs1PtqVbLmd5x8FCPuc02FOlUkQGxu4A5CRM4oRr6uBHOmvakA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=TEQAGZRLI9K7xOpMGy+CYkXV3siGJmgopR0d6rugEcaCKMjtEBTOoPhszr44gtQxYddxajgqeuv54xucW5JcoJ2HwMTDYu9QjeYrdRuzskq/bniAdbbEUC09uyf6lYCjNpJHqmKGe+q+TRM/LgHEWMo755yXVUOv1J8n/D4jcGayVKGGZE3KLF9MNaYVV2pLyJnc4nvPjhXP8H+ujYI7qia/PXseIrPegwp1WlVlQO+CIFPVo0fkpJUl5rZWXUmO1lzCPPWUzz6Q+LjG+U5DZeEyZWqdaeE0fkv7z2v0ntrzzDy2YigPg4ldD/0pvWOE20SZO11CZfxZePwKI0/RdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2pyOlySe7vXPGm7Xsf4IULIzTasyZRfXCj9H37LiNiA=; b=mSL+UgH1+jCoj4DZ2V3XBBUgacE/L1SSVciVn0+SYdA/dqsRXWocEzEnAvzXuEPHsdCkVySLdtZBXSo0aRtpnbUCD6/Wzh6VhVGlbBDq4JqQKoSMpp+33ia9yD6lrytx07ep+yT7KT3Hy+FxBZD4Z8WQqeOqQnjl+tjrvpU3VDI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:44 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:44 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 06/21] metadump: Postpone invocation of init_metadump() Date: Mon, 6 Nov 2023 18:40:39 +0530 Message-Id: <20231106131054.143419-7-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0152.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::32) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 032d203d-2172-4c66-bc50-08dbdec9ecb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XRdhIHRa5HJ/kpClyGGwTFwIy2tW9xDGFfmV4PTOyw/R8tv4hVzstZXA5vC4GoD2wno3fGoQjDahUWBUEiC8HxqsXD2rVOvSkRmQVBcxxNJ1iT/4LJ/usQhirDg0xyXN83ZfX3MDF154sQmYamFr5cjdEpbo0QCqcQ01XafSqWlyVz+mTTEW2Fv0sbYpSl+t4GiyXlftn2TmE/mooHBk9rAWTLH8izdkA20oYv9lm3TI/WIBsu/c4qlINT66AEAWqLI8T0FZnkJ7PzBJVFB0meF6IxdKwHS9bf8IW/S5vC+5NDLrcHHWQ7NvfPCY5WJL27oP82meXUmEa159sbLNA3GDmG2o3MH4Tt0PgnLn6dRLOiFsxI70xU7AULK/BgbgLjBREhMItNE9Y5qfoV/LAR3Y+vruJ4+ipr6YrcDFomZH5dIpZVDsCyHh5uLhLzCl5qQ84CJOL4a/NRlds9WspClJQ+Uoqh0DZyHXFGqxSnxl8nJyvVSscvVzjIWb8MIGMYx2Hf4uqJjqtXZ6jinYt6kg06UuAaMX1HXXiA4gxBPhhCgnoJJldpAwQ/K16mGz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7I+i4NdPNJkQznJxQEgj31Qt1QepPAbMAfDr6FJtnzWBapK2nkL9DQCXEVXJB5ZReDNKM8pS8k4vIvP8Ve0xJ4I7kXcFreE3QCBsliqWNKK4rTFS4ywZe8qcU0O2HikgH17M6A2dx63u3ur8BKHVWHebiOElfsPzWn5MhmfqgK4GnXPlqsFiIxdbG2GjVYQXTjVLz2qSaWJj4EzavCi1WvgQt5QonPnkBwV0Uguk4tg1xrPIrxfm4p573F25HXKGvEefAg5nzXmI7pcOx4i9YeKs2pm2Y24Rd2BbjqDI8TFdYF4ktsOL5ngj6+EHow8VY6bNUhs4w4otCOrmuQN4qk+SZkqbJQGpIhiXwZJHCZuQwpJQusfcsK0q094/Skl4Yi19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YAhWMKrjs21MBb1CIUXaUWwPybraWKlAQQFHvLdFctBBCkwvswzKvZnx9Eps+qrPS1Itgz4GDbplP+8g9WjCw/6cTss41RF2A7d10neYZ8UH6qBQcOgH/IvcDg2E X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kIp3k1dKXlPl9imDjyTyuUWqoRZmf5FfP00s9TibAFZyLUDHuqdqgnsFnQpkoKqL/HkcTrCAkZ2f6d5DTFISMt+kJhrpe8Ppd80iamEcM0/pkQPjz0vgyaU4uRntVsl5YkGutG5IXHi88ciuRWEAPk7lPZX5stjGxpYgTZQBbT7ENQ+niIbSKJbvAmB005rFHS3wpIsZdEvYQf/2buKCdx+k7U03XLpuAM7SPb1qFfF08tec7pLYeHrWIqenYXMmdD0op+A/CSAw/DrdYPnqPhqAZLiAZsgfIvMzh16ymURGSw9vuKrfHB0NgtK55WRqvpaEfZQDCEySufTvtgW7Ys9GdCDwG/JcvfYJmLWiRXUZjS/wmXqTut/YFlSrM2yEKcqlbJD/QhEjSr5l46QTLry9udrImVzgEP1pcIYjporVVkXQMPvEY2+5Yboyy6OUZ8mz9V9c1kPADhxJxf4ojXitK3o13qsLruP2QXVsLRhrUk8galav6Uf31bOsiWTa+n6uH0uPsoRL7+lyTK9wOD/PS9JMHS87zF8PHSJcypGPpSrHMM0mGErRpyvDIAVc5fPV15QwyGMsTW+9RH0kc7+9EBZJPCVKFj7DftylRuPHpmW/AU/DL8wbVgRkHoTMnjP9gN87Z/xvmLJXaXuJ6tbLLIRSPpncHhKZB1+pba0A4gZLMPIjBM2BGn6Yb87NbX6hHKUxh4lNuIXmiCrAjQg3kQusMBbJ9uXoHejLv6U80m/Qvg9RxrUsoWsecJGr+xh/8DNTr9pUE6aIVbfU0kIfLJmQ7Zsoe78yJmGa8Rs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 032d203d-2172-4c66-bc50-08dbdec9ecb9 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:44.7250 (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: jr+Z+dTmP1pW56/yLvZezY04v5ql7txWoqly0PJ6KVhFnZHlh7zhViLgu4B8NPmZiG2nfl/RrPh6Eg1vBeGQ0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: b9aVw21I4UNM89myojrG48bmWiCpCjbi X-Proofpoint-ORIG-GUID: b9aVw21I4UNM89myojrG48bmWiCpCjbi Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The metadump v2 initialization function (introduced in a later commit) writes the header structure into the metadump file. This will require the program to open the metadump file before the initialization function has been invoked. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index 8d921500..24f0b41f 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2805,10 +2805,6 @@ metadump_f( pop_cur(); } - ret = init_metadump(); - if (ret) - return 0; - start_iocur_sp = iocur_sp; if (strcmp(argv[optind], "-") == 0) { @@ -2853,6 +2849,10 @@ metadump_f( } } + ret = init_metadump(); + if (ret) + goto out; + exitcode = 0; for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { @@ -2890,8 +2890,9 @@ metadump_f( /* cleanup iocur stack */ while (iocur_sp > start_iocur_sp) pop_cur(); -out: + release_metadump(); +out: return 0; } From patchwork Mon Nov 6 13:10:40 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: 13446913 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 6084DC4332F for ; Mon, 6 Nov 2023 13:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbjKFNMF (ORCPT ); Mon, 6 Nov 2023 08:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232100AbjKFNL6 (ORCPT ); Mon, 6 Nov 2023 08:11:58 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3EF7A9 for ; Mon, 6 Nov 2023 05:11:55 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1x4U006671; Mon, 6 Nov 2023 13:11:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=ZNLNTlXh5jrHqVARtWjz+tOU4L1pFYKo1SKoHVEGlpqoCubowlHH7j3S0HVZD7pcM0yH M96j6/B8ayLyD8RoNmdS43sr4/UvrtgDTgnZ1BzfNrBAehvXqzbmebVHuVcjdvMrLus9 uSrBHKfUWmllqQDhjGI8JSzJtVakBTFzefSxhafDAvg6c8Loxs4eK0oeRs9e+ciBXfSX KDpFIfDM7D3bpNPn+IFI9b1u54PvkJcT98UAVDj2LadT8m23b8qAKtcSBuAlV6zIcXL8 LIaN5Dtns9+oT0UJcjDwe/wjwMgcehsHGMcptJ0O22dFL/NlEtHPXVRcWe2jIWN9qW4q 6A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcayyc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:53 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6BvWic024757; Mon, 6 Nov 2023 13:11:52 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba4rq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d6SoxqFwl8j6/b3Osy9byQjHbPiQf9aU0koteLb4f5rybVAUqYNehh6CwekH1Zc8/efFWxeW8rHkSB1zll0XKOC4XJCWWWJ+2H4X/KglXXYyvfm4UT+u+Ex/gWYuNisByMkCT3/qhfnZIhuyNFVvEnCAdRhXuBbjRZYm2OWEs6u1JaGgz7GCtv/EAYKc8SHegqCKthkJL3OhKS2WCpUzr4Q3Utea6JZJLCZJXuZp6jmucBhQJiC91nxTC8Rbbs2cSLmThCfmlrzLrR8lSKSj8Cxa2Qnm5Yd7UeebrJw8aDHBSPKqLEHAr9MbogEiIyBonX0cddWXb2318YSoFMDN6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=ZMMVWc4lzKBJ/ZDpMRRiRlJbH3Zb3XAX21lvjGBpWzDF9egSXRaCxXetDl/j4sY+8WIZnaifohXxteY8g2aX8eTn2jWY4ei4NyJgAR/2ufb5SjrxB5lcF4BLeLa/s3nIr0rll56HBvYqPMem+XIydXBU8djsVP8gQh28wO8aBLFoYt76wpFjzlJj7Kgjs7qCLV52TyaceObARecJcgzNt4/MeyFb++6luTpBAsioQalNx2iuXGkw5kLSnqt4BWvan8BiYrsCwGPW+Ih887QMc50vn2clOA5Ot0laydlh4ecWn0GlgvPJqfuRsAiyF7eLX2IxeW/vOxQTtujJSGgLow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I0zjj2CL6DlbFMncP2dw5WzEyx+XqTByG5FVAskQdFE=; b=mTRXZHtJHu9CIjdjJcgK1c8g1flOY4p5k8+tqqU0Wpzn/tk6lieUFciohI1o6Pfs/ybklFBgGzNY+Z1EPsJk882o6gW6nr4HWnoLsAJEzT/VIwrGNoJ9+fwXJltjJuPjuBt8u4yP3OjesWK+Lpkhju5HDl9bXTvsyUd/bCIW5J8= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:50 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:50 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 07/21] metadump: Introduce struct metadump_ops Date: Mon, 6 Nov 2023 18:40:40 +0530 Message-Id: <20231106131054.143419-8-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2P153CA0038.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 7417422d-3ea0-455a-a9ed-08dbdec9f011 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 79X1FRkLpfoZVdLke8t4OliF4QTjsK1HtYleibsx1A+Z+KFU7dM2ZdVGY8v2kIN9pwRptyIpB9Y7vCj1UYGzSjU3aUBo15gbuh5wHPeF8kaD7y2t2qDTIej4Dd5quc/mh8WXnvutMAWgnqLeXD72o1Kncx8htd4/p9TvLEce2ne5ACu6lORyHAfQkB5mIX2tvWSCzEgS/qE5ZD54gaS7d3i+m7zA6sIHIUn9byGBk7nOhzscgQYrKVXyYKnWFIMdJpD9s/CpdV1a51/vvi1mzkKF0GIOQymQuGSIVpD94on4mgcuoF0wGsE83VooWb06Qo65Qz4howNqm2M9UtWsQkylvYW2c2/1hBOsPWEpIlTIE3FzQenkoDc2R5B2HgnpXLCMBKO0pn4C0Il+pEnfRyuiVnV3Xc1J2aAS1StzI+fFOYIVcKUHECBgw3yeX4uw4QCknfYV+cA3tkWOHQVnvPxIgc+iESWztYFLTaSM78LrOYX28RiukjQfEqMBh+VUcVH6y4nElDVVlX6w/wUnltcdUHHNo/nCJffNjl32121ZHKLIeHSYRnUHd5UbrhD3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KFFQ4fLdo0DHnbk5+t6UckRJ9WPuOzrtiDXCHnHRQK8cc5YgoIcaA5HlfAC001I0lkhjX6KDBQBVEfnkFjuI+rLV6QoAAlbwkPLsVGwO3H1Nzhuup0x0TYIUMNps1MMexW2Ma21SmtJ2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NH4jKv5f460ztuzH2KLzbp6bg2RoZ1ETnpMDwvUFplz6SknLgvhqztpGcbYOnKKjiPpM4Bk9ryV85T+WVoln5MuR/Z9fRsn2d2hHP4nZtSr4/+b7M3RUAhmNxUqKCH+XGJP6mjjiyFKsC+2yjcH3aJPboeQsJtru9ZaXjT059Wek+0KFeSbCa+XLoxmxbVVMuDth/bu73ZvkCNZaM69119sXsMYv5yk7yYaBS3/M7GjCxYg2auW3qWXYwnGYj2kHBP6WTawlpYT8rDqcK4HAu2Ityos7dQS8r79423v9JiSPMzQ0EZyu/XChsyuqApkpc8DYjemF72lTeBh1OsmWGYnycJQWmR9FwYtoxuFdgEdJquNCYzL0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3SYlSyl0QiBMjHwnlongZWlvWp3FOxq1navtIizF+cP9HFLS+PoJigmQLP5udyu7/e2KRUY79VVv2V6h4oWGimUfCdUx8A74i8hII32WBTNKEslkkMEssoYhg4tiWNabm2ckoZzYZU74IOXGnaM6n5s9nYHNyJWidCkFX1eS94TE3nNJ7xUB/e/V7cRoriMAeEVvy1MJlBI1PiHPgGoxVxWTuTuQgOFMBxTYFsj6/W/rDn6ii4AFqLrnf/irIgthbgHv5lP6CmdNWX63xS9hLB4K/uj0LGxIOuC8d75WoJg7rRDyfGX4alncKbyGXVIB2jTE4Fe9dCnGKfbmW3d6h4d8S30T4ybJPNfp2BQuca/WQarQQxqPZwhiHqQTkl2MPltdYiU1o1/mYc41vUZNVM5TRFhSAM6wggyxjhrJHT1LGDSVHI9Rsb6hv09mDMkbupWZIktXg9BEst+2KqnBqlJD934NRWS6mD0oZ+FQhwAc08Nq8TIuRq4uG2kWx4P1d/ws0to+V28JicAxQnGfC7ZA09cvUUGBrLSlnarKEi3XBSB/4o8/WtPeEG7n96YbSO9vCfgckVSjZZHyLOGXF+iU9aabDHKnwSh8G6a70DHLKbjP+slqRdAtJUclCF/Bic5J3BqGgyH1lD/F5qLbfnmX+jyMFM6ABwFgkWEecrk3USTw2NQr4Lw2pvyEWukE0Iro0tuHql1owecww1XZvqAU3p6c2W1LNcJhcg3XfQPsHOf5MURJb8FWSZhHbmsqi459vpJrznBs9u9TBhfA9GCdNdl89j/ZmfRR5to8hGM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7417422d-3ea0-455a-a9ed-08dbdec9f011 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:50.3395 (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: 6NVxT9ZQgLBN+XcZ5WcM4nTL6aDS1nqCTPLXXX/Qhh8+gpPjhZbVV5s7pl9BSHcB4+Sv7R94k6vUfeuAHx885A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: GlTQITOm3ZWS-IIqWI11YbGB5OcVC0zC X-Proofpoint-ORIG-GUID: GlTQITOm3ZWS-IIqWI11YbGB5OcVC0zC Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We will need two sets of functions to implement two versions of metadump. This commit adds the definition for 'struct metadump_ops' to hold pointers to version specific metadump functions. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/db/metadump.c b/db/metadump.c index 24f0b41f..a2ec6ab5 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -41,6 +41,30 @@ static const cmdinfo_t metadump_cmd = N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), N_("dump metadata to a file"), metadump_help }; +struct metadump_ops { + /* + * Initialize Metadump. This may perform actions such as + * 1. Allocating memory for structures required for dumping the + * metadata. + * 2. Writing a header to the beginning of the metadump file. + */ + int (*init)(void); + /* + * Write metadata to the metadump file along with the required ancillary + * data. @off and @len are in units of 512 byte blocks. + */ + int (*write)(enum typnm type, const char *data, xfs_daddr_t off, + int len); + /* + * Flush any in-memory remanents of metadata to the metadump file. + */ + int (*finish_dump)(void); + /* + * Free resources allocated during metadump process. + */ + void (*release)(void); +}; + static struct metadump { int version; bool show_progress; @@ -55,6 +79,7 @@ static struct metadump { xfs_ino_t cur_ino; /* Metadump file */ FILE *outf; + struct metadump_ops *mdops; /* header + index + buffers */ struct xfs_metablock *metablock; __be64 *block_index; From patchwork Mon Nov 6 13:10:41 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: 13446914 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 AA3F0C4167D for ; Mon, 6 Nov 2023 13:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbjKFNMK (ORCPT ); Mon, 6 Nov 2023 08:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbjKFNMF (ORCPT ); Mon, 6 Nov 2023 08:12:05 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF8BDD47 for ; Mon, 6 Nov 2023 05:12:01 -0800 (PST) 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 3A6D26t1011551; Mon, 6 Nov 2023 13:11:59 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=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=M0FqB2CYj5iaQrVTCNNm0jZHvCHjeLvo8wMyu/I0F9KrmXgZ27IxDpurLa4vB/IenxmY 0vdV1/KRgVwNDsnSJzL07Mp6EbD5hEXwV4TmkmhMyWA6744UqG1uiSOlK3S4it59KFtT huwpVSldEcE/0/MYwXCyS9pfWaY4L2rIF+joec1L3FzU2XjLqI/A/khaEXw+PzV4yBT0 WJCbVUgZRoyuza7HRuNa6FrLMGTLo/dU3q2DOIAKP/LGG/IX1/z3kWojs1yHAC+PjoUq xH9v7B6RhmLoTMpk1EvzThTQfRYYkWMDLVR2h/q9gcCuKVfTAXXwcmB6SR6DtHt2xlK9 Lg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cj2u00m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:59 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D0KN7024790; Mon, 6 Nov 2023 13:11:57 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba53r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:11:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QktTtIAu/SU3UtrLKRWrEjU/egKbeg9/RLZjkAlW10Sf3aPHqnd7gL5Z9cpADnJHfMlNJx8IfEU68t7AEIqWsn+0xGO6cUfAv0yqIPe8jMyPUTKGeTmQsW8u2YHogxKQpqEWYHoMIzU435KOicqhy91Hk5PgusmIUvGlCc/5C7o2QEgHvm75gT2pUyY25Fqy5svMht9mBnM1+4pH73HPMbjWgt/CTOtwvWNjqJ4+egTTpwaWnRfhLr8I7Fi4FRnE6M8aHW//qwr4zxEZN5//xzO/d+AnsAis/PZSWVr/1NB0tuilsB0kYx//pALl6q3Du5kl7T9F/R6gSga6jjZ4eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=Ck5bN8GViBFRaPBprEm4vAESo02IqKE84/u3p9FFvleoLPGszklOcvYgo5wwe1gj9dTUJ/dhR5OqvdNIF57f6Na2DrTefY3SNrEGMbMKDWGvGV807Iw4RnTHTm4NLlBikIJiBtmWinuy2KZfKH6D+dBcehWoNpsm5u2xdIsK78M5KLS+JWJuyuNLn0NphoS9ektsC+PAHcvCQCg3OSqqRG5GrJqeHudjZMYlGhATeUwa+toHfy07o+7lViCONey1X6dsMzli7wO7aplYvlPLmJKqnY3697KDlX8OotwOQ+31fZ8rxDQPG8M9H4NKk26nYMHuoM1WTUPlZnh50jHESw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zg+LiX2+A7AAxu2bDeLHcJSn0EW+5AHLZUHu4L356dI=; b=pKlS7XjG8BMiuolyUmlwzeOPLvtCZoqT6Buehl3AKrBg7YmmtRW4hYYdKSGiZD3XVOov+325pLBenirnwIyEKZ9FQTH2/d3OZDRS4x1Gv5Bm1PK64TEfJl7nQW91lsqO3vCKgastZ9wczcqv4D/VqdkoHA74RwQprAEZ8XITxQE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:11:55 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:11:55 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 08/21] metadump: Introduce metadump v1 operations Date: Mon, 6 Nov 2023 18:40:41 +0530 Message-Id: <20231106131054.143419-9-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0138.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::18) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: c46852ec-536d-416a-eac6-08dbdec9f2fb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oKGEUsH9HYN6w7sBAoaBkQteX1c3felEkoN0bwYye69MMc/hTJGmEdgSwGEU22AlcjQaVypvNfonGoPpPa5uzuUvTc6hlrdotavC6bjUUKa6z7OqtWNqkwFU6til7NF3pF3FPwCJ212PRpGoDzNODYXgTg0jwha/a/mrbNZcwObNsHSc/bYzJVIpa3YG3zJw2WrX/4FQoQKs9kevUyCiqOaZuClQhER7rk3LEHahO+aOnVH6lzf85l8AWIZwWKdAoPUudYulxN1VUbHgZ7cMVoeZ2zc7SbhLefF6Sk5fubzp5q5hKnMslTQKD8MuC2ffN7pxlq1vM3UZvc7qhiA6aomSayv63H/3Cge/M+DPwzO2gU8RYksphbY8ggXpYOkD5nEGyHEBeTs72h5ox9fnREXCvaEyCCP3rLjayvjWBDU4WDFAkM6m7kvlP13LTPVOjCm59JX6gtffCwu2HPlv2AONZCJrh5qkbMUnSFThxpYA382VqgDA72qsb5Fr2ZdzVROXZIMV2xbeQHtWzcJPbV4/8uB+akSSDIR4ep9fZSBXiCxFIBnq/IaURAg6MdaLZ0x0CcS27BbuQe42/7m0jlZ4nlEjQrq1SCIOxeD0KlgyS46f9iYc7uFCInrYLYRr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b8aI0eMAfVODzZhvJ74dipy+AMvQPPoBMRmqzyAh/OodIje2ZNH0mS3pI3t8EmDLDbN6TZYnNhSFE1j8ssGUT0RNb+SKqSkPpKfWcNdS9JRg56vDaWRAq+Sh+WQOyixL6LWkxcjCth3EqOhVmYKraFPXOQ3uqLr4WwfFOE3XF1JjF739fWiV0fCIReF5HGTB75n4ucRkTudwvSL3yeCcNSC2AHBzSVeRQQDYM14oJSAXtnHUc7Y9Ob19cA9OcuSXCPoXNFii6nUDJXTlS/3vB7baZh+QND+BNlGTHxZGasasKABxycLzRQ+g8jm0mJHBQRmmRpSNkZ4mlq0SoBYpA90YKSufZt34Ry0Fb7Mgj8c7nJaP8QomCCMQJcEkQi6XQQUfveKS/ObR1+5BJKzoxm+Eta7HxP05CHtbIvGacTHT2nKjA8e4I0EwewwHxw7RirFKGQit0C8ssopsrCnrHBdKEWepYZSMo5Q2PHQGETVl5BsvOgTWd3Y8LPPwGpVATiNELtC4vcw3LVIoooA3NYQ+/FxqUfRnywlnQE34olMZ9LG7QpNoeDGDKVhxJueohjz6QaGgqWF9Y+mfQmyuqWjG10jD4Dan6TpG8jtGBZ2Rvt6Jl68Ys0iVAushpOJx/kOna+leMAjTsy454KWJbgvfJgkLcsA/SsyENjB4RpKdRts63nVKBapqyVyqvZ/9In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kU0XhwKdM0I/6bQ1QFGpEbgRHrJ3F0jslb5GfW4zXN+WuRjMq4GQ5oFyeU1gJPov62EwGmNbtkCSFvZ56U2p+w9/xQPQl/iH/zRVAxf0OMBrkCxj6xt69GXSexdjmWw+2dcW/LtvBDhXMm1PKEpgmd5zOOWb/HqIz56atOtxcrDpFw0FfWgwfd+VpUVfmYlT9tygS12LJHQVMlIrfVVvXRUtgC36RKrrvM9UOEwF7HFKBbVCOO6c9RWvWx9wDBwXv6zX1kL54vKHkmL6+xQ2zOukey3iW4WNdO33mvsRksPLKdo0PO6IGMDdGuJfk8fKVK9RjZ5HfVuO0dnkadOMK20hZquvuIBYzL5igNWO/iIxrdg7PAMWnp5Thxs2Km0wVR+SgcV7E71dIGaMUd6tf3Ny9FN/y3mdH2BJE7JCKV+1fQbJv9BytdbglheG088HG3NAerzwvfuitJLAf/V/GKImmRhLfJOXmkR2IQkkX6EoyT3ZjiPfAsitRN1napAwoe4WUoWgC+q+P2VghlVSwy58T1EHK6Pd4VrnlgnMkbrLDgDMNOW3drdSBjXNrsKkBG6oqvSKonx3wxRTjIMn7sWCm8FOBHIpOdW0fcj1YN0PZ13bO6vPzoS673QCp/vjuzQcEbwXrs5o+078zVxAxW27FQqjS5rB4mZq/5iRjBug4/M4T+eG2McOHGCj4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c46852ec-536d-416a-eac6-08dbdec9f2fb X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:11:55.2573 (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: L168qdbHmC6LDhMA1cO1lgFxevYBdRTSEf/cvF1FDJ459aG76JeOKOHNsnPKX5xVxHB0nU32Jx5Oqq3bLi7WaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: iPlBcepEeCYRPBbFn-TWb-pIWO1lUULW X-Proofpoint-GUID: iPlBcepEeCYRPBbFn-TWb-pIWO1lUULW Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with writing metadump to disk into a new function. It also renames metadump initialization, write and release functions to reflect the fact that they work with v1 metadump files. The metadump initialization, write and release functions are now invoked via metadump_ops->init(), metadump_ops->write() and metadump_ops->release() respectively. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 124 +++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index a2ec6ab5..c11503c7 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -153,59 +153,6 @@ print_progress(const char *fmt, ...) metadump.progress_since_warning = true; } -/* - * A complete dump file will have a "zero" entry in the last index block, - * even if the dump is exactly aligned, the last index will be full of - * zeros. If the last index entry is non-zero, the dump is incomplete. - * Correspondingly, the last chunk will have a count < num_indices. - * - * Return 0 for success, -1 for failure. - */ - -static int -write_index(void) -{ - struct xfs_metablock *metablock = metadump.metablock; - /* - * write index block and following data blocks (streaming) - */ - metablock->mb_count = cpu_to_be16(metadump.cur_index); - if (fwrite(metablock, (metadump.cur_index + 1) << BBSHIFT, 1, - metadump.outf) != 1) { - print_warning("error writing to target file"); - return -1; - } - - memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); - metadump.cur_index = 0; - return 0; -} - -/* - * Return 0 for success, -errno for failure. - */ -static int -write_buf_segment( - char *data, - int64_t off, - int len) -{ - int i; - int ret; - - for (i = 0; i < len; i++, off++, data += BBSIZE) { - metadump.block_index[metadump.cur_index] = cpu_to_be64(off); - memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], - data, BBSIZE); - if (++metadump.cur_index == metadump.num_indices) { - ret = write_index(); - if (ret) - return -EIO; - } - } - return 0; -} - /* * we want to preserve the state of the metadata in the dump - whether it is * intact or corrupt, so even if the buffer has a verifier attached to it we @@ -242,15 +189,17 @@ write_buf( /* handle discontiguous buffers */ if (!buf->bbmap) { - ret = write_buf_segment(buf->data, buf->bb, buf->blen); + ret = metadump.mdops->write(buf->typ->typnm, buf->data, buf->bb, + buf->blen); if (ret) return ret; } else { int len = 0; for (i = 0; i < buf->bbmap->nmaps; i++) { - ret = write_buf_segment(buf->data + BBTOB(len), - buf->bbmap->b[i].bm_bn, - buf->bbmap->b[i].bm_len); + ret = metadump.mdops->write(buf->typ->typnm, + buf->data + BBTOB(len), + buf->bbmap->b[i].bm_bn, + buf->bbmap->b[i].bm_len); if (ret) return ret; len += buf->bbmap->b[i].bm_len; @@ -2691,7 +2640,7 @@ done: } static int -init_metadump(void) +init_metadump_v1(void) { metadump.metablock = (xfs_metablock_t *)calloc(BBSIZE + 1, BBSIZE); if (metadump.metablock == NULL) { @@ -2732,12 +2681,61 @@ init_metadump(void) return 0; } +static int +finish_dump_metadump_v1(void) +{ + /* + * write index block and following data blocks (streaming) + */ + metadump.metablock->mb_count = cpu_to_be16(metadump.cur_index); + if (fwrite(metadump.metablock, (metadump.cur_index + 1) << BBSHIFT, 1, + metadump.outf) != 1) { + print_warning("error writing to target file"); + return -1; + } + + memset(metadump.block_index, 0, metadump.num_indices * sizeof(__be64)); + metadump.cur_index = 0; + return 0; +} + +static int +write_metadump_v1( + enum typnm type, + const char *data, + xfs_daddr_t off, + int len) +{ + int i; + int ret; + + for (i = 0; i < len; i++, off++, data += BBSIZE) { + metadump.block_index[metadump.cur_index] = cpu_to_be64(off); + memcpy(&metadump.block_buffer[metadump.cur_index << BBSHIFT], + data, BBSIZE); + if (++metadump.cur_index == metadump.num_indices) { + ret = finish_dump_metadump_v1(); + if (ret) + return -EIO; + } + } + + return 0; +} + static void -release_metadump(void) +release_metadump_v1(void) { free(metadump.metablock); } +static struct metadump_ops metadump1_ops = { + .init = init_metadump_v1, + .write = write_metadump_v1, + .finish_dump = finish_dump_metadump_v1, + .release = release_metadump_v1, +}; + static int metadump_f( int argc, @@ -2874,7 +2872,9 @@ metadump_f( } } - ret = init_metadump(); + metadump.mdops = &metadump1_ops; + + ret = metadump.mdops->init(); if (ret) goto out; @@ -2897,7 +2897,7 @@ metadump_f( /* write the remaining index */ if (!exitcode) - exitcode = write_index() < 0; + exitcode = metadump.mdops->finish_dump() < 0; if (metadump.progress_since_warning) fputc('\n', metadump.stdout_metadump ? stderr : stdout); @@ -2916,7 +2916,7 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - release_metadump(); + metadump.mdops->release(); out: return 0; From patchwork Mon Nov 6 13:10:42 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: 13446915 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 8D0D8C4332F for ; Mon, 6 Nov 2023 13:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbjKFNMM (ORCPT ); Mon, 6 Nov 2023 08:12:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbjKFNMK (ORCPT ); Mon, 6 Nov 2023 08:12:10 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D922100 for ; Mon, 6 Nov 2023 05:12:07 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1uM2024913; Mon, 6 Nov 2023 13:12:04 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=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=eIsabf0KRHPXM5h5xuGG0e4RUYm3q0AYVkCHzLcTCW/ncqlMmPv4XCg1/ABBfm9uUjdZ S2iUbXZeEJfiz/UedrRZV4+bQnPzWBfVwqohpd2pEWyOUtIfVVwrkQwHoVDyDowSQdpE ylGJ0Op74C7HgL3cLmVEsJUfDFbtWrG4Jv+ueF5bgWHEJyOUcE4yK3K5tXUdRL6z0MqA hluB1ReC1BR2JzD55dOQKiK4WAseeyf+up57IhLDC1Cv3i8z7RpZvXPJpFKWKml5RDYE W6LNqiyzBUcTpbzIFHTmIsL/R6HBSUQPizWIslBdy0Y47raOAHyzr5OdbDFKtyTAND5w jw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdty1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:04 +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 3A6C3kJN024830; Mon, 6 Nov 2023 13:12:03 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba5gc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RFm0VBekzPZW/M44njuO9UdLaoj2xoFZhTXGziDlxVu83waDoaWPw8/JOaz+1j8iTMkoJ7yC2kjnvqZsIdhPxhuUrhzKCytIhhqWxoMHyrDGTRvDnAwyHAr9v5pL7oQQe8P85nlvEifSr7h6SXsAqp+yzkYz6OswnCu1qfT0WjvY1aZ2KRolC4JewsROz7ZKHtL32GPPyRYo3j6TM3I0gQKtYNS6mvGFti3URjNRKokxKkr7hRjuvSAbIZB29lynnte/uowZ0i5iKNJNHRWJQcep0HZQh25QsRGmJMnwZ4ZIhkQ6rRKcsV541B1m18UfO7JDVTj98hPl4wGt0HZN9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=HR777c1FyUs2c4nRor8+Mn25KFgrj+M9rM2nf4YaP+SUBd5h+JfzNNwNMP3r0hiHmPjbsBqPz6aJD3bhJTw1/UK/RhUF1f/1lN0qrR3QdSa2o8+sGJCo2JGUPE9x1TPDqBFyJsEBbPWFUJOc3jomNzLmePEVOJxouroIKGod7SfJbpWYDAn7IQ4nEWPgsXv9Z/lAfgZv5NT1As3ZOGLzFpszvN9/F9nMAZJwl1vXgtwb7CM3l9U4EQCZq+4Q0+TemJbAxrQ5rv7B/NQgAztkiQRp+7tuglxGf2YnhMsSwgQVWB42lT9J0qzI4qH2WfgDwBOpi6A1cm0uxdNojyH5AA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I5o91/g7roOyr9+XK0T/OumcpM6f4JRfXcBVBgZT7j4=; b=X9YDXw1F1KMLARF4iLbA3DlbNBhlQJJwEA0OwUnyCPK53dVDQefzgj4wBOEAF054qK15fNI7NeQWNUovPN9VdJDKZt+YuVF81NoG3C7ZGqUBn5xGXpfl0NLyhETQo+Z0N4UaRXbhYecrmDYoKrQ4FveNBoQweVXicMdbX9Y//Fo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:01 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:01 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 09/21] metadump: Rename XFS_MD_MAGIC to XFS_MD_MAGIC_V1 Date: Mon, 6 Nov 2023 18:40:42 +0530 Message-Id: <20231106131054.143419-10-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::17) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 87214041-0641-47d8-9a30-08dbdec9f696 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ymng6xBBtMc2qZkLKFeurU9WSas4036RP8RXJ2/ayimpUFPHy13Fyp8U7WLmSOs9ehfwWGnwxsJ/RFFSlE/HBMPMICcC6s9WRK5sdObeJg6eMqEqWr0Sn5P7AkutRO6AgQjrfurs6UZAEd3n2lYZXjAhUndo1S6V+2bH5WmeWmSauSqXvHhevaNKYj8qHFBchqAF7glpaMtBSzERjMkMpSaTz21gpMUgQlHOUjnofN5PI+Wu9i/ZK6BCn/fFjgr1/dpRn6gFsFQETyEwvRySMSxEWHCEgOPKB9rR+LFavcLZ0j15ZXrNlrGFN6KrTma46ASGx9l/Hi0bltAEpZvedrhxPsNPlPUHFmAYlKQryfXK+W+MZBDehaQYHimqVezGEPsmdNod3tHQXwLkRrE4RPddtpDJyVzYgphOEkXyiuOOv9B7hK+XLmw1vDV50xg/oRESEpf8yFKo4yhBMt+t6mQ5uGbT7DVnVR9E2knTUb/SPltEVgyEzDwOslhUjgEOjkdkz/P+M5jHFtTBR3SAtfbJrFqvafk/sudtCXbit0eR2Y+aZM2mVSZkHNN4JHuv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a4m14aR95tx9RVSQX24UJCXFOlNPKDzDXi+eExT6byqgQDsl4KttGlFswb4Vmj6Pwh72hdnDuXbjNdCojT6R0KSQ5cVtM2AkmJop7N9/km9vw1onw2uHtR8qUrkDCdi5VCUezQfSn3mbzuBMlg/i9cSwOsEboZmDaGrCgz7Q0KedsAwE5/a0pC9Iruya30j9DYTUXv4yKOMvPnwuG++1gz785JlZlmdofCAHT/jiDPxh04WkaI9/U5Koe8U0BYVNt3LZvPW6jmD50uAytOoRu9ucBhY2Xzph0d1iEOUr9MsoU4nK9bojc0gOsI0uhb1zjkYa3Hy17VCLPELlV3puMXfoCQ299VfNhQnxTv5Ghc2rib5btNSqnkwESkFv2iuirZnLMWJuijlSLGqWE5tYcYRBpt8JSEJybNp41Gxi+QAe6NqmqKWi46bAooQ04lwGD72pcUX2KJPBiLiYYw7qk+Y7Tg7Dee4xG4933hLd3iuhXASuuTbL/6sSVzZtuWjBc8WJr/OzSasUA+qOmNsTeLCXarrsvXqU/ouv8SIPspBx/PgJ83hv7H3j7r/CVNi3Jab+/C/dnmAdCyqk/xgsiSXdXAPirUiSbPqiAAsr3NKKluHVjrnfS02rusdTESWU+Sz5s8tItFUeFqSRZJ1Rtot1A8MN2axGP8hdg6Y7YuPbcyaqmFQTzVGb/z4hVaDIN1CnQ5wgV5fOFHh1T2GVMIJB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Hu5PNyoufFI1mYL1eJc0jYjqva44shkqfdg/Kl5a72Hi8kmmbGHY4w99HA6OYZ9nE4pkeDdZRF/X1XOfbcL1jc9Z0l4VaB9XgPuiHDsWwWWdM6JhdQwXYw0nVKe759mNLLfXUpopiQEoqmliYg6FiKEk/BC2gdIvaw7pTz3cLdD93v9fzdjElQto8xs5HK2bdEhaU+2OplSiOfFUUI+Gbq3ZM0QjDtwbpDBXgdESogq+fcnO8OaIDLpen4BrQL/JbLBX9Y/TTJS4YhL3FjNwtQOpovOJdCJoeTYxwNbfOBYf0FpQbdhkkdIGXRfO4lT0Mv9JKz6EEfmvSUeb5u2p9uFw6uATWzGx+ue0PhCZB9BFV/kv4qO019cOCpX0WScPvxtv2yanZF/JWKDk6HctoxVrgzAE9YOyWzZL5vsjh2xlaxzHiIVjcj97MzGsP2lsKZ0f7J9sVosJ7Fr7aX07UrM3IEwGT9ziYadU556DFpwADEyIJBz/KUOefz0O9T3PTbykFSuEfFdeywR7UeD+72OovBbIPCY8DLTUuImESSGpNEBJpsQYHnbFwxYbTqtRo6PTmmZCR5OQXam1XntYAZsSS2brFxkQ3lVR58D/O0d3jaQMkeIdJ2mCBoTfsCq41JJDqFWqU7QlOx0+Q4mnI7PY1H2wV9cDw3mk+RI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87214041-0641-47d8-9a30-08dbdec9f696 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:01.2840 (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: VKtDltdX5xUdRwTVsyDjOBufBTAtRpYo2Hv/1EVU8zJnR0jDZ/3Ot9TLUA2yStMugqC1Y1KpnlgGVcqtalEPEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: TnZhfvW1NGZXS_1SuCfMeiN5LZ3SMpDi X-Proofpoint-GUID: TnZhfvW1NGZXS_1SuCfMeiN5LZ3SMpDi Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 2 +- include/xfs_metadump.h | 2 +- mdrestore/xfs_mdrestore.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index c11503c7..bc203893 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2648,7 +2648,7 @@ init_metadump_v1(void) return -1; } metadump.metablock->mb_blocklog = BBSHIFT; - metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC); + metadump.metablock->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); /* Set flags about state of metadump */ metadump.metablock->mb_info = XFS_METADUMP_INFO_FLAGS; diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index fbd99023..a4dca25c 100644 --- a/include/xfs_metadump.h +++ b/include/xfs_metadump.h @@ -7,7 +7,7 @@ #ifndef _XFS_METADUMP_H_ #define _XFS_METADUMP_H_ -#define XFS_MD_MAGIC 0x5846534d /* 'XFSM' */ +#define XFS_MD_MAGIC_V1 0x5846534d /* 'XFSM' */ typedef struct xfs_metablock { __be32 mb_magic; diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 333282ed..481dd00c 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -240,7 +240,7 @@ main( if (fread(&mb, sizeof(mb), 1, src_f) != 1) fatal("error reading from metadump file\n"); - if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC)) + if (mb.mb_magic != cpu_to_be32(XFS_MD_MAGIC_V1)) fatal("specified file is not a metadata dump\n"); if (show_info) { From patchwork Mon Nov 6 13:10:43 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: 13446916 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 822C7C4167D for ; Mon, 6 Nov 2023 13:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232127AbjKFNMS (ORCPT ); Mon, 6 Nov 2023 08:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbjKFNMO (ORCPT ); Mon, 6 Nov 2023 08:12:14 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840D6134 for ; Mon, 6 Nov 2023 05:12:11 -0800 (PST) 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 3A6D264Z011546; Mon, 6 Nov 2023 13:12: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=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=r4lV6I51NH5J8Y4YolGBxmU/s+xid3h+XM7kawV5woiHEXjFuN+YW5nuHljVYOYbW3MN bmDslDJMS5ngYv0hriQLhTfcCoU+yN1xah307BwK0pXERcEUJ6JFgxLZkEZ67yIc8K9g yKW07Hm4FTWsLsjCySg/L1q38oFYVRxMbBJ4G10rDoGx9MQmsp7z3X6jlQeZ3UPSCDGg WcvSMAm8a5M2FeAg06eBVJTpQ1h7lfCZwOgAXwaDhdABRPxHQOY8SaDDp3+tzykbMoVd mGOKHimBTWylg7tOftkIUN7vM4WYq3jiZXUKSxi4SgOWYGJluJuYhujj3TIMl67uwP0r IQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cj2u01c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:08 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6CiaFM023587; Mon, 6 Nov 2023 13:12:08 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tbau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dLtsSEsWY12ykg78/xzdMuWYb9xNRzniRUKdLNYnz1bH/dCy9EVmYz3ZVSaa80G+tigYukhjp4oMxhWYOVpcHDqt9vmhudauYqEwPBywVR25wsz1HYwYG76wH3pW/yFHpsSA2O02/146wZN1MbTB7Z5L/Xd3KjRrrU5ofm2r/g6FCRJh/8BDB6TYWt7QsMhhSrGgHcGNumNGUurAEDZZ0rWkTViUrffsJ/h86CSvzOGqju3hCjEY6hYh4ALtn5uU1ZsKmSw7s2oezf0HMOgoom48JZL70Hp4JkbTZFsrjbw3qX+z1qjyc9p9BbQ7x0jWkxU28bvu7b8xD5YG8hoUqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=etQPZkL/r0UmdsIM0hUG1fQgitzEi8QydUDZXSZnSHkp2ujUHwlfcA0zA/ezDDNWP4r35c2YL96UxGU1BO/FdJpietj7HI0JEXbicqgz8K4eey2K5ExDtdt3FBoktI0XxLAwEqNqFmEnXLxec/sJm7SrxROTiJHUtRD28DXnD2ACu8rPItS7jy90n+85rmBnJFdj1SCKNfTh9BPX7kIWi+jcbzEtR8yQQMgNksafoe12BzOByTZusWUIx9vp9vVpMWkvxvbIU3TztrsjosIILWY8LH3o6HDsWC1+qD8AyKGlk1vI+M7cWZ+UH07AGNFuqIb7fY8LBadx2JrxfOVMug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dXWGwBKOi/IjEjIn3QLJ0Qfk0SqwnjsNke14A7fAt0Q=; b=ORGIdRL90ud/1FHILJcSu0Zs4Hg+2e814fwloMNmlSbq1YRLMAhdml2ZvTk9/iosDLRZDknuJhAB6KCLvjA/JXEw3Tz1xdtoPjgtvFaSy0EmM+xfIuvp18FyJnESlIFw9Q3kk2bjDH/RyXTqkjcsyjDLJccDaHt0pHmHZStYrRo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:06 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:06 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 10/21] metadump: Define metadump v2 ondisk format structures and macros Date: Mon, 6 Nov 2023 18:40:43 +0530 Message-Id: <20231106131054.143419-11-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR01CA0192.apcprd01.prod.exchangelabs.com (2603:1096:4:189::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: 28fba699-25e8-4fcf-6594-08dbdec9f96b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9XYar4wQHx6VB+4AUTo6U4JLMEU9KgKtOwIUBj++N9CmaOEK+ZPO8IhZChQyGQNjyVv6VnhhUUV2OvcH+5SP0o9DPf2R4SUV8qgYBiv43OP60QsWXkuP2n6EBPKf1u83aiLF24/0lrFWoHZ/YhshLuJb0zeDbxbWK2EElm0UPTdvv0K7hsbUkD+fWvAkrp8OM98DOVM0ES4mZBha8paZBS1DwzMH77K/UlSEfrCP2fVHp1vENAgwadmeFjgcxXMYXyBy5NgyofrJraph2cjBDss6A9jZu9p9mDiBmATzGjweLzBikx9JY8G2AJSrRWvl+g0CBxquigxFffaMFABdQAuxUg6oBp3kzi3aRNYUtjm664vrWgmraCWcw6VdSV5JVHqFBfXCfkdX1JVFF90VIALK4/gL+L6BkZ+BkoeJJm5ODA6lsLVd62P/PCV8Fc1s1AqViJwPJSGG6Xgb/l/sc9zcSQ46gInAN7SAGvBtocqRgS5gC090T6CdIEqDNV2tSiT7aLaemUMcK8jATLWQJ0r0xelGt7rQRKo/wACoFA6riYkftFIk6Ov0olaMULKDARCJQI7tTSYOqImPc064+Et65kkazSqoq8Sdr+sf7d0E/Yvcnb1gIMHzWqDgHYKr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(66899024)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS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6xdCh5RywbBGY2U1g/qpwXzYsr5KyUBpC1bj92o8FSG5/UTHTTAi7QHYmKgY6jWbvRrCZczOObXVZs0IsHBRwKxtwZjolEHS1WK98sMc7a0ibAO/KxJatf1GMcdA88LkCPVsb45eV6owPEG8cf+HkoiHJM/mt20sAZchZWAWexKZWMemfEjbXJhq8qtvLHwr/ZYUPPJfFtlVieJyFjgUu0bTwAGZYP0gWZiURPPU0jncOK1fk8+26EYvcjGZk9Z+l2h/if8JZJE0kuDfFnr58O/vr8zM7iBEfRxUX7JHtTCr1vJItSkgq4qVsvlygU1bzZfvHJ3gvcnJU5yFRvIxZ1nIgNOb23vJEDBgQOatT4hDPqc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28fba699-25e8-4fcf-6594-08dbdec9f96b X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:06.0279 (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: L9zEVd8HGMRQ7LR1lq4XW4cUWBno1O7RGDCCY7yrDhlivPMwkr2V5sdThHPuNHCA3sPlSmYBzd7aOh9sybLgyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: 5rUx5Dev_YJ7SlxY3SwWWDHLlVdx1p2n X-Proofpoint-GUID: 5rUx5Dev_YJ7SlxY3SwWWDHLlVdx1p2n Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The corresponding metadump file's disk layout is as shown below, |------------------------------| | struct xfs_metadump_header | |------------------------------| | struct xfs_meta_extent 0 | | Extent 0's data | | struct xfs_meta_extent 1 | | Extent 1's data | | ... | | struct xfs_meta_extent (n-1) | | Extent (n-1)'s data | |------------------------------| The "struct xfs_metadump_header" is followed by alternating series of "struct xfs_meta_extent" and the extent itself. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- include/xfs_metadump.h | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/xfs_metadump.h b/include/xfs_metadump.h index a4dca25c..e9c3dcb8 100644 --- a/include/xfs_metadump.h +++ b/include/xfs_metadump.h @@ -8,7 +8,9 @@ #define _XFS_METADUMP_H_ #define XFS_MD_MAGIC_V1 0x5846534d /* 'XFSM' */ +#define XFS_MD_MAGIC_V2 0x584D4432 /* 'XMD2' */ +/* Metadump v1 */ typedef struct xfs_metablock { __be32 mb_magic; __be16 mb_count; @@ -23,4 +25,70 @@ typedef struct xfs_metablock { #define XFS_METADUMP_FULLBLOCKS (1 << 2) #define XFS_METADUMP_DIRTYLOG (1 << 3) +/* + * Metadump v2 + * + * The following diagram depicts the ondisk layout of the metadump v2 format. + * + * |------------------------------| + * | struct xfs_metadump_header | + * |------------------------------| + * | struct xfs_meta_extent 0 | + * | Extent 0's data | + * | struct xfs_meta_extent 1 | + * | Extent 1's data | + * | ... | + * | struct xfs_meta_extent (n-1) | + * | Extent (n-1)'s data | + * |------------------------------| + * + * The "struct xfs_metadump_header" is followed by alternating series of "struct + * xfs_meta_extent" and the extent itself. + */ +struct xfs_metadump_header { + __be32 xmh_magic; + __be32 xmh_version; + __be32 xmh_compat_flags; + __be32 xmh_incompat_flags; + __be64 xmh_reserved; +} __packed; + +/* + * User-supplied directory entry and extended attribute names have been + * obscured, and extended attribute values are zeroed to protect privacy. + */ +#define XFS_MD2_COMPAT_OBFUSCATED (1 << 0) + +/* Full blocks have been dumped. */ +#define XFS_MD2_COMPAT_FULLBLOCKS (1 << 1) + +/* Log was dirty. */ +#define XFS_MD2_COMPAT_DIRTYLOG (1 << 2) + +/* Dump contains external log contents. */ +#define XFS_MD2_COMPAT_EXTERNALLOG (1 << 3) + +struct xfs_meta_extent { + /* + * Lowest 54 bits are used to store 512 byte addresses. + * Next 2 bits is used for indicating the device. + * 00 - Data device + * 01 - External log + */ + __be64 xme_addr; + /* In units of 512 byte blocks */ + __be32 xme_len; +} __packed; + +#define XME_ADDR_DEVICE_SHIFT 54 + +#define XME_ADDR_DADDR_MASK ((1ULL << XME_ADDR_DEVICE_SHIFT) - 1) + +/* Extent was copied from the data device */ +#define XME_ADDR_DATA_DEVICE (0ULL << XME_ADDR_DEVICE_SHIFT) +/* Extent was copied from the log device */ +#define XME_ADDR_LOG_DEVICE (1ULL << XME_ADDR_DEVICE_SHIFT) + +#define XME_ADDR_DEVICE_MASK (3ULL << XME_ADDR_DEVICE_SHIFT) + #endif /* _XFS_METADUMP_H_ */ From patchwork Mon Nov 6 13:10:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446917 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 D0085C4167B for ; Mon, 6 Nov 2023 13:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbjKFNMW (ORCPT ); Mon, 6 Nov 2023 08:12:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232097AbjKFNMU (ORCPT ); Mon, 6 Nov 2023 08:12:20 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9959EA for ; Mon, 6 Nov 2023 05:12:17 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1uvn024922; Mon, 6 Nov 2023 13:12: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=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=orZbNJ0RSrG2VJy64L7XjI4NkHqZMKdPG+FQ92mLLbxJGtplVLEpzS4r2WoilHSweeex M8QGcthH4XmcKpZGoHdLQ272hD6iINA9zq4kFF1xknyclr4qIEDPA1hQVOAHKIMvmxHz jykiVllkZ5SiFoi1A1vUWjpSqopeYsovFGjKcmcRqd5qRsD5zibGeosw7T9h2wEBX+J+ FBkQEup1NcPzfIrLzbSl6wpEJ7aq3XUGJVL9fTbfpxRgGov5qTjFkirT0NWFIm0w2kec brggc2Xb28kIB9ReC0fxyR8BVnuAL//ClUT9HZ3rhV5nIDKUAFa2jvCW7jTo9wCYpsXW Yw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdty29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:14 +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 3A6C46c3020427; Mon, 6 Nov 2023 13:12:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdbacq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=asXSjr6XTbU4RwtLb8UrwhS73ijrDpAuo+Ihgk/miun/VJYTpNSmiyC17ikd84X8YUGOH0ulKZLz9NG7EBL4n6D5h2ddtLTIXHxfuJsEHbQ/NOKyrSfaZjtlN+PFDzF7nmZJ1J5h0rq83FEV1+s96VrLZHfbtolBNY+8DcPnJ5CCNo+tw+fRDZPvWkjTrsHQVdJ3T/yo8DIeCC0pUmN/H/8J4Dltv+rx3HvdVI6j/gBLUfLGriylS0bu6MuROJn6x89z+VZ13ERo0rZhC0pIg8lNfQdrGn6ZLaVtwjx5UXIA8sPloaG5oKVFzL4Evj3FvOcd3Z4GvDWNMK1o0nGQuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=PoSCVZiNNz0BOn6s7HrNWYbpcz2AF3RxxuLxXSbdJlqjfIc+HKm+J3vBcVqF9H5LAMIOFIeWKzurl4l4zPjxa49AzZ70Z5n/4stBPHTmojhsxGzhRsh39KZcnG0Skg53MsYfddClrWWsi/hT1NxNPaCwJGeJmDJxS90Di4yiiQIZmHLmFdaRt2pYvdAWb0DtiAGD694arpGAbbY0iMVacEe520e5vG21FP6d1hkk14Ot6dABUUMK22kDXTqd8QdQfyHkVDFjgGymohvGbnBTp+ZSdls86tx6BsW5nnc3AFkUmgM24UkwILQLHvbh7TX9ZyGMN1iQ7P/oJM3lbzVA0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/KP32ZJg7SDQdPTH1tDHHHVFET+KgjOaSgavp0Oa2D8=; b=CQYjqT0nZXpOkPIFSr/Ukf9dY+WhH8lrjO2YyrDYHei03DXP+kPXA89FImnWm1cr2wjrpKT9tMEgwOn7QhFV1xLUH2CFu3q2Q9aGajLKTo6RG85RB6adGRQyN7awwChNMJclc5J6RhiEFvAVywwfdaz+GPcsTkECbaVVQ63KYsU= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:12 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:11 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 11/21] metadump: Define metadump ops for v2 format Date: Mon, 6 Nov 2023 18:40:44 +0530 Message-Id: <20231106131054.143419-12-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR02CA0083.apcprd02.prod.outlook.com (2603:1096:4:90::23) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: c404922c-76ef-4eef-164d-08dbdec9fce7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5gRwrrokzKRzBzt9JHSooaqFm+1HyIX95cJuG11/k/uKHy3ngTkqnTkbZJTwFktqKrf9Fa4l5vi9ReadXFwKzOBMFtHtpEqB4ju5OA7rtQN8BrxZmRzQX4SOwf3EI0Hj7WyTwxLWK28D9a0YPF4YNbkbcCXxIZZ/Jyg4ttT/wljL3RVv5V080KhNNz81WrHIBdAv7aPXmrMVPB/G90Am+8mTZABT/M9a0EKwRRt5GgyVcNf2jy20hGeHHN/vOnPnCcjkrGzgh8/RL227hwpjTo6bJ9ArM4093VzwszDssogWWO3JaJp609BKU01KqjIVPZhv5+CCcH+EXg8FnldE+TMhLoHb+7kAkTI8x7kMxNCdScksyI413s8hALLrLJxMbOBfnfBI2xQ19Rg1YP083LvcqQofksS05cd+AzJM8zeLuxUXLQ625OG7tgghqyBhM5KXG+SJH/6VQOOje2mhZm6q2TasuPDynkRCpgIhowv9xx5aEY4shP+nvCD1FaZkT2/IxdUjGyFqJzgjcrge55UoMFGmTJwlzGrguTBWR9azJILjELzaZf1+OIGUQyN0Wk4VZJ0XV1zMaPqX6hYkSfD0y4Kq9Jj/3+NNnY80uNxbGNaeiKa1TLAsI2wlxA8L X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TTXVMcmfPx/qDS9johnZpuUxgs2sOf9aGp/AsJ+CaL560oWYil8ho+ROGaXUdajDISdb3a6XBJFf2c/CdTeoWNFFvQ1HHK2I7HRD787vlAPnY/W7hg5u/+qOpmlVRNeSU8XXGCebaDeDRC/G8xbd/zz8I3Ag643WmHGR2RaYFzUIDn8XT+BxVqGrZh6XYDSaGDVlcdtac3whj2aFV4nWk3Gmkniarn0q6Yl3C2XOzMXyyjXwU1Sgpqf4cIizs52jENHcAJzIHyInmQuaj+NU+Pa8U13Zhn7+Crt6+GDyioLhs2aPPwAv9uQegoSffclv+KZX1aLXCf0UJRmhPtIr3IyCHWoSMGdvjBd4mZ1bP9HBvtjydbb+iyMlSdQXJdXwkfLesV83pFBeXROBQ95ugjugpqTNq88gYzwklTYAj9airitEj05E9vOpvxt/VIIA8KFdUKbnbGeYxbAErl6CSnho6nNqTSLrm2EL0YekPh6BprXY+bbGy1xBrcH3z3/nX2v9KQP1j+oZG1Qp/m8V59y4nbilFem3t/08kzhtMbCOSejBt4kRk+C3/IAv+qZcTPVFLJvUSlrNZleINPR2Vh27+O3wN4AVf9kafqPSg0yrE4y7zArX+6TM1B9dLVY3OPu6eTpJJl5D+nLxsMD33lXurlUnrC6ZttKuz8E/vzpY0qVbOF07VAX0KDjEdZgy6juaFklY0xtt5riA3hgyCMuSF+g0Jo4NgFJaEkK37HeEr5zNYyLQ1pp4hQ4dUAfxuPeUN4tqV8etgnuZC+X4NYPmQIz+G7qxS5NxTu+zdhw2Ciipof5KFPoIt6/MTJ2pfuL6n8A0k2nwcsE0PF54iLsQNTIDoJ6LcOpUrObg2ng9Ad4gSXm2ymkL+DtsF5oeySStmgtq+EkRvcL4JSQepq7SknKotgnLah7s5SCgp62IaD09hdJcB/dyKlQusY4OHo/cXFzzP4EpYTe4JsywvI8NDgruaiXwK8O9hnnEEzFfwYUMyWDj5igHnAwVjsssQVRMhaCUrsI+507xEodqso3H6+cAvMQTv8V0WWaTvoJx28inM9ysTFSGVR24pmzS8hG9w8hMKO2ZwPp+Q3R3nuUsB2BlNGpKMNhD3fTriF34tX5S0trS11DfqUMh4o13rzZ3IIAeiolfOfvyq3XxQcRun1iDEmkty7oFmCUesjp6eOIERmRQ8601gmmmT0RgiKwLNOhFttC4sn4avQDwJyM9Q6YdRVBfmdokzi0UiRUur8e98cfOnsS59OsBIV/AXKxfR4nR5mZT+87JQuqb1uowm+N152jeEeZrq22csFq0KWXcdV3SrAjgU+tFowAPSejIO/DarwyVwag0yLefFAoFcWCoHabYi6yTQBDRagJua/NNyh8QjaQfFB3nlApIfZca9GHICoLIwdGVEk6SsdIzBkQX7rOciklwSmFQJQwxshA4w8C8/Kart5vZuiYbyio0sb/eQRAHkYhI+LU4R5T+U+ym54DSWV0L6vprrbLO4ctYqu8rkGYd0woC404rFZ+upToaBHh3tGcck1vbWdCf1L5MZvfzIuyf5Sv5WteF1shzbgklkSTIXBjPz2YYBjQs+GFtmFk6GY+wpCbhGw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 6pE5m1dDaS30S6/tXiocX1xNoN1QnNk7cpmcM6IcfHgun6GfxatV8icF4K8exW4gAzy299YWWAsYAjI0eBvCmf2A7WXyh4g2JyABUvp4d2FNZDXLEaDoxfVssxdEWuSyJAF8SocIVeElm7EpPpZtUkNHy0Mmllf0e412g1KFR48iAM699T0AytBjNHb75FC+2z84uwdsfcK1h2F40aV1pgDHIiVfXKcLs7PkAuTW8OZFmcn2Gnv48hQYD3wgyTACE9wB0mavQNf5f4PXNSinhsoiOtfI0jRwPvaW5hDR/4cHlzG1SxjUkzCz5jrGTc0pti61OJNNiPLaEMxl7OKzM3/FnDZlitDEbgTiknpWfWgI0EbuHpA/bzGemttLK8sF4e0371wKDRRv4kvejNM4upHoCyuIGzxAHB3B/nBx/O1GtVtCLoU5O2MWOIKJqlYGmxaSixOVWl8L014mDqnd3kpzjf50eEQa0TH33H6vCx0rRQP5b0cMdCqaCGGFD6uTNYjBLaLstG9RIpRSpWOre6O+sgF0XjFiT56jwKLV730BMh/N77mdkH9k/7+VTT6C13F5aakDDg6CFjor7lEgWcappHFBUBjdsoXP/iMU5Dx/76k9pc0ZdXcIbi9Ld3bI7xxL+jhsGJjN3++i5wr7m6DPqOB/yh2tXe83QvWeVkJMtV6e05quXeWKcb57pOx/Duxh+MXpW/fMOXF4a58Yjh8b1JVeMV60w8EwzdXxU9bMJErIjYzmiRWa+UO+McUb3UDlqWObhGBQO9KvrmMRobYXqHPP4nqoh9udw2NIWbk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c404922c-76ef-4eef-164d-08dbdec9fce7 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:11.9133 (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: 1oUboKjAU5aBDH+xfFhiCj3CoRR1C/6p1XG7uhO9LjTuNscFiyP7r81aroW7v6DR58CX6Qnp1VSahkjTk+G/Kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: iLFK3hPj2yS-0l-qWDjx_Gt3oRZMwjsJ X-Proofpoint-GUID: iLFK3hPj2yS-0l-qWDjx_Gt3oRZMwjsJ Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to dump metadata from an XFS filesystem in newly introduced v2 format. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/metadump.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/db/metadump.c b/db/metadump.c index bc203893..81023cf1 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2736,6 +2736,70 @@ static struct metadump_ops metadump1_ops = { .release = release_metadump_v1, }; +static int +init_metadump_v2(void) +{ + struct xfs_metadump_header xmh = {0}; + uint32_t compat_flags = 0; + + xmh.xmh_magic = cpu_to_be32(XFS_MD_MAGIC_V2); + xmh.xmh_version = cpu_to_be32(2); + + if (metadump.obfuscate) + compat_flags |= XFS_MD2_COMPAT_OBFUSCATED; + if (!metadump.zero_stale_data) + compat_flags |= XFS_MD2_COMPAT_FULLBLOCKS; + if (metadump.dirty_log) + compat_flags |= XFS_MD2_COMPAT_DIRTYLOG; + + xmh.xmh_compat_flags = cpu_to_be32(compat_flags); + + if (fwrite(&xmh, sizeof(xmh), 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -1; + } + + return 0; +} + +static int +write_metadump_v2( + enum typnm type, + const char *data, + xfs_daddr_t off, + int len) +{ + struct xfs_meta_extent xme; + uint64_t addr; + + addr = off; + if (type == TYP_LOG && + mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) + addr |= XME_ADDR_LOG_DEVICE; + else + addr |= XME_ADDR_DATA_DEVICE; + + xme.xme_addr = cpu_to_be64(addr); + xme.xme_len = cpu_to_be32(len); + + if (fwrite(&xme, sizeof(xme), 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -EIO; + } + + if (fwrite(data, len << BBSHIFT, 1, metadump.outf) != 1) { + print_warning("error writing to target file"); + return -EIO; + } + + return 0; +} + +static struct metadump_ops metadump2_ops = { + .init = init_metadump_v2, + .write = write_metadump_v2, +}; + static int metadump_f( int argc, @@ -2872,7 +2936,10 @@ metadump_f( } } - metadump.mdops = &metadump1_ops; + if (metadump.version == 1) + metadump.mdops = &metadump1_ops; + else + metadump.mdops = &metadump2_ops; ret = metadump.mdops->init(); if (ret) @@ -2896,7 +2963,7 @@ metadump_f( exitcode = !copy_log(); /* write the remaining index */ - if (!exitcode) + if (!exitcode && metadump.mdops->finish_dump) exitcode = metadump.mdops->finish_dump() < 0; if (metadump.progress_since_warning) @@ -2916,7 +2983,8 @@ metadump_f( while (iocur_sp > start_iocur_sp) pop_cur(); - metadump.mdops->release(); + if (metadump.mdops->release) + metadump.mdops->release(); out: return 0; From patchwork Mon Nov 6 13:10:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446918 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 6057BC4332F for ; Mon, 6 Nov 2023 13:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjKFNM2 (ORCPT ); Mon, 6 Nov 2023 08:12:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbjKFNM1 (ORCPT ); Mon, 6 Nov 2023 08:12:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0D1EA for ; Mon, 6 Nov 2023 05:12:24 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D28Xd002119; Mon, 6 Nov 2023 13:12:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=Acxx4c9uXB6zMq3dOB9nfcOAnkzMLGm1ugI1L99kc0tSrl/mrPWPOHPJrbaJn1xEU05d 1V0gs4AFKOYUXNkLkRcB+gbjjuwjjkDCE4oDRPEjqQJM//bTdB6tQe2kqWSQPBwm+bOq ibeX6gIWD4qo2Z3BD/eB6xMlhx97r01ShKBjzeQVKXBsH5MqGj0aWhH89ScDK+AskRUl kdLNmc0lHxDW5K2FqjfXNqf5CKrgTFH+OBcxYwDbJ3IkK//Ct4O9UBl6Kxb02u6bkoKA f9si1n0jMvlESZ5We5N2aQPvSKepvMFXsFz/+rvd3PbFm/LjWNvUp/yh3laCnNvaAG2l /A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5dub2x7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:21 +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 3A6DARGN023579; Mon, 6 Nov 2023 13:12:20 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tc5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jPDKGS6o7TJehXM7+J4EkB5zrXC2YIK6sMbYomJi8MC1BjM+Uid/g/X0oKkMUYV6nl2nSmTj5en49F55qem4anXbdFf2n3/NVaLuyyt2GKVaIP2muLKq02C65n1Oh3zHAutgWAeoQNVnfIKmC8PJEJRgWODFdUPGkgvrOyCSLqn84FRjh6lbPSjpLPJuQ6ksrhSdTmwO1AlnU8h7iZQji7N6ckhlW6s+5CtwoZgDyF+xfNEd7r7Hkh1V7FkhpxN+u/PAOJoNPZvzK2uun3JT/fU5xfkpf37ThRUfsGTJuOR6BVP+SBhhXkZmqQpE2iXT3VALHZZbxIYDQgpLEU3JHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=GJM0/DOwSwtvL97fQra+rIIpO98yUCfSJevVC3wRao34e3+FAuTwQ+UE+FUaYzYBJ8o5U5/+b3wljun1PhaweAQFhnNQZgeu2e6SRJPBWpdVmAs3KGnWz6mcsaBIP9M6yR3hFadm33zlOLIa/bwCV4GQehR9ZELIxm0CTI6/5dz3Y02H7+Fg80s46zchrVXqd60iZKU2rXElVDOvU5mTBfOEQiCzJzE0/0ThP9dBpLz1nAH57M71Kq2qDkNHTq03NDOMVy40RHlwSRPsonN/Z44kFY1hzq90vR3JGhKOBsycN6UBEyLAF4VZqPTxpnsFCX2I8TAawXRyY67bRXjByA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TIIT5iWYXUdP6+gBKlVmMeZLeNQuOUyWfCTqol6iMXw=; b=lFRYg7/QkY5JOwy3KRVC2rL2rqDrfQ15tF04N4j8H/d1AOSOafVLk6+ASMqGgM3+WG28V4SxsrHO1E4v+F4JrrpTbVwMe07SiLVQ7IGpItBYbwvSfZfFSRLr3YGZTvVSX5N/w3cSJFGHwpPUFUfJ6s1bCBKjPFyX3wLbtxvlz5k= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by MW4PR10MB6534.namprd10.prod.outlook.com (2603:10b6:303:224::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:18 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:18 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 12/21] xfs_db: Add support to read from external log device Date: Mon, 6 Nov 2023 18:40:45 +0530 Message-Id: <20231106131054.143419-13-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR02CA0127.apcprd02.prod.outlook.com (2603:1096:4:188::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_|MW4PR10MB6534:EE_ X-MS-Office365-Filtering-Correlation-Id: d6c96c74-d4a8-4603-b29e-08dbdeca006e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E3E50HfbI8c5wvOR+YMqui3Es17ymB46J8OOPTv744SVAWTxaMQB98OCTYNuD2gU0c61oKKMHfyci34HnfTjpSVEqe/rd2wa7EsQrSGqYGeseiyTz3JFHiYjYd+AVDcCOen3smJALeCYKuHxX1JQ/F/HfUClE33p1A5DXHhA3DWXJ2MY4puKOMInBA9TcjCPw1/OgoiEFFidXcj556jegbzitx+xYXWyIALv6D1UHpXQutz6zqq7L61mYiDpVVouTTX2qoF7qHKB0Mj/2Ehxbts3cK6M1muXPQ4rWE1xuekmJN7p6f89x+PlcbQ9SQ0oRu8dMONM6C1eV/mwuWHoEavenfoMSL3ETKcWfU6R4HLEie2N3Plwbk5IdYTZX/vaqtwHJH5me0UEv9KMnSSDd9DVIKDIbr2wq7B/GAt6VAAi6o9MLl8F+Dy0bfYwHv++vKiPp/0swezWVP/hM1M8H3c8KGXqoU0ANIqq3Hg9PW4BLhnauSCbpekQwGSnne2gFUOBEc9VedXMhN/kG0fNBy5DIkcOH2UFwmDN4XZpk92lnjvKhGObEWLhis9ym7QPgJ3h8h52oAm2P1tJdR3QU64vVLQvAq+bXlwGLFg9nog0uVB+rR9HPTqTjY3b+G1B X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(39860400002)(376002)(366004)(230173577357003)(230273577357003)(230922051799003)(1800799009)(64100799003)(451199024)(186009)(2616005)(6512007)(1076003)(26005)(478600001)(6486002)(5660300002)(8936002)(36756003)(4326008)(8676002)(41300700001)(86362001)(2906002)(66556008)(66476007)(6916009)(66946007)(316002)(6666004)(6506007)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DPzcYnmCezf6C5Ad9VbjKJV/3g8AqHN2PizGPdve/sfHSCKVPGy4ZonXW9o7wi8TUWrj2MlnrHOzB/igkli8RAa3r1WGpKDnl/a1txDYTr4TmKqNgmGheUncdHi9BOfJkelUCBU3D6EZl2LuM93Fx3+rPGBSfydzOoyK57zIwPXakkZ0pcwBhPLjbPHJgqW0JUy52LaXhH+954///SzL7w/UqsfQ4S2Qd1io2wL8Rph/rPSHAM5pes1jO987UMMnMGFq5wz3ukB5e+tcbMLfzk0KhJ6pZelv44ecnB6+21jqJ/Nl91fXWspJIumPwN70b0iIgF2MlOUu/M+GJEBQRr8eXaLBjBIlory0GOdCj+lKMhmUPcnqHsUjWIj5XUjAimszH6XXoRsy+lOLD6uS8iGAeWMgY5/uP6MuvWIhpylupMkcF9ibJPZ/8VeLDWKn2KVZZdwFkk9RoVZKq1p0Ie7QqWYT709T8/I+Mg0FipOtclOMYRhrk6gWH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Ft8k7JeoHzGN2PDdkRdpUlzg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ae8nS7JwHcYs7cMWCRVu2rA99Jb/1JHDgAUqh171QIu2OCB2fyTM7/96Oo9PCDAumPrDw/lqXON+jb5aV6PhepRlf0GhlDXITkc0NdgPCce/b9nzoLprKuM4CBpBvp0ypgHAofSFbzXaf4D11gQwzClUyL7w1Ag+smgA4E/pTJXVEsuKLEgXD1YkpvCeYBNMeByuZU9CRVmtpFIINOvyX9blqVH3rGSk+ly7UWAXFMr7bk9CGmeL9n+JVlMVlGlsSVyOLrQHU26GpAIfGDKTD6HLhn7mkw5UX0r3iTeJte3oiUbB7HVVzlk9qFyS9/vLSsDJ3fT6iPuWxFRxns/FPHnqexXIr0lDNYZSsgX5N/mRM0AOlTS3EY6YthbP+E6ut4wxHctx0QvQkWb1CsP1Gcp8At3WCmVyA9DbDnLI4L1lAcUzbeLi/IP1pJW2X/p/iK7FYgEg6iKStWsMUyXSBRkAdkJqtKQdB0MqpAZ8a58mn2jfYhlE+/sM6Ih50DuGuCuCb2k02fuavkuSuqP8sqIm4oDkei1UFhbBB9VHU0FEZ4+MEKXmiQTV6WabahVbuCInx0YHJxk1ScNWXB1Hm0gw5CJmDyh1/eiwodWrexXdT7xFP7JMGJim3X0gnRIlbR7K8dleZuGjI1Jm5NrMNw9pZJ3At+xcRW4Gh9dWIsZECwA85pVs2TPVr3RJfFy3rUECepDNnD5o3UF8rBgaCe26xocY9hDft8gsF6oL4AyO+WkSJbr75xA0L3m1muAZGPjSspm3PCTCvjRUKOGc9umCSXemYSEk5QeHqDGkTu4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6c96c74-d4a8-4603-b29e-08dbdeca006e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:18.1539 (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: 0uTIT6hGj85blxzwhivnWf4rR5LVEWJFW8p7N35gDipqFpKp9iPrc/shYTumIPJluIiidf0vF9Whk2oO68Nbfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6534 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: AYXbaMNg2n5btpTUo3vPC0gA90VfQJR- X-Proofpoint-ORIG-GUID: AYXbaMNg2n5btpTUo3vPC0gA90VfQJR- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit introduces a new function set_log_cur() allowing xfs_db to read from an external log device. This is required by a future commit which will add the ability to dump metadata from external log devices. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- db/io.c | 56 +++++++++++++++++++++------- db/io.h | 2 + db/metadump.c | 81 +++++++++++++++++++++++++++++++++++------ db/xfs_metadump.sh | 3 +- man/man8/xfs_metadump.8 | 14 +++++++ 5 files changed, 131 insertions(+), 25 deletions(-) diff --git a/db/io.c b/db/io.c index 3d257236..5ccfe3b5 100644 --- a/db/io.c +++ b/db/io.c @@ -508,18 +508,19 @@ write_cur(void) } -void -set_cur( - const typ_t *type, - xfs_daddr_t blknum, - int len, - int ring_flag, - bbmap_t *bbmap) +static void +__set_cur( + struct xfs_buftarg *btargp, + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) { - struct xfs_buf *bp; - xfs_ino_t dirino; - xfs_ino_t ino; - uint16_t mode; + struct xfs_buf *bp; + xfs_ino_t dirino; + xfs_ino_t ino; + uint16_t mode; const struct xfs_buf_ops *ops = type ? type->bops : NULL; int error; @@ -548,11 +549,11 @@ set_cur( if (!iocur_top->bbmap) return; memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap)); - error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b, + error = -libxfs_buf_read_map(btargp, bbmap->b, bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp, ops); } else { - error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len, + error = -libxfs_buf_read(btargp, blknum, len, LIBXFS_READBUF_SALVAGE, &bp, ops); iocur_top->bbmap = NULL; } @@ -589,6 +590,35 @@ set_cur( ring_add(); } +void +set_cur( + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) +{ + __set_cur(mp->m_ddev_targp, type, blknum, len, ring_flag, bbmap); +} + +void +set_log_cur( + const typ_t *type, + xfs_daddr_t blknum, + int len, + int ring_flag, + bbmap_t *bbmap) +{ + if (mp->m_logdev_targp->bt_bdev == mp->m_ddev_targp->bt_bdev) { + fprintf(stderr, "no external log specified\n"); + exitcode = 1; + return; + } + + __set_cur(mp->m_logdev_targp, type, blknum, len, ring_flag, bbmap); +} + + void set_iocur_type( const typ_t *type) diff --git a/db/io.h b/db/io.h index c29a7488..bd86c31f 100644 --- a/db/io.h +++ b/db/io.h @@ -49,6 +49,8 @@ extern void push_cur_and_set_type(void); extern void write_cur(void); extern void set_cur(const struct typ *type, xfs_daddr_t blknum, int len, int ring_add, bbmap_t *bbmap); +extern void set_log_cur(const struct typ *type, xfs_daddr_t blknum, + int len, int ring_add, bbmap_t *bbmap); extern void ring_add(void); extern void set_iocur_type(const struct typ *type); extern void xfs_dummy_verify(struct xfs_buf *bp); diff --git a/db/metadump.c b/db/metadump.c index 81023cf1..f9c82148 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -38,7 +38,7 @@ static void metadump_help(void); static const cmdinfo_t metadump_cmd = { "metadump", NULL, metadump_f, 0, -1, 0, - N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), + N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] [-v 1|2] filename"), N_("dump metadata to a file"), metadump_help }; struct metadump_ops { @@ -75,6 +75,7 @@ static struct metadump { bool zero_stale_data; bool progress_since_warning; bool dirty_log; + bool external_log; bool stdout_metadump; xfs_ino_t cur_ino; /* Metadump file */ @@ -108,6 +109,7 @@ metadump_help(void) " -g -- Display dump progress\n" " -m -- Specify max extent size in blocks to copy (default = %d blocks)\n" " -o -- Don't obfuscate names and extended attributes\n" +" -v -- Metadump version to be used\n" " -w -- Show warnings of bad metadata information\n" "\n"), DEFAULT_MAX_EXT_SIZE); } @@ -2589,8 +2591,20 @@ copy_log(void) print_progress("Copying log"); push_cur(); - set_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), - mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); + if (metadump.external_log) { + ASSERT(mp->m_sb.sb_logstart == 0); + set_log_cur(&typtab[TYP_LOG], + XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), + mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, + NULL); + } else { + ASSERT(mp->m_sb.sb_logstart != 0); + set_cur(&typtab[TYP_LOG], + XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), + mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, + NULL); + } + if (iocur_top->data == NULL) { pop_cur(); print_warning("cannot read log"); @@ -2751,6 +2765,8 @@ init_metadump_v2(void) compat_flags |= XFS_MD2_COMPAT_FULLBLOCKS; if (metadump.dirty_log) compat_flags |= XFS_MD2_COMPAT_DIRTYLOG; + if (metadump.external_log) + compat_flags |= XFS_MD2_COMPAT_EXTERNALLOG; xmh.xmh_compat_flags = cpu_to_be32(compat_flags); @@ -2811,6 +2827,7 @@ metadump_f( int outfd = -1; int ret; char *p; + bool version_opt_set = false; exitcode = 1; @@ -2822,6 +2839,7 @@ metadump_f( metadump.obfuscate = true; metadump.zero_stale_data = true; metadump.dirty_log = false; + metadump.external_log = false; if (mp->m_sb.sb_magicnum != XFS_SB_MAGIC) { print_warning("bad superblock magic number %x, giving up", @@ -2839,7 +2857,7 @@ metadump_f( return 0; } - while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { + while ((c = getopt(argc, argv, "aegm:ov:w")) != EOF) { switch (c) { case 'a': metadump.zero_stale_data = false; @@ -2863,6 +2881,17 @@ metadump_f( case 'o': metadump.obfuscate = false; break; + case 'v': + metadump.version = (int)strtol(optarg, &p, 0); + if (*p != '\0' || + (metadump.version != 1 && + metadump.version != 2)) { + print_warning("bad metadump version: %s", + optarg); + return 0; + } + version_opt_set = true; + break; case 'w': metadump.show_warnings = true; break; @@ -2877,12 +2906,42 @@ metadump_f( return 0; } - /* If we'll copy the log, see if the log is dirty */ - if (mp->m_sb.sb_logstart) { + if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) + metadump.external_log = true; + + if (metadump.external_log && !version_opt_set) + metadump.version = 2; + + if (metadump.version == 2 && mp->m_sb.sb_logstart == 0 && + !metadump.external_log) { + print_warning("external log device not loaded, use -l"); + return 1; + } + + /* + * If we'll copy the log, see if the log is dirty. + * + * Metadump v1 does not support dumping the contents of an external + * log. Hence we skip the dirty log check. + */ + if (!(metadump.version == 1 && metadump.external_log)) { push_cur(); - set_cur(&typtab[TYP_LOG], - XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart), - mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL); + if (metadump.external_log) { + ASSERT(mp->m_sb.sb_logstart == 0); + set_log_cur(&typtab[TYP_LOG], + XFS_FSB_TO_DADDR(mp, + mp->m_sb.sb_logstart), + mp->m_sb.sb_logblocks * blkbb, + DB_RING_IGN, NULL); + } else { + ASSERT(mp->m_sb.sb_logstart != 0); + set_cur(&typtab[TYP_LOG], + XFS_FSB_TO_DADDR(mp, + mp->m_sb.sb_logstart), + mp->m_sb.sb_logblocks * blkbb, + DB_RING_IGN, NULL); + } + if (iocur_top->data) { /* best effort */ struct xlog log; @@ -2958,8 +3017,8 @@ metadump_f( if (!exitcode) exitcode = !copy_sb_inodes(); - /* copy log if it's internal */ - if ((mp->m_sb.sb_logstart != 0) && !exitcode) + /* copy log */ + if (!exitcode && !(metadump.version == 1 && metadump.external_log)) exitcode = !copy_log(); /* write the remaining index */ diff --git a/db/xfs_metadump.sh b/db/xfs_metadump.sh index 9852a5bc..9e8f86e5 100755 --- a/db/xfs_metadump.sh +++ b/db/xfs_metadump.sh @@ -8,7 +8,7 @@ OPTS=" " DBOPTS=" " USAGE="Usage: xfs_metadump [-aefFogwV] [-m max_extents] [-l logdev] source target" -while getopts "aefgl:m:owFV" c +while getopts "aefgl:m:owFv:V" c do case $c in a) OPTS=$OPTS"-a ";; @@ -20,6 +20,7 @@ do f) DBOPTS=$DBOPTS" -f";; l) DBOPTS=$DBOPTS" -l "$OPTARG" ";; F) DBOPTS=$DBOPTS" -F";; + v) OPTS=$OPTS"-v "$OPTARG" ";; V) xfs_db -p xfs_metadump -V status=$? exit $status diff --git a/man/man8/xfs_metadump.8 b/man/man8/xfs_metadump.8 index c0e79d77..1732012c 100644 --- a/man/man8/xfs_metadump.8 +++ b/man/man8/xfs_metadump.8 @@ -11,6 +11,9 @@ xfs_metadump \- copy XFS filesystem metadata to a file ] [ .B \-l .I logdev +] [ +.B \-v +.I version ] .I source .I target @@ -74,6 +77,12 @@ metadata such as filenames is not considered sensitive. If obfuscation is required on a metadump with a dirty log, please inform the recipient of the metadump image about this situation. .PP +The contents of an external log device can be dumped only when using the v2 +format. +Metadump in v2 format can be generated by passing the "-v 2" option. +Metadump in v2 format is generated by default if the filesystem has an +external log and the metadump version to use is not explicitly mentioned. +.PP .B xfs_metadump should not be used for any purposes other than for debugging and reporting filesystem problems. The most common usage scenario for this tool is when @@ -134,6 +143,11 @@ this value. The default size is 2097151 blocks. .B \-o Disables obfuscation of file names and extended attributes. .TP +.B \-v +The format of the metadump file to be produced. +Valid values are 1 and 2. +The default metadump format is 1. +.TP .B \-w Prints warnings of inconsistent metadata encountered to stderr. Bad metadata is still copied. From patchwork Mon Nov 6 13:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446920 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 05284C4167D for ; Mon, 6 Nov 2023 13:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbjKFNNK (ORCPT ); Mon, 6 Nov 2023 08:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbjKFNNG (ORCPT ); Mon, 6 Nov 2023 08:13:06 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA8D125 for ; Mon, 6 Nov 2023 05:13:00 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D2AEY006802; Mon, 6 Nov 2023 13:12:58 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=k9+mjxxIKbX6Qhzmb9dVC2kqTzofCdx4KOEesbF4pCz8Kv9BfMcq2gk0LMmEdBZFyzEs LaycCPbblj+Llu1D7sW5igtE8MHB4nF39aDVNofFqZqBaKGX6FIoyM2knV5BGPw+1zfN IBJsSs6QA9eZDCmFRlP/RWbeRUDbkttniRuolMnggAop8GR5bPu25hgY1TCATr/kRNv+ NOc3BLwc++0TGm2YaUXUqdzAA1ThaKEF/cCX41C3rYOiElcCcLDRjngeS9mWb3/BbBev 3YotHfVLBvCUF+A+Nvrv3qd1qmJq8YxGYM/M92z4Qxkk2NHZ6sZA9B8XguDvdUZ9JZP1 JA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcb08m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:58 +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 3A6D8Rjj023535; Mon, 6 Nov 2023 13:12:57 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HM26XDAceA5WbYCWCB16kc6qDVSZcndacVeaPRhw+57JDyunnM+YESYlgIQcE5+Bm8Y01xZuyO+9HiEw33wx1eoVxfKT5ywo5+lWo3gCV7hpxDmJE/9QjuB7uenLsIKB3VHTf2ESyWk3br83+X3xVbYAUIivd21dxncHprU5JkKLh+sPM2/IWwBbSp2GTfSu6Tya4PPuXSSz/GdNC3c2a11H1XgnBAFS9W7FfrresoC+crGIMJpv0OV3jyPXeA/Qgwa2efiWr9X75h6kKSj39D1K+8csnu4T40QNkBntxc4meO8JSHrFGw2hEZgMwZR+1KlBSYGcM26S4SnUYfLlVA== 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=e+CWMQY/9L5NmgpkhWXwgiEJXddfBDsPpLU1bMTDWp/kUXhcQGV7eDSOP/hVSyhRHTLnN8nZxRpCJR13DdhSZr1sduJz1qwqU36WXEdPJOLXuQzIcLEMOVFL/17dAZFnH1LWhGSqybX/h4L85B7L7Jyc517McO6xSqTavt4jga61Ml8xk+m9wmYxSP16n453eUrCU536ziOO8Eisqq0KKdR0UTRRlSHBraLhQ7RQ3NiyfOFMX0cty3wppQ6hd80N1oFx0roktSq5Aq7pc8K76ve1CGlpbK4M0YFbDzKnU2zddJyjSssoFuToKvUd6Ul/jWtutx7Jj8Nnns3cwJ66dw== 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=Vs06s6VxSrNlUU5cM+b/IbncFMlvIwTkiTjP1GgMwBgevwZpecfaSozanFqUapNDUASxJrnJ1lZskeM7/MARQxo2qgxBoNZXhwqV6Ep+9qvqV344fO14+Z+OsCzkwEiGE7/blqrrauwYGwSTXU96+M1trb3mLJFA7gDBWd3gJ5Q= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4513.namprd10.prod.outlook.com (2603:10b6:303:93::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:23 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:22 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 13/21] mdrestore: Declare boolean variables with bool type Date: Mon, 6 Nov 2023 18:40:46 +0530 Message-Id: <20231106131054.143419-14-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR04CA0181.apcprd04.prod.outlook.com (2603:1096:4:14::19) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|CO1PR10MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 49014c4f-3204-458e-5498-08dbdeca037a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lGsOxKqOVUqfcDrPve3sqCSRpQtNhZNRU3JQy27vn6HuTh0ucRCvhCuIMUXfl7j3TNRJjsTP1uEKR15GykaGkeBUK5tigGwUP31rezHGKS2POmPv54bkyJlKuAonWidQ1gyJsYzohzCEI6/2pTUq+1+/uadztNHAnTDab/alUBcmQwf8tDJXXL+FstG8YhTuITFsrIbTf+OF7+za5AskDOMSaoyHxJvJCpspHPKex9PNpvPT5Ph7Wbd/AtzLaM6738icJ3HkBkrnxHGrYpKejzzD7OEO9RAZNrRKCrRaQWASrnNa47QsGIxzqKd1a6Jn9G8dNR1Ar3LsyAEIsGsNRCvibOV1WIZ7pBSxrVhxqRBAVSgCbxOsX+Hyiotm7gZoLl97o+iAAWJ0EIqf/lGlf5kGzeiDRPwogfTeNFuuZWYuSuGynS/4BUVQGJij+ThZsz6yEaoOvskxP3yywangy8nVOUhAHxUeOLTuKNinHVy96qF74naNdgZpMbrqUT/7VuPCvD9T2To7Yx9VSLLxgSQwn4AU4eZ/ww49WlxiYYAeJB9D7d67nvmslmkMyzCWd0u82XrZzgnCs++woPOnAtrOvBjcFXCETIQ0wgdF3k0hIRJ/FibpZMgRHlanqN3R X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230273577357003)(230922051799003)(230173577357003)(186009)(1800799009)(64100799003)(451199024)(6512007)(41300700001)(6486002)(66476007)(66946007)(66556008)(6666004)(478600001)(5660300002)(6506007)(1076003)(4326008)(8676002)(6916009)(8936002)(316002)(2616005)(26005)(2906002)(83380400001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E1fRuRCf3q4jq3Zci9YIhsvz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uK3r4q6ddfWRkuYqy7VDwTiGzZLPI/p/OvzsSpa8pQ4QZsS1gkZQSvlEAmHiPbyFx+Cr3SnwwO1Xq0Q7l/wHC/6hMOuxkev95E2PYl63XONI6JEvvk15PYNXILXBtRiPnfupjABGU1YgQ9ZoUAZ8ed/vnTH7N6PHSkT+0q9vY+Y8KQAnFIDJXovNloLBGpmUEemIn8FDH/xD3xzHQxsftPO4xyoUQEPKO86zxErJFWMBXDHedrUQciWAT9wUVti0fKWGXPddSGC6/boAOAoDE+lFlPoD5YzMu18AQ523JTMB2nn2S30mp7kB6aqUl5XNJh2h3P/TRTRYR4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49014c4f-3204-458e-5498-08dbdeca037a X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:22.9155 (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: 6Xve98O7GydvlO+ScK12o1r/7GOfRwQ5SI39/PjPDNFPzGfSt0AfC2Ureatxsecy9/Yz8TxV/cXFNCbmqtTJLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4513 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: 6ZsshsMpqPoX-UmVUE0sU8AJy9UlJDV6 X-Proofpoint-ORIG-GUID: 6ZsshsMpqPoX-UmVUE0sU8AJy9UlJDV6 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 Nov 6 13:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446921 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 DA8D3C4167B for ; Mon, 6 Nov 2023 13:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232165AbjKFNNL (ORCPT ); Mon, 6 Nov 2023 08:13:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbjKFNNH (ORCPT ); Mon, 6 Nov 2023 08:13:07 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F119D6A for ; Mon, 6 Nov 2023 05:13:01 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1xAQ009953; Mon, 6 Nov 2023 13:12:59 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=SHA0WP4y2SFIigj9AwIKk5ZQqDqymD8v0vetE8VhBLh0410krayxRO1d1XClUAihXoyT lxNhu4E88qg9Vyqyj7v6zKlBcHZKQ4mQUwpm13cmMHQWn1QvjYnoEmfPFYEI+9RZbBvc xpwTklfS7RDA07ECKunz+r01WmWsSbSwp3gh+CxBrULnP1OY5WGvse4fS5dXIn9qEAqz Bq5w4ump5Yl6ws3VmlZ8k2jMHYQugtXd72/iaAduhbO2hvrA0zP0O0tz3AFUysP3pMEi u7HLNgUJRgkqp69uNMoSqHMeTOwxLhRib2wWRASw9R8D8MaE9FuG6s0bg74UVU6dH8yF kQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5egvax22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:59 +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 3A6D8Rjl023535; Mon, 6 Nov 2023 13:12:58 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcfa-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hy7x143aDJ52bKKAqGWcZEpRPRqYp4azBfmTSQIUchwLWlwCDebS+YtnHlJWGtlFpWN0AtW/pWyvDw+j8cZANL9MA1tXW2Q0KE8s+QDoNZBhpqx4Ar1HE97pTd6aBd6hKxqVZsgmgFoyPz7xOe56MmB5Y8Nu9mhHtVMR12O5SneM6GjC1z1/KtvdT1KEVaLjpoEYuxbyzd8e451lUDBgLke9nrKs+3M3DkeMEoO6bw42Jp9UrsmySweC46Wsq5Q+ZJhWdXVOHViPAyPz4KwyLLpX67vRGteDjsqu/gil3SPEOsB2qFSnKdErDXW0C/DD0wuoIL0DEbZdh9TSZMi+Fg== 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=hlHzAZXdujDX9FpUXdu2YahoJtS3BUG/0M8pq5JSX/+8pU1gaboXuC17B9X7TZ+P1z50zmzMPPADDeqCVPZ/eBX+vGDabGpWYCGBTsmeaHVY5em6P0pZCNyh+vgOH+FXU4gOVY9f3OzQr9cokMhlNzc43haUAb9VqthFN4YuIuKVYWUGSny6KBs6WJ5EenWgiug5hzpWHJzj6lmtqBVy3KFavClBiCJXaVTaxih4qjUb+fBWKw4Y13ep1/70oAQiXbXWyEc0+FDbX63hWxjfUXY3ARO6T20gDsKzhDFaq7MMkr9MDhWbux7oaTyKcx2GGxb4qoDKNEMmM5ZJtARvMw== 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=sSnOxX74GGJLIy0i1dnppCci9aqkPYvmpAwvN9WJLw3lUbu5+y1nJU3w8DQfjD6uA3RXMvB5cOG7pfjcG0ioB0+WElXi86kqQVP6T6gh6obfoGr53PaXJZQr+yxq1IJvL5KeoqANFWURghcveKGbjwepjf+HghtG+5nt66KrD8g= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4513.namprd10.prod.outlook.com (2603:10b6:303:93::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:28 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:28 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 14/21] mdrestore: Define and use struct mdrestore Date: Mon, 6 Nov 2023 18:40:47 +0530 Message-Id: <20231106131054.143419-15-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR02CA0100.apcprd02.prod.outlook.com (2603:1096:4:92::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_|CO1PR10MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 75d7a1da-4730-40c8-6844-08dbdeca06f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P61r4wjyQDW8W2L8SlkYJLuM7HlMpKjmeuVUgM3Vc/N23stJA30qR3SH9tYVgIs27ISPB27BstHqBy48qt4M5G3k0QsFSKW21SHTwaAAF/o60wYMuy6U7258EzHqiUmr01Z5I4BrWOwzkUTqzAjR0yFQfy1yB45cHc/VwdAA2CasFHypUKTaIxGsI3emm+cVZws7795ycyrnsv2Pyd7G5rSACQSmr6EGbuTzAixizo33xwKs+Gqa2P2sZAAeV6Dy8CdU0wKCZUetr6+mDYtiULh3x1P4iEsrS6PnlCLH4sNs48CRE8Lls79cdQw2nfwqrYYjyMbuSjJh0osAbdYH+yZZ8rKuh+8kHoAATzvRW3VZOz17GuBh2KmHsUq7S92BlqLabgDR8OaRP4je3zgP3hA/re7cIR5XqxvgitD5YEfB4vENY20GtACwDSxHt6/hUV98pxpmR285SUGFu/xCts68xUwrV1LTRArJW814nheCI4q8dftnZOwvAepdq55rwGQYhSas6a1b7E9BViMr1Sev1QDvLmQsVeG0qwpgBexGUalTPLzucbbNpDgaYQRaBxog+lYIfnKxN27I6SeY0OJplY4jg4w4uomz5Ikgxui1H46pfSeZfL3N/7OjxcZi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230273577357003)(230922051799003)(230173577357003)(186009)(1800799009)(64100799003)(451199024)(6512007)(41300700001)(6486002)(66476007)(66946007)(66556008)(6666004)(478600001)(5660300002)(6506007)(1076003)(4326008)(8676002)(6916009)(8936002)(316002)(2616005)(26005)(2906002)(83380400001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i9l3ZSMU5vtoCy+C7ggkXjzxpdXF4uhXW+sR1Nt68fqvyxdrCVCnaf2q9zxHXGi1Z1ffjHMpTM28UN546hX8gmlXGvYgNHf+qfuZufgHkWy6TOLO7CycwqxUeJXQy7BZ4JPX/+0wgy5knmJVASE7q9ztKGUQFWc1teQ6sxIpm0ofFaXNzjrcyNz7L/wMSxvAnqY+At5iENuyFMExhWlFdzK5atIuwqjwR3+XrePN+c891AwIWkrvhH9YjRIpfzHYQmlEDmP7ddmadSPFPM0c6eNp/vc1J2Cyk0ukmKkhSfG6bIS005MsADFQZkHbgPQR3d1eAEFkAfetXnaIM2ckvDZl9WmK9MmNQTn62ZzqWxBHDKrAVKsiZbHG7blmI+yPCD2IM4HoqOVYu+yfbG0jLcCImuXeABfBS20XR8gIcHdTl35UBB6UKyAKBidBIAiksr0aAdpad8Rdp4tjtm036DRMioykEs62IDU8ywNtk/TvnlkfAcmfS3f1OPisUiDJiwdhbxkgVzT1QOHZoqkKgxzbE7kIwrRcZtZL7alKY8LNoDEOxNEHm+gyHB9ktf/tN5KN2I2D+Dr9My+Pk6vBGWIlRTCijbz5X5q/SCXkvpP+38QlzZYZOjM8iBhLza7BfhhncOH2f3oWnWuu9hQNAuAbIo1k4Pn7czL4MZUZwPRAud6L9rC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7spxMBrUJ9+xD2eb417DjhAwIO3/hI1NZCxlL0b1LIujYzSOoc3U9/GLWGkg36uo1pqW7YrOg3Xgj+gIJ6bhb4umLqZzaqOkpL8tEdn0qxCS0KcfkD2FNwN7ZRJvqGLQOGeVp/O5kcxmZP424HRVaHYUHq3ToCk293MSyQZizM/7fZziFAerzza5IIVFGt2ovP5jJBWUlG0xuTzHiMgu9j/bHShJVdWa7jYMosItaO2fiDEr9lv8bWtxYqMMnqEOuyI7IPZelJ0kK86rCl9ocrs/yKoWTycmbKqvz3K+xqXHwrnknUd38rlggkvAZwV/DwhOVpaizeFRCPaP9Waih8XcnCr5F5nu5o8+O0Voilu8zGUJSCqfTYfy5cmYBPjlPqK3m7GWgEvcovg57KgJsEl+ROFWiyvjaEirJYKaS5Evb2pgBRHOLh8Bj4TPXbGoihFTCNpTNBdH+E/NRMMmGp0NMSlwITwoYk+mnU/S1hFzF5FkwdmYBzaA4mAWKSO07LUEAlDhwsaaMuEtCPvPi/Tlx+7U3PxOnittAIn5XamlfrnXE6sXm2PyXaE0c/lZzAh12DolUyoC2gkOw5LBmvPlgkmmYJ5j5rWpAhZQnz56GuaTjBa8Ee5LaZINInFB97HJwtKzsHQoJlSUU+4dAKWZkionizH5QCaZ4GcUa27uuJ5CiWND+oJaPIlkmJqll4Cl2Gg1u9oQjppWZ8DiBam6C+kxG9ddJeyaiRe0zyQ/x4sw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75d7a1da-4730-40c8-6844-08dbdeca06f8 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:28.6100 (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: N4h02wlzZDVZzJP6olNlPiYRgndZX3bij64bb214NV/XRNe2pVRKE8v36WlhOJPiV/X1zjzyrUdo4oLNiNi8SQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4513 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-GUID: T2H2RPeVPWtPXb20ud7-aVbjhcX8z4Ds X-Proofpoint-ORIG-GUID: T2H2RPeVPWtPXb20ud7-aVbjhcX8z4Ds 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 Nov 6 13:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446923 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 99FDAC4332F for ; Mon, 6 Nov 2023 13:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232106AbjKFNNc (ORCPT ); Mon, 6 Nov 2023 08:13:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbjKFNNb (ORCPT ); Mon, 6 Nov 2023 08:13:31 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D2BBF for ; Mon, 6 Nov 2023 05:13:29 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1xLA006674; Mon, 6 Nov 2023 13:13:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=bQupO75Zvy0ifEPUPUOBCixJ8Lj5K4EIaTt5b0MTbAs=; b=r87c5TJAF8oM+yGz9zyGJ8stvBxtZOhUieZkZWKo/yehcC+uJf8/i9smtlytuPajuwWg /tAd7W8yqul/brfavFF+2zZfR+ENWaSVKX/NfepPPefcKqFo19jHE5XxyVum/dzRFNu4 0U3R3ceYv8WwHrALIgHsSsDKLunNTdSxeK5EYJNDQykDhAEjTCpMZ61yWCVCCHrrS1GW 7ccdM6/rOHRH76gRxrNTqORw0it2YjRz9BD+Qu/u1DQss2z3+vwAHekglZHG8SS9axW6 skUqZbNuF6KXnCgBdszlrb4eJb7LFjKI3ISSDk46wa3ZUu0aJuuDHSHangaFXBp+7NNH fA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcb098-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:27 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D8Rjq023535; Mon, 6 Nov 2023 13:13:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcfa-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZcjA7scStaxyc8zrKLOGVYLfQ7zwCsdDQRXog6g6oxepaPOihfZfKXVKR/fpJHmFqapxD6SGW0+CknFrXzEr1SJLWXf/k8zG5tehsdhSdSBYeXLUbPm15K4gmpNAW/z63MhlNUymYbPQwO7Ysghmw/zYsMMSwQICRakuc8RNflHIN+2Hq5vvIdEJLvFcha+1W09pN/VOpY6fsst1PPRQbJZBr243kLfyDFxhC21qDIpL9daYuCyBy5qEwMi2CMIjKF16R1lh2vLu8IvEumilthqboeUg8MRmufh8mXhxLveU2/k9n6rMe3TeUlNWKmVKuSytX4H5MKjadRI2y0gRWw== 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=ngspb3EVCOWmMIkeW+9yFJH/nhKtvetFZFuxkqdpl7sEjexM8n3fR0fp3J67n2XKZIU7Dh9aMMPwrtXuiucPeLdRBY1BwHzPa4nGePcInidZ/Xd+xSIHEXxJfifEhSEStxPGhrkyI/ETRT+9r2TCxmzJ5UURTr4Oap2+64gBMgFowQWZEPpN1QUN7TbPxw/3dYHoto3BMeGElK0AtDqtcfrz1UH2o5RBwFcz0D52pVKmAjgiI5JXotY/JrzzrRt+iCUbYj9iBRyRQOC7h6/tEV483fuoRpmhU5yR+UGmjsEX3lVtpk3vquh5oqiA+FtDQYCQcycve6xC6Swkeh+EGw== 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=IerdUxFt4MkZyi92YUYcR2l2Dia6R9D4pvyjoqvHYoycZv0a6BONYzMgPd6Eqs7e10E2J4W8zhBPquqyPKm4tmN0vKet2taTw6Bq5q8HOeCmvKSFeSqSKrTjWHCyS8GVgvdNne5DHAIWjmMZxlfddpN3InU2qqe6leY6RNwi8SI= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4513.namprd10.prod.outlook.com (2603:10b6:303:93::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:34 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:34 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 15/21] mdrestore: Detect metadump v1 magic before reading the header Date: Mon, 6 Nov 2023 18:40:48 +0530 Message-Id: <20231106131054.143419-16-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG2PR06CA0182.apcprd06.prod.outlook.com (2603:1096:4:1::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_|CO1PR10MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b878381-93e3-4fbd-dfcf-08dbdeca0a3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U2/9Js4R9A9g7zi+aPTqJmWnVE6zrgTvUAUA1v6Vlp3xMeZQ9DF2J5HqzEfvCSjv1M56saOgg/gsYYwpds4AcnrFTHx91GGSUJSnGv01JusH8XkoOzryvwielYBaOSJFfMDV3rVGOyipBXSZxLoJFcrJO0A0HMCdbmVCDIyzbz9DABPhM8m0NZt0JK/p93uxp6mo9Fz+7Mwqoi/1XkRRXhEr3nXCvUmrTfnl28H0eAc+Z273hhNObv7u3MIqkXCHM+E49FKpP2y4mAUyMabyiHq2BDGe7mjcq0RLNvH5VlImcLnBGZC2RR6GpADDAxjba7kufarmVQPf1cBcITrsFEEi5JkNl7kApBeCdz+yq57M5QRoRSEH3jv4LqxEQxrHNzKpsZeWFl6NRkqZO+Qm8xWso4K90GuKAyE8DiUKtPLYHY/laVr0eJf3VXKyrd3K9l4LgY3+Ts9rykkJlzq/zVawYay49+O7fWCoHfbNy9WTQ/Ijau8jrdDt+HsuGx7zZZ77OUUDF9LszhCUuD3zgHVKPfUzoSpuRinC9MwSp1CvNTHwxVoU56TFnTJ7O8t0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230922051799003)(186009)(1800799009)(64100799003)(451199024)(6512007)(41300700001)(6486002)(66476007)(66946007)(66556008)(6666004)(478600001)(5660300002)(6506007)(1076003)(4326008)(8676002)(6916009)(8936002)(316002)(2616005)(26005)(2906002)(83380400001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9solgzHxLCUfrGw+eFofWa4sSky4fxnQGBPHUu1rkNHQ3OWwP0RfZkPyAfclZXGOGgdYNtXeMUvbHueBmAgc6oJ7YLEurNKJHPPhYklvvrS2pYP0xU/8wuiBy/X3yRRhy0XZwCUTPZOMPL9cDKNeJ76JVdMrB4D5eT4iyHSiUDj+L3HLeUIx/Q/5+Gnr+q8dYLICu/gjq+z9Eig9RllHRTQYQvvXr7aVRo4ZQEYSpCuAkIRPY2eKF6gqkGKx/hYNIRtc5m0PaBlS8cARAvQjpb1EygnxHd8ujpSpLwMw+mvI0mxkvK8Y8WK0wo+wiaUj3DdrjF2LkF6v1HDcrNgPPK9Dz4cND6BBGpn7ZD3Amn5/zGDUs0hGM1j/WdAVRNyFst/TlF98npeYqDcoOla+1+JTQVfsv1T3beNTo31q2gviuQDAovUpdXWTBLuNhUavtkxYanMQzPEoA3QxOPnQ3e9ksZMbiL8+Ew3ottAKX9ooajvNvAtzG91OGdAJvaDgmfNmy4B9mNHQjr/PCgZMEPIChJJBarAppFstqdlTQ/KRvwfMLE+g9Kl8GrHK3kD3qu1UX1lAEiUuTqzGoMJvILNiuBbK1Ho55WJu8O41uCO60wj1L7VdaunaqT6/YrGKS5tDRLOg6jNQiBW7wV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PkYWlyEKg2phkKpTLGeru8rRUHIGj2c3zrkU2aMWe0LMVuthlIVSYTWFrupk8AuDhWDvS5YeG/EZy+Ufm2gm+UFZlRB5mBbYGpf4JxfArKIIx0cB4Ywe9vs9ueu/k3YoeI+iRq33MMma4eSyezuL8loJKTz+pu76zwCCXYmWjgC04q44zGGw+Sm5pDLbk+2GMiqXw2SI3hIcuCuZFwfgOeOGjVXa8tTcYqEMuZzjGDy0EFwH5uEhh97aDByaLvNnW7GehJHMkOhqMoJrpYhPBp1HQCmjuuR9hw8Mibi37f7j5ITIVwTny0sXoATHohEj+5bHeRBs+17DaXpoMrWUM63og2BuVAwxcE7NFYVnFMmZ2HoAB/PUG4H3ZQ0bPYGrfzDf/PolgFEfn3ioNMD3TnsRKlp9ak6UxRFD8jX64EkXUXTgYaiJDcKORCLdwxc+B0MHUsGrwhJd7d9+IdVReB3XiXFnWkvb6duQDrW0Oeji/SNcMX5JmDrqGbnWqP+L7N2ggX8Z34/hOI2sMJBeoWvk6uS69VXkx0ciEAycZU9XSnf/jqJoi1xpUuHYPAn89Mo5EwJZg6lVi4Fs8HS4ioo3pNF0pYYxxTfnycyaE60/U1pJGmRTLx5UDigFHPNmfTPQi/vCQLUmGcYSOBCFirgqIH2pKpaIj7zaP9J7wP3RMn+QdScd6+ZFICHcsOBNK34GkEVSk8o6k8DrJgC7YSH8mKnHtMPicQ9+A6MsaFA1MmdnO9stOvu3zbl4MlqNRJkTU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b878381-93e3-4fbd-dfcf-08dbdeca0a3a X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:34.2214 (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: iAiXEIz+JrkfO1zaJ99ZHMAeXM+SW5FSPSNbjFxVPRytBvRio110HPrjFZ4TwBkyKFRvwao7FWC9RtvuVEVx4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4513 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060107 X-Proofpoint-GUID: SnUpMvO9OXDs9cNKn8FwX6I94An32FNg X-Proofpoint-ORIG-GUID: SnUpMvO9OXDs9cNKn8FwX6I94An32FNg 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 Nov 6 13:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446924 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 B53C2C4167D for ; Mon, 6 Nov 2023 13:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232143AbjKFNNk (ORCPT ); Mon, 6 Nov 2023 08:13:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232168AbjKFNNi (ORCPT ); Mon, 6 Nov 2023 08:13:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 406DCBF for ; Mon, 6 Nov 2023 05:13:35 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1sJE009902; Mon, 6 Nov 2023 13:13: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=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=Zr8LAYp4u2PVYKTBVluCnnL/C7+fINCtxlX8ru9NIFnFxgyAayRVaYfDTPWTgPxY3DBi jwbkQnYED0Nd6OrsfG7GcFoM/BN61ik4FfTUWHc1IfkY4M8Ww6Rywj3OBquaNkKSGDkL X7xKvsR4AJQ00cLc9FGh3MW86QOd47m9rsb+kOFjTaKbE1Hfy1Nil7A4N+pCxNy1GVh8 58Onk2eihaZTMAx6TXYTrMJuTMMIx7RVcGg5u9Sh76kdUa5guNpM0Jaha2Xgl0nPMRmJ m61imqM0nfFCQq3OrKnLZEk6HGmZX49QffCTxOPImNVI3YVTnvjXpFwy0XwSiJycDasX dQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5egvax2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:33 +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 3A6D8Rjs023535; Mon, 6 Nov 2023 13:13:32 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcfa-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DOGHX99tiYBo3btI36fH8KgGzpHXEDppxVZujitIUf96jPfLXDGRF8eRmWnH4FEQiDBXz2PV9TRBCekTR9pAv/lN6EjsbmSY6j6BICSgHHV5RUfo/plWwV8nLk9piB1Okhh3YL1YCptvVEBDsGCix+sFUlfMPV15X8VM6PmVc06yGilCRoOpZuYmfImgJaSo6owzbqQtOIilW/h75Zvn4T/p7LKExPSOD+gXF624EpF3nErcWmMG+LwzDOU3/NW+40fnNomcI5+f7ZuKuMKsFv1WCpJIbSvwPKpY63WiYjzCcMIbcTbiDmCfuq9VIV9ulnxAVhxkumQu7JZXHhVZQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=kutp2UB3CuvdI0+of+orOlZJgfNHe6wtk5T0Vr7LT0vGqn5hWM3OmG7dVJmE8J5ztncz1jDfzxb+0EbdL7ur0o65r0l7loGsDPls40777+2WTzLZ2HObjwFKC/SxajwzSgpWudmyQgRLXhGwZKC6yYR2wNFeL1BpsOZY8zTcztq5s1B9pu9tTpkHzXUssk32qLT+M0UuqpwB1DhDvUBDm7L0h5UXcEcFOErNmmCBH5nxjFCIeouIWAzhbixxJstD4szWpdYh1EmJ33BcJpGfmPXELpkGub/fYyXAT/NSJfiHNnkFT5h+6dmx37Vmqp5RLB///jYAN7CBV33pn5bPPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l0pNoZ59fm0VaFkivCF4gquo1FAAkx+AV4XSeRzAT64=; b=Z9bOTrbJDZeP0pY/45CUhOE11F5sKd6fRFp05g7IPGIsJdaLiSXwUNV90Aqk7lgBxhcJ9+YIHfCzxikGptIjJ5EhkY7euwRd4w6u1iGZ69E9Z37PAhgI1uMCHfgn2slGYfMpZdffR/YGsMY4B/5v2fnwARMeRCGddYfw3XJWn58= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4513.namprd10.prod.outlook.com (2603:10b6:303:93::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:40 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:40 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 16/21] mdrestore: Add open_device(), read_header() and show_info() functions Date: Mon, 6 Nov 2023 18:40:49 +0530 Message-Id: <20231106131054.143419-17-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR01CA0015.apcprd01.prod.exchangelabs.com (2603:1096:4:191::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_|CO1PR10MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 039842c7-31ae-4a14-3f70-08dbdeca0de6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6ARr2eU+82RnPlB2TWH1w2138xxs2Fubs0kkxJ3COoSdvIqwQL1TYjtt3LUVQXhnAJmfeDRp+NMhziwKh8Hmoj23AqZS+zyWWS3jjtzONjsMOXsjsnuiCtIZE3ls4MdcAdNjzsrtx3zV9Y0R3NsrbV3cSFUxzI9GVC2oNRHYs+Gdc5WNCKOoo2APHwNuaAxBB8KhHQ2/FZXesFi5+KgpwIuw4FRd2AgnAZXxALNV6ymS8MzWXJV5AWUKXwjpl9lErLO0dp+5L+TSceBWy07/VjO4/wiVFL3E+K3/HhISA4OgHuifa1FMBUCijwKNiakBI438pG8t+cdol7osvhjzA+nhzLCmZe8DPMLLnYA5KkCFw3zPictrAl4AjqArj9BZRWAc9H/DbXTqqP1d/hj0iW7nnzPfj9udBaN6qvGphDg9/Q+QIR9hdNjakbXvfqi66rqeDTq2o3wwTR+D5x/9K86QRLG7Vsx7AAeqVlf4igRX7ZackCyWO2caktZhDWFkAGznHvBjLcHgyPo0sDmYQKgH2ZFXyESrUYAdmC07egDxiVGsyUO6jR/R+W0DDNFIb1fiWFh5Q37zv0sMjUehUIz+K0Y8fis9bwPyYLKCt9C5oO4J0SrDuTn1bj187KKs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230273577357003)(230922051799003)(230173577357003)(186009)(1800799009)(64100799003)(451199024)(6512007)(41300700001)(6486002)(66476007)(66946007)(66556008)(478600001)(5660300002)(6506007)(1076003)(4326008)(8676002)(6916009)(8936002)(316002)(2616005)(26005)(2906002)(83380400001)(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dQ79SI1V/W5TtH3zuBsioA4c6JEDh/ws7RVjKvSkRAQoJdGgNX/l5lz7QOnqEplK8qqo7dFiMA0Ysze5tXEYrMNU8ftya9kTX3BWjdIW9+Y1IzxHOIPLR/y94mZbRX1DVtuOr3UB/WhbkAPfi5s8K9ju8TwvArZXWnuiR38PsNaKRk0dKnaFjnvtt4//FNN2EPdsAIVEhu090VQN/mJ0Zz21w6Tkqt2Icmcz48drqIoloOimaVX0QYvn0Zf8/kt6Kvog9MLOc45rwmN7lflGgG3d2nGbeQU3pYby1jhOYEOoGe+obbARF/MdDWcaY37li7P1Q/+A2xpmIDPBIibLgJU5uo3cTOeleJiKKIsmrwM1iH+kSjPfWPjxpC8yDTFVr+gntVzd7DKYCkHq8khNz09uO6c3ZVgmOiFPCQQujn7R3zU0QhiUODjmILd4bc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 039842c7-31ae-4a14-3f70-08dbdeca0de6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:40.3976 (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: hB5nR7U5JXGP9Ps/kFuz/b0PJFYqiD4QJR4PywouiV7iexfxHzFNpvMmbaBfbSWT3iE7xlduMTpcnMGXjcjfBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4513 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060107 X-Proofpoint-GUID: j084U_1NgrbBdS4aJRNc8uWvPINvIzJc X-Proofpoint-ORIG-GUID: j084U_1NgrbBdS4aJRNc8uWvPINvIzJc Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit moves functionality associated with opening the target device, reading metadump header information and printing information about the metadump into their respective functions. There are no functional changes made by this commit. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 141 +++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 57 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index ffa8274f..d67a0629 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -6,6 +6,7 @@ #include "libxfs.h" #include "xfs_metadump.h" +#include static struct mdrestore { bool show_progress; @@ -40,8 +41,71 @@ print_progress(const char *fmt, ...) mdrestore.progress_since_warning = true; } +static int +open_device( + char *path, + bool *is_file) +{ + struct stat statbuf; + int open_flags; + int fd; + + open_flags = O_RDWR; + *is_file = false; + + if (stat(path, &statbuf) < 0) { + /* ok, assume it's a file and create it */ + open_flags |= O_CREAT; + *is_file = true; + } else if (S_ISREG(statbuf.st_mode)) { + open_flags |= O_TRUNC; + *is_file = true; + } else if (platform_check_ismounted(path, NULL, &statbuf, 0)) { + /* + * check to make sure a filesystem isn't mounted on the device + */ + fatal("a filesystem is mounted on target device \"%s\"," + " cannot restore to a mounted filesystem.\n", + path); + } + + fd = open(path, open_flags, 0644); + if (fd < 0) + fatal("couldn't open \"%s\"\n", path); + + return fd; +} + +static void +read_header( + struct xfs_metablock *mb, + FILE *md_fp) +{ + mb->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); + + if (fread((uint8_t *)mb + sizeof(mb->mb_magic), + sizeof(*mb) - sizeof(mb->mb_magic), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); +} + +static void +show_info( + struct xfs_metablock *mb, + const char *md_file) +{ + if (mb->mb_info & XFS_METADUMP_INFO_FLAGS) { + printf("%s: %sobfuscated, %s log, %s metadata blocks\n", + md_file, + mb->mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", + mb->mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", + mb->mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); + } else { + printf("%s: no informational flags present\n", md_file); + } +} + /* - * perform_restore() -- do the actual work to restore the metadump + * restore() -- do the actual work to restore the metadump * * @src_f: A FILE pointer to the source metadump * @dst_fd: the file descriptor for the target file @@ -51,9 +115,9 @@ print_progress(const char *fmt, ...) * src_f should be positioned just past a read the previously validated metablock */ static void -perform_restore( - FILE *src_f, - int dst_fd, +restore( + FILE *md_fp, + int ddev_fd, int is_target_file, const struct xfs_metablock *mbp) { @@ -81,14 +145,15 @@ perform_restore( block_index = (__be64 *)((char *)metablock + sizeof(xfs_metablock_t)); block_buffer = (char *)metablock + block_size; - if (fread(block_index, block_size - sizeof(struct xfs_metablock), 1, src_f) != 1) + if (fread(block_index, block_size - sizeof(struct xfs_metablock), 1, + md_fp) != 1) fatal("error reading from metadump file\n"); if (block_index[0] != 0) fatal("first block is not the primary superblock\n"); - if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, src_f) != 1) + if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); @@ -111,7 +176,7 @@ perform_restore( if (is_target_file) { /* ensure regular files are correctly sized */ - if (ftruncate(dst_fd, sb.sb_dblocks * sb.sb_blocksize)) + if (ftruncate(ddev_fd, sb.sb_dblocks * sb.sb_blocksize)) fatal("cannot set filesystem image size: %s\n", strerror(errno)); } else { @@ -121,7 +186,7 @@ perform_restore( off64_t off; off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb); - if (pwrite(dst_fd, lb, sizeof(lb), off) < 0) + if (pwrite(ddev_fd, lb, sizeof(lb), off) < 0) fatal("failed to write last block, is target too " "small? (error: %s)\n", strerror(errno)); } @@ -134,7 +199,7 @@ perform_restore( print_progress("%lld MB read", bytes_read >> 20); for (cur_index = 0; cur_index < mb_count; cur_index++) { - if (pwrite(dst_fd, &block_buffer[cur_index << + if (pwrite(ddev_fd, &block_buffer[cur_index << mbp->mb_blocklog], block_size, be64_to_cpu(block_index[cur_index]) << BBSHIFT) < 0) @@ -145,7 +210,7 @@ perform_restore( if (mb_count < max_indices) break; - if (fread(metablock, block_size, 1, src_f) != 1) + if (fread(metablock, block_size, 1, md_fp) != 1) fatal("error reading from metadump file\n"); mb_count = be16_to_cpu(metablock->mb_count); @@ -155,7 +220,7 @@ perform_restore( fatal("bad block count: %u\n", mb_count); if (fread(block_buffer, mb_count << mbp->mb_blocklog, - 1, src_f) != 1) + 1, md_fp) != 1) fatal("error reading from metadump file\n"); bytes_read += block_size + (mb_count << mbp->mb_blocklog); @@ -172,7 +237,7 @@ perform_restore( offsetof(struct xfs_sb, sb_crc)); } - if (pwrite(dst_fd, block_buffer, sb.sb_sectsize, 0) < 0) + if (pwrite(ddev_fd, block_buffer, sb.sb_sectsize, 0) < 0) fatal("error writing primary superblock: %s\n", strerror(errno)); free(metablock); @@ -185,8 +250,6 @@ usage(void) exit(1); } -extern int platform_check_ismounted(char *, char *, struct stat *, int); - int main( int argc, @@ -195,9 +258,7 @@ main( FILE *src_f; int dst_fd; int c; - int open_flags; - struct stat statbuf; - int is_target_file; + bool is_target_file; uint32_t magic; struct xfs_metablock mb; @@ -231,8 +292,8 @@ main( usage(); /* - * open source and test if this really is a dump. The first metadump block - * will be passed to perform_restore() which will continue to read the + * open source and test if this really is a dump. The first metadump + * block will be passed to restore() which will continue to read the * file from this point. This avoids rewind the stream, which causes * restore to fail when source was being read from stdin. */ @@ -251,11 +312,7 @@ main( switch (be32_to_cpu(magic)) { case XFS_MD_MAGIC_V1: - mb.mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); - if (fread((uint8_t *)&mb + sizeof(mb.mb_magic), - sizeof(mb) - sizeof(mb.mb_magic), 1, - src_f) != 1) - fatal("error reading from metadump file\n"); + read_header(&mb, src_f); break; default: fatal("specified file is not a metadata dump\n"); @@ -263,16 +320,7 @@ main( } if (mdrestore.show_info) { - if (mb.mb_info & XFS_METADUMP_INFO_FLAGS) { - printf("%s: %sobfuscated, %s log, %s metadata blocks\n", - argv[optind], - mb.mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", - mb.mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", - mb.mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); - } else { - printf("%s: no informational flags present\n", - argv[optind]); - } + show_info(&mb, argv[optind]); if (argc - optind == 1) exit(0); @@ -281,30 +329,9 @@ main( optind++; /* check and open target */ - open_flags = O_RDWR; - is_target_file = 0; - if (stat(argv[optind], &statbuf) < 0) { - /* ok, assume it's a file and create it */ - open_flags |= O_CREAT; - is_target_file = 1; - } else if (S_ISREG(statbuf.st_mode)) { - open_flags |= O_TRUNC; - is_target_file = 1; - } else { - /* - * check to make sure a filesystem isn't mounted on the device - */ - if (platform_check_ismounted(argv[optind], NULL, &statbuf, 0)) - fatal("a filesystem is mounted on target device \"%s\"," - " cannot restore to a mounted filesystem.\n", - argv[optind]); - } - - dst_fd = open(argv[optind], open_flags, 0644); - if (dst_fd < 0) - fatal("couldn't open target \"%s\"\n", argv[optind]); + dst_fd = open_device(argv[optind], &is_target_file); - perform_restore(src_f, dst_fd, is_target_file, &mb); + restore(src_f, dst_fd, is_target_file, &mb); close(dst_fd); if (src_f != stdin) From patchwork Mon Nov 6 13:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446926 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 A659DC0018A for ; Mon, 6 Nov 2023 13:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232201AbjKFNNz (ORCPT ); Mon, 6 Nov 2023 08:13:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232215AbjKFNNx (ORCPT ); Mon, 6 Nov 2023 08:13:53 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8CF3D6A for ; Mon, 6 Nov 2023 05:13:48 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6Cx4JA005779; Mon, 6 Nov 2023 13:13:45 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=EEm7+mmfslog3GKIhxsY3ArZni03JxPlBAnllghLzng=; b=poPWiHG2IUcxwkBD6ktnQVa7WYLkmSGjc42VAhzZ/LS5cW5nv2DkngTWb1Y0u3ToNMRw 16N9sNKIoYyrwRKNT/WeiKc2xVoe+7pXT1psbR+WTUhOV6JSitS1c7Kp68DUe8EYdqGe j8iNEJLKYqLvX72iXI/z3ztXfq15k7WkcU1CyKoXmqSBX7/yDnHIj4mcNDTS2mzV8fzT CGHuUB7EuqDe4wxKb8X0lkcETzmF0iih4xMRv2UxngAURr6jfSw+D5Hw75ph+5xi+yNv cFtERI7LEFJeyQxUnIAQ0qhR/SIh2wNNhHnAwsJJu/atZrdz3Y6T8z+6eNBzBgu2d5ol hA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5e0dtwey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:45 +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 3A6D8Rkg023535; Mon, 6 Nov 2023 13:13:42 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcfa-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b91HODliWt5ifkZOYjgatQj/I4sqLPLThXR1QqY3+tQNYzkldwg2pEHo8pxLPMNrXNyuTvq4Vzcp3uOPgvhpohYtoLBg5/nJ4ZZfIYrgCHBskdXTjxhiDdiliN+PVBcAWtY25L6TGvi1l1idlYHH2vtLhG7qpyN+nckuiMERRpBy23nUU3lT4Q3bOIJcqKgcttk9KKDh6gpmT4HL+km4kb3rjJwtTwADv6Vqq2eVU193kfEPmq5rWEjuaKB4KQg3VAd1Uva6U9McmGzW4Jc0J4vzkLNyzsQWa7HA1C68D0E+OO49Epd7lZAFizkE+FkupCaIHsluIW7y5tm+WrPYIg== 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=EEm7+mmfslog3GKIhxsY3ArZni03JxPlBAnllghLzng=; b=Uv+W294Q8ZFo4Og6VYEvDl8DLRxuMkVVzoHA3u1J5GQnF5EP1JJe2sm9T4DMuj4wEu8haesz4Tta0SWBgAjEA39cMKspDe6cZqeewME3vo0EEsR/S2/2tLIHpjQS4NRti7Xc27TO9kkBUzAQ+qYBgYMMNwHHgP79QSk4bXJEU4sF5fhIeMDwQF4Hwm5cWlNm8mlHf7k+y25WQML0Vem2fAm4z3pRSGRfo6Opd1ty7A2yFU43Cg8Fg2zFXL0pe1Ev8tRgF4NlnM/Lq+O3aNKSFUbDL1jwFjqNfbdFdfk6Q8D5ek3Ev0mfAMtD0pQF4uoCXw/bstscPE0mFJsEBUkUaw== 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=EEm7+mmfslog3GKIhxsY3ArZni03JxPlBAnllghLzng=; b=moGHhyIwsuVK5UZYI5S4WideMdgNH51PedsM7n5Sc5SS8+44zqD9auhCpQ/a2AA/Lng60Y0jixmWVmsSssPh+gxl/AAGPmt/7YGvzGRaBO9YBR1BhLP6+wNE0yWMvdyTSvx8+F1/vxkUYaPVYUxnGCbIbIX4z4YjlNgOC7xXhLM= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by CO1PR10MB4513.namprd10.prod.outlook.com (2603:10b6:303:93::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:46 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:46 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , chandan.babu@oracle.com, djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 17/21] mdrestore: Replace metadump header pointer argument with a union pointer Date: Mon, 6 Nov 2023 18:40:50 +0530 Message-Id: <20231106131054.143419-18-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SG3P274CA0004.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::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_|CO1PR10MB4513:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a680747-f3b7-4084-3cd3-08dbdeca118f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TihIrhhwts+X2+wAglKw8kwBqDd4pIyT3RR37x+tdXKXwKkpiX+6s7dabyO9Dbej7NY/rp6BMSLfQ3vidW3HdjT6yqj4WgMZ5V5pq4BIRFkrK3hlannKoX8FsHkqQUgJEw4JFh1FhPP2JTAsPNARtekHqe39R8JXW6TYB5BcIqE3euHG/2aZhmBEzu4AIgzPDBUiSwg+qAqX0RwkTaWXsJD7a+kKCJcvRY9BAXx8g0ihhiB43nUFbOCCOyvSucG7pHMnKpP8lEnfWkpcnKjUPhoZpvq5+1hXvCzsR7au6ldr4ekbh11nzpy5fS7Z3DE3dL+cVplbKln5ol3RlLfeZz79lZnefmUk9QMn7zqLWjzeUzC0U2vqGlP7yq/aqg9ZioEuqAVK77xuiGZaR4jUYxOlnt8JuaRVMPKP0fRrcs2eqUvlLDZgPVkR+v8oCi9C1ek2pguRlqZud79tSdYh5DqaO/XzMGdYmOGSpiNl7nNngDMSzw45LdYV4XDO0LvCbu3M6DcRSMVStgBudrv86LYPI34O7eBgsrcGDK5VglK5VezIHhX+KrSpkmK/RfcCL3ddHhiRNSyBhpbrRoPp9bYSjRUwfecVlNsDrEFToLFzYyyeUWiaokzOMSvBJOYO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230273577357003)(230922051799003)(230173577357003)(186009)(1800799009)(64100799003)(451199024)(6512007)(41300700001)(6486002)(66476007)(66946007)(66556008)(6666004)(478600001)(5660300002)(6506007)(1076003)(4326008)(8676002)(6916009)(8936002)(316002)(2616005)(26005)(2906002)(83380400001)(38100700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UeDH5hlKCOpRDxelwkZb/dcoJpMf6cadgYtcGWf08WhCEeIsMz/3gXieu03DCOqMwMQ40ppVyDtjQ8xb8wvWlKnoBAfJ2SuYbunMwcui1iGPi57WUsMuOtW3YPoC31DVISlL1wm8/N+v/8Y6DWCTJ6gff+xqEsW+l/L/16HQC+iVjqarCgtQT929St8YoMc3pUyeRS9P4MCwN26+NyqVoBfrj8LRd1XzseA1g+nVt0ET2emPNOQQe4LFGm/UXsPz98ehn2MSgUthu/yl77WhPKRK9AbFjoumwqYLUoJ4XP0XCAgqSfxfusNqPhYEZ1uVpk+qjeQm0EnAwag7JZ/jAyikfRz4r4kW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rg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a680747-f3b7-4084-3cd3-08dbdeca118f X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:46.3615 (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: 1vXBu/ZqX/zzzHmEuwE46bVU99bXgbk86OgV0yeNCkmS4al5514a9BUVAS+GnST5VIMsU5HMH79Zpa372fAf9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4513 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060107 X-Proofpoint-GUID: X36CD7ImpRoPT9TP3frUqMHHwxtXWBRT X-Proofpoint-ORIG-GUID: X36CD7ImpRoPT9TP3frUqMHHwxtXWBRT Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Chandan Babu R 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 Reviewed-by: Darrick J. Wong --- mdrestore/xfs_mdrestore.c | 66 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index d67a0629..40de0d1e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -8,6 +8,11 @@ #include "xfs_metadump.h" #include +union mdrestore_headers { + __be32 magic; + struct xfs_metablock v1; +}; + static struct mdrestore { bool show_progress; bool show_info; @@ -78,27 +83,25 @@ open_device( static void read_header( - struct xfs_metablock *mb, + union mdrestore_headers *h, FILE *md_fp) { - mb->mb_magic = cpu_to_be32(XFS_MD_MAGIC_V1); - - if (fread((uint8_t *)mb + sizeof(mb->mb_magic), - sizeof(*mb) - sizeof(mb->mb_magic), 1, md_fp) != 1) + if (fread((uint8_t *)&(h->v1.mb_count), + sizeof(h->v1) - sizeof(h->magic), 1, md_fp) != 1) fatal("error reading from metadump file\n"); } static void show_info( - struct xfs_metablock *mb, + union mdrestore_headers *h, const char *md_file) { - if (mb->mb_info & XFS_METADUMP_INFO_FLAGS) { + if (h->v1.mb_info & XFS_METADUMP_INFO_FLAGS) { printf("%s: %sobfuscated, %s log, %s metadata blocks\n", md_file, - mb->mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", - mb->mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", - mb->mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); + h->v1.mb_info & XFS_METADUMP_OBFUSCATED ? "":"not ", + h->v1.mb_info & XFS_METADUMP_DIRTYLOG ? "dirty":"clean", + h->v1.mb_info & XFS_METADUMP_FULLBLOCKS ? "full":"zeroed"); } else { printf("%s: no informational flags present\n", md_file); } @@ -116,10 +119,10 @@ show_info( */ static void restore( + union mdrestore_headers *h, FILE *md_fp, int ddev_fd, - int is_target_file, - const struct xfs_metablock *mbp) + int is_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ __be64 *block_index; @@ -131,14 +134,14 @@ restore( xfs_sb_t sb; int64_t bytes_read; - block_size = 1 << mbp->mb_blocklog; + block_size = 1 << h->v1.mb_blocklog; max_indices = (block_size - sizeof(xfs_metablock_t)) / sizeof(__be64); metablock = (xfs_metablock_t *)calloc(max_indices + 1, block_size); if (metablock == NULL) fatal("memory allocation failure\n"); - mb_count = be16_to_cpu(mbp->mb_count); + mb_count = be16_to_cpu(h->v1.mb_count); if (mb_count == 0 || mb_count > max_indices) fatal("bad block count: %u\n", mb_count); @@ -152,8 +155,7 @@ restore( if (block_index[0] != 0) fatal("first block is not the primary superblock\n"); - - if (fread(block_buffer, mb_count << mbp->mb_blocklog, 1, md_fp) != 1) + if (fread(block_buffer, mb_count << h->v1.mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); @@ -200,7 +202,7 @@ restore( for (cur_index = 0; cur_index < mb_count; cur_index++) { if (pwrite(ddev_fd, &block_buffer[cur_index << - mbp->mb_blocklog], block_size, + h->v1.mb_blocklog], block_size, be64_to_cpu(block_index[cur_index]) << BBSHIFT) < 0) fatal("error writing block %llu: %s\n", @@ -219,11 +221,11 @@ restore( if (mb_count > max_indices) fatal("bad block count: %u\n", mb_count); - if (fread(block_buffer, mb_count << mbp->mb_blocklog, + if (fread(block_buffer, mb_count << h->v1.mb_blocklog, 1, md_fp) != 1) fatal("error reading from metadump file\n"); - bytes_read += block_size + (mb_count << mbp->mb_blocklog); + bytes_read += block_size + (mb_count << h->v1.mb_blocklog); } if (mdrestore.progress_since_warning) @@ -252,15 +254,14 @@ usage(void) int main( - int argc, - char **argv) + int argc, + char **argv) { - FILE *src_f; - int dst_fd; - int c; - bool is_target_file; - uint32_t magic; - struct xfs_metablock mb; + union mdrestore_headers headers; + FILE *src_f; + int dst_fd; + int c; + bool is_target_file; mdrestore.show_progress = false; mdrestore.show_info = false; @@ -307,20 +308,21 @@ main( fatal("cannot open source dump file\n"); } - if (fread(&magic, sizeof(magic), 1, src_f) != 1) + if (fread(&headers.magic, sizeof(headers.magic), 1, src_f) != 1) fatal("Unable to read metadump magic from metadump file\n"); - switch (be32_to_cpu(magic)) { + switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: - read_header(&mb, src_f); break; default: fatal("specified file is not a metadata dump\n"); break; } + read_header(&headers, src_f); + if (mdrestore.show_info) { - show_info(&mb, argv[optind]); + show_info(&headers, argv[optind]); if (argc - optind == 1) exit(0); @@ -331,7 +333,7 @@ main( /* check and open target */ dst_fd = open_device(argv[optind], &is_target_file); - restore(src_f, dst_fd, is_target_file, &mb); + restore(&headers, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Mon Nov 6 13:10:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446919 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 5CD97C4167B for ; Mon, 6 Nov 2023 13:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbjKFNNI (ORCPT ); Mon, 6 Nov 2023 08:13:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbjKFNNC (ORCPT ); Mon, 6 Nov 2023 08:13:02 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4AF100 for ; Mon, 6 Nov 2023 05:12:59 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1uw3024922; Mon, 6 Nov 2023 13:12:56 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=JszUE3hDIwu+ktwFgTaUEwNT/MEZ3xigHTSeM3YS8Mc=; b=RBr7v5TlgHoc3yqFHJjrO0eG0cAU0WPNPajt0H/9Aub/Ckq5G1izLCrgXL5XFWxeijzE atCzILitbK/XlLNM/6hPrX5Od0/L0zMl6PESKC8eFvwdCbsGxPCsewMINifrjQzdzomG QEEFxE8eN+6gm73nXYhXgbwn4I7vuRiS2YeRIBhSW5nHqjXHrorX+tnS+yX8Kg6iPQVB z9ZdOX9ZSa7Mz75w94/M3x+Wh2XOK8of540IVSuHlChIVUW1PnpTt9PMJqE2Jnsi6NtG c2GfE3th+6VNyQy4VoDig7tnDo45TJ5w6nHYr2gh+W+KNv1u6mTR7wpS3N9wcyCGQqWq dw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5ccdty71-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:56 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6CH7Dn030442; Mon, 6 Nov 2023 13:12:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4tcks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:12:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jFSz0T5w5LtfPn1SAKmE0wEtnJu9+vhIYNqUaQfxp5tpq1oTkRLBep4fnFzVxFZlJlyu4pnruvMjHr+fKX9UnGpA6SfBLvxzGk7U2neyx6GPAP7NqV+shAMxHj6SAOss11/c0HE0pKdcwIsNIUHbA+HGLzTXq7Sm5+NxZtUrWR5FFzRP+ceujOh5h8ZGu8AhF/uoRkSUXVPuGigFGAaAcYX191iwd1jd0iVHPesesmSE6vIMol0mE0yQrnGs6qeYXpH0h+RVSKDlz/JF6UEbqC8bbOZ0sno96jiXz0iJiBe5IyA3aM3KFkpjbddL3vA0AT8R4f0DKf45wLC/HVw7Kg== 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=JszUE3hDIwu+ktwFgTaUEwNT/MEZ3xigHTSeM3YS8Mc=; b=NtTkMxYfpNrfnRRY+1eaFMm54j5yf2LAvnEdkLl2ekwuqXtRvNmxgk78nv91Y9cPwjoiRSnI/4W/6P6dXOcDbbNxwswwrFPM51ODIrY+ads05omK/PfdpfgZGiAC445CAtb+h3Ccg5SxAHMWdCJWTLkHtRk0lRGnJSIKurwAxZgcyqP6OK80JsPXEkhzx0HEhrbXx/1AiJWYD1ndDsE94PkrPdopmGeFrAVG6fGD+gAuF4p6jYUAU1EEY9bh7dkVFeTpboGPRUB94+qjoGIuE561/TobtjzwFLHpyOY7/2MSIh+U26ru7SwnQumY4jEKOE5yEFUnVE+aWMLiwhvs/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JszUE3hDIwu+ktwFgTaUEwNT/MEZ3xigHTSeM3YS8Mc=; b=bX6Z5f3MexMwkLn1/UdPExfHo/RXk9RJGpuMaJqGpz+ZfqWGGAYCoi65sLSa7yaDB1vZ9BnpbffE5gBgxtTaAeKvahCcuhzSNS+GHXBGcJHq7mpX5j2hF2FLKX+Xnnjcbjj6/DtVpoIAWgRK55w6GvV2eHpXXjvXAO8BtSTUnzo= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BN0PR10MB5127.namprd10.prod.outlook.com (2603:10b6:408:124::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:52 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:52 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , chandan.babu@oracle.com, djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 18/21] mdrestore: Introduce mdrestore v1 operations Date: Mon, 6 Nov 2023 18:40:51 +0530 Message-Id: <20231106131054.143419-19-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:196::23) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BN0PR10MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: c7eaccec-7689-4600-89cc-08dbdeca1527 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cOFGDojM5TMGCtuQjpCILf6zKn/pRCdP3vUPEWDTGvAtIU6LgVfv0xlWwCvJdZVbdu1ssyYSymYIvYpjic4AYSQtJJwZ0VpZOPkCsqyqbBujsdZ8urZMLZX+RG51PtnELt4TJ9S7kdFV6s7nenr/PxkokiFn3TfoldHuIAzz/5PpKwbMi/d/C6hZDHp6NcGGMSrh8laSPU8no2Hnu8JHNFCyuxOK3AWIW+oSa3bhyou+lI3lBdzXctyDXUQn7OSBsbgauPqU1qMTf1IIgzyLY+ks+EyTZ2Bi9zzOxNUcqXwugcBDekCcsBeAiU6IgHwaPzJjqhClosmRG8E0mHZtZFZLVXX1hHbN9TWrIBR5z9lBu8yNY+iZ9MCA3i2PpFdjWIQ4KOUvhcmC/+Hdkipgc67SK+mxUpqqSLg7XuFzdgXRKIZUivf8ChHlQZxsPEnN+XjUaRC6UW8sSvtFvHScnh1htURdNnsjAm0oeBAYNRC5GAkzNUI8U76WkwK3fOopwGwsBOCeXOa2dgyoJMzc8ORVy4WAFhvUYdl8vuQ5mpH0+QWKmLsCUXLdHqs1SlSG1PZnAPOaPlgx5NS4noq9b0PoKduW+3KNoBmffZ1OWJ7xMC4jqAEq4wH3hsQIY003 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(366004)(136003)(346002)(376002)(230173577357003)(230922051799003)(230273577357003)(64100799003)(1800799009)(186009)(451199024)(478600001)(41300700001)(6512007)(6506007)(2616005)(6486002)(83380400001)(8676002)(8936002)(2906002)(1076003)(5660300002)(66946007)(26005)(316002)(6916009)(66476007)(66556008)(38100700002)(4326008)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YC9sPEmsr8qZIyR2sgSibFGazORkhKVvgEzxP6/08EfLLAnmBdOBzdwFE8vsSK/yeCH7/I1hG1cEGX25s3p6MQLsX9w0wY9ghkBrZ0p0fPr/GGq3J5srQTsIknosew0y/5PAuW/C8lvh2Z+ljAAJ2H19/ubaRCxeC118UdIKKGgPEroV6ssEPTnE/dzscNSJXWa1924hngST1KjUPnf3DdCNgTmgDtpMrdrRF0zIg7WwzXTKKhrykTWEqR68pmDIKsWk2I0Zyn38wIdPLcI20XmFtMn+PcA4f9f4ENHdoQtdPZirjrQZhVGe1bq+8HhTbqe14LExz91hwmMRriRLD1+YJ6A9l9GoDeddmkE/hdjvDp/1DR0n2YddydRrxg8uxbozjuhI8dOU/AK+BJL3ZR4N43QO/hnjtwJVlIlG1vz3aNuFuqAbKSIAeULIAAbXAMsX8r6z2jD4oqH2cjzEJAF+MeG3TFhWT0+xplycRx4jECBwWmOT20Uk6h1t57Sql+3ti6ZkJ8w0thbeDcHMcTYBYKpjXBCr65gJeNYfcRV1P0eDiOw2DOrVrusZRmVJ7OI0ZujZhD//GwfpEq+aruBlaCLhvl7r7/gOQz4p6l/SefrKH++0HIRJ+O85i+X9IVwODEEzLBRP0HUjF5FROcoFRoWO7qS76MTFNbAXYByVsvIrb1tnLsc/sMvvQhA2WwKYadWoAjdoJS4OkYs3anrJl0yd8Pf4MD1xmPgdxPPQIppFd6SagncB4fP6eR+WVtMCk9PnaNeLTxVwqffIfX3kDILAsdggFCddvyZcSyTsr25pGccB+wYqWP+SRDyIHieHaGVjOwfDOtAISxS9A/reoYg+REzVc/Yc55BBz6rudj9cXDlsa1zqx7Riy9kOtJ5zjPyp3NdiDcToi0tClvswMd+T+hCmTjzHxSanoxAG+zjyh/EMUzO0q3z9tdsXWZdOqPOVujmDclfuFf99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mYikuFTOm/2blKIPAWZWIZo9SDply5WOaHiZ0srfP+r5BPBhMStZ5dYdp+FtAq9FIg9haXBbGQKUmIeFeqNy3KE9aZAGg1YRJqQ8qVt8QWRJptgCp5GSShyjiKiIJNHNGSWCQQlwXNy72fhLGH3spYVB3FofgMdCK8qQ+UXtWMHw+CQlJijBUALIP9Y4WhaHwNlv9Bj4PIxQQeNhzacry0YsXAhB3pMpWgkRZ0oxV4tmlDxKEIiJGxObeB7UGnsUh+7NUD36eACgMkI/DTGWxdjxpjc1Il2RCZxM6cqnwAe06wQvoqE2fsMbtOu5Asiq2uzJCE7CxsZPyHsLqYsp66iZKYqnqSmw0uFHJPPgND5aHItjjvX5OqwnRDDpMjWe1KA8pTNay7r0EKm4XR4fPujpIWsszkPJ14BYJWg+GA24Kb0vjSgEy//FK5CBvN+e0A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7eaccec-7689-4600-89cc-08dbdeca1527 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:52.3758 (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: IUicWUG+VeiVJr4ByDUg3Bxx/dKCYo0lpObZvKY/8yK3bA7I8ZFUI3pHZLmkQskIRYInH1wt2OwC0A6PDo4mwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5127 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: l0c9bzUAYAYKKOv3GlRIy3b1F4cmJExM X-Proofpoint-GUID: l0c9bzUAYAYKKOv3GlRIy3b1F4cmJExM Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Chandan Babu R In order to indicate the version of metadump files that they can work with, this commit renames read_header(), show_info() and restore() functions to read_header_v1(), show_info_v1() and restore_v1() respectively. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 40de0d1e..b247a4bf 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -13,10 +13,18 @@ union mdrestore_headers { struct xfs_metablock v1; }; +struct mdrestore_ops { + void (*read_header)(union mdrestore_headers *header, FILE *md_fp); + void (*show_info)(union mdrestore_headers *header, const char *md_file); + void (*restore)(union mdrestore_headers *header, FILE *md_fp, + int ddev_fd, bool is_target_file); +}; + static struct mdrestore { - bool show_progress; - bool show_info; - bool progress_since_warning; + struct mdrestore_ops *mdrops; + bool show_progress; + bool show_info; + bool progress_since_warning; } mdrestore; static void @@ -82,7 +90,7 @@ open_device( } static void -read_header( +read_header_v1( union mdrestore_headers *h, FILE *md_fp) { @@ -92,7 +100,7 @@ read_header( } static void -show_info( +show_info_v1( union mdrestore_headers *h, const char *md_file) { @@ -107,22 +115,12 @@ show_info( } } -/* - * restore() -- do the actual work to restore the metadump - * - * @src_f: A FILE pointer to the source metadump - * @dst_fd: the file descriptor for the target file - * @is_target_file: designates whether the target is a regular file - * @mbp: pointer to metadump's first xfs_metablock, read and verified by the caller - * - * src_f should be positioned just past a read the previously validated metablock - */ static void -restore( +restore_v1( union mdrestore_headers *h, FILE *md_fp, int ddev_fd, - int is_target_file) + bool is_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ __be64 *block_index; @@ -245,6 +243,12 @@ restore( free(metablock); } +static struct mdrestore_ops mdrestore_ops_v1 = { + .read_header = read_header_v1, + .show_info = show_info_v1, + .restore = restore_v1, +}; + static void usage(void) { @@ -294,9 +298,9 @@ main( /* * open source and test if this really is a dump. The first metadump - * block will be passed to restore() which will continue to read the - * file from this point. This avoids rewind the stream, which causes - * restore to fail when source was being read from stdin. + * block will be passed to mdrestore_ops->restore() which will continue + * to read the file from this point. This avoids rewind the stream, + * which causes restore to fail when source was being read from stdin. */ if (strcmp(argv[optind], "-") == 0) { src_f = stdin; @@ -313,16 +317,17 @@ main( switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: + mdrestore.mdrops = &mdrestore_ops_v1; break; default: fatal("specified file is not a metadata dump\n"); break; } - read_header(&headers, src_f); + mdrestore.mdrops->read_header(&headers, src_f); if (mdrestore.show_info) { - show_info(&headers, argv[optind]); + mdrestore.mdrops->show_info(&headers, argv[optind]); if (argc - optind == 1) exit(0); @@ -333,7 +338,7 @@ main( /* check and open target */ dst_fd = open_device(argv[optind], &is_target_file); - restore(&headers, src_f, dst_fd, is_target_file); + mdrestore.mdrops->restore(&headers, src_f, dst_fd, is_target_file); close(dst_fd); if (src_f != stdin) From patchwork Mon Nov 6 13:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446922 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 533C1C0018C for ; Mon, 6 Nov 2023 13:13:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbjKFNNN (ORCPT ); Mon, 6 Nov 2023 08:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbjKFNNI (ORCPT ); Mon, 6 Nov 2023 08:13:08 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E89D49 for ; Mon, 6 Nov 2023 05:13:04 -0800 (PST) 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 3A6D2656011546; Mon, 6 Nov 2023 13:13: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=Utm5Lvcd+DgY9K4VopJp4jyGdtSR30ppD5dN5Gzx6HY=; b=AR2vBAuo4aBGNhZYsAOyxobPbmeaVQyMzc39fAoIBhMaocK/WjsGAlFrbZYOx1scsZFl Y7Cysg4W1Qaqu2WoECsVRWN9Aa/okuB3wNRlB68ZRQx19jidsk9pPam0IAqW0B2WxJ1o 35EOjAmPyFn8ALsUYNwYZlN6j39G0cn/Ykq3jOD35IADpu86AX35eOnrBxo37eUstgXk qaS3JTimcv1s/PrP0zmZ9i22P5A0pBMnV4mTnb20pBiwY+/mpiFBtr2m4+AVToSYyYuS nEpt4mc+rnMjSKWi+8PEQJOVzI8LrNARymCJZjv1EpqwHrdzXIIS74F9A7QPasuZyIs8 fA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cj2u09c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:03 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6CvwM9030456; Mon, 6 Nov 2023 13:13:02 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cd4td05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ehAjxuOLuNeO5O2ALXfXJUbw7KZk0EnCXBSxZ3BuRO00XR/+V20ztWa3WuLs/6nZDHJKoaVHePCtZERXJ2QXNEhXzCDUZimojupqZa+xSDAh80uWJI4m7zTgnKQt2YWflk0sj35tXCUvoKpnBE7XAYE0RifQEQxx5/6b/b0TC5BvsRN7fi0duq++J36zP1AuObcGGnm6r5Y5NCE8+PRxd3p3iA+nl4vI5ANbXIcwc4CT/pb4MXsmBdkTIh1PdzYD/00G90gV/6Ic4SegJ2T7h9R9npHVKrcbKJ5sxt+qFW6C+qcBd0dI4TGrYo7RNFx1O6tnNYBBCQT/THAERliI0g== 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=YLHcvnSrL8RRq6DxrXWZzxzh7RbKNfkWfPe+ZvhkzawAWmZjafIkxBcCq+ot24hKELQjkvcdA6gxuOr9naHOCxzAHtHHFNp98AhSvpr3IMbjvB1Zyyikkpnll/ZgJllwBFm4dSZ26C9DakveBYNxpmhYCgtN4Rnv2CUDp9gMGQUuOqMSq9Bmompi7iYZyzFv/V1YPFPq/kPJcbm+sCGtjQwVVmZZuwab0007sRT1TQofuxoKJ0kkcAANu4lDe/pH+4unnKveZrStVv656Qx0Mlq+WHf8fpmhaVPWVWkB+z0jMkwvZyXanzv/5VXxfMYfWAunvtP5xBoWQi6NAaE/0g== 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=tU7hC2Xkfg7xRwdjky+uyyKUZFFN4fSop+KnAQzUW5li92i9Aw6QNK6TjNHBQu5gkgynTDhVRJ+us2L/EGpA2AR+rim0lgBguGQoeYIWE5PHuCKxiV0SP0anedpMnuZNFEH72mWtGwjHdJCqZosKlsOyTO01vOH7QsQ4Gpmwx/k= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BN0PR10MB5127.namprd10.prod.outlook.com (2603:10b6:408:124::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:12:58 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:12:58 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 19/21] mdrestore: Extract target device size verification into a function Date: Mon, 6 Nov 2023 18:40:52 +0530 Message-Id: <20231106131054.143419-20-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2P153CA0012.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::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_|BN0PR10MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: 98f04c05-42c8-4aed-9f75-08dbdeca1867 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KvDqprYFcBO/iyLrpmrZucBmSuUdPbo0evlVNc1TMlqny5tCWdZnNAypck1LKBgBtmAJXc/j1rMmDp7SylqfucL8HgplB7z+yuLw5XQXy44Xut3ad/swRJ8oZc8qyIsygHrkdX4UNtvjQxKVKYOYyJG38ZJRuDe6LTpBez7TzY/s+weCNW8+VcjI7R4AqhxqmNa7wHdiSBWxqm77oZXIdykpM/hRFmht/avDEzyemlkyzIVPpD9KWSIsADCewzyJEYblhE9nLUoCVKC0fz54dibnXS9kgHRfrMbrO/7R4t3gk0hIQUdTDUpMawcQQo4I0o/QU8YBW8+FAVPdh0KEz7l/izS6ZbFPeSnMjyEeOlMwyWfx0fIkW0MhiI6Gk5TJjUA/spaveWxRvDEv2yL4AjTSbvEJagUtPIcV2HTRYMGOFMWyetLb69eYKN6Ep0njVAvTuSJbFz5RExh9+RF6jwrVKcE+gEGrJq9E3BvSW+/RtPgibtDiPRlqiV1OkppZRdgs9I9mEk5AQYUohLKzgC0fOWCH1XzG08dE5XZ2NbJX1/Nk5bb4Ry/Uqm0hRFv3+0MCaDocAeqmzg7XPxRh8kLcOXKN+AuzS9ENK/QAWXOuGWNa3UZZoOkQ9VSxQb/U X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(366004)(136003)(346002)(376002)(230173577357003)(230922051799003)(230273577357003)(64100799003)(1800799009)(186009)(451199024)(478600001)(41300700001)(6512007)(6506007)(2616005)(6486002)(6666004)(83380400001)(8676002)(8936002)(2906002)(1076003)(5660300002)(15650500001)(66946007)(26005)(316002)(6916009)(66476007)(66556008)(38100700002)(4326008)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S/iQLD3qVtWJ4wfPql6iZ/hHyEeuESsl7g2SsOtwfC6CQwmIHi6icXDVyp1qVUWD9YyskLukaSfCVG+bTe//G394AZ0zvzD5aeQ6xwbG13xMEFe1uYtVPjVgIQdqhJV2JYIlrfHvkkjTOR9WY/JvComjR01TO7W4JcET/qZtAGFYbUjppPk+LlgH83ix1OrXyA1JY9mEhmpUZfKR+u/wrjEcsjqa7oQpYwbSajbnCeOYuPRsVCL9eTFOpeH05wXygGm+wjYlTkkqNJSGM73fcxgPYW5atPIe59PylU6nwpzVS74s6y/vpLPNHCX4GkGV3YF3Aa444gvdHgDV1/oBvKaVKXQC5nRAflLoKrX954ZwZQ98wBkVN6/znL+rrbnexPNpRrUtzgxUScu0Sz4Xjv0fkd8msQmeANexjkMt1h7xJk7bCQp8XDt6q+H1qGTB67vRNM+u0JVN3nBe47OTCSxmQUVRNEc7UHon0gvr/T/WahRgBoXyNVVTYoAXAwttJdFUUhBiixq/B9kq88BkFDNIc2VHdu9KG8RQ0uUj9Qv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ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YtPHm82Mv/8ut+zIlnJRJcFp4AbDlICCXV4xW/+IjL6Gab7qSXYvWOAAK6ufX4/veOaeD3T0DWfJMXy3Zpad9c9QSwFXM8o98xjIg9JRQZc2e1ScSsCUwh/j3mDEqPLIxm6VtIMlj0ZPsSpeGaU4NL0393vinI7ycdpzeqmbu0DXfOpvW6cZ6TFD7lJF/oVRqhK/QpOsOrBnNV75s4kKZgI8tfgbiPu4DqNcZQAth72pU3CHhI5ZxktbDxbehFtjnI/Dqm+9QumzwYJcTndRvXYfFwyZVgGruZflE1hZHAgG37Z5jjWblp54btBWOxrSjhIpGRtTf/WraQBLizR4QJ0DOQgeWeIuy59aDvPngk7etE82l9Qv2G3xeYElvxtcNkCvR1wH2fyoGcQ3EMFRlnhOi8RsvOgWRP583p/FRbQ+bTpVerc4G89Bj8/PLN7fh2CsrBVdJqW8XkX712FwpWmB5h1tbc8m77fDkPEHcsGuynDyvawSvWrunnpt+kMZHk+KenLJ2S8vCrd+/S0cBI6/mMicm3UOhrfxAJ6Sbl6H4SCP8i6ZRSDsEv3ySHarBHBZu+ilyPvGc26RoCzkG3ax3I9FqR82mHPlkqYUOnlfFJtFd7EnVJsGr+0ZGyOFyaJ87RSKbMNfMcppicgsSCP3UMg59DgAGKtyYjsWb0dAuC9cLY7/o1SnqFS6uYM/7buRWMoPUxO6kLLBOnlnttbVamE+61gjr1SeqTKDuKvR+l3oaRjZE4LvqSIJkuexfZF/jWTA0SfEI8bsMPXkzSY8Y9QU4gNwkQb+7sCBSAs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98f04c05-42c8-4aed-9f75-08dbdeca1867 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:12:58.0051 (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: w6bZxDXj/zjVHsbeasZtpEozULQjgE2g3QXfYiIPW6ojVozOssz7Xm9BWhlrHaz8BIKCdek3M00D5UFsi5/AxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5127 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060106 X-Proofpoint-ORIG-GUID: TgcMQ1fIaUUo0EBP-KmiuxOlEGSWdiaE X-Proofpoint-GUID: TgcMQ1fIaUUo0EBP-KmiuxOlEGSWdiaE 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 Nov 6 13:10:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446925 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 DA350C4167D for ; Mon, 6 Nov 2023 13:13:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232168AbjKFNNs (ORCPT ); Mon, 6 Nov 2023 08:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232199AbjKFNNr (ORCPT ); Mon, 6 Nov 2023 08:13:47 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F2C136 for ; Mon, 6 Nov 2023 05:13:44 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1xBB006667; Mon, 6 Nov 2023 13:13: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=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=qsSBIzLiz+5fFrWU+k3DXu1TrRQoJi7bPeZbiXiFVyq1fJ+R4e4o0QbhMwHsOdMJLEs0 HgoKkWdVIMMnANPqLTVKZT/jB6iNEhml55k3NPn55kRupZiyz88cA009GWsfVn6tLPEN 35vfLp60eLQ6UebteQ4NKzJzeAwBQw3uoqqMWWy4XU+0B6J51cngE6MXpAGfiE+b9oT8 b1lyEA4MMaqGzXRhaWfjwLI12H6h8W9UveD/MJ3zcfKteWOjNPFXeeghz9rtBfKXh0M0 iJQL/ILy9NzyYZFzhNukpyvnCTa3DkHF2gJ+rxADXxyL+MPpOc2t+5WH75r880rDAoIW PA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcb09w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:40 +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 3A6CaunF024808; Mon, 6 Nov 2023 13:13:39 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba9fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WRLy/7Aknkt3tLGQpnbVD9L37+3tTrWaBiEQsaQflejsp+OQQMlug2BY7k2CT8vaXanr1bUUt4gaLklwYQ4+b1s8uFbF6Cn5zD7amzrXcz4V77lk9zJY1E8HA6LcvjMxbCdxvDno/cPvIIBGX5ARJFDSFhGNiS3Mgy/0QmMD4S3dhTOLepLoXcqwbK3frN33hspq24n4VTzBrqf6SHqFOgkGOVQx4QZJHVYikbO40fGosdrd3Mak6akkNylyuwokdlTqiVu2mODuLQeZRV/ITIMVLEbadscFnt6Kr3xiYf8cM1g34ARcMFbnAXtdmp6wohtWvae5WFxLqLFDRKGtGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=kS04tjH7/tgOCkDyhlf6kUKBY4PzshWN+/cNsU+6KMgUvCVXeHqLYPhP6pIEPLOaKGneQmtGEmlwOxiWPjrA+kPYwq6OCsaPSd7GzZElfIcSa1iSveAyXBObW5tmAU2xlxx/gl8te+4sO8X53ELpDx1988koUCCC8QaqBTC7HGaai5KbMz9ME/vupfzobIOSMC5vz9qj35xPUZ1HVGTKLWep7tCqBHRJWHUrxKBJ7ZyXENHDTVHE2hc3suCVXdeznNNuNR7yD+Ehk7RelCFtfbT1Rv0mwK0vVI4063eFwTtYRf4NEdEogUB3+bmTPc2Ge/7Y+bQWtOIiYKcFBhhswg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GtfiDGiHWQhg/lFBykhY49xpmv51EHtbMSF0OyQcM3s=; b=c4sWlNdoLTgm7W+wezbqXc7fghk8py+n4HYwMktQ+6Q6JUyFQHw3aUyqqT2hQfkdvFs4oGp/LryWwTna5T87nsIjrjB4E4QTVtTd6+a65/SaR9UctxJLpQed7SZIWmDx1gWmMUnCsb3lHDg02L+TIXS9fzFLQbp9fXIPFAkPlRE= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BN0PR10MB5127.namprd10.prod.outlook.com (2603:10b6:408:124::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:13:03 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:13:03 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 20/21] mdrestore: Define mdrestore ops for v2 format Date: Mon, 6 Nov 2023 18:40:53 +0530 Message-Id: <20231106131054.143419-21-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI1PR02CA0020.apcprd02.prod.outlook.com (2603:1096:4:1f4::9) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|BN0PR10MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: 05016bc5-6452-4cdd-8b32-08dbdeca1bde X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SkQUcOR0qPsO2fliA65iw5QTSJ9pPcEyo7piGAWcQaxfsfLPQ2T8klet29wWye+N6zQLblrmx1D9IBxwtqAKnSeAMOKhb9No52Z/OhQDhXsu9AYKyiTtEC3mRNyH5pdQJwVjhpz46ESzx250JmfsBRkDofj+ucGMuk9o/PfCIN7CuSAq5Z5JI24hLgeU2qDXic9ccqeCIkbIhPhSoCjFaAI9/+x6LeJUUTcgPNyg7OUfUfuk3ySPX2DRcAT0SNaMuu+F3Az9p0/yGYKApPQH5RJAO6srS2RF3nmQ4/MykQmokccbr6ezZkauQxkGNdondfkQYMwRbuOjOWdxs45/aqibyUhbI4fei+zcwlD6ev3CWqFgjmFbbj6VMP8ge4pTlcjqE0B+fLJfrbpZO/LduYCvHF3z+5O4IMR+fl/gIAQTRlAl+mgi0Ds+mTrYt07c4I6Q8i+IGYd7WXNrH/zZL4i1IXdrlLjruSHTkpqJHLr6iRHiDRfrCjLM6ZeErYHRdynS9E0ow7QjwWfNTgfNVQLohm4Ovx9RWTBLwM92+bHI6rOcX1feGB6TxpOf8mc8u6td32hKCsPXW6VtaIsyRAYNLXmGjORX8bhf4dKaRup+xpomeDHpcAI4JNO96ySr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(366004)(136003)(346002)(376002)(230173577357003)(230922051799003)(230273577357003)(64100799003)(1800799009)(186009)(451199024)(478600001)(41300700001)(6512007)(6506007)(2616005)(6486002)(6666004)(83380400001)(8676002)(8936002)(2906002)(1076003)(5660300002)(66946007)(26005)(316002)(6916009)(66476007)(66556008)(38100700002)(4326008)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C4t92JS2R1MPQq5Z5sp74tOPh0USvo13IgkIUlDk3kO3fLetPrOIQ6/v5CbeSkPX4/QCS7zTX4/mTL3twQdg3uqk9Q+NlW6QAR3dtJrR/eVjEIDacEjM/Tjw4rFLP2MvqESYQEITtnpN8e3OALd8qfZhDtQmTvXEBBYfVeqCT1k2/v+WjDwhx7ZLgOpqVuz5aGieRUqnvCYutP0bHoXlV/43kkhrMV3jEPOSQttuRzaelLM6yQRVqvd/4uGWahY5tVojFstEQPKFczEKI+wpBVXuYwbfQRbAaH0kM6pPQ8S3k5g08iAWOpkEpVeywzOo0VBn9WThWeWeP4VIx96nXV6ivTNC5X/wM7Tx6OguG+deprNibB2tiujMCv3ROj+BG/za7WIgjfbE+8APtyHQDQRjRU2HDcaf2SeGD+3YcpWIj7OI3mzS1GZGXQ4vb/K7AucQCse7puUPjQ4guUN0pXpUZR33Zl6Dwk218jFXsZuuf7/Ulb6ESupRG9wbhn9ZIfDLBE0fh4G3SgfpaCiR++p1cyz9kJhMUUkiwfcfK3GLnkZFgyriZqgAIdgtqz+B78aXY6GgLC0igmgB+/2psf22ZfE8XBbYVnKsXzPuTSkxXgYnbRtW9ZpsPDpd9i4DIod3xkrzNz0B+u/Qa33koFtYVUCSRFMQgTbmRImT9z4myr/fqxpmfTkEvUdmS9yrvLqP+k7SVriSIa3N+GL9zMCkG5BpYNdd9ElebqdQiE3pr/DjkdSuX+7Prbdyy6g6+JXvuXFyTPYRjGnat2n5/QFHdollGo6BnzxNqj19eSZvGCxNxx4Bl3V9qGzUvNwYDLwdDpjZPhIVQ8+OlISEr2y3guxQjA+u5iP+IGlact4qbrAvmngcWnxnx5nOqKQyCpjzXEGRo8mR1YR931CfDgdEqw1j5BBmuMunabShY60F/PDe/IGwbUtz4/RjA/bmZaYiDnxvS1hyTq4IxKg+kMtdSJL+JzIs1XIcerrhxrmJEeIKZhw//NkRADMynsl5MCwD6tTYdRZpynW8ynasKeVDN3OFw/D7di4HLqOitdPRHX7VLSAOBR8vvoTh568yX9uLmeOpXLbGSRNoTNbwzdmoHD/7L+ZZEK+5K6rs1ugVPFiUHScdchv35KSmHP44ggFCLoEcmajE8Uqs6F0giFAzrn0Fny6qkx567BUGGdJHHw94cnSpMUBrVySrCleyFoybtR3/aVGCLLCw8MIavihNeiKJOwV8uo3rMdxnmqvmWZnYi5lc904pZSNww9WH/zBTjhhAtjpzJKipKdC/AiK0jV0CXGShickokv0QV4BqP5+rm8XmESxYGPB8J1MSXWiUp+cb+qbT8EGg8Smk35/+jrCxcouX1fNWk04KgVww06Ha/IGMZR81Pviu7VJE0e+jevyKaIH9n96uGfPaJnYRN0LVme/3rTHBlZoEdat6DvtkyJweGDtCsBoNIHzJAz687DPfQ3AvlZU6C2xXAtje441ash74ak/xFVlZ5MBdY5sk6rdn0mVBP+kBw3uALWcgtPu9sIQntRqFK9YBpCmDKwZZddZRbe5rwB/RBLIeHTMtJYUIDbEPeOfVNYNpAdKveU0WrkcjGIJOLzy7/Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OR44VUlzBDRu1Tl7ROJpHKSxL9iNrI9NUxDJ7orFyy6gFV6Y79WtiGeGMoDNdeKRADuGm465NLuO7adKdTsM+ILYyvNqAm4iRguwNYrxqsaGMzYfVJmlB6lEBhIQy0jZUuuZx1SQtJ8e8/H6HbfDf6EP9jIQW3uXQyObnQzbZQF3+ouskMdQDEQ7ldIOVy1DsofBNihp/0Q5aTmnT31Lmr6jeU25SR1VzaNqA4w1Wk4d1meHd66LfvpdrmpZbjibN1AeREMWx3SSnnLsmyRphPAR6pWBq2pZWixJ3ncHAad45jEKCeV6HHIYwpFdf2qVeIytZAzRPlmdsXBJ7wPkD8yRSAqdEweEYII4oRbGHZ48Oq+C8tb9fv5mA50alOLkydj3A66Cd4PRzw/mykrDjZ42mWSRzLzAhyx4gf+pLF8+FsC6L6/KEOt++7e4E3Q3dUIu6LaPr/gBcFfKVXoJCKN6WodM2DBTXxUZG4RaI4haDKqeQ0qo10TGa8gDv1CtTzTeMz1iUbQtNPJ9xdkJKsVj3GbYb+8zy1n9K1wYvglPlrd0GbSrBeOpccpZH9e1nEPmNbpz3w2wddjRsBF7bvNadj9ZX8TgzqZHxRWhAaDRNeF5mUdp+yG7wvjus4EftpJPSNxrGoTJ3C0RNd/ltCcNCHzF59UujrWhzJ9sv6L1fh/Sk9AQ81YBnW61v6ks2rbw/iEXHLDZ+0d7XYzbei254K80OUWZfs7lNC/Xa/UTJxmRS/2xn3xacBI9iGvhVG5Gl6PH7NlH+DA7Kp2ZlnfGt9tHwKR/x+bHGvkFsVI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05016bc5-6452-4cdd-8b32-08dbdeca1bde X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:13:03.8168 (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: O7UhgKbMoAqwIJMGlDowM1nStkh7fmk5hKQR9jMlL7MrzgjoICflqL1ziMqqR8w7r47FEY/MAX7KqGybxUDNTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5127 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060107 X-Proofpoint-GUID: CMzpI9nxrXFOoldnMHfVg2J9h9GGfVRU X-Proofpoint-ORIG-GUID: CMzpI9nxrXFOoldnMHfVg2J9h9GGfVRU Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds functionality to restore metadump stored in v2 format. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- mdrestore/xfs_mdrestore.c | 240 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 228 insertions(+), 12 deletions(-) diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 0fdbfce7..105a2f9e 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -9,15 +9,17 @@ #include union mdrestore_headers { - __be32 magic; - struct xfs_metablock v1; + __be32 magic; + struct xfs_metablock v1; + struct xfs_metadump_header v2; }; struct mdrestore_ops { void (*read_header)(union mdrestore_headers *header, FILE *md_fp); void (*show_info)(union mdrestore_headers *header, const char *md_file); void (*restore)(union mdrestore_headers *header, FILE *md_fp, - int ddev_fd, bool is_target_file); + int ddev_fd, bool is_data_target_file, int logdev_fd, + bool is_log_target_file); }; static struct mdrestore { @@ -25,6 +27,7 @@ static struct mdrestore { bool show_progress; bool show_info; bool progress_since_warning; + bool external_log; } mdrestore; static void @@ -144,7 +147,9 @@ restore_v1( union mdrestore_headers *h, FILE *md_fp, int ddev_fd, - bool is_target_file) + bool is_data_target_file, + int logdev_fd, + bool is_log_target_file) { struct xfs_metablock *metablock; /* header + index + blocks */ __be64 *block_index; @@ -197,7 +202,7 @@ restore_v1( ((struct xfs_dsb*)block_buffer)->sb_inprogress = 1; - verify_device_size(ddev_fd, is_target_file, sb.sb_dblocks, + verify_device_size(ddev_fd, is_data_target_file, sb.sb_dblocks, sb.sb_blocksize); bytes_read = 0; @@ -258,6 +263,199 @@ static struct mdrestore_ops mdrestore_ops_v1 = { .restore = restore_v1, }; +static void +read_header_v2( + union mdrestore_headers *h, + FILE *md_fp) +{ + bool want_external_log; + + if (fread((uint8_t *)&(h->v2) + sizeof(h->v2.xmh_magic), + sizeof(h->v2) - sizeof(h->v2.xmh_magic), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + if (h->v2.xmh_incompat_flags != 0) + fatal("Metadump header has unknown incompat flags set"); + + if (h->v2.xmh_reserved != 0) + fatal("Metadump header's reserved field has a non-zero value"); + + want_external_log = !!(be32_to_cpu(h->v2.xmh_incompat_flags) & + XFS_MD2_COMPAT_EXTERNALLOG); + + if (want_external_log && !mdrestore.external_log) + fatal("External Log device is required\n"); +} + +static void +show_info_v2( + union mdrestore_headers *h, + const char *md_file) +{ + uint32_t compat_flags; + + compat_flags = be32_to_cpu(h->v2.xmh_compat_flags); + + printf("%s: %sobfuscated, %s log, external log contents are %sdumped, %s metadata blocks,\n", + md_file, + compat_flags & XFS_MD2_COMPAT_OBFUSCATED ? "":"not ", + compat_flags & XFS_MD2_COMPAT_DIRTYLOG ? "dirty":"clean", + compat_flags & XFS_MD2_COMPAT_EXTERNALLOG ? "":"not ", + compat_flags & XFS_MD2_COMPAT_FULLBLOCKS ? "full":"zeroed"); +} + +#define MDR_IO_BUF_SIZE (8 * 1024 * 1024) + +static void +restore_meta_extent( + FILE *md_fp, + int dev_fd, + char *device, + void *buf, + uint64_t offset, + int len) +{ + int io_size; + + io_size = min(len, MDR_IO_BUF_SIZE); + + do { + if (fread(buf, io_size, 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + if (pwrite(dev_fd, buf, io_size, offset) < 0) + fatal("error writing to %s device at offset %llu: %s\n", + device, offset, strerror(errno)); + len -= io_size; + offset += io_size; + + io_size = min(len, io_size); + } while (len); +} + +static void +restore_v2( + union mdrestore_headers *h, + FILE *md_fp, + int ddev_fd, + bool is_data_target_file, + int logdev_fd, + bool is_log_target_file) +{ + struct xfs_sb sb; + struct xfs_meta_extent xme; + char *block_buffer; + int64_t bytes_read; + uint64_t offset; + int len; + + block_buffer = malloc(MDR_IO_BUF_SIZE); + if (block_buffer == NULL) + fatal("Unable to allocate input buffer memory\n"); + + if (fread(&xme, sizeof(xme), 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + if (xme.xme_addr != 0 || xme.xme_len == 1 || + (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) != + XME_ADDR_DATA_DEVICE) + fatal("Invalid superblock disk address/length\n"); + + len = BBTOB(be32_to_cpu(xme.xme_len)); + + if (fread(block_buffer, len, 1, md_fp) != 1) + fatal("error reading from metadump file\n"); + + libxfs_sb_from_disk(&sb, (struct xfs_dsb *)block_buffer); + + if (sb.sb_magicnum != XFS_SB_MAGIC) + fatal("bad magic number for primary superblock\n"); + + ((struct xfs_dsb *)block_buffer)->sb_inprogress = 1; + + verify_device_size(ddev_fd, is_data_target_file, sb.sb_dblocks, + sb.sb_blocksize); + + if (sb.sb_logstart == 0) { + ASSERT(mdrestore.external_log == true); + verify_device_size(logdev_fd, is_log_target_file, sb.sb_logblocks, + sb.sb_blocksize); + } + + if (pwrite(ddev_fd, block_buffer, len, 0) < 0) + fatal("error writing primary superblock: %s\n", + strerror(errno)); + + bytes_read = len; + + do { + char *device; + int fd; + + if (fread(&xme, sizeof(xme), 1, md_fp) != 1) { + if (feof(md_fp)) + break; + fatal("error reading from metadump file\n"); + } + + offset = BBTOB(be64_to_cpu(xme.xme_addr) & XME_ADDR_DADDR_MASK); + switch (be64_to_cpu(xme.xme_addr) & XME_ADDR_DEVICE_MASK) { + case XME_ADDR_DATA_DEVICE: + device = "data"; + fd = ddev_fd; + break; + case XME_ADDR_LOG_DEVICE: + device = "log"; + fd = logdev_fd; + break; + default: + fatal("Invalid device found in metadump\n"); + break; + } + + len = BBTOB(be32_to_cpu(xme.xme_len)); + + restore_meta_extent(md_fp, fd, device, block_buffer, offset, + len); + + bytes_read += len; + + if (mdrestore.show_progress) { + static int64_t mb_read; + int64_t mb_now = bytes_read >> 20; + + if (mb_now != mb_read) { + print_progress("%lld MB read", mb_now); + mb_read = mb_now; + } + } + } while (1); + + if (mdrestore.progress_since_warning) + putchar('\n'); + + memset(block_buffer, 0, sb.sb_sectsize); + sb.sb_inprogress = 0; + libxfs_sb_to_disk((struct xfs_dsb *)block_buffer, &sb); + if (xfs_sb_version_hascrc(&sb)) { + xfs_update_cksum(block_buffer, sb.sb_sectsize, + offsetof(struct xfs_sb, sb_crc)); + } + + if (pwrite(ddev_fd, block_buffer, sb.sb_sectsize, 0) < 0) + fatal("error writing primary superblock: %s\n", + strerror(errno)); + + free(block_buffer); + + return; +} + +static struct mdrestore_ops mdrestore_ops_v2 = { + .read_header = read_header_v2, + .show_info = show_info_v2, + .restore = restore_v2, +}; + static void usage(void) { @@ -270,15 +468,19 @@ main( int argc, char **argv) { - union mdrestore_headers headers; + union mdrestore_headers headers; FILE *src_f; - int dst_fd; + char *logdev = NULL; + int data_dev_fd; + int log_dev_fd; int c; - bool is_target_file; + bool is_data_dev_file; + bool is_log_dev_file; mdrestore.show_progress = false; mdrestore.show_info = false; mdrestore.progress_since_warning = false; + mdrestore.external_log = false; progname = basename(argv[0]); @@ -328,6 +530,11 @@ main( case XFS_MD_MAGIC_V1: mdrestore.mdrops = &mdrestore_ops_v1; break; + + case XFS_MD_MAGIC_V2: + mdrestore.mdrops = &mdrestore_ops_v2; + break; + default: fatal("specified file is not a metadata dump\n"); break; @@ -344,12 +551,21 @@ main( optind++; - /* check and open target */ - dst_fd = open_device(argv[optind], &is_target_file); + /* check and open data device */ + data_dev_fd = open_device(argv[optind], &is_data_dev_file); + + log_dev_fd = -1; + if (mdrestore.external_log) + /* check and open log device */ + log_dev_fd = open_device(logdev, &is_log_dev_file); + + mdrestore.mdrops->restore(&headers, src_f, data_dev_fd, + is_data_dev_file, log_dev_fd, is_log_dev_file); - mdrestore.mdrops->restore(&headers, src_f, dst_fd, is_target_file); + close(data_dev_fd); + if (mdrestore.external_log) + close(log_dev_fd); - close(dst_fd); if (src_f != stdin) fclose(src_f); From patchwork Mon Nov 6 13:10:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13446927 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 0D0B6C4167B for ; Mon, 6 Nov 2023 13:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbjKFNN4 (ORCPT ); Mon, 6 Nov 2023 08:13:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbjKFNNw (ORCPT ); Mon, 6 Nov 2023 08:13:52 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A27FD45 for ; Mon, 6 Nov 2023 05:13:48 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6D1xLH006674; Mon, 6 Nov 2023 13:13:46 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=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=yO2AUvbzklbWb0hX19KxAK/urHrfpqT+t6NQbaj+m8PzRsrogdGkRLFbuwrXo4qEeTOD ZgXyuxiYr1djkQk0XemfDQSeWY2bBSODRp0bseoNIbB0hEcDvHa5mBhZh3CROV92eAHz qm6rBjqgcZvBNjSzBNkLJ+wNW3q5a/QKeet9EfI2/4AOwxXzdt6K+XhizwL08iCvC/RQ E4lgWvf9bQIs4ef74qPoJQWL68y2vepkQ6y5OZPniyic4fzjcB2CXpkRrKdBFS1vdCfo 1MUmnxpnJ1yf4xkmz4aTmNrvSJ3O8mmvKD6uW4iCIXI1s5dxzwfJskYWuEYxtRvn2YE1 vA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3u5cvcb0aa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:45 +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 3A6Caung024808; Mon, 6 Nov 2023 13:13:44 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2169.outbound.protection.outlook.com [104.47.56.169]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3u5cdba9fv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Nov 2023 13:13:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JiHAtqqSoctkYxIXB1X1+odnWHUUeWCCtdQPxQZ91ST2Jnyd/oWjnDGcKL+JJ3QY2HmMQgPra+2l8AB6Gh3wlkb0wJg1tI3cORo2CxG66+P8MDP3Xym/WnBI04bUclsVAgjOZ/Qqnvb4Ku97WdE2IF3xxProAySDlM5uADP7B10iGgl4UoUlGs8oRcv8QIf+nmlJbIlFcDHpfZ1hiffww4g/nE/adS4k2g1Ed4kIKwJKy6FMXv5ysDnecOvGw22NG0lT4WRBKMx696snVpiYkvizvOnnVsIATe8ksUcoY7i1EgFaDEGf2e+JbPaT9yHEDzOvqWpwAMwaWDcZR6QSBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=odzP4ph++ccM8HuYeo/PMwQtgEa1OJ1S4nh3LN0sq0YvbwU+PcUCkEpY/r1wNy9qt8SfpIrPSMephAtcUzH7LtSoM2eK2NAVWWVr0FX/vUfVUnNXCMaXhPSDf+F9AkhKbs5zMuhXx+ddBDXJTGnLnAb9OBRgkMXnw0fr9gnQxzKHsy7bYvryU0QjGXq1JFYhKAcqVDpV3upYcV6ES5ZN/zoq2GJsNnXw0OSnqwNdRbFaZbCnu4ti1nCL7y1hqtTaVlbzPtM1ryqbgKF4OkIhExpDSP4r/P5XJNUEA8HI6oQ1mYAjI8AGuHHfW9j+Zp3JJiZlZDYGK9tdcoAvHtE75g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c0aqiVk+K8zuzG8NEp16kJakpNxtYtI1xbz+J/Z9R5U=; b=RAOlm+1cZrf8a+UJWThxnrjf3UWt5z15wUNjSgQt89iGTSjXoWE8BAuLPIH3WAyUS7B4Q6dkjUONH8Q/u83BojeAqQoxW0GX9ty1SsEpzdHRY1ujiVeHA961CG4bDBSytmxSaJshE50FJjNh4oxT4JPmtlmM6p47hJr4yq5JC2g= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by BN0PR10MB5127.namprd10.prod.outlook.com (2603:10b6:408:124::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 13:13:09 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::9bf4:a5ad:d9cd:f62d%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 13:13:09 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V4 21/21] mdrestore: Add support for passing log device as an argument Date: Mon, 6 Nov 2023 18:40:54 +0530 Message-Id: <20231106131054.143419-22-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231106131054.143419-1-chandan.babu@oracle.com> References: <20231106131054.143419-1-chandan.babu@oracle.com> X-ClientProxiedBy: SI2PR06CA0001.apcprd06.prod.outlook.com (2603:1096:4:186::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_|BN0PR10MB5127:EE_ X-MS-Office365-Filtering-Correlation-Id: 46acd054-f2dc-405e-b528-08dbdeca1f12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y3HRskgAELjzh5mLW4Ma9IltxCqelLzExo8XvaKMBW8ZCmDNWekvX9+WBOl7vBC8U+UPg1b7iJ7VaZKong9xOOldH+y66I+6w32xPa+EiQFTqJZH4scXgp/0bkFHZ+B/Lypu4cr9cQ08z5GdRkA6218EOv6yzzX3m1AIKcsYy4h2fZo5OaF2ulDq6i3wgG5ujJTPajsdrZwRJi21J5Pzb4UET8hz8FVzA9/YQ2/VERmHWG+2UBAdyjiE2V/LKiSNmVL8sEk4Xt4Wc0MG6W1G1fERRfliQ4VHImgYHQNiiNuWXFBIF5mNU5SqvuVAhs1Kc1rdw0AthIUt+2HXPfJYpGj3JfqEgNLOKm1NqGD9R4/RqeYmf1Y81dkgeKUMnT920QJ1Fg6nqP6ysJ89mqJ7Nx8x7ZQT59Nc+OZZi54U55kuohL/bx7uozOYLVjV/2UTSMGY9eoREQU85/JElZAZNO56g42hOjn0ErVhyIzM+NAtqsWEl/v3ncEKorvw6cxoAznrB4sCh1GqR8uxE80iZCS8rSe8pizHQdT6C/vZ7yE9Rb07omUchLBE8NtShxPoRttXjpizYs8X48Noclqlp4uSfAvW6h+Qlaf6tlYxgi4l4gefuHwGfitRm5DsUnBo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(366004)(136003)(346002)(376002)(230173577357003)(230922051799003)(230273577357003)(64100799003)(1800799009)(186009)(451199024)(478600001)(41300700001)(6512007)(6506007)(2616005)(6486002)(6666004)(83380400001)(8676002)(8936002)(2906002)(1076003)(5660300002)(66946007)(26005)(316002)(6916009)(66476007)(66556008)(38100700002)(4326008)(86362001)(36756003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ga51pPtrw4WUZUijS7WwotMpxfGzLVKfYNfCMK0gsmDqHuadaK3a62JDOWzLcMdsaAJEyn5158rSPxK091+Y8shVaeeselQBGniCGL6I14M+HLpz7NvzIuZQxNmu4M1/i2UJb6gnx3Aw6ciHcqkK2j2Xc4CNi3MLG+P/d2N1vaW7mf7p4Srs5Yj+AVoH4/RsJGOcrU/tdC6yS7tBZE+L8G4+s7g04YRKmckVcAvpeELDY4Fy/5Qg8h7asFHtqZ5lSckDg5q5ep2eFEeR9mxmfAkp+OfRjBOGREe5iEbOIXs5IrefFO++vTjvmL6M9GUOuBWdPTTMTlZAVPG/wpA96vCpeiEXrKyQsnfORE2l175U6UYxaPGAlXPFBZC+vtYrqiH5c+toCH8vfhX4NF9mtDPKx+ZLI4yh52BzbBIk6cYrYGch0Pw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46acd054-f2dc-405e-b528-08dbdeca1f12 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 13:13:09.1975 (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: wiH4rSe11VBMPcnCdB9cYIlkjfLuqeGR9HIqHvFEOHwWWZugRjrB1RPWcRUqob1b7elDl9WaKD7MWdM82BBSKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5127 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060107 X-Proofpoint-GUID: hRZ_9ZiIawamlIugXYPXIPV4kN6SMuwu X-Proofpoint-ORIG-GUID: hRZ_9ZiIawamlIugXYPXIPV4kN6SMuwu Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org metadump v2 format allows dumping metadata from external log devices. This commit allows passing the device file to which log data must be restored from the corresponding metadump file. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- man/man8/xfs_mdrestore.8 | 8 ++++++++ mdrestore/xfs_mdrestore.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/man/man8/xfs_mdrestore.8 b/man/man8/xfs_mdrestore.8 index 72f3b297..6e7457c0 100644 --- a/man/man8/xfs_mdrestore.8 +++ b/man/man8/xfs_mdrestore.8 @@ -5,6 +5,9 @@ xfs_mdrestore \- restores an XFS metadump image to a filesystem image .B xfs_mdrestore [ .B \-gi +] [ +.B \-l +.I logdev ] .I source .I target @@ -49,6 +52,11 @@ Shows metadump information on stdout. If no is specified, exits after displaying information. Older metadumps man not include any descriptive information. .TP +.B \-l " logdev" +Metadump in v2 format can contain metadata dumped from an external log. +In such a scenario, the user has to provide a device to which the log device +contents from the metadump file are copied. +.TP .B \-V Prints the version number and exits. .SH DIAGNOSTICS diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 105a2f9e..2de177c6 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -459,7 +459,8 @@ static struct mdrestore_ops mdrestore_ops_v2 = { static void usage(void) { - fprintf(stderr, "Usage: %s [-V] [-g] [-i] source target\n", progname); + fprintf(stderr, "Usage: %s [-V] [-g] [-i] [-l logdev] source target\n", + progname); exit(1); } @@ -484,7 +485,7 @@ main( progname = basename(argv[0]); - while ((c = getopt(argc, argv, "giV")) != EOF) { + while ((c = getopt(argc, argv, "gil:V")) != EOF) { switch (c) { case 'g': mdrestore.show_progress = true; @@ -492,6 +493,10 @@ main( case 'i': mdrestore.show_info = true; break; + case 'l': + logdev = optarg; + mdrestore.external_log = true; + break; case 'V': printf("%s version %s\n", progname, VERSION); exit(0); @@ -528,6 +533,8 @@ main( switch (be32_to_cpu(headers.magic)) { case XFS_MD_MAGIC_V1: + if (logdev != NULL) + usage(); mdrestore.mdrops = &mdrestore_ops_v1; break;