From patchwork Tue Oct 29 12:09:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13854822 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 8D024D2AB38 for ; Tue, 29 Oct 2024 12:11:58 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t5l4n-00040W-GH; Tue, 29 Oct 2024 12:11:58 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t5l4k-00040A-6L for linux-f2fs-devel@lists.sourceforge.net; Tue, 29 Oct 2024 12:11:54 +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 :References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YuEjuxLobaTvyfQkV99PVdX4wNmQANwWNPnrhHLxbLk=; b=WxtgNufLLnsS9bx5wS8A0+apX4 /jYc9otgxTOi3nwg/DQtKrPwHf/LCQLvt4JnaBGMrv0fm4S8PMOma5vY9oEBknPeux/rat5Rx0Gns YG3/NUNIvMCZDmjauBoepW1XuleBtTMGw9XCcZyW02pXeO5KsBkLelrtcfD0sTKp7vV4=; 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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YuEjuxLobaTvyfQkV99PVdX4wNmQANwWNPnrhHLxbLk=; b=U5UqfTwws7qQur0jSkDSHf0WHt qNeYJ1x1u+JDd9/0z+m7MIZ1u0amNsU9Y6LEHOYy6Etv5CA2OIEr0GsRTI5fGzt4NQc/3JTizt3iT ozUNGVhIy7NftVcU5fcZ+oKb+MiuGOoxJs5uNe1seeSSZ+piBDgrTfJIlRABRNxi5HA4=; Received: from mail-eastasiaazon11010001.outbound.protection.outlook.com ([52.101.128.1] helo=HK2PR02CU002.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 1t5l4k-0007RS-6G for linux-f2fs-devel@lists.sourceforge.net; Tue, 29 Oct 2024 12:11:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kcx/bF3rL/n7YKdoCvyOQmpY9rcpUAI9YFbPDAiueddUkwPybptIRY0+P7XEdySAwxBQECz4Dfk7ATGELX5+FaODHARRpywMrA2InFl08Jut0ffQpV6A+e4HKUQlfDpgoDH6aJ1rd9x5/7tzRM4khxnFWh5sVezROlzJU1V4ywGOLgVd9tkw/1qHr4P9mAsgmPvdwg35ex0izTgVdRD9/cLSq/bLlq7wViV0msFhVtYKKbeDPCZkwgPoIA18X2N7m/7pPUt8kjUG+UXRL6bTWDmHGXnEZXtG5AzwRzisjbFD5K/DcoHoc1Xa4e/PG9f7RDfbWJf3DTYKFjG5xkZBUQ== 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=YuEjuxLobaTvyfQkV99PVdX4wNmQANwWNPnrhHLxbLk=; b=Ks465ZNCv3lq99ToqZurk9MR5K1ZgNCBDqoPLeZvuj8zD8CYUUZBpXsCtWpjQI8Yqe1z8HmmWbSm8k4MPtXVu+mU5ArCMkbw8pTCUyz7wssU1wdIJqgGPTtJhE68kGxcE4aWDYaMz4MFGI97DDVWyQFBXaxfZY/AArcQAUDtg4nqdbKqMONQEbYSdf2L6iVmTilM0TVwZXHGY/ZioCNli0Zy17Gpx7Fcss/NvyYmSdbzky1EN6kldcY+Ym78XCW8t7xyuH3rMfmieopOvmiG692yJa+HXRi1zCADuWaGv+iRAHczokM2iC0Y8l8lEl2L5hmbkqtDJazMi1HP6ZAk6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YuEjuxLobaTvyfQkV99PVdX4wNmQANwWNPnrhHLxbLk=; b=EQG0KwqDPppytQ/akpTN9KzZ+7tQm9DJFVgktiuAlZcPMXNgV3VuQPjt/uNxto0fVISxB1fCtQULVwlAxrEZUBP605az4MlkzhPRjYaP0U+zMdyzN4N/UQpqcpQPD/s/Qbabnwjt6ipLbJxyO3lsCP1IRYnrd5VdvTq5bHOsgq0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from SEYPR02MB6014.apcprd02.prod.outlook.com (2603:1096:101:6b::10) by KL1PR02MB7877.apcprd02.prod.outlook.com (2603:1096:820:13e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.28; Tue, 29 Oct 2024 12:11:40 +0000 Received: from SEYPR02MB6014.apcprd02.prod.outlook.com ([fe80::bb06:c283:a50:7796]) by SEYPR02MB6014.apcprd02.prod.outlook.com ([fe80::bb06:c283:a50:7796%7]) with mapi id 15.20.8093.023; Tue, 29 Oct 2024 12:11:40 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Tue, 29 Oct 2024 20:09:43 +0800 Message-Id: <20241029120956.4186731-12-shengyong@oppo.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20241029120956.4186731-1-shengyong@oppo.com> References: <20241029120956.4186731-1-shengyong@oppo.com> X-ClientProxiedBy: SG2PR01CA0175.apcprd01.prod.exchangelabs.com (2603:1096:4:28::31) To SEYPR02MB6014.apcprd02.prod.outlook.com (2603:1096:101:6b::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR02MB6014:EE_|KL1PR02MB7877:EE_ X-MS-Office365-Filtering-Correlation-Id: ea0c7792-ad61-4d1e-0fad-08dcf812d892 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: +4sCJg6J01INyejJGz/1JgAToJc/mVBaN3UR4rwGc+6Hru01krvSCHTXetd5VPRXt9OGP4b8C5JI3J+YXrjD4OqYFKQUDh4HzYKmbRxdccblBxmK1Q5a+yGlDTLwLyaWoux9DPrCQrlqD40datQkgr+/m7N+4SchBuhmKINvDmhf/C6zoOzyF8PgnGYB9g4wGiQI9YJPMu7z39naS8NtJWlbKvHHKxOMBgO3RsQbDwIKX5D+4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WtJk8UhzPxdBn6oL2XAPJdEjvNtamp15thYKlyKgDEz/eZQvDVoLlGjh79tnrjUB6raL64QQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEYPR02MB6014.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fkrrdV1IpILxBICzviDpl6dfNSnieD7XqogKOmKWK466QM6qbDM6ou/+WFe++TTUl5XK8VtDZDQSOEV4pgDhqtD7UpU3HfB2AikT76AL+fwGheUCJytGvBDUsSlMPKq/FLLk86XHIUieQxaVvdhnuCK5wOx0tCUEYQ5jx4tI6xuRmncPlFc9yBNtp56/oQaGefSLD6ryYXWQEBH68HDNU7yyLPkbZUSwwUyv3xPtaLhNYIzF0XQM/1MDKk8boTBzEDlB55Y52AMD2f/+adMQaU+T69LfauLBBj19HFWSxxRKbjRaTy+7GQV0rTxyqAM0eUDoHzQTsuyqhKkH1ltaoofIciMrqDubad9cIEIdm+NvLnYF/mbwr7yBgKMmJ6pqN5g2bAP6pQ0+qoUOHVOUqSKyDFeEMK1r5+pAa+qNC0UJX1CZfSqug1af7OCE/SsV7+CsSalgE3I/d3/W76OCFTP9ujgyJWsF4tnkLXeaLGPg5/Cw8S6yDsNIE3xVZRqZuGkAZKV5l6JAdDxC6EjfapceM/p4jYEUs+NEm1xPsB7ZnEiG7Xs+htjx8wUzDZ6FV6zU4MJZJGycH90GHGpg+KQ6Ir3p7c0QKVA9qnWUqr9PTk/n5OUt06VTMEZt9zVTbHC6q7gd/TJphaN/s3tBevXvHv5DfHULJdD1bWWOkz4OWgp0yiP3TQ3BFNEO+fTUy45KYXg7v/pMHKohXvuZgM9WJoBiBthSfisSAKQmZXoWBpCpBRNdRPUtmBETJSpi8tIsaBr7Z9AwnZ/u1SPdYFxuHatrS4NevHOCdedGiMDVKI82hWw+jJf3Qeutrew/Nn8ZJasD+jS3b5CziTksGlB0Nk4Kp2/MoqwqsgkkMfpHw5s7Qa5tioPboxL+rP3RCdlKRY6qPNrmamDqDu9QybPUThV/Vl8naFl3BJrez5hwLweohpqQM4LusoSlL55tb/J+wmnZ+KFhEruRQriEEo0JmRmmw8G35+qdh51zOYF/UAht52KYkukB14wKrOfbHLy//gP92SFvZRiWIy/5jacQ6fc1gH0CLWSSCgRuog6zCCSliSST/bbOPQLm4yEU+QNwgqxalzPqynVNy/a41rBv2rSmw5fPi9C4dkpSm9bzA/E7Y5jDVWML25DGvj/x29LCWS+/xbEkbQ3El3y+rBIaRUmzmD/J99h3q/Ghhy7bosmGTM5ZmYD82oItoJrA/bk7Fkez7rMf35nUSqGyi9yE0DQejGxh74TBzS9av3Jy9YMXrkJqtqXGpaHRVMpLxKmoJREKS78I7tDQZ3Q/AL4ITWXAZt5ibe4ijsj1FxM7P6k+OrAmFI7SvBjEpUP3wNkJNOlBtk5qtBWCd7YXGXkeKz8yXjBJQpzrKIgfcln/sOxTzz/SJ1czAYsn5G9pkdcuY3N6och+9bKk0QT3vEbnzLXmqGOYztJ/6UXmWkTntQ53D9iM4B7Wx1riMVACB2cNokbYLoIEATwcT1+sLJVM8jSH/xLvEqzcdg14NS8buEGy9Erd00zmBGYXT9YkH8X2cg8lGLVKJBNc5AX+RKPN33C2etOEc5qdVCDmgumF3FnwKI1URxaWYc8FHuGI X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea0c7792-ad61-4d1e-0fad-08dcf812d892 X-MS-Exchange-CrossTenant-AuthSource: SEYPR02MB6014.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 12:11:40.8026 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: emY8ygYevCEbrY01mgBrYsKZI52u3RkQaT5YdYR62TXv9BpLV4mKIdrYLy0tOfM3MpmdCydftmZBkaWaU5h0Vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR02MB7877 X-Headers-End: 1t5l4k-0007RS-6G Subject: [f2fs-dev] [RFC PATCH 11/24] tests: add fsck testcase of fixing cp crc 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: Sheng Yong via Linux-f2fs-devel From: Sheng Yong Reply-To: Sheng Yong Cc: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Signed-off-by: Sheng Yong --- tests/f_cp_bad_crc/README | 5 ++++ tests/f_cp_bad_crc/expect.in | 22 +++++++++++++++++ tests/f_cp_bad_crc/script | 46 ++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/f_cp_bad_crc/README create mode 100644 tests/f_cp_bad_crc/expect.in create mode 100644 tests/f_cp_bad_crc/script diff --git a/tests/f_cp_bad_crc/README b/tests/f_cp_bad_crc/README new file mode 100644 index 000000000000..250ece3f8b5a --- /dev/null +++ b/tests/f_cp_bad_crc/README @@ -0,0 +1,5 @@ +1. create f2fs image +2. create a new file +3. inject crc in current cp with value 0x12345 +4. fsck fixes bad cp by copying backup cp +5. compare cp1 version with cp2 version, both cp should have the same version diff --git a/tests/f_cp_bad_crc/expect.in b/tests/f_cp_bad_crc/expect.in new file mode 100644 index 000000000000..f21fecd2ae17 --- /dev/null +++ b/tests/f_cp_bad_crc/expect.in @@ -0,0 +1,22 @@ +Info: Automatic fix mode enabled. + Invalid CP CRC: offset:_OFFS_, crc:0x12345, calc:_CRC_ +Info: checkpoint state = x : nat_bits crc fsck compacted_summary unmount + +[FSCK] Unreachable nat entries [Ok..] [x] +[FSCK] SIT valid block bitmap checking [Ok..] +[FSCK] Hard link checking for regular file [Ok..] [x] +[FSCK] valid_block_count matching with CP [Ok..] [x] +[FSCK] valid_node_count matching with CP (de lookup) [Ok..] [x] +[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x] +[FSCK] valid_inode_count matched with CP [Ok..] [x] +[FSCK] free segment_count matched with CP [Ok..] [x] +[FSCK] next block offset is free [Ok..] +[FSCK] fixing SIT types +[FSCK] other corrupted bugs [Ok..] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: write_checkpoint() cur_cp:x + +Info: Automatic fix mode enabled. +Info: checkpoint state = x : nat_bits unmount +Info: No error was reported diff --git a/tests/f_cp_bad_crc/script b/tests/f_cp_bad_crc/script new file mode 100644 index 000000000000..5ef689c33ebe --- /dev/null +++ b/tests/f_cp_bad_crc/script @@ -0,0 +1,46 @@ +#!/bin/bash + +DESC="current cp with invalid crc" + +. $TOPDIR/tests/helpers + +cleanup pre > $LOG 2>&1 +make_f2fs >> $LOG 2>&1 + +mkdir $TESTDIR/mntdir +safe_mount $MNT_OPTS $META $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot mount f2fs image" + exit +fi +touch $TESTDIR/mntdir/testfile +safe_umount $TESTDIR/mntdir >> $LOG 2>&1 +if [ $? -ne 0 ]; then + echo "cannot umount f2fs image" + exit +fi +rm -rf $TESTDIR/mntdir + +offs=`get_cp checksum_offset` +crc=`get_cp crc` + +echo "crc:$crc offs:$offs" >> $LOG + +$INJECT --cp 0 --mb crc --val 0x12345 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -a $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -a $META >> $OUT 2>&1 + +cp1_ver=`$INJECT --cp 1 --mb checkpoint_ver --val 0 --dry-run $META | grep "inject checkpoint_ver of cp" | awk '{print $(NF-2)}'` +cp2_ver=`$INJECT --cp 2 --mb checkpoint_ver --val 0 --dry-run $META | grep "inject checkpoint_ver of cp" | awk '{print $(NF-2)}'` +if [ $(($cp1_ver)) -ne $(($cp2_ver)) ]; then + echo "cp1_ver: $cp1_ver" >> $OUT + echo "cp2_ver: $cp2_ver" >> $OUT +fi +cat $OUT >> $LOG + +CRC=`printf "0x%x" $crc` +sed "s/_CRC_/$CRC/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_OFFS_/$offs/g" $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1