From patchwork Fri Jul 21 09:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13321721 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 50E61EB64DC for ; Fri, 21 Jul 2023 09:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbjGUJqI (ORCPT ); Fri, 21 Jul 2023 05:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231463AbjGUJpv (ORCPT ); Fri, 21 Jul 2023 05:45:51 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD5C730F1 for ; Fri, 21 Jul 2023 02:45:49 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36KLMd7D002174; Fri, 21 Jul 2023 09:45:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=ESzHEwhEcuR5hY/+F3/R2rSD7x5Dzbbeb6xox3SU3Bk=; b=ihlZNTLOCeaIjOxYBeQ/AaUTovnSF81ZG0PP0LncG3EWF6MnV6YE7tHwhjO3PcjTpQCK I55HdUuvhwhZfZiwqxOwSvFGd4H1xKANmB/+3QH08lhP8mMZ0srJ87eoHfJ35U62lt1s BKKVYQQObc4zi3QPH4Q1iKHdqERhQrrsgnH0reT3hRXf8S1lFI5oy0ZlrFknOriRNrLM eJRplBOMGTCCb4TDrJqhFWYRagxTIRAjY5E+dMp3E6nfdrhR/MoQCnuri9iInSdYI0PI ZA8PfPJgVaaaRHoCIOc252t62iPHmuKeuoGNYVgfZ6M9RfPdXXET2VDzuu/PEi/lXB1T 7A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3run8abkty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 09:45: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 36L8hboX038247; Fri, 21 Jul 2023 09:45:45 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ruhw9sq1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 09:45:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QlrpuySrMvnKeO6afoOA7sJHrK0w7z3xdci6DHkOlmrSwx3Gs512x2eShPLmSH+Gf1XsmiWAxYb7wM5HCwWRIo4Tuk/axpa5dONhZlfAWKB2ikPsckacajSIyEz0ToE3XrqEP9nb8jxJd0ppPxQf7tz43DDuEwCwqxZTCmMnmGz0y2Cyzr9+CgnkcvwWEomzJMDJCBxSJv0y+ABMq0tQI6Ty1kTs0FFfPZX46LUo+/v+orkDw7cqEy/pJ3D9YAc/0Y+FzK8GAmOPePNGS4zpU+wEphO282vOPx6A/AB8rv9LXKeSfMRVCyD66++hPZB+mhmJmfM+maU7HVbiepW2Lw== 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=ESzHEwhEcuR5hY/+F3/R2rSD7x5Dzbbeb6xox3SU3Bk=; b=kdFGpYDLP/dS5gZSm0CJfc5keJC5fR60JpJJV3hYiGAuRE20xVadtABsi4Aj/TlloiRHjJ+y5PysOePqi/rWtOrdl3G5BeRbxa42RXrGcZSb79G0gBJmIX/o0z78E5vxONb0tTQA+S/cVKRpGhR9tNkp+N7Qsm1ApIxfMZme7bYNXDeXs+51ktz0LJ9VcZxX+0tdBn5Sz5l2CdoJ9g//IFCUyigHaE6/MnP37AFGGLGbFT14VHKX3zkWwxvvsyd5h6aDUefQmjb7aq16pDkVFQfEMvVKGNb2M998zrqGZQ5bjRAIz4FQklaXENFjUqbXOZQosdC4OXYE1zfLqsN4nQ== 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=ESzHEwhEcuR5hY/+F3/R2rSD7x5Dzbbeb6xox3SU3Bk=; b=VKWZ+Ag50fVfch90k0osduGZGT75SqvJPFm1YBQLzgUodJ6nbO1d/xuT/TYK7t/gMzauuwph3bVpZ11VfT2zC90LPXibOy1biumoA8ojExwNrrgHTt3o2LcXLxn098SEWN6Sx3Myd08Jj11gGxflBv34tNbZz3kRJLt1Tr/w/DQ= Received: from SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) by SA2PR10MB4412.namprd10.prod.outlook.com (2603:10b6:806:117::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28; Fri, 21 Jul 2023 09:45:43 +0000 Received: from SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0]) by SA1PR10MB5867.namprd10.prod.outlook.com ([fe80::707c:5a02:87a1:38e0%3]) with mapi id 15.20.6609.024; Fri, 21 Jul 2023 09:45:42 +0000 From: Chandan Babu R To: linux-xfs@vger.kernel.org Cc: Chandan Babu R , djwong@kernel.org, cem@kernel.org Subject: [PATCH V3 00/23] Metadump v2 Date: Fri, 21 Jul 2023 15:15:10 +0530 Message-Id: <20230721094533.1351868-1-chandan.babu@oracle.com> X-Mailer: git-send-email 2.39.1 X-ClientProxiedBy: TYAPR01CA0128.jpnprd01.prod.outlook.com (2603:1096:404:2d::20) To SA1PR10MB5867.namprd10.prod.outlook.com (2603:10b6:806:233::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA1PR10MB5867:EE_|SA2PR10MB4412:EE_ X-MS-Office365-Filtering-Correlation-Id: 14176793-43dd-4038-0005-08db89cf3fe3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jjn7sqzYGBuVpOXX8CY3MDIU0QRBhDAkj4FAwHeDKrsyyNQrBn1zNkR8VVkKGjtymfbUUIvIN1G0l7qJy9BUVzl2EZfbuzVPDplJlQt4mSTkBML9rJLXV9Ldf0IxyO5fp/KXzRGHHX3Pp4+2UpXbpkOWNOvQPocgSNNqcNYn81XjL3+NxE03ODUwvMjV4dV2NXyGzpjJjf3UB4FQByHJDcVb92qXYN3Or5IlQlRw2McVqoKQ1np1LKBXG59Z4MLD+rH7ZjcMYwFIjryWL3NxsCQmfJBAKulMvylkG9NfBlAPqYoLL9utB3cpuzBQUBXE20dnRJjXla2kup4fIo9VAkezk3qs2TkXYTWfgX1+kAgv4n5t2fRPu5WpWxFal3msEEe4bbCxQ0OQDPLvhhbQSV0LnZi6qZXwo4DieJCEDPJINyg3zJ+MuusJV4GNnSCuKdwGXy8gYGYvKvKgiEe1G27u3+lgu9DyiQ9XuyiMsAzs8TiX1TryqHh2nUGW2P72JPt3VTm3hxnIytBbtyT+0CLLZEu0KMP+7ZEEz5y0giDD0mlPdDtglC/jlCLrz9kEMObjRqKtBLGvj+cq5usHfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR10MB5867.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(39860400002)(346002)(136003)(396003)(366004)(451199021)(6486002)(966005)(6666004)(6512007)(83380400001)(36756003)(2616005)(86362001)(38100700002)(6506007)(186003)(26005)(1076003)(2906002)(8676002)(8936002)(316002)(66946007)(66476007)(66556008)(4326008)(6916009)(478600001)(5660300002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hY3EPvjvgldv5PQoqgWi8ogLvydpM7LUcpVzXih4ZL3PYMK3r6p0oqs3cnXKerYd5kmUQvSTscgSNUL1RF+1dB6DUzh6BeneeUAOtiWbgp+sybUMSKswgWyecWe7rzGMrlUV2R3wXExFjkYC0XxRhwTiiqtq1zA5TDW2dqXxK4kVguKeqKiqJ/wpLccbTFl+mh98lD2icfWkssZKCY6Auf+BSceTMjPvo1phrPhuItn3CaGXKbCNLyuhY0gHORtcv8FygUB5GgEUmXysFqKeM1HGUm01kwI67J/gbwYISv3JFc5LkS67C+m2S7ZzEaJJcl+IoxGuEsUruSMCJ0+EYS66TCiur44TaAk6h0TEVxrVcGjOdL4507qZ6dCyTRIwhktSgNU8tABhwJL2ZODKPTQcYKlkxBMaSjdYE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diU6YaxzsiyCG9xaEcCUZXq2jfKAkksSQr3f73mKDYPSoqjHVJnAOBDzsKienaVHbxOotd/xKBKRWQAnyYYEqqwi1LO+V4JfgBRgpj1koukm06aK X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ANItVvNpLt+irO18sF5p3vgHUBtzxoA0m9yn+fJIECjvhQDw1HaKWxOWq44RZOjq8kHryqn3A/GI1A74GkncyJtc2hS/4YU1RI1EWZ1+3MN01mbJiE1fOPgR33lMmcSfck4xy5VK4TLWpVHrGgB+frphaiitnAWB/j6+0Mab+GZOrdj+QNRLfOPgqoskQBQzJwPw+A/Jy/KyR6B/5j5vnuD4nYO6gwlgK7RYRqG9FrcoZaeMWou3lzMFMHfhQmz3CGge2meS7yiFlihFCdxSCFBv9oS7pTWs/t3rEzN5jSXBHvK/KwxmEIw6LJChOPJt05fiE51euQ3sU1VgwNYj1zz80RMTl7NUwCldJgRKUW0C+LJDji0HutpJmkv3AAEBp5IyPBhCSn220jQrLnXkCsA4gDD0sMtEW4g9ZyRH2+SSDq7remNozugCVB7YPstKsrFW4ZyfQ9EokUtC5E/O0Jd5Z2Rb+1uHd3ySZ4s9ALneQ8QXAESViFO90jWI7FJoYuQ8JXwqaUKs6fv5lfLwsaXibZH9OI4KhuuCnu5UB8ndj9S9yEOQNM5PRxfLcCv9orx0nzor59+51Ylvv+3/Yd4s2iBYJXuZ+h2ASazD/mJSd96pXgmgjxAgJ6TIyMEx3pZJYwLlsT8QcoXaXAXSEnhfrY01MXHWQTphMCZLDuBwzdU0GU+4hmH2TTVl2+ua77KH/uZ0CdAf0f5eE05iPSRO+aVvqNZDhWfe6y2Q4HH3+lcUm2y4TfsKk49MMroUVehDgQ12IU05sXlwkRqL8mmIJF+czytnW/6sUJ5/qzs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14176793-43dd-4038-0005-08db89cf3fe3 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5867.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2023 09:45:42.8394 (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: llqCZ8uiNUiaWO4MT5ayT+HWWfLZuM6mtioYJSZAWGfhPh8cDkPeyrq3howWdNMdcpoL6k/0hEhRUAfy/t6zvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4412 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-21_06,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210087 X-Proofpoint-ORIG-GUID: DBQzwuIuQcRMhvOr-YXwMIFoiDhmX4B- X-Proofpoint-GUID: DBQzwuIuQcRMhvOr-YXwMIFoiDhmX4B- Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Hi all, This patch series extends metadump/mdrestore tools to be able to dump and restore contents of an external log device. It also adds the ability to copy larger blocks (e.g. 4096 bytes instead of 512 bytes) into the metadump file. These objectives are accomplished by introducing a new metadump file format. I have tested the patchset by extending metadump/mdrestore tests in fstests to cover the newly introduced metadump v2 format. The tests can be found at https://github.com/chandanr/xfstests/commits/metadump-v2. The patch series can also be obtained from https://github.com/chandanr/xfsprogs-dev/commits/metadump-v2. Darrick, Please not that I have removed your RVB from "metadump: Add support for passing version option" patch. copy_log() and metadump_f() were invoking set_log_cur() for both "internal log" and "external log". In the V3 patchset, I have modified the patch to, 1. Invoke set_log_cur() when the filesystem has an external log. 2. Invoke set_cur() when the filesystem has an internal log. Changelog: V2 -> V3: 1. Pass a pointer to the newly introduced "union mdrestore_headers" to call backs in "struct mdrestore_ops" instead of a pointer to "void". 2. Use set_log_cur() only when metadump has to read from an external log device. 3. Rename metadump_ops->end_write() to metadump_ops->finish_dump(). 4. Fix indentation issues. 5. Address other trivial review comments. V1 -> V2: 1. Introduce the new incompat flag XFS_MD2_INCOMPAT_EXTERNALLOG to indicate that the metadump file contains data obtained from an external log. 2. Interpret bits 54 and 55 of xfs_meta_extent.xme_addr as a counter such that 00 maps to the data device and 01 maps to the log device. 3. Define the new function set_log_cur() to read from internal/external log device. This allows us to continue using TYP_LOG to read from both internal and external log. 4. In order to support reading metadump from a pipe, mdrestore now reads the first four bytes of the header to determine the metadump version rather than reading the entire header in a single call to fread(). 5. Add an ASCII diagram to describe metadump v2's ondisk layout in xfs_metadump.h. 6. Update metadump's man page to indicate that 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 on the command line. 7. Remove '_metadump' suffix from function pointer names in "struct metadump_ops". 8. Use xfs_daddr_t type for declaring variables containing disk offset value. 9. Use bool type rather than int for variables holding a boolean value. 11. Remove unnecessary whitespace. Chandan Babu R (23): metadump: Use boolean values true/false instead of 1/0 mdrestore: Fix logic used to check if target device is large enough metadump: Declare boolean variables with bool type metadump: Define and use struct metadump metadump: Add initialization and release functions metadump: Postpone invocation of init_metadump() metadump: Introduce struct metadump_ops metadump: Introduce metadump v1 operations metadump: Rename XFS_MD_MAGIC to XFS_MD_MAGIC_V1 metadump: Define metadump v2 ondisk format structures and macros metadump: Define metadump ops for v2 format xfs_db: Add support to read from external log device metadump: Add support for passing version option mdrestore: Declare boolean variables with bool type mdrestore: Define and use struct mdrestore mdrestore: Detect metadump v1 magic before reading the header mdrestore: Add open_device(), read_header() and show_info() functions mdrestore: Introduce struct mdrestore_ops mdrestore: Replace metadump header pointer argument with a union pointer mdrestore: Introduce mdrestore v1 operations mdrestore: Extract target device size verification into a function mdrestore: Define mdrestore ops for v2 format mdrestore: Add support for passing log device as an argument db/io.c | 56 ++- db/io.h | 2 + db/metadump.c | 777 ++++++++++++++++++++++++-------------- db/xfs_metadump.sh | 3 +- include/xfs_metadump.h | 70 +++- man/man8/xfs_mdrestore.8 | 8 + man/man8/xfs_metadump.8 | 14 + mdrestore/xfs_mdrestore.c | 497 ++++++++++++++++++------ 8 files changed, 1014 insertions(+), 413 deletions(-)