On Mon, Mar 10, 2025 at 07:56:21PM +0800, Chao Yu wrote: > This is a regression test to check whether fsck can handle corrupted > nlinks correctly, it uses inject.f2fs to inject nlinks w/ wrong value, > and expects fsck.f2fs can detect such corruption and do the repair. > > Cc: Jaegeuk Kim <jaegeuk@xxxxxxxxxx> > Signed-off-by: Chao Yu <chao@xxxxxxxxxx> > --- > v2: > - make _scratch_mkfs() to format f2fs image forcely > - adjust _check_scratch_fs() to allow specified parameter of f2fs > - add _fixed_by_git_commit > - add _require_command inject.f2fs > - simply return value handling > common/rc | 9 ++- > tests/f2fs/009 | 133 +++++++++++++++++++++++++++++++++++++++++++++ > tests/f2fs/009.out | 2 + > 3 files changed, 143 insertions(+), 1 deletion(-) > create mode 100755 tests/f2fs/009 > create mode 100644 tests/f2fs/009.out > > diff --git a/common/rc b/common/rc > index bf24da4e..e156f3af 100644 > --- a/common/rc > +++ b/common/rc > @@ -993,7 +993,7 @@ _scratch_mkfs() > mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \"" > ;; > f2fs) > - mkfs_cmd="$MKFS_F2FS_PROG" > + mkfs_cmd="$MKFS_F2FS_PROG -f" > mkfs_filter="cat" > ;; > ocfs2) > @@ -3682,6 +3682,13 @@ _check_scratch_fs() > ubifs) > # there is no fsck program for ubifs yet > ;; > + f2fs) > + if [ "$FSCK_OPTIONS" == "--dry-run" ]; then > + fsck -t $FSTYP $device -- $FSCK_OPTIONS >> $seqres.full 2>&1 > + else > + _check_generic_filesystem $device > + fi If the "--dry-run" of fsck.f2fs is similar with "-n -y" of fsck.ext4. Then you might need to change the fsck_opts() function in common/config. _fsck_opts() { case $FSTYP in ext2|ext3|ext4) export FSCK_OPTIONS="-nf" ;; reiser*) export FSCK_OPTIONS="--yes" ;; f2fs) export FSCK_OPTIONS="" ;; ... } The default FSCK_OPTIONS for f2fs should be "--dry-run". f2fs) export FSCK_OPTIONS="--dry-run" Then ... [snip] > + $F2FS_INJECT_PROG --node --mb i_links --nid $ino --val $nlink $SCRATCH_DEV \ > + >> $seqres.full || _fail "fail to inject" > + > + export FSCK_OPTIONS="--dry-run" ... then you can save this export FSCK_OPTIONS="--dry-run". I've explained more in your v1 patch review, refer to: https://lore.kernel.org/fstests/20250310194818.wki325qreuta26nc@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/T/#u Thanks, Zorro > + _check_scratch_fs >>$seqres.full 2>&1 && _fail "can't find corruption" > + _repair_scratch_fs >> $seqres.full > + _check_scratch_fs > + > + _scratch_mount > + _scratch_unmount > +done > + > +echo "Silence is golden" > + > +status=0 > +exit > diff --git a/tests/f2fs/009.out b/tests/f2fs/009.out > new file mode 100644 > index 00000000..7e977155 > --- /dev/null > +++ b/tests/f2fs/009.out > @@ -0,0 +1,2 @@ > +QA output created by 009 > +Silence is golden > -- > 2.48.1 >