From: Dave Chinner <david@fromorbit.com>
To: Chao Yu <chao@kernel.org>
Cc: Zorro Lang <zlang@kernel.org>,
fstests@vger.kernel.org, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
Date: Wed, 26 Mar 2025 10:20:30 +1100 [thread overview]
Message-ID: <Z-M6PkLZI2LIOlXY@dread.disaster.area> (raw)
In-Reply-To: <20250325125824.3367060-6-chao@kernel.org>
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
WARNING: multiple messages have this Message-ID (diff)
From: Dave Chinner via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Chao Yu <chao@kernel.org>
Cc: jaegeuk@kernel.org, Zorro Lang <zlang@kernel.org>,
fstests@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v5 6/6] f2fs/009: detect and repair nlink corruption
Date: Wed, 26 Mar 2025 10:20:30 +1100 [thread overview]
Message-ID: <Z-M6PkLZI2LIOlXY@dread.disaster.area> (raw)
In-Reply-To: <20250325125824.3367060-6-chao@kernel.org>
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
next prev parent reply other threads:[~2025-03-25 23:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-03-25 23:20 ` 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
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=Z-M6PkLZI2LIOlXY@dread.disaster.area \
--to=david@fromorbit.com \
--cc=chao@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--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 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.