* [PATCH v2] f2fs/023: test sanity check condition w/ error injection
@ 2025-11-03 6:21 Chao Yu
2025-11-15 8:18 ` Zorro Lang
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2025-11-03 6:21 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel, Chao Yu
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>
---
v2:
- use _filter_scratch to filter scratch mountpoint
- check output message of inject.f2fs rather than return value
- add _require_attrs
- add f2fs/023 to attr group
- fail testcase if mkfs failed
tests/f2fs/023 | 49 ++++++++++++++++++++++++++++++++++++++++++++++
tests/f2fs/023.out | 2 ++
2 files changed, 51 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..33108421
--- /dev/null
+++ b/tests/f2fs/023
@@ -0,0 +1,49 @@
+#! /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
+. ./common/attr
+. ./common/filter
+_begin_fstest auto quick rw attr
+
+_fixed_by_kernel_commit 5c1768b67250 \
+ "f2fs: fix to do sanity check correctly on i_inline_xattr_size"
+
+_require_attrs
+_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 || _fail "mkfs failed"
+_scratch_mount "-o inline_xattr_size=512" >>$seqres.full 2>&1
+touch $testfile
+_scratch_unmount
+
+# inject .i_inline field: clear F2FS_EXTRA_ATTR bit
+output=`$F2FS_INJECT_PROG --node --mb i_inline --nid 4 --val 0x1 $SCRATCH_DEV`
+echo "$output" >> $seqres.full
+echo "$output" | grep "unknown or unsupported member" && _fail "i_inline is unsupported"
+
+# inject .i_inline_xattr_size field from 512 to 2048
+output=`$F2FS_INJECT_PROG --node --mb i_inline_xattr_size --nid 4 --val 2048 $SCRATCH_DEV`
+echo "$output" >> $seqres.full
+echo "$output" | grep "unknown or unsupported member" && _fail "i_inline_xattr_size is unsupported"
+
+_scratch_mount
+
+$GETFATTR_PROG -n user.test "$testfile" 2>&1 | _filter_scratch
+
+status=0
+exit
diff --git a/tests/f2fs/023.out b/tests/f2fs/023.out
new file mode 100644
index 00000000..f9635d38
--- /dev/null
+++ b/tests/f2fs/023.out
@@ -0,0 +1,2 @@
+QA output created by 023
+getfattr: SCRATCH_MNT/testfile: Structure needs cleaning
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] f2fs/023: test sanity check condition w/ error injection
2025-11-03 6:21 [PATCH v2] f2fs/023: test sanity check condition w/ error injection Chao Yu
@ 2025-11-15 8:18 ` Zorro Lang
2025-11-15 11:05 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Zorro Lang @ 2025-11-15 8:18 UTC (permalink / raw)
To: Chao Yu; +Cc: Zorro Lang, fstests, jaegeuk, linux-f2fs-devel
On Mon, Nov 03, 2025 at 02:21:43PM +0800, Chao Yu wrote:
> 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>
> ---
> v2:
> - use _filter_scratch to filter scratch mountpoint
> - check output message of inject.f2fs rather than return value
> - add _require_attrs
> - add f2fs/023 to attr group
> - fail testcase if mkfs failed
> tests/f2fs/023 | 49 ++++++++++++++++++++++++++++++++++++++++++++++
> tests/f2fs/023.out | 2 ++
> 2 files changed, 51 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..33108421
> --- /dev/null
> +++ b/tests/f2fs/023
> @@ -0,0 +1,49 @@
> +#! /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
> +. ./common/attr
> +. ./common/filter
> +_begin_fstest auto quick rw attr
> +
> +_fixed_by_kernel_commit 5c1768b67250 \
> + "f2fs: fix to do sanity check correctly on i_inline_xattr_size"
> +
> +_require_attrs
> +_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 || _fail "mkfs failed"
> +_scratch_mount "-o inline_xattr_size=512" >>$seqres.full 2>&1
> +touch $testfile
> +_scratch_unmount
> +
> +# inject .i_inline field: clear F2FS_EXTRA_ATTR bit
> +output=`$F2FS_INJECT_PROG --node --mb i_inline --nid 4 --val 0x1 $SCRATCH_DEV`
> +echo "$output" >> $seqres.full
> +echo "$output" | grep "unknown or unsupported member" && _fail "i_inline is unsupported"
> +
> +# inject .i_inline_xattr_size field from 512 to 2048
> +output=`$F2FS_INJECT_PROG --node --mb i_inline_xattr_size --nid 4 --val 2048 $SCRATCH_DEV`
> +echo "$output" >> $seqres.full
> +echo "$output" | grep "unknown or unsupported member" && _fail "i_inline_xattr_size is unsupported"
I think we might need a common helper to do f2fs injection and return
error if injection fails, if F2FS_INJECT_PROG always can't return error
properly. Anyway, that's another story. For this patch:
Reviewed-by: Zorro Lang <zlang@redhat.com>
> +
> +_scratch_mount
> +
> +$GETFATTR_PROG -n user.test "$testfile" 2>&1 | _filter_scratch
> +
> +status=0
> +exit
> diff --git a/tests/f2fs/023.out b/tests/f2fs/023.out
> new file mode 100644
> index 00000000..f9635d38
> --- /dev/null
> +++ b/tests/f2fs/023.out
> @@ -0,0 +1,2 @@
> +QA output created by 023
> +getfattr: SCRATCH_MNT/testfile: Structure needs cleaning
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] f2fs/023: test sanity check condition w/ error injection
2025-11-15 8:18 ` Zorro Lang
@ 2025-11-15 11:05 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2025-11-15 11:05 UTC (permalink / raw)
To: Zorro Lang; +Cc: chao, Zorro Lang, fstests, jaegeuk, linux-f2fs-devel
On 11/15/2025 4:18 PM, Zorro Lang wrote:
> On Mon, Nov 03, 2025 at 02:21:43PM +0800, Chao Yu wrote:
>> 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>
>> ---
>> v2:
>> - use _filter_scratch to filter scratch mountpoint
>> - check output message of inject.f2fs rather than return value
>> - add _require_attrs
>> - add f2fs/023 to attr group
>> - fail testcase if mkfs failed
>> tests/f2fs/023 | 49 ++++++++++++++++++++++++++++++++++++++++++++++
>> tests/f2fs/023.out | 2 ++
>> 2 files changed, 51 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..33108421
>> --- /dev/null
>> +++ b/tests/f2fs/023
>> @@ -0,0 +1,49 @@
>> +#! /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
>> +. ./common/attr
>> +. ./common/filter
>> +_begin_fstest auto quick rw attr
>> +
>> +_fixed_by_kernel_commit 5c1768b67250 \
>> + "f2fs: fix to do sanity check correctly on i_inline_xattr_size"
>> +
>> +_require_attrs
>> +_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 || _fail "mkfs failed"
>> +_scratch_mount "-o inline_xattr_size=512" >>$seqres.full 2>&1
>> +touch $testfile
>> +_scratch_unmount
>> +
>> +# inject .i_inline field: clear F2FS_EXTRA_ATTR bit
>> +output=`$F2FS_INJECT_PROG --node --mb i_inline --nid 4 --val 0x1 $SCRATCH_DEV`
>> +echo "$output" >> $seqres.full
>> +echo "$output" | grep "unknown or unsupported member" && _fail "i_inline is unsupported"
>> +
>> +# inject .i_inline_xattr_size field from 512 to 2048
>> +output=`$F2FS_INJECT_PROG --node --mb i_inline_xattr_size --nid 4 --val 2048 $SCRATCH_DEV`
>> +echo "$output" >> $seqres.full
>> +echo "$output" | grep "unknown or unsupported member" && _fail "i_inline_xattr_size is unsupported"
>
> I think we might need a common helper to do f2fs injection and return
> error if injection fails, if F2FS_INJECT_PROG always can't return error
Yes, let me find free slot to clean up, thanks for the suggestion and
review. :)
Thanks.
> properly. Anyway, that's another story. For this patch:
>
> Reviewed-by: Zorro Lang <zlang@redhat.com>
>
>> +
>> +_scratch_mount
>> +
>> +$GETFATTR_PROG -n user.test "$testfile" 2>&1 | _filter_scratch
>> +
>> +status=0
>> +exit
>> diff --git a/tests/f2fs/023.out b/tests/f2fs/023.out
>> new file mode 100644
>> index 00000000..f9635d38
>> --- /dev/null
>> +++ b/tests/f2fs/023.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 023
>> +getfattr: SCRATCH_MNT/testfile: Structure needs cleaning
>> --
>> 2.49.0
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-15 11:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-03 6:21 [PATCH v2] f2fs/023: test sanity check condition w/ error injection Chao Yu
2025-11-15 8:18 ` Zorro Lang
2025-11-15 11:05 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox