From patchwork Tue Oct 29 12:09:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yong X-Patchwork-Id: 13854858 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 ED550D2AB33 for ; Tue, 29 Oct 2024 12:26:24 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1t5lIm-0003wh-C4; Tue, 29 Oct 2024 12:26:24 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t5lIl-0003wT-1w for linux-f2fs-devel@lists.sourceforge.net; Tue, 29 Oct 2024 12:26:23 +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=VvZSFVU8G4lYBTsMjCjSOcByqZKQ+STlB0oq2AHmrLs=; b=AARN49BTjX0MVMj/TVYlb8GRkM BgZp9FBL7GEV9/OwtzfWCl9gK3Ox+uJDCj+ZHS6SPSKPYj0KDduGtqGU0YOpbah9LLO+hp9HrlVmc j6ZJMI8bIsx+rd3MFNBj58bMzU2+hPnqi6t+0ufEG6f5Fto1/1gyu2ijmc6r5KQLah38=; 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=VvZSFVU8G4lYBTsMjCjSOcByqZKQ+STlB0oq2AHmrLs=; b=O5+hLcti1s7fUhhOMUHvezrdGD 6VNGDcvy+2354MfzXRmuUAatygz2zwMVMp79hcNC4ljgNkKOrlBEg7jdou6O3axTpWYMETdwZE5Gp ymHPX1mXDrUNHqqKmQhwfqLVg2o67SgPnV17jy160QC0HmtC4UziVeOredV4AUpkHVps=; Received: from mail-koreacentralazon11013056.outbound.protection.outlook.com ([40.107.44.56] helo=SEYPR02CU001.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 1t5lIk-0000VE-6k for linux-f2fs-devel@lists.sourceforge.net; Tue, 29 Oct 2024 12:26:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Inv3fhSTUHf7Mt/qyNC+DbIgZ8EdBUXazW/vTTN5njuYUixJxu9araHx3I/XcrNDXEJC26swN+SfObw6C9y2SGYLDPuBYAbYEhnZlm3ZKc+cOvKygc2MlAAb/VfOK5Fj2P8BGqwGBsPiODzqdLk4+M8vDoEFZLsrCwyvN4DCNYqHwU70jag1JjwguyF+P80KaeVRxnWftoYrjRB+iqDwcOXa1fRmJZKa8rNkKj6EbLdaG0JFD7MLQVOPK6V10l5Q7aayygJn1ZEb9K1g4siH5ItXNAmYH7dzXJ9tREJ6vNyoT4noNjmU49vuq8VY2pQAutrHnWVfIPJi9vRN+Yxyvg== 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=VvZSFVU8G4lYBTsMjCjSOcByqZKQ+STlB0oq2AHmrLs=; b=JKcHVrCOq1ZCJ0s3Wr2CjNRq4a6aZqZ2PziBUiXvJmnKhbDgZejmWHtO1AJTFFGO///zkmQwW3RxBTxirl2/y+JOufYnyJWlwWb5A+/MkPliZJcSFy2Qw97zL+iKryOS6aoIaLyXrMSMWnQYze2lo7QcUHJLI3tFMaa4MRK8+uGMgZ38Vb0MWfyKWwBRNT8AqSs+njJX8qvIJnGKqYK+YQjGj+UmIaEOymxyahFy9pxPPBwZaYX3sdkukFoueypJvWqgO6BLsBdUS2IQ5J3lfXu/2PN7pMIoit26wwdPf3Yi+g0+Ig5ZlUX7QPzdtVU9+VKj63D5L2rOdN8+dv36aA== 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=VvZSFVU8G4lYBTsMjCjSOcByqZKQ+STlB0oq2AHmrLs=; b=BEzuJ/WAwO2QOVozIGIwIchOp2s+7qjEuu8j7G52U8xL/ZS+ZSzP7R8D2hnqTMMuIcREq8MgSjcnhCJcboPtJ4vPWxv7OXm7pWvFvOkwBgvZ5gpAaiJX4N/zWBHIhzTjCrjmjEsitjo5amUtH9KuX7Pa0aNZieRart1fLFpBW3k= 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 TY0PR02MB6982.apcprd02.prod.outlook.com (2603:1096:405:e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Tue, 29 Oct 2024 12:11:50 +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:50 +0000 To: jaegeuk@kernel.org, chao@kernel.org Date: Tue, 29 Oct 2024 20:09:51 +0800 Message-Id: <20241029120956.4186731-20-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_|TY0PR02MB6982:EE_ X-MS-Office365-Filtering-Correlation-Id: 16658ffd-07d0-498e-bf22-08dcf812de48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: YzqACBfRZSh26xE1nJkN25kTN4EfJetDWYAhOE9Jf8C2+p0/sQpZwIIHl5y9Oa4Q73aYIgselfKmNr9ZcW4KLoGVodnHm9G4vWt3pRNu7hKg5A4x7Efo5CQ3wb+vxU47iKlajX6ALYgK/aqVmXOKyoELwRwuQnPl592Q5qdqS5v9IjkuW03BTxAj2EDyyQjqiokuv9kS4icRrIS2IZzwARwmAUVTpj6mXy4r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caxtEAVNt2fhi84kEVxPkJrPLS2yYRr8tdt3bGgAZeMvp3UMj5Jntezo5rUx9vkxyQPSNnPjDsgLU2gCX/EKEAM= 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)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SVywDv9VVNZkELBF6JpxT6IGMXGRuuoOQ6mVxg4jq6DfCY8TjHsIpDwtxRA+S7pZ5sD4o+LxnsTTUdOcuwpz21GBiD27wzFiCzyZh9gFdX5f/MmqRx4GC+boxcvLzSa0kfVfW+fB0CJbrmjHMt/kYv+NQhYm9JlDcYTa8f+3SZzAFajWcEZQEH8q//MJds/1BxScknojQ0pz328xCJvEIknWEG+dtCYTz2zgasPwn50ugmSMW9tjoWRd5Xbm9YqMQ3Ug0UOYGPuCfrH08yvdV4ZFEDQlGnAt20agrcCv7KsK9ODlSeNv0TAAxcQk/nYuv8cVo7qQmBdR7MUHnvcddpqvBIaUKZxeJqJPLmTs6290ptzvGVKzAyXvfwE1RIm2xgK2OtoeG2PlC12T2V+D+/RLoT9wgTbiO1NHFyo0S3A9pKUI+Usnhmf1QzPg3XrdVQFmKvjr/QjrSIarmdkyhx2FYeJIjvo1i6lJbQsF0Y4W5ZiuagvxaXH5wr8zKkLhTo0TJkGopTIPTGIT4vW1nH4XL8OKbdIJAHz3LpCjU3Mas+iiJhjXUR6wieyRWRjG+a+QZ0i9LiDEHd2vBBb11fMTDU6KKik7zs4q58IaMaPI34qFEY58LDD8SsuiE/trTNNfe0qYU7BiwxamZrH5CUimH/bsKP26HibXpfXcdbTyjXAaUudM6f+NstJrPRHMGwI0NfKonAeaA3BZn4uavsAXfSA8SVeTKTna9zeCwycRdYXelrXyERtezADeuCDg3ABgJUrsEdyizGqits+XEsNlM9PyPVGvi9ga8Wej3/j4gLvOw2swF+IJLAF9oLVYDwzddnr3wNDuMES2pFmSrKaMHEJ82Ee7+VhxSgprMvkXfgS3trkLAXCNPYO+Dbzt6J/UCOPzjOlhU+mLIY3L6Cab7TBXYouDkljl64YULWbXhtSEG21liEiKf7D8BtAiXNP5SLvkz5Sn5UpUKaEs/B1P/X0Kx849T59QrCjE6N37Js9TiGf3PAtMoG6jTtSlkeLhFQuexRFfCquJ9JU50ImqEAtsuskL6xuIz4y9rRe53nWiF0X7R9iuBezFQHOfDu6JVw1n+ezA1rx9yPQyEJJI9tXjC+aKVxSnf2A7M0bTuK+JpuCCR9842NDk6gwFnhFeIpkuATwPQbywjbofW76r2X/E15J9Iu8Zo0b0LFdTvItQfngAEENInBbFUbwT1N3/KQZlxXiMGic3qhnO9c/QA01qOK1GaxIxVRArGM789xKWz7RKAjwbBmfiudJ3Ar4LuJkXeQHVYfUS2z/hc8s2BXaH6yPxVua/+CoOxyMmhVW7SqgoXelC82maurqkaU1i10F5NqHaEDZ0A8kiEOTd76LudMBTNpTdWqCJu0GjqE9VZ+jTjbfTAlZyudkcSHr2TXWEvW5u0rlOtEV5Qlg09W6V25CWz3evAZh0vNE4UmJRbdkLPN8jkjEAdErZYWTB2HsKRBjAYC0NI8R6Wy9/0loqf+XaiX1N9jWEAiwXhgOL48zpLVSQf0tqiL9hy2a15qjCjEMCuJemlG6OwsVya0jWuVGBRyN9zfBmtn0tWEgB2QTEi/yOjFSgmiag X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16658ffd-07d0-498e-bf22-08dcf812de48 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:50.4095 (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: 8VSCnb8kcSICpJsQTvs0z/Oa0060cw+lAslxYVfVa4b3ATUF5m310kmRvgoBL+WbZMw71tJp3pYy86/FNf8laA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR02MB6982 X-Headers-End: 1t5lIk-0000VE-6k Subject: [f2fs-dev] [RFC PATCH 19/24] tests: add fsck testcase of fixing sum entry ofs_in_node 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_ssa_bad_ofs_in_node/README | 5 +++ tests/f_ssa_bad_ofs_in_node/expect.in | 34 +++++++++++++++++++++ tests/f_ssa_bad_ofs_in_node/script | 44 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/f_ssa_bad_ofs_in_node/README create mode 100644 tests/f_ssa_bad_ofs_in_node/expect.in create mode 100644 tests/f_ssa_bad_ofs_in_node/script diff --git a/tests/f_ssa_bad_ofs_in_node/README b/tests/f_ssa_bad_ofs_in_node/README new file mode 100644 index 000000000000..65fbf6aa4f1b --- /dev/null +++ b/tests/f_ssa_bad_ofs_in_node/README @@ -0,0 +1,5 @@ +1. create f2fs image +2. mount f2fs and create a regular file and write data +3. get a block address by dumping the inode +4. inject ofs_in_node in the ssa entry of the blkaddr +5. fsck fixes the ssa entry diff --git a/tests/f_ssa_bad_ofs_in_node/expect.in b/tests/f_ssa_bad_ofs_in_node/expect.in new file mode 100644 index 000000000000..a3a6c94993a7 --- /dev/null +++ b/tests/f_ssa_bad_ofs_in_node/expect.in @@ -0,0 +1,34 @@ +Info: Force to fix corruption +Info: checkpoint state = x : nat_bits crc compacted_summary unmount +[ASSERT] (is_valid_ssa_data_blk: x) --> Set data summary _SEGNO_ -> [_INO_] [0x0] [_OFS_IN_NODE_] + +[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 [Fail] +Info: Duplicate valid checkpoint to mirror position x -> x +Info: Write valid nat_bits in checkpoint +Info: fix_checkpoint() cur_cp:x + +Info: Force to fix corruption +Info: checkpoint state = x : allow_nocrc nat_bits 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..] + diff --git a/tests/f_ssa_bad_ofs_in_node/script b/tests/f_ssa_bad_ofs_in_node/script new file mode 100644 index 000000000000..a9d17e5d045e --- /dev/null +++ b/tests/f_ssa_bad_ofs_in_node/script @@ -0,0 +1,44 @@ +#!/bin/sh + +DESC="ssa entry with invalid ofs_in_node" + +. $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 +dd if=/dev/zero of=$TESTDIR/mntdir/testfile bs=4K count=513 status=none +ino=`stat -c "%i" $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 + +$DUMP $DUMP_OPTS -i $ino $META >> $LOG 2>&1 +base=`$DUMP $DUMP_OPTS -i $ino $META | grep i_addr | head -n 1 | sed 's/i_addr\[\(0x[0-9a-f]\+\)\].*$/\1/g'` +blkaddr=`$DUMP $DUMP_OPTS -i $ino $META | grep "\[0x100\]" | sed 's/i_addr\[0x100\].*: \([0-9]*\)\]$/\1/g'` +echo "ino:$ino blkaddr:$blkaddr" >> $LOG + +$INJECT --ssa --blk $blkaddr --mb ofs_in_node --val 99 $META >> $LOG 2>&1 +$FSCK $FSCK_OPTS -f $META > $OUT 2>&1 +$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1 +cat $OUT >> $LOG + +segno=`get_segno $blkaddr` +SEGNO=`printf "0x%x" $segno` +INO=`printf "0x%x" $ino` +OFS_IN_NODE=`printf "0x%x" $((0x100 - $base))` +sed "s/_SEGNO_/$SEGNO/g" $TESTDIR/expect.in > $TESTDIR/expect +sed -i "s/_INO_/$INO/g" $TESTDIR/expect +sed -i "s/_OFS_IN_NODE_/$OFS_IN_NODE/g" $TESTDIR/expect + +check_result +cleanup post >> $LOG 2>&1