From patchwork Mon Mar 31 03:29:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 14033155 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 7DAAEC28B20 for ; Mon, 31 Mar 2025 03:30:09 +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 1tz5qh-0003ow-Fm; Mon, 31 Mar 2025 03:30:08 +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 1tz5qg-0003ol-KI for linux-f2fs-devel@lists.sourceforge.net; Mon, 31 Mar 2025 03:30:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :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=pfdVDlIj2ipI8JIp8JMzxyWuoJJlrfR9Z7A0lxoh25A=; b=NJnkNXpBn+wY38YMu1By1I2Blo Lik69bl7hUo/zvpPFH5iuKvRkXvvBdm+SajYISKGux4IpJa1ZU1bYTPLYKbZjXKl7YceHIOty+uxh Ti2lk0gSAdP48QiEnQ0B/EYTmjPPqOxVEW6pr+AoFsUTTt4mH04IZ/co4y0YPBIFxo9A=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version: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=pfdVDlIj2ipI8JIp8JMzxyWuoJJlrfR9Z7A0lxoh25A=; b=P ZG4wPi30ORHRbYavjPH01vyL6NwcB2VEVcq4692taN0h+XALkG1A5aNR6PTxCzGpkyvtdFnbiB+Fs akMLk9qI2ARWxgwxoTChjTzon5G0bro0Upt9BWuHx7o77p0SJ/B7bXk6SjKrCDlvTOc5tlLh5RGsW R9OvFNQWSMPTE1cY=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tz5qW-0005sO-GS for linux-f2fs-devel@lists.sourceforge.net; Mon, 31 Mar 2025 03:30:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id B7775436E7; Mon, 31 Mar 2025 03:29:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC02FC4CEE4; Mon, 31 Mar 2025 03:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743391786; bh=vCeKXokJDtsIiaj5SsmYmTNxsKqJ9Qwa0X6PWRrP9Og=; h=From:To:Cc:Subject:Date:From; b=E+svVkoKzlmMfe+uGwOxbeVEzhF/VnU0iH3OId2xOdzcPlGxaRe95wHteqWKAiYjp jPutDuMFkcdiaNNX1gIXdhuBhwTti3XRHF/NbsnmQqgf/H82y+MY+OynkelcLg0MPJ F2s3dJkVr84ZET8FZLMjaIE/92sf2zyvPzC9W2z4oiiGZtwGhT3KTqDbR5BUyiJFuw fQEaaK8OrroShsknduLij6410X3whUiOpda+PWmks75VkbHisQDUUCzSE2mkHqp/5P uOazd7QuhX4/IwuHhrYQdVD1lRe7B/V0pnFfpaNzqIux25AUMXQJUv/YhF92bCBgFs YCT5t3ThtVY8g== To: Zorro Lang , fstests@vger.kernel.org Date: Mon, 31 Mar 2025 11:29:16 +0800 Message-ID: <20250331032916.489543-1-chao@kernel.org> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog MIME-Version: 1.0 X-Headers-End: 1tz5qW-0005sO-GS Subject: [f2fs-dev] [PATCH] f2fs/012: test red heart lookup 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: Chao Yu via Linux-f2fs-devel From: Chao Yu Reply-To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net As Han Qi reported in bugzilla [1], commit 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points") changes logic to handle ignorable code points, when we handle filename which has special unicode charactor like red heart ❤️, utf8_casefold() may return different length than in the past, result in that f2fs cacluates hash code incorreclty, eventually, filename w/ special unicode charactor will not be found w/ the wrong hash code. f2fs has introduces a linear lookup fallback w/ commit 91b587ba79e1 ("f2fs: Introduce linear search for dentries"), once hash-based lookup fails, it tries linear lookup as a fallback. This patch can help to check whether linear lookup fallback works well or not. Firstly, we use below testcase to check how hash code changes: mkfs.f2fs -f -O casefold -C utf8 /dev/vda mount /dev/vda /mnt/f2fs mkdir /mnt/f2fs/dir/ f2fs_io setflags casefold /mnt/f2fs/dir touch /mnt/f2fs/dir/$'\u2764\ufe0f' umount /mnt/f2fs dump.f2fs -i 4 -d 3 /dev/vda dump.f2fs -b $blkaddr_of_dir -d 3 /dev/vda w/o ("unicode: Don't special case ignorable code points") [dump_dirent: 991] bitmap pos[0x2] name[❤️] len[0x6] hash[0x19dd7132] ino[0x5] type[0x1] [dump_dirent: 998] name(hex)[0xe2 0x9d 0xa4 0xef 0xb8 0x8f 0x0] w/ ("unicode: Don't special case ignorable code points") [dump_dirent: 991] bitmap pos[0x2] name[❤️] len[0x6] hash[0x9a2ea068] ino[0x5] type[0x1] [dump_dirent: 998] name(hex)[0xe2 0x9d 0xa4 0xef 0xb8 0x8f 0x0] Correct hash code: 0x19dd7132 Wrong hash code: 0x9a2ea068 So, we can test as below: 1. create file w/ red heart as its filename 2. inject wrong hash code to the file 3. disable linear lookup, expect lookup failure 4. enable linear lookup, expect lookup succeed [1] https://bugzilla.kernel.org/show_bug.cgi?id=219586 Cc: Jaegeuk Kim Cc: Daniel Lee Signed-off-by: Chao Yu --- tests/f2fs/012 | 54 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/012.out | 2 ++ 2 files changed, 56 insertions(+) create mode 100755 tests/f2fs/012 create mode 100644 tests/f2fs/012.out diff --git a/tests/f2fs/012 b/tests/f2fs/012 new file mode 100755 index 00000000..fdc30bea --- /dev/null +++ b/tests/f2fs/012 @@ -0,0 +1,54 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/012 +# +# This testcase checks whether linear lookup fallback works well +# or not as below: +# 1.create file w/ red heart as its filename +# 2.inject wrong hash code to the file +# 3.disable linear lookup, expect lookup failure +# 4.enable linear lookup, expect lookup succeed +# +. ./common/preamble +_begin_fstest auto quick casefold + +_fixed_by_kernel_commit 91b587ba79e1 \ + "f2fs: Introduce linear search for dentries" + +export LC_ALL=C.UTF-8 +_require_scratch +_require_command "$F2FS_IO_PROG" f2fs_io +_require_command "$F2FS_INJECT_PROG" inject.f2fs + +_scratch_mkfs -f -O casefold -C utf8 >> $seqres.full +_scratch_mount + +dir=$SCRATCH_MNT/dir + +# red heart charactor in unicode format +redheart=$dir/$'\u2764\ufe0f' + +mkdir $dir +$F2FS_IO_PROG setflags casefold $dir >> $seqres.full +touch $redheart +ino=`stat -c '%i' $redheart` +_scratch_unmount + +$F2FS_INJECT_PROG --dent --mb d_hash --nid $ino --val 0x9a2ea068 $SCRATCH_DEV >> $seqres.full + +$F2FS_FSCK_PROG --nolinear-lookup=1 $SCRATCH_DEV >> $seqres.full +_scratch_mount +[ -f $redheart ] && _fail "red heart file should not exist" +_scratch_unmount + +$F2FS_FSCK_PROG --nolinear-lookup=0 $SCRATCH_DEV >> $seqres.full +_scratch_mount +[ -f $redheart ] || _fail "red heart file should exist" +_scratch_unmount + +echo "Silence is golden" + +status=0 +exit diff --git a/tests/f2fs/012.out b/tests/f2fs/012.out new file mode 100644 index 00000000..3afeca2f --- /dev/null +++ b/tests/f2fs/012.out @@ -0,0 +1,2 @@ +QA output created by 012 +Silence is golden