From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Zorro Lang <zlang@kernel.org>, fstests@vger.kernel.org
Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH] f2fs/023: test sanity check condition w/ error injection
Date: Wed, 29 Oct 2025 19:54:13 +0800 [thread overview]
Message-ID: <20251029115413.1085987-1-chao@kernel.org> (raw)
After commit 5c1768b67250 ("f2fs: fix to do sanity check correctly on
i_inline_xattr_size"), f2fs should handle corrupted i_inline_xattr_size
correctly, let's add this regression testcase to check that.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
tests/f2fs/023 | 44 ++++++++++++++++++++++++++++++++++++++++++++
tests/f2fs/023.out | 2 ++
2 files changed, 46 insertions(+)
create mode 100755 tests/f2fs/023
create mode 100644 tests/f2fs/023.out
diff --git a/tests/f2fs/023 b/tests/f2fs/023
new file mode 100755
index 00000000..d1b7df32
--- /dev/null
+++ b/tests/f2fs/023
@@ -0,0 +1,44 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Chao Yu <chao@kernel.org>
+#
+# FS QA Test No. f2fs/023
+#
+# This testcase tries to inject fault into inode.i_inline_xattr_size,
+# and check whether sanity check of f2fs can handle fault correctly.
+#
+
+. ./common/preamble
+_begin_fstest auto quick rw
+
+_fixed_by_kernel_commit 5c1768b67250 \
+ "f2fs: fix to do sanity check correctly on i_inline_xattr_size"
+
+_require_scratch_nocheck
+_require_inject_f2fs_command node i_inline
+_require_inject_f2fs_command node i_inline_xattr_size
+
+testfile=$SCRATCH_MNT/testfile
+
+# remove all mkfs options to avoid layout change of on-disk inode
+export MKFS_OPTIONS=""
+
+_scratch_mkfs "-O extra_attr,flexible_inline_xattr" >> $seqres.full
+_scratch_mount "-o inline_xattr_size=512" >>$seqres.full 2>&1
+touch $testfile
+_scratch_unmount
+
+# inject .i_inline field: clear F2FS_EXTRA_ATTR bit
+$F2FS_INJECT_PROG --node --mb i_inline --nid 4 --val 0x1 $SCRATCH_DEV \
+ >>$seqres.full || _fail "failed to inject i_inline"
+
+# inject .i_inline_xattr_size field from 512 to 2048
+$F2FS_INJECT_PROG --node --mb i_inline_xattr_size --nid 4 --val 2048 $SCRATCH_DEV \
+ >>$seqres.full || _fail "failed to inject i_inline_xattr_size"
+
+_scratch_mount
+
+getfattr -n user.test "$testfile" 2>&1 | awk -F ': ' '/Structure needs cleaning/ { print $NF }'
+
+status=0
+exit
diff --git a/tests/f2fs/023.out b/tests/f2fs/023.out
new file mode 100644
index 00000000..7f16f33f
--- /dev/null
+++ b/tests/f2fs/023.out
@@ -0,0 +1,2 @@
+QA output created by 023
+Structure needs cleaning
--
2.49.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next reply other threads:[~2025-10-29 11:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 11:54 Chao Yu via Linux-f2fs-devel [this message]
2025-11-01 15:23 ` [f2fs-dev] [PATCH] f2fs/023: test sanity check condition w/ error injection Zorro Lang via Linux-f2fs-devel
2025-11-03 2:51 ` Chao Yu via Linux-f2fs-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251029115413.1085987-1-chao@kernel.org \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=chao@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=jaegeuk@kernel.org \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).