From patchwork Wed Jul 24 10:35:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 13740838 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 856EDC3DA61 for ; Wed, 24 Jul 2024 10:21:41 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sWZ7t-0007IR-3T; Wed, 24 Jul 2024 10:21:41 +0000 Received: from [172.30.29.67] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sWZ7s-0007IK-BT for linux-f2fs-devel@lists.sourceforge.net; Wed, 24 Jul 2024 10:21:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8H8uOA80LCcAeLWbw0mMEJimoYhNaWRIFK+pZQ0pxk4=; b=A40dI1nvM2+c1D+lnFFafHR0vf 2xEYCeqhTkXPwelUfiSKMmIhT1NTFCHe90lYgPe1Eejng30Dr7WFW24EV6q+ezbqyouYVBbkMBAOg WYtzBXqF6fpTuo7z4iGRptfKbEdiJwwV+Yua51tZ1KMrJ6r/Pihc87XViII94UPbVKIg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=8H8uOA80LCcAeLWbw0mMEJimoYhNaWRIFK+pZQ0pxk4=; b=E UIbUUK2kOCw0GU7UzMYn+J5BHHuQQxwqNFlR4Z9OmePESasgsT++SgUi0NQIf3/KHhMqQq+wA+l6N 0nzni4V9h1tL2azdSh176Dm+57RjZk4I9WRZn7EStsRX8j42EhcCEOwhAABxrJufruOoqOzyFDWHP 7TDrDK7YMurvyM+c=; Received: from mail-psaapc01on2053.outbound.protection.outlook.com ([40.107.255.53] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sWZ7r-00061F-KW for linux-f2fs-devel@lists.sourceforge.net; Wed, 24 Jul 2024 10:21:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BYNJgeVcER8eNWnX+Uf4MNXSIy3hptYDRTFmN5pqfG/vqmpmSpCD7LIPtdE5ak8EQjlyqHc/e/HHCm36v469WekA7SXtFoVNule4ziJXHQvNVrhJdMOu8xHxZZWxxWaUAq1OeuXRLq64lP9e3cLQVar8yzD4bjlVtJErqo0+2W1phj3l7+b06TWwV2UkRWgziRAjpbH7hG6ajOyswSp+pHu11+v4tEaxmQtYgL8oLCkcJ+ArZ/XVN7Wm5XEcd6pNvDQBpSQ5Q9hqvaz73s2YWQuXrhHCca3cMlTH9T7+s6Wvr55s0QBO5hjfdZxYJKOpH2NaIAP32FG4ciC5/WaJmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8H8uOA80LCcAeLWbw0mMEJimoYhNaWRIFK+pZQ0pxk4=; b=BatltojdeQfmNudI3R2FfWbIwwlToZI57a29cp2pDEDDIToQ4B0+cd/Xo6/rtNHihEHkRBNK/DQOVbUPNy3MIZMBFLEsdkFOd4pySWWgKU6f/Wm87xfoMs600pcRchqwDO9ASILIOLBhwxAzwjHjDENdC+wD8wpzjRHC+SRRwrg+urLB+JYixAtTvKWbjQgLd4aEWstFgLt9b8BNdMLLrPrgnPESSXMLDmEpmMyQA/EGssCG/Cp2GBUBgplzhvVaLSf1IIHNvXrUGx2tvPTPkVO2W9xQakzIjlt2CDGJT0B36YYPaBi++nEYfR/b8gzjqlIeMuwZ1dzuSuUYWfDrzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8H8uOA80LCcAeLWbw0mMEJimoYhNaWRIFK+pZQ0pxk4=; b=JYVsgCpnBzdBnY8q27SR8FI+AhC2rOMXuAQP++7uZSltBtn/RNiI2OmbbIyVHiVHEDBT1YmWqV8bdKL/rGsdeRnfszZNime94tb3qqO00I04ao77CqzhzHj5wBHbaKnKFT/PwYxmW6VfYR9FMP0x/pxJ96yLiF5N1cyufPwUmepVRav5rPMflBjuIm7JhYNtJCiJjHUwEV1a+nP77NZ+dFZ+OMxEJBOergKw9n3aDK6KdXTq8HH3/21J1q5oAfvRLz42FjGr7wItDK/TVD0sp39zoN7E6Q2jFvaGL0kILsUvFvHeVN6qQh9PU0eBotDmVsLHbBQWJoKKAF4qHIufWA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) by JH0PR06MB6656.apcprd06.prod.outlook.com (2603:1096:990:2f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Wed, 24 Jul 2024 10:21:20 +0000 Received: from PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5]) by PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5%5]) with mapi id 15.20.7784.017; Wed, 24 Jul 2024 10:21:20 +0000 To: Jaegeuk Kim , Chao Yu Date: Wed, 24 Jul 2024 04:35:43 -0600 Message-Id: <20240724103543.2666271-1-bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SI2P153CA0023.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::6) To PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAPR06MB4486:EE_|JH0PR06MB6656:EE_ X-MS-Office365-Filtering-Correlation-Id: 45f78ff4-c22d-47ad-0ca4-08dcabca5ca0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: M7dAwzeintYITDaG+qqKj/rF9/LzyJXAJckb76t2tgspKFXg1uGnxY4CtFr+tT222f5bRNiaWQAE6pDDXsk+o4Sl0xJJK4J+fxe9F8dWl9o/9sscHNb6H0MnFUeKUzkoEew5s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CYm1DEQln3zCkZzAq96YAVwvbqZP7/d1SgQkju5P9VPaUkQueh2XXLxvC4gFP/ULiQM6ys3LaMBY/q/dCgvP7/5ASiIStDJfFavBAB+rMSGE7relNbKiQ6bK7EtvDdm+d18Alm2XSFEyDVRWBqDaigwDetVc4PwyPwES0XBKvdT1fkCBQkoK2JrO9c06SjHiwTll6+c+dow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PSAPR06MB4486.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rnJNKH+a74OAVt8WK6fiT34Vi/sHoJe21i6HcT32RcATgVTKGEU2OAs+z6Hx8OX7+LxjQDu3PxOBcL2TQUm5XRpgWwU8DeJkm3znPf95oCCRDQ6tKMwYPdfqc5VfFvKDnbUv4hQ/JUoVeir9cjun0k7Olgl7Rxykvlw5NPjVJhe6DHoOLy2b8dSV91LljLXwFkYIa3MkSffo07C+LvGGARUlJDeeWKEpuEdVrp1F38P1fOcdPiNLHyZpxV6kbQ3jyiEkQ5q0wyfj7Gm4Ew+Z8z/LZ8vVFnTTvAN9yEmJD3QPIcBwAFfYSv+AzcGwY/QHZx6rbRnijmTvc5kBolLwU2Gavjy2gmz1b1oO79f/rE9ToRjXNc0OPPXymiRAmsZpkhYccJ/InKOxPs0un9CyqMcZrMKs+0iNgHlz+aFircBKr+3mQh605YH0zSk8btXyF65NL2sJWFOQK47U5BJ8X5YMEA7odkVDAVkhsXj7ea8Adnme+GQXxwbttSGXimGnuQ2ykhLGFP6sUKEurCSSH2vQ1fkHKbAlkmQuTiOab/+ol2ptJysOP4J1zuaNxOoHX6o30rXmzXCXfqBrXB8QYK7GqAbPwKIvd4ijy7kQC3OhdK0CoXUHim4ZJ6SiDrWH+VtS5rLQYWGusI13gguA06W1wbCuEo3mUaTfgIvvL9gWXWHiMXoHE0HPl4wvnPHYVcoVUnEf7bajk+IQl3OwwWlY8Vfio8w6qYVNGRbmtksMekoZhQ+TKME1A0lRXskwopkLoKCzvM7scIFBIzRp1Y8O8+Sz4XdJ19B4aUyKAW+tNlRTVeF1H/s3pxMqlUrXx2wve/YgQWKZx8x8Vd2Q3F3aBIht8QvLMPAwh896F6o7wE/adbknd+8ed3qSu0e+RhUC6zGGpQNpNaF+1gT1pCIWN8IkrgRv3DTv97HX8l+H3B7mV+ssu8QkpLHOggyGPnodvo4HjCP79fBf74AoIa315RdmJJLkSDGJZ7JFkSAXf9W6xfhTDtrrKYD7iqjMtIyGPKfKmIYsW8wTomBMo1E1xSLMQZUhEQc/JLT8GK58Oo46hN51PJVLP7hVd2g3nTF5+p3f0nAk+x1yVJnhd5UGe3Al4kNINsik/c3VWbYDz6d/a44BbvAm3JhSFuP3x21Ab/O11I5H1Y6ZrYAffXCsbkINOVIbyKwL+FA/LlMGtf937IFpiT4uXnhj4DtuXpZyB/fku82CxuPXnCcGlsdwnZjIbAnn02zoOF3aj98ff7EmtJxZTzihB/Q4rReAS3b8VMU3F9RCMVXDZJs3H0g7pBFaXdOowYEoFKNe9dMeheIOh9q1/0btNAAe3yfmurdAapufjRuVPElYWhQO9LR0ywrDz7npM7iEhpCfUDQOzywgpEmV8+Z+opPHq4TeXZ8mJm324FwBu8Hhmv3x424NopuNOBF1/A2qZaAQkz3vMa7Kf7ybxemHyTGrOOksVOVezywoxme9iSqtRcFzvPRcj7L01VIjJpfrv1FrjsDXivbt2pbn8umeVjvrmSU+DF6XEX5ppfazecFwC8mq7V5KICcu6qdLua2fa9IHuFw9Igg5wIRWv74xxzhrVyAs X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45f78ff4-c22d-47ad-0ca4-08dcabca5ca0 X-MS-Exchange-CrossTenant-AuthSource: PSAPR06MB4486.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2024 10:21:20.6929 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IG200Up6kQihgTrwF2OepcCtuNzyxfNQQyFDe04Zgzg/f5EHX7u2Pk4clz31qfrPfjaO4f5E2FiIPllGESvjQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR06MB6656 X-Headers-End: 1sWZ7r-00061F-KW Subject: [f2fs-dev] [PATCH] dump.f2fs: add checkpoint version to dump_nat X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Wu Bo via Linux-f2fs-devel From: Wu Bo Reply-To: Wu Bo Cc: Wu Bo , linux-kernel@vger.kernel.org, Wu Bo , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net The cp_ver of node footer is useful when analyzing data corruption issues. Signed-off-by: Wu Bo --- fsck/dump.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c index 8d5613e..ca38101 100644 --- a/fsck/dump.c +++ b/fsck/dump.c @@ -21,7 +21,7 @@ #endif #include -#define BUF_SZ 80 +#define BUF_SZ 256 /* current extent info */ struct extent_info dump_extent; @@ -38,6 +38,7 @@ void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat) { struct f2fs_nat_block *nat_block; struct f2fs_node *node_block; + struct node_footer *footer; nid_t nid; pgoff_t block_addr; char buf[BUF_SZ]; @@ -47,6 +48,7 @@ void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat) ASSERT(nat_block); node_block = (struct f2fs_node *)calloc(F2FS_BLKSIZE, 1); ASSERT(node_block); + footer = F2FS_NODE_FOOTER(node_block); fd = open("dump_nat", O_CREAT|O_WRONLY|O_TRUNC, 0666); ASSERT(fd >= 0); @@ -54,6 +56,7 @@ void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat) for (nid = start_nat; nid < end_nat; nid++) { struct f2fs_nat_entry raw_nat; struct node_info ni; + int len; if(nid == 0 || nid == F2FS_NODE_INO(sbi) || nid == F2FS_META_INO(sbi)) continue; @@ -66,15 +69,15 @@ void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat) ret = dev_read_block(node_block, ni.blk_addr); ASSERT(ret >= 0); if (ni.blk_addr != 0x0) { - memset(buf, 0, BUF_SZ); - snprintf(buf, BUF_SZ, + len = snprintf(buf, BUF_SZ, "nid:%5u\tino:%5u\toffset:%5u" - "\tblkaddr:%10u\tpack:%d\n", + "\tblkaddr:%10u\tpack:%d" + "\tcp_ver:0x%08x\n", ni.nid, ni.ino, - le32_to_cpu(F2FS_NODE_FOOTER(node_block)->flag) >> - OFFSET_BIT_SHIFT, - ni.blk_addr, pack); - ret = write(fd, buf, strlen(buf)); + le32_to_cpu(footer->flag) >> OFFSET_BIT_SHIFT, + ni.blk_addr, pack, + (uint32_t)le64_to_cpu(footer->cp_ver)); + ret = write(fd, buf, len); ASSERT(ret >= 0); } } else { @@ -87,15 +90,15 @@ void nat_dump(struct f2fs_sb_info *sbi, nid_t start_nat, nid_t end_nat) ret = dev_read_block(node_block, ni.blk_addr); ASSERT(ret >= 0); - memset(buf, 0, BUF_SZ); - snprintf(buf, BUF_SZ, + len = snprintf(buf, BUF_SZ, "nid:%5u\tino:%5u\toffset:%5u" - "\tblkaddr:%10u\tpack:%d\n", + "\tblkaddr:%10u\tpack:%d" + "\tcp_ver:0x%08x\n", ni.nid, ni.ino, - le32_to_cpu(F2FS_NODE_FOOTER(node_block)->flag) >> - OFFSET_BIT_SHIFT, - ni.blk_addr, pack); - ret = write(fd, buf, strlen(buf)); + le32_to_cpu(footer->flag) >> OFFSET_BIT_SHIFT, + ni.blk_addr, pack, + (uint32_t)le64_to_cpu(footer->cp_ver)); + ret = write(fd, buf, len); ASSERT(ret >= 0); } }