* [PATCH v5 1/6] common/config: remove redundant export variables
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests
Cc: jaegeuk, linux-f2fs-devel, Chao Yu, David Disseldorp, Zorro Lang
F2FS_IO_PROG and TIMEOUT_PROG are exported twice, remove the redudant
one.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 2 --
1 file changed, 2 deletions(-)
diff --git a/common/config b/common/config
index 2afbda14..aa525825 100644
--- a/common/config
+++ b/common/config
@@ -191,7 +191,6 @@ export XFS_COPY_PROG="$(type -P xfs_copy)"
export FSTRIM_PROG="$(type -P fstrim)"
export DUMPE2FS_PROG="$(type -P dumpe2fs)"
export RESIZE2FS_PROG="$(type -P resize2fs)"
-export F2FS_IO_PROG="$(type -P f2fs_io)"
export FIO_PROG="$(type -P fio)"
export FILEFRAG_PROG="$(type -P filefrag)"
export E4DEFRAG_PROG="$(type -P e4defrag)"
@@ -220,7 +219,6 @@ export UBIUPDATEVOL_PROG="$(type -P ubiupdatevol)"
export THIN_CHECK_PROG="$(type -P thin_check)"
export PYTHON3_PROG="$(type -P python3)"
export SQLITE3_PROG="$(type -P sqlite3)"
-export TIMEOUT_PROG="$(type -P timeout)"
export SETCAP_PROG="$(type -P setcap)"
export GETCAP_PROG="$(type -P getcap)"
export CAPSH_PROG="$(type -P capsh)"
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 1/6] common/config: remove redundant export variables
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests
Cc: jaegeuk, Zorro Lang, David Disseldorp, linux-f2fs-devel
F2FS_IO_PROG and TIMEOUT_PROG are exported twice, remove the redudant
one.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 2 --
1 file changed, 2 deletions(-)
diff --git a/common/config b/common/config
index 2afbda14..aa525825 100644
--- a/common/config
+++ b/common/config
@@ -191,7 +191,6 @@ export XFS_COPY_PROG="$(type -P xfs_copy)"
export FSTRIM_PROG="$(type -P fstrim)"
export DUMPE2FS_PROG="$(type -P dumpe2fs)"
export RESIZE2FS_PROG="$(type -P resize2fs)"
-export F2FS_IO_PROG="$(type -P f2fs_io)"
export FIO_PROG="$(type -P fio)"
export FILEFRAG_PROG="$(type -P filefrag)"
export E4DEFRAG_PROG="$(type -P e4defrag)"
@@ -220,7 +219,6 @@ export UBIUPDATEVOL_PROG="$(type -P ubiupdatevol)"
export THIN_CHECK_PROG="$(type -P thin_check)"
export PYTHON3_PROG="$(type -P python3)"
export SQLITE3_PROG="$(type -P sqlite3)"
-export TIMEOUT_PROG="$(type -P timeout)"
export SETCAP_PROG="$(type -P setcap)"
export GETCAP_PROG="$(type -P getcap)"
export CAPSH_PROG="$(type -P capsh)"
--
2.48.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 2/6] common/config: export F2FS_INJECT_PROG
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests
Cc: jaegeuk, linux-f2fs-devel, Chao Yu, David Disseldorp, Zorro Lang
export F2FS_INJECT_PROG w/ inject.f2fs, it can be used for fault injection.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/config b/common/config
index aa525825..7d017a05 100644
--- a/common/config
+++ b/common/config
@@ -316,6 +316,7 @@ export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
export DUMP_F2FS_PROG=$(type -P dump.f2fs)
export F2FS_IO_PROG=$(type -P f2fs_io)
+export F2FS_INJECT_PROG=$(type -P inject.f2fs)
export BTRFS_UTIL_PROG=$(type -P btrfs)
export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 2/6] common/config: export F2FS_INJECT_PROG
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests
Cc: jaegeuk, Zorro Lang, David Disseldorp, linux-f2fs-devel
export F2FS_INJECT_PROG w/ inject.f2fs, it can be used for fault injection.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/config b/common/config
index aa525825..7d017a05 100644
--- a/common/config
+++ b/common/config
@@ -316,6 +316,7 @@ export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
export DUMP_F2FS_PROG=$(type -P dump.f2fs)
export F2FS_IO_PROG=$(type -P f2fs_io)
+export F2FS_INJECT_PROG=$(type -P inject.f2fs)
export BTRFS_UTIL_PROG=$(type -P btrfs)
export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
--
2.48.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 3/6] common/config: export F2FS_FSCK_PROG
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel, Chao Yu, Zorro Lang
Let's export F2FS_FSCK_PROG, then we can use it in
_check_f2fs_filesystem() later.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/config b/common/config
index 7d017a05..79bec87f 100644
--- a/common/config
+++ b/common/config
@@ -317,6 +317,7 @@ export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
export DUMP_F2FS_PROG=$(type -P dump.f2fs)
export F2FS_IO_PROG=$(type -P f2fs_io)
export F2FS_INJECT_PROG=$(type -P inject.f2fs)
+export F2FS_FSCK_PROG=$(type -P fsck.f2fs)
export BTRFS_UTIL_PROG=$(type -P btrfs)
export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 3/6] common/config: export F2FS_FSCK_PROG
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, Zorro Lang, linux-f2fs-devel
Let's export F2FS_FSCK_PROG, then we can use it in
_check_f2fs_filesystem() later.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/config | 1 +
1 file changed, 1 insertion(+)
diff --git a/common/config b/common/config
index 7d017a05..79bec87f 100644
--- a/common/config
+++ b/common/config
@@ -317,6 +317,7 @@ export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
export DUMP_F2FS_PROG=$(type -P dump.f2fs)
export F2FS_IO_PROG=$(type -P f2fs_io)
export F2FS_INJECT_PROG=$(type -P inject.f2fs)
+export F2FS_FSCK_PROG=$(type -P fsck.f2fs)
export BTRFS_UTIL_PROG=$(type -P btrfs)
export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
--
2.48.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 4/6] common/rc: use -f for mkfs.f2fs by default
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel, Chao Yu, Zorro Lang
Otherwise, mkfs will fail due to there is an existing filesystem
in the image.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/rc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/rc b/common/rc
index e5168638..ac2bac81 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)
@@ -1336,7 +1336,7 @@ _try_scratch_mkfs_sized()
f2fs)
# mkfs.f2fs requires # of sectors as an input for the size
local sector_size=`blockdev --getss $SCRATCH_DEV`
- $MKFS_F2FS_PROG $MKFS_OPTIONS "$@" $SCRATCH_DEV `expr $fssize / $sector_size`
+ $MKFS_F2FS_PROG -f $MKFS_OPTIONS "$@" $SCRATCH_DEV `expr $fssize / $sector_size`
;;
tmpfs)
local free_mem=`_free_memory_bytes`
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 4/6] common/rc: use -f for mkfs.f2fs by default
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, Zorro Lang, linux-f2fs-devel
Otherwise, mkfs will fail due to there is an existing filesystem
in the image.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/rc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/rc b/common/rc
index e5168638..ac2bac81 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)
@@ -1336,7 +1336,7 @@ _try_scratch_mkfs_sized()
f2fs)
# mkfs.f2fs requires # of sectors as an input for the size
local sector_size=`blockdev --getss $SCRATCH_DEV`
- $MKFS_F2FS_PROG $MKFS_OPTIONS "$@" $SCRATCH_DEV `expr $fssize / $sector_size`
+ $MKFS_F2FS_PROG -f $MKFS_OPTIONS "$@" $SCRATCH_DEV `expr $fssize / $sector_size`
;;
tmpfs)
local free_mem=`_free_memory_bytes`
--
2.48.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 5/6] common/rc: introduce _check_f2fs_filesystem()
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel, Chao Yu
_check_generic_filesystem() will fail the test once it detects
corruption, let's introduce _check_f2fs_filesystem() to just check
filesystem w/ --dry-run option, and return the error number, then
let caller to decide whether the corruption is as expected or not.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/rc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/common/rc b/common/rc
index ac2bac81..cabd44de 100644
--- a/common/rc
+++ b/common/rc
@@ -3527,6 +3527,50 @@ _check_generic_filesystem()
return 0
}
+_check_f2fs_filesystem()
+{
+ local device=$1
+
+ # If type is set, we're mounted
+ local type=`_fs_type $device`
+ local ok=1
+
+ if [ "$type" = "f2fs" ]
+ then
+ # mounted ...
+ local mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ $F2FS_FSCK_PROG --dry-run $device >$tmp.fsck.f2fs 2>&1
+ if [ $? -ne 0 ];then
+ _log_err "_check_f2fs_filesystem: filesystem on $device is inconsistent"
+ echo "*** fsck.f2fs output ***" >>$seqres.full
+ cat $tmp.fsck.f2fs >>$seqres.full
+ echo "*** end fsck.f2fs output" >>$seqres.full
+
+ ok=0
+ fi
+ rm -f $tmp.fsck.f2fs
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$seqres.full
+ _mount >>$seqres.full
+ echo "*** end mount output" >>$seqres.full
+ elif [ "$type" = "f2fs" ]
+ then
+ # was mounted ...
+ _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+ ok=$?
+ fi
+
+ if [ $ok -eq 0 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
# Filter the knowen errors the UDF Verifier reports.
_udf_test_known_error_filter()
{
@@ -3631,6 +3675,9 @@ _check_test_fs()
ubifs)
# there is no fsck program for ubifs yet
;;
+ f2fs)
+ _check_f2fs_filesystem $TEST_DEV
+ ;;
*)
_check_generic_filesystem $TEST_DEV
;;
@@ -3687,6 +3734,9 @@ _check_scratch_fs()
ubifs)
# there is no fsck program for ubifs yet
;;
+ f2fs)
+ _check_f2fs_filesystem $device
+ ;;
*)
_check_generic_filesystem $device
;;
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 5/6] common/rc: introduce _check_f2fs_filesystem()
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel
_check_generic_filesystem() will fail the test once it detects
corruption, let's introduce _check_f2fs_filesystem() to just check
filesystem w/ --dry-run option, and return the error number, then
let caller to decide whether the corruption is as expected or not.
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
common/rc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/common/rc b/common/rc
index ac2bac81..cabd44de 100644
--- a/common/rc
+++ b/common/rc
@@ -3527,6 +3527,50 @@ _check_generic_filesystem()
return 0
}
+_check_f2fs_filesystem()
+{
+ local device=$1
+
+ # If type is set, we're mounted
+ local type=`_fs_type $device`
+ local ok=1
+
+ if [ "$type" = "f2fs" ]
+ then
+ # mounted ...
+ local mountpoint=`_umount_or_remount_ro $device`
+ fi
+
+ $F2FS_FSCK_PROG --dry-run $device >$tmp.fsck.f2fs 2>&1
+ if [ $? -ne 0 ];then
+ _log_err "_check_f2fs_filesystem: filesystem on $device is inconsistent"
+ echo "*** fsck.f2fs output ***" >>$seqres.full
+ cat $tmp.fsck.f2fs >>$seqres.full
+ echo "*** end fsck.f2fs output" >>$seqres.full
+
+ ok=0
+ fi
+ rm -f $tmp.fsck.f2fs
+
+ if [ $ok -eq 0 ]
+ then
+ echo "*** mount output ***" >>$seqres.full
+ _mount >>$seqres.full
+ echo "*** end mount output" >>$seqres.full
+ elif [ "$type" = "f2fs" ]
+ then
+ # was mounted ...
+ _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+ ok=$?
+ fi
+
+ if [ $ok -eq 0 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
# Filter the knowen errors the UDF Verifier reports.
_udf_test_known_error_filter()
{
@@ -3631,6 +3675,9 @@ _check_test_fs()
ubifs)
# there is no fsck program for ubifs yet
;;
+ f2fs)
+ _check_f2fs_filesystem $TEST_DEV
+ ;;
*)
_check_generic_filesystem $TEST_DEV
;;
@@ -3687,6 +3734,9 @@ _check_scratch_fs()
ubifs)
# there is no fsck program for ubifs yet
;;
+ f2fs)
+ _check_f2fs_filesystem $device
+ ;;
*)
_check_generic_filesystem $device
;;
--
2.48.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel, Chao Yu
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@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v5:
- clean up codes suggested by Dave.
tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
tests/f2fs/009.out | 2 +
2 files changed, 143 insertions(+)
create mode 100755 tests/f2fs/009
create mode 100644 tests/f2fs/009.out
diff --git a/tests/f2fs/009 b/tests/f2fs/009
new file mode 100755
index 00000000..864fdcfb
--- /dev/null
+++ b/tests/f2fs/009
@@ -0,0 +1,141 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Chao Yu. All Rights Reserved.
+#
+# FS QA Test No. f2fs/009
+#
+# 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.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+if [ ! -x "$(type -P socket)" ]; then
+ _notrun "Couldn't find socket"
+fi
+
+_require_scratch
+_require_command "$F2FS_INJECT_PROG" inject.f2fs
+
+_fixed_by_git_commit f2fs-tools 958cd6e \
+ "fsck.f2fs: support to repair corrupted i_links"
+
+filename=$SCRATCH_MNT/foo
+hardlink=$SCRATCH_MNT/bar
+
+_cleanup()
+{
+ if [ -n "$pid" ]; then
+ kill $pid &> /dev/null
+ wait
+ fi
+ cd /
+ rm -r -f $tmp.*
+}
+
+_inject_and_check()
+{
+ local nlink=$1
+ local ino=$2
+
+ echo "ino:"$ino >> $seqres.full
+ echo "nlink:"$nlink >> $seqres.full
+
+ _scratch_unmount
+
+ $F2FS_INJECT_PROG --node --mb i_links --nid $ino --val $nlink $SCRATCH_DEV \
+ >> $seqres.full || _fail "fail to inject"
+
+ _check_scratch_fs >> $seqres.full 2>&1 && _fail "can't find corruption"
+ _repair_scratch_fs >> $seqres.full
+ _check_scratch_fs >> $seqres.full 2>&1 || _fail "fsck can't fix corruption"
+
+ _scratch_mount
+ _scratch_unmount
+
+ _scratch_mkfs >> $seqres.full
+ _scratch_mount
+}
+
+inject_and_check()
+{
+ local nlink=$1
+ local create_hardlink=$2
+ local ino=$3
+
+ if [ -z $ino ]; then
+ ino=`stat -c '%i' $filename`
+ fi
+
+ if [ $create_hardlink == 1 ]; then
+ ln $filename $hardlink
+ fi
+
+ _inject_and_check $nlink $ino
+}
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+
+touch $filename
+inject_and_check 0 0
+
+mkdir $filename
+inject_and_check 1 0
+
+mknod $filename c 9 0
+inject_and_check 0 0
+
+mknod $filename b 8 0
+inject_and_check 0 0
+
+mkfifo $filename
+inject_and_check 0 0
+
+socket -s $filename >> $seqres.full 2>&1 &
+pid=$!
+sleep 2
+ino=`stat -c '%i' $filename`
+kill $pid >> $seqres.full 2>&1
+inject_and_check 0 0 $ino
+
+ln -s $SCRATCH_MNT/empty $filename
+inject_and_check 0 0
+
+touch $filename
+ino=`stat -c '%i' $filename`
+$F2FS_IO_PROG write 1 0 1 zero atomic_commit $filename 5000 >> $seqres.full 2>&1 &
+stat $filename >> $seqres.full
+rm $filename
+$F2FS_IO_PROG shutdown 1 $SCRATCH_MNT/ >> $seqres.full
+sleep 6
+inject_and_check 1 0 $ino
+
+# hardlink
+touch $filename
+inject_and_check 0 1
+
+mknod $filename c 9 0
+inject_and_check 0 1
+
+mknod $filename b 8 0
+inject_and_check 0 1
+
+mkfifo $filename
+inject_and_check 0 1
+
+socket -s $filename >> $seqres.full 2>&1 &
+pid=$!
+sleep 2
+ino=`stat -c '%i' $filename`
+kill $pid >> $seqres.full 2>&1
+inject_and_check 0 1 $ino
+
+ln -s $SCRATCH_MNT/empty $filename
+inject_and_check 0 1
+
+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
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [f2fs-dev] [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
@ 2025-03-25 12:58 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-25 12:58 UTC (permalink / raw)
To: Zorro Lang, fstests; +Cc: jaegeuk, linux-f2fs-devel
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@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
---
v5:
- clean up codes suggested by Dave.
tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
tests/f2fs/009.out | 2 +
2 files changed, 143 insertions(+)
create mode 100755 tests/f2fs/009
create mode 100644 tests/f2fs/009.out
diff --git a/tests/f2fs/009 b/tests/f2fs/009
new file mode 100755
index 00000000..864fdcfb
--- /dev/null
+++ b/tests/f2fs/009
@@ -0,0 +1,141 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Chao Yu. All Rights Reserved.
+#
+# FS QA Test No. f2fs/009
+#
+# 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.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+if [ ! -x "$(type -P socket)" ]; then
+ _notrun "Couldn't find socket"
+fi
+
+_require_scratch
+_require_command "$F2FS_INJECT_PROG" inject.f2fs
+
+_fixed_by_git_commit f2fs-tools 958cd6e \
+ "fsck.f2fs: support to repair corrupted i_links"
+
+filename=$SCRATCH_MNT/foo
+hardlink=$SCRATCH_MNT/bar
+
+_cleanup()
+{
+ if [ -n "$pid" ]; then
+ kill $pid &> /dev/null
+ wait
+ fi
+ cd /
+ rm -r -f $tmp.*
+}
+
+_inject_and_check()
+{
+ local nlink=$1
+ local ino=$2
+
+ echo "ino:"$ino >> $seqres.full
+ echo "nlink:"$nlink >> $seqres.full
+
+ _scratch_unmount
+
+ $F2FS_INJECT_PROG --node --mb i_links --nid $ino --val $nlink $SCRATCH_DEV \
+ >> $seqres.full || _fail "fail to inject"
+
+ _check_scratch_fs >> $seqres.full 2>&1 && _fail "can't find corruption"
+ _repair_scratch_fs >> $seqres.full
+ _check_scratch_fs >> $seqres.full 2>&1 || _fail "fsck can't fix corruption"
+
+ _scratch_mount
+ _scratch_unmount
+
+ _scratch_mkfs >> $seqres.full
+ _scratch_mount
+}
+
+inject_and_check()
+{
+ local nlink=$1
+ local create_hardlink=$2
+ local ino=$3
+
+ if [ -z $ino ]; then
+ ino=`stat -c '%i' $filename`
+ fi
+
+ if [ $create_hardlink == 1 ]; then
+ ln $filename $hardlink
+ fi
+
+ _inject_and_check $nlink $ino
+}
+
+_scratch_mkfs >> $seqres.full
+_scratch_mount
+
+touch $filename
+inject_and_check 0 0
+
+mkdir $filename
+inject_and_check 1 0
+
+mknod $filename c 9 0
+inject_and_check 0 0
+
+mknod $filename b 8 0
+inject_and_check 0 0
+
+mkfifo $filename
+inject_and_check 0 0
+
+socket -s $filename >> $seqres.full 2>&1 &
+pid=$!
+sleep 2
+ino=`stat -c '%i' $filename`
+kill $pid >> $seqres.full 2>&1
+inject_and_check 0 0 $ino
+
+ln -s $SCRATCH_MNT/empty $filename
+inject_and_check 0 0
+
+touch $filename
+ino=`stat -c '%i' $filename`
+$F2FS_IO_PROG write 1 0 1 zero atomic_commit $filename 5000 >> $seqres.full 2>&1 &
+stat $filename >> $seqres.full
+rm $filename
+$F2FS_IO_PROG shutdown 1 $SCRATCH_MNT/ >> $seqres.full
+sleep 6
+inject_and_check 1 0 $ino
+
+# hardlink
+touch $filename
+inject_and_check 0 1
+
+mknod $filename c 9 0
+inject_and_check 0 1
+
+mknod $filename b 8 0
+inject_and_check 0 1
+
+mkfifo $filename
+inject_and_check 0 1
+
+socket -s $filename >> $seqres.full 2>&1 &
+pid=$!
+sleep 2
+ino=`stat -c '%i' $filename`
+kill $pid >> $seqres.full 2>&1
+inject_and_check 0 1 $ino
+
+ln -s $SCRATCH_MNT/empty $filename
+inject_and_check 0 1
+
+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
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
@ 2025-03-25 23:20 ` Dave Chinner via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner @ 2025-03-25 23:20 UTC (permalink / raw)
To: Chao Yu; +Cc: Zorro Lang, fstests, jaegeuk, linux-f2fs-devel
On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v5:
> - clean up codes suggested by Dave.
> tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
> tests/f2fs/009.out | 2 +
> 2 files changed, 143 insertions(+)
> create mode 100755 tests/f2fs/009
> create mode 100644 tests/f2fs/009.out
>
> diff --git a/tests/f2fs/009 b/tests/f2fs/009
> new file mode 100755
> index 00000000..864fdcfb
> --- /dev/null
> +++ b/tests/f2fs/009
> @@ -0,0 +1,141 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
> +#
> +# FS QA Test No. f2fs/009
> +#
> +# 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.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +if [ ! -x "$(type -P socket)" ]; then
> + _notrun "Couldn't find socket"
> +fi
Perhaps something like:
_require_command $(type -P socket) socket
would be more consistent with all the other code that checks for
installed utilities that a test requires?
> +_require_scratch
> +_require_command "$F2FS_INJECT_PROG" inject.f2fs
> +
> +_fixed_by_git_commit f2fs-tools 958cd6e \
> + "fsck.f2fs: support to repair corrupted i_links"
> +
> +filename=$SCRATCH_MNT/foo
> +hardlink=$SCRATCH_MNT/bar
> +
> +_cleanup()
> +{
> + if [ -n "$pid" ]; then
> + kill $pid &> /dev/null
> + wait
> + fi
> + cd /
> + rm -r -f $tmp.*
> +}
> +
> +_inject_and_check()
Single leading "_" is reserved for fstests functions, not for local
test functions.
Just call this one "inject_and_test", because that is what it does,
and call this one:
> +inject_and_check()
> +{
> + local nlink=$1
> + local create_hardlink=$2
> + local ino=$3
> +
> + if [ -z $ino ]; then
> + ino=`stat -c '%i' $filename`
> + fi
> +
> + if [ $create_hardlink == 1 ]; then
> + ln $filename $hardlink
> + fi
> +
> + _inject_and_check $nlink $ino
> +}
something like check_links()
Otherwise this is a good improvement.
-Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [f2fs-dev] [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
@ 2025-03-25 23:20 ` Dave Chinner via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Dave Chinner via Linux-f2fs-devel @ 2025-03-25 23:20 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, Zorro Lang, fstests, linux-f2fs-devel
On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v5:
> - clean up codes suggested by Dave.
> tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
> tests/f2fs/009.out | 2 +
> 2 files changed, 143 insertions(+)
> create mode 100755 tests/f2fs/009
> create mode 100644 tests/f2fs/009.out
>
> diff --git a/tests/f2fs/009 b/tests/f2fs/009
> new file mode 100755
> index 00000000..864fdcfb
> --- /dev/null
> +++ b/tests/f2fs/009
> @@ -0,0 +1,141 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
> +#
> +# FS QA Test No. f2fs/009
> +#
> +# 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.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +if [ ! -x "$(type -P socket)" ]; then
> + _notrun "Couldn't find socket"
> +fi
Perhaps something like:
_require_command $(type -P socket) socket
would be more consistent with all the other code that checks for
installed utilities that a test requires?
> +_require_scratch
> +_require_command "$F2FS_INJECT_PROG" inject.f2fs
> +
> +_fixed_by_git_commit f2fs-tools 958cd6e \
> + "fsck.f2fs: support to repair corrupted i_links"
> +
> +filename=$SCRATCH_MNT/foo
> +hardlink=$SCRATCH_MNT/bar
> +
> +_cleanup()
> +{
> + if [ -n "$pid" ]; then
> + kill $pid &> /dev/null
> + wait
> + fi
> + cd /
> + rm -r -f $tmp.*
> +}
> +
> +_inject_and_check()
Single leading "_" is reserved for fstests functions, not for local
test functions.
Just call this one "inject_and_test", because that is what it does,
and call this one:
> +inject_and_check()
> +{
> + local nlink=$1
> + local create_hardlink=$2
> + local ino=$3
> +
> + if [ -z $ino ]; then
> + ino=`stat -c '%i' $filename`
> + fi
> +
> + if [ $create_hardlink == 1 ]; then
> + ln $filename $hardlink
> + fi
> +
> + _inject_and_check $nlink $ino
> +}
something like check_links()
Otherwise this is a good improvement.
-Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
2025-03-25 23:20 ` [f2fs-dev] " Dave Chinner via Linux-f2fs-devel
@ 2025-03-26 0:47 ` Zorro Lang via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Zorro Lang @ 2025-03-26 0:47 UTC (permalink / raw)
To: Dave Chinner, Chao Yu; +Cc: fstests, jaegeuk, linux-f2fs-devel
On Wed, Mar 26, 2025 at 10:20:30AM +1100, Dave Chinner wrote:
> On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
> > Signed-off-by: Chao Yu <chao@kernel.org>
> > ---
> > v5:
> > - clean up codes suggested by Dave.
> > tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
> > tests/f2fs/009.out | 2 +
> > 2 files changed, 143 insertions(+)
> > create mode 100755 tests/f2fs/009
> > create mode 100644 tests/f2fs/009.out
> >
> > diff --git a/tests/f2fs/009 b/tests/f2fs/009
> > new file mode 100755
> > index 00000000..864fdcfb
> > --- /dev/null
> > +++ b/tests/f2fs/009
> > @@ -0,0 +1,141 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
> > +#
> > +# FS QA Test No. f2fs/009
> > +#
> > +# 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.
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto quick
> > +
> > +if [ ! -x "$(type -P socket)" ]; then
> > + _notrun "Couldn't find socket"
> > +fi
>
> Perhaps something like:
>
> _require_command $(type -P socket) socket
Good point! Maybe double quotation marks -- "$(type -P socket)" is
helpful, due to if socket isn't installed, there will be only one
argument.
>
> would be more consistent with all the other code that checks for
> installed utilities that a test requires?
>
> > +_require_scratch
> > +_require_command "$F2FS_INJECT_PROG" inject.f2fs
> > +
> > +_fixed_by_git_commit f2fs-tools 958cd6e \
> > + "fsck.f2fs: support to repair corrupted i_links"
> > +
> > +filename=$SCRATCH_MNT/foo
> > +hardlink=$SCRATCH_MNT/bar
> > +
> > +_cleanup()
> > +{
> > + if [ -n "$pid" ]; then
> > + kill $pid &> /dev/null
> > + wait
> > + fi
> > + cd /
> > + rm -r -f $tmp.*
> > +}
> > +
> > +_inject_and_check()
>
> Single leading "_" is reserved for fstests functions, not for local
> test functions.
>
> Just call this one "inject_and_test", because that is what it does,
> and call this one:
>
> > +inject_and_check()
> > +{
> > + local nlink=$1
> > + local create_hardlink=$2
> > + local ino=$3
> > +
> > + if [ -z $ino ]; then
> > + ino=`stat -c '%i' $filename`
> > + fi
> > +
> > + if [ $create_hardlink == 1 ]; then
> > + ln $filename $hardlink
> > + fi
> > +
> > + _inject_and_check $nlink $ino
> > +}
>
> something like check_links()
>
> Otherwise this is a good improvement.
Hi Chao, if you agree with all these changes, and don't need to change more, I can
help to merge this patchset with above changes. Or you'd like to send a new version?
Thanks,
Zorro
>
> -Dave.
> --
> Dave Chinner
> david@fromorbit.com
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [f2fs-dev] [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
@ 2025-03-26 0:47 ` Zorro Lang via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Zorro Lang via Linux-f2fs-devel @ 2025-03-26 0:47 UTC (permalink / raw)
To: Dave Chinner, Chao Yu; +Cc: jaegeuk, fstests, linux-f2fs-devel
On Wed, Mar 26, 2025 at 10:20:30AM +1100, Dave Chinner wrote:
> On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
> > Signed-off-by: Chao Yu <chao@kernel.org>
> > ---
> > v5:
> > - clean up codes suggested by Dave.
> > tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
> > tests/f2fs/009.out | 2 +
> > 2 files changed, 143 insertions(+)
> > create mode 100755 tests/f2fs/009
> > create mode 100644 tests/f2fs/009.out
> >
> > diff --git a/tests/f2fs/009 b/tests/f2fs/009
> > new file mode 100755
> > index 00000000..864fdcfb
> > --- /dev/null
> > +++ b/tests/f2fs/009
> > @@ -0,0 +1,141 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
> > +#
> > +# FS QA Test No. f2fs/009
> > +#
> > +# 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.
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto quick
> > +
> > +if [ ! -x "$(type -P socket)" ]; then
> > + _notrun "Couldn't find socket"
> > +fi
>
> Perhaps something like:
>
> _require_command $(type -P socket) socket
Good point! Maybe double quotation marks -- "$(type -P socket)" is
helpful, due to if socket isn't installed, there will be only one
argument.
>
> would be more consistent with all the other code that checks for
> installed utilities that a test requires?
>
> > +_require_scratch
> > +_require_command "$F2FS_INJECT_PROG" inject.f2fs
> > +
> > +_fixed_by_git_commit f2fs-tools 958cd6e \
> > + "fsck.f2fs: support to repair corrupted i_links"
> > +
> > +filename=$SCRATCH_MNT/foo
> > +hardlink=$SCRATCH_MNT/bar
> > +
> > +_cleanup()
> > +{
> > + if [ -n "$pid" ]; then
> > + kill $pid &> /dev/null
> > + wait
> > + fi
> > + cd /
> > + rm -r -f $tmp.*
> > +}
> > +
> > +_inject_and_check()
>
> Single leading "_" is reserved for fstests functions, not for local
> test functions.
>
> Just call this one "inject_and_test", because that is what it does,
> and call this one:
>
> > +inject_and_check()
> > +{
> > + local nlink=$1
> > + local create_hardlink=$2
> > + local ino=$3
> > +
> > + if [ -z $ino ]; then
> > + ino=`stat -c '%i' $filename`
> > + fi
> > +
> > + if [ $create_hardlink == 1 ]; then
> > + ln $filename $hardlink
> > + fi
> > +
> > + _inject_and_check $nlink $ino
> > +}
>
> something like check_links()
>
> Otherwise this is a good improvement.
Hi Chao, if you agree with all these changes, and don't need to change more, I can
help to merge this patchset with above changes. Or you'd like to send a new version?
Thanks,
Zorro
>
> -Dave.
> --
> Dave Chinner
> david@fromorbit.com
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
2025-03-26 0:47 ` [f2fs-dev] " Zorro Lang via Linux-f2fs-devel
@ 2025-03-26 3:24 ` Chao Yu via Linux-f2fs-devel
-1 siblings, 0 replies; 18+ messages in thread
From: Chao Yu @ 2025-03-26 3:24 UTC (permalink / raw)
To: Zorro Lang, Dave Chinner; +Cc: chao, fstests, jaegeuk, linux-f2fs-devel
On 3/26/25 08:47, Zorro Lang wrote:
> On Wed, Mar 26, 2025 at 10:20:30AM +1100, Dave Chinner wrote:
>> On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>> ---
>>> v5:
>>> - clean up codes suggested by Dave.
>>> tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
>>> tests/f2fs/009.out | 2 +
>>> 2 files changed, 143 insertions(+)
>>> create mode 100755 tests/f2fs/009
>>> create mode 100644 tests/f2fs/009.out
>>>
>>> diff --git a/tests/f2fs/009 b/tests/f2fs/009
>>> new file mode 100755
>>> index 00000000..864fdcfb
>>> --- /dev/null
>>> +++ b/tests/f2fs/009
>>> @@ -0,0 +1,141 @@
>>> +#! /bin/bash
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
>>> +#
>>> +# FS QA Test No. f2fs/009
>>> +#
>>> +# 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.
>>> +#
>>> +. ./common/preamble
>>> +_begin_fstest auto quick
>>> +
>>> +if [ ! -x "$(type -P socket)" ]; then
>>> + _notrun "Couldn't find socket"
>>> +fi
>>
>> Perhaps something like:
>>
>> _require_command $(type -P socket) socket
>
> Good point! Maybe double quotation marks -- "$(type -P socket)" is
> helpful, due to if socket isn't installed, there will be only one
> argument.
>
>>
>> would be more consistent with all the other code that checks for
Agreed.
>> installed utilities that a test requires?
>>
>>> +_require_scratch
>>> +_require_command "$F2FS_INJECT_PROG" inject.f2fs
>>> +
>>> +_fixed_by_git_commit f2fs-tools 958cd6e \
>>> + "fsck.f2fs: support to repair corrupted i_links"
>>> +
>>> +filename=$SCRATCH_MNT/foo
>>> +hardlink=$SCRATCH_MNT/bar
>>> +
>>> +_cleanup()
>>> +{
>>> + if [ -n "$pid" ]; then
>>> + kill $pid &> /dev/null
>>> + wait
>>> + fi
>>> + cd /
>>> + rm -r -f $tmp.*
>>> +}
>>> +
>>> +_inject_and_check()
>>
>> Single leading "_" is reserved for fstests functions, not for local
>> test functions.
Oh, got it.
>>
>> Just call this one "inject_and_test", because that is what it does,
>> and call this one:
>>
>>> +inject_and_check()
>>> +{
>>> + local nlink=$1
>>> + local create_hardlink=$2
>>> + local ino=$3
>>> +
>>> + if [ -z $ino ]; then
>>> + ino=`stat -c '%i' $filename`
>>> + fi
>>> +
>>> + if [ $create_hardlink == 1 ]; then
>>> + ln $filename $hardlink
>>> + fi
>>> +
>>> + _inject_and_check $nlink $ino
>>> +}
>>
>> something like check_links()
>>
>> Otherwise this is a good improvement.
Thanks Dave for all your review and suggestion!
>
> Hi Chao, if you agree with all these changes, and don't need to change more, I can
> help to merge this patchset with above changes. Or you'd like to send a new version?
Zorro, I'm fine w/ all the changes, I'm appreciate for that if you can
help to update the patch!
Thanks,
>
> Thanks,
> Zorro
>
>>
>> -Dave.
>> --
>> Dave Chinner
>> david@fromorbit.com
>>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [f2fs-dev] [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
@ 2025-03-26 3:24 ` Chao Yu via Linux-f2fs-devel
0 siblings, 0 replies; 18+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-03-26 3:24 UTC (permalink / raw)
To: Zorro Lang, Dave Chinner; +Cc: jaegeuk, fstests, linux-f2fs-devel
On 3/26/25 08:47, Zorro Lang wrote:
> On Wed, Mar 26, 2025 at 10:20:30AM +1100, Dave Chinner wrote:
>> On Tue, Mar 25, 2025 at 08:58:24PM +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@kernel.org>
>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>> ---
>>> v5:
>>> - clean up codes suggested by Dave.
>>> tests/f2fs/009 | 141 +++++++++++++++++++++++++++++++++++++++++++++
>>> tests/f2fs/009.out | 2 +
>>> 2 files changed, 143 insertions(+)
>>> create mode 100755 tests/f2fs/009
>>> create mode 100644 tests/f2fs/009.out
>>>
>>> diff --git a/tests/f2fs/009 b/tests/f2fs/009
>>> new file mode 100755
>>> index 00000000..864fdcfb
>>> --- /dev/null
>>> +++ b/tests/f2fs/009
>>> @@ -0,0 +1,141 @@
>>> +#! /bin/bash
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +# Copyright (c) 2025 Chao Yu. All Rights Reserved.
>>> +#
>>> +# FS QA Test No. f2fs/009
>>> +#
>>> +# 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.
>>> +#
>>> +. ./common/preamble
>>> +_begin_fstest auto quick
>>> +
>>> +if [ ! -x "$(type -P socket)" ]; then
>>> + _notrun "Couldn't find socket"
>>> +fi
>>
>> Perhaps something like:
>>
>> _require_command $(type -P socket) socket
>
> Good point! Maybe double quotation marks -- "$(type -P socket)" is
> helpful, due to if socket isn't installed, there will be only one
> argument.
>
>>
>> would be more consistent with all the other code that checks for
Agreed.
>> installed utilities that a test requires?
>>
>>> +_require_scratch
>>> +_require_command "$F2FS_INJECT_PROG" inject.f2fs
>>> +
>>> +_fixed_by_git_commit f2fs-tools 958cd6e \
>>> + "fsck.f2fs: support to repair corrupted i_links"
>>> +
>>> +filename=$SCRATCH_MNT/foo
>>> +hardlink=$SCRATCH_MNT/bar
>>> +
>>> +_cleanup()
>>> +{
>>> + if [ -n "$pid" ]; then
>>> + kill $pid &> /dev/null
>>> + wait
>>> + fi
>>> + cd /
>>> + rm -r -f $tmp.*
>>> +}
>>> +
>>> +_inject_and_check()
>>
>> Single leading "_" is reserved for fstests functions, not for local
>> test functions.
Oh, got it.
>>
>> Just call this one "inject_and_test", because that is what it does,
>> and call this one:
>>
>>> +inject_and_check()
>>> +{
>>> + local nlink=$1
>>> + local create_hardlink=$2
>>> + local ino=$3
>>> +
>>> + if [ -z $ino ]; then
>>> + ino=`stat -c '%i' $filename`
>>> + fi
>>> +
>>> + if [ $create_hardlink == 1 ]; then
>>> + ln $filename $hardlink
>>> + fi
>>> +
>>> + _inject_and_check $nlink $ino
>>> +}
>>
>> something like check_links()
>>
>> Otherwise this is a good improvement.
Thanks Dave for all your review and suggestion!
>
> Hi Chao, if you agree with all these changes, and don't need to change more, I can
> help to merge this patchset with above changes. Or you'd like to send a new version?
Zorro, I'm fine w/ all the changes, I'm appreciate for that if you can
help to update the patch!
Thanks,
>
> Thanks,
> Zorro
>
>>
>> -Dave.
>> --
>> Dave Chinner
>> david@fromorbit.com
>>
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-03-26 3:25 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 12:58 [PATCH v5 1/6] common/config: remove redundant export variables Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 12:58 ` [PATCH v5 2/6] common/config: export F2FS_INJECT_PROG Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 12:58 ` [PATCH v5 3/6] common/config: export F2FS_FSCK_PROG Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 12:58 ` [PATCH v5 4/6] common/rc: use -f for mkfs.f2fs by default Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 12:58 ` [PATCH v5 5/6] common/rc: introduce _check_f2fs_filesystem() Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 12:58 ` [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption Chao Yu
2025-03-25 12:58 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2025-03-25 23:20 ` Dave Chinner
2025-03-25 23:20 ` [f2fs-dev] " Dave Chinner via Linux-f2fs-devel
2025-03-26 0:47 ` Zorro Lang
2025-03-26 0:47 ` [f2fs-dev] " Zorro Lang via Linux-f2fs-devel
2025-03-26 3:24 ` Chao Yu
2025-03-26 3:24 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.