* [PATCH v4 0/2] generic: new test to check nlink returned by fstat()
@ 2026-07-30 2:12 ChenXiaoSong
2026-07-30 2:12 ` [PATCH v4 1/2] generic/002: add test to hardlink group ChenXiaoSong
2026-07-30 2:12 ` [PATCH v4 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
0 siblings, 2 replies; 5+ messages in thread
From: ChenXiaoSong @ 2026-07-30 2:12 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, hch, zlang
Cc: linux-cifs, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
v3->v4:
- Patch#01: only add generic/002 to the "hardlink" group.
- Patch#02: use `_fail` and `_exit`.
v3: https://lore.kernel.org/linux-cifs/20260724031210.332153-1-chenxiaosong@chenxiaosong.com/
ChenXiaoSong (2):
generic/002: add test to hardlink group
generic: new test to check nlink returned by fstat()
tests/generic/002 | 2 +-
tests/generic/798 | 59 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/798.out | 2 ++
3 files changed, 62 insertions(+), 1 deletion(-)
create mode 100755 tests/generic/798
create mode 100644 tests/generic/798.out
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/2] generic/002: add test to hardlink group
2026-07-30 2:12 [PATCH v4 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
@ 2026-07-30 2:12 ` ChenXiaoSong
2026-08-03 10:44 ` Zorro Lang
2026-07-30 2:12 ` [PATCH v4 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
1 sibling, 1 reply; 5+ messages in thread
From: ChenXiaoSong @ 2026-07-30 2:12 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, hch, zlang
Cc: linux-cifs, ChenXiaoSong, Christoph Hellwig
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The test creates and removes hard links, so add it to the hardlink
group.
Suggested-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
tests/generic/002 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/generic/002 b/tests/generic/002
index 6df57a7a..a0773e22 100755
--- a/tests/generic/002
+++ b/tests/generic/002
@@ -7,7 +7,7 @@
# simple inode link count test for a regular file
#
. ./common/preamble
-_begin_fstest metadata udf auto quick
+_begin_fstest metadata udf auto quick hardlink
# Import common functions.
. ./common/filter
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] generic: new test to check nlink returned by fstat()
2026-07-30 2:12 [PATCH v4 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
2026-07-30 2:12 ` [PATCH v4 1/2] generic/002: add test to hardlink group ChenXiaoSong
@ 2026-07-30 2:12 ` ChenXiaoSong
2026-08-03 10:40 ` Zorro Lang
1 sibling, 1 reply; 5+ messages in thread
From: ChenXiaoSong @ 2026-07-30 2:12 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, hch, zlang
Cc: linux-cifs, ChenXiaoSong, Christoph Hellwig
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
Add a test to verify that fstat(2) returns the expected
st_nlink value as hardlinks are created and removed.
Regression test for kernel commit:
9dd1964ac59d ("smb/client: fix incorrect nlink returned by fstat()")
Suggested-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
tests/generic/798 | 59 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/798.out | 2 ++
2 files changed, 61 insertions(+)
create mode 100755 tests/generic/798
create mode 100644 tests/generic/798.out
diff --git a/tests/generic/798 b/tests/generic/798
new file mode 100755
index 00000000..e48a69a1
--- /dev/null
+++ b/tests/generic/798
@@ -0,0 +1,59 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2026 KylinSoft Co., Ltd. All rights reserved.
+# Author(s): ChenXiaoSong <chenxiaosong@kylinos.cn>
+#
+# FS QA Test 798
+#
+# Check that fstat(2) returns the correct hard link count for a regular file.
+#
+# from
+# tests/generic/002
+# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
+#
+. ./common/preamble
+_begin_fstest metadata auto quick hardlink
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".* "$testdir"
+}
+
+_require_test
+_require_hardlinks
+
+_fixed_by_fs_commit cifs 9dd1964ac59d \
+ "smb/client: fix incorrect nlink returned by fstat()"
+
+_get_nlink()
+{
+ # This calls `fstat()`, see `stat_f()` in xfsprogs-dev.git io/stat.c:
+ # https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/io/stat.c
+ $XFS_IO_PROG -c 'stat -r' "$1" |
+ sed -n 's/^stat\.nlink = //p'
+}
+
+testdir=$TEST_DIR/$seq
+rm -rf "$testdir"
+mkdir "$testdir"
+
+touch "$testdir/tmp.1"
+for ((l = 2; l <= 20; l++)); do
+ ln "$testdir/tmp.1" "$testdir/tmp.$l"
+ nlink=$(_get_nlink "$testdir/tmp.1")
+ if [ "$nlink" != "$l" ]; then
+ _fail "Expected nlink $l after creating link $testdir/tmp.$l, got ${nlink:-nothing}"
+ fi
+done
+
+for ((l = 20; l >= 1; l--)); do
+ nlink=$(_get_nlink "$testdir/tmp.1")
+ if [ "$nlink" != "$l" ]; then
+ _fail "Expected nlink $l before removing link $testdir/tmp.$l, got ${nlink:-nothing}"
+ fi
+ rm -f "$testdir/tmp.$l"
+done
+
+echo "Silence is golden"
+_exit 0
diff --git a/tests/generic/798.out b/tests/generic/798.out
new file mode 100644
index 00000000..216d6e93
--- /dev/null
+++ b/tests/generic/798.out
@@ -0,0 +1,2 @@
+QA output created by 798
+Silence is golden
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] generic: new test to check nlink returned by fstat()
2026-07-30 2:12 ` [PATCH v4 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
@ 2026-08-03 10:40 ` Zorro Lang
0 siblings, 0 replies; 5+ messages in thread
From: Zorro Lang @ 2026-08-03 10:40 UTC (permalink / raw)
To: ChenXiaoSong
Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, hch, linux-cifs, ChenXiaoSong,
Christoph Hellwig, fstests
On Thu, Jul 30, 2026 at 02:12:38AM +0000, ChenXiaoSong wrote:
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> Add a test to verify that fstat(2) returns the expected
> st_nlink value as hardlinks are created and removed.
>
> Regression test for kernel commit:
> 9dd1964ac59d ("smb/client: fix incorrect nlink returned by fstat()")
>
> Suggested-by: Zorro Lang <zlang@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
This version is good to me now,
Reviewed-by: Zorro Lang <zlang@kernel.org>
(Please To/CC fstests@vger.kernel.org)
> tests/generic/798 | 59 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/798.out | 2 ++
> 2 files changed, 61 insertions(+)
> create mode 100755 tests/generic/798
> create mode 100644 tests/generic/798.out
>
> diff --git a/tests/generic/798 b/tests/generic/798
> new file mode 100755
> index 00000000..e48a69a1
> --- /dev/null
> +++ b/tests/generic/798
> @@ -0,0 +1,59 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2026 KylinSoft Co., Ltd. All rights reserved.
> +# Author(s): ChenXiaoSong <chenxiaosong@kylinos.cn>
> +#
> +# FS QA Test 798
> +#
> +# Check that fstat(2) returns the correct hard link count for a regular file.
> +#
> +# from
> +# tests/generic/002
> +# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
> +#
> +. ./common/preamble
> +_begin_fstest metadata auto quick hardlink
> +
> +_cleanup()
> +{
> + cd /
> + rm -rf "$tmp".* "$testdir"
> +}
> +
> +_require_test
> +_require_hardlinks
> +
> +_fixed_by_fs_commit cifs 9dd1964ac59d \
> + "smb/client: fix incorrect nlink returned by fstat()"
> +
> +_get_nlink()
> +{
> + # This calls `fstat()`, see `stat_f()` in xfsprogs-dev.git io/stat.c:
> + # https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/tree/io/stat.c
> + $XFS_IO_PROG -c 'stat -r' "$1" |
> + sed -n 's/^stat\.nlink = //p'
> +}
> +
> +testdir=$TEST_DIR/$seq
> +rm -rf "$testdir"
> +mkdir "$testdir"
> +
> +touch "$testdir/tmp.1"
> +for ((l = 2; l <= 20; l++)); do
> + ln "$testdir/tmp.1" "$testdir/tmp.$l"
> + nlink=$(_get_nlink "$testdir/tmp.1")
> + if [ "$nlink" != "$l" ]; then
> + _fail "Expected nlink $l after creating link $testdir/tmp.$l, got ${nlink:-nothing}"
> + fi
> +done
> +
> +for ((l = 20; l >= 1; l--)); do
> + nlink=$(_get_nlink "$testdir/tmp.1")
> + if [ "$nlink" != "$l" ]; then
> + _fail "Expected nlink $l before removing link $testdir/tmp.$l, got ${nlink:-nothing}"
> + fi
> + rm -f "$testdir/tmp.$l"
> +done
> +
> +echo "Silence is golden"
> +_exit 0
> diff --git a/tests/generic/798.out b/tests/generic/798.out
> new file mode 100644
> index 00000000..216d6e93
> --- /dev/null
> +++ b/tests/generic/798.out
> @@ -0,0 +1,2 @@
> +QA output created by 798
> +Silence is golden
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/2] generic/002: add test to hardlink group
2026-07-30 2:12 ` [PATCH v4 1/2] generic/002: add test to hardlink group ChenXiaoSong
@ 2026-08-03 10:44 ` Zorro Lang
0 siblings, 0 replies; 5+ messages in thread
From: Zorro Lang @ 2026-08-03 10:44 UTC (permalink / raw)
To: ChenXiaoSong
Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, hch, linux-cifs, ChenXiaoSong,
Christoph Hellwig, fstests
On Thu, Jul 30, 2026 at 02:12:37AM +0000, ChenXiaoSong wrote:
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>
> The test creates and removes hard links, so add it to the hardlink
> group.
>
> Suggested-by: Zorro Lang <zlang@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
So you‘ve given up on re-writing this old case :)
Anyway, this's good to me.
Reviewed-by: Zorro Lang <zlang@kernel.org>
(Please CC fstests list)
> tests/generic/002 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/generic/002 b/tests/generic/002
> index 6df57a7a..a0773e22 100755
> --- a/tests/generic/002
> +++ b/tests/generic/002
> @@ -7,7 +7,7 @@
> # simple inode link count test for a regular file
> #
> . ./common/preamble
> -_begin_fstest metadata udf auto quick
> +_begin_fstest metadata udf auto quick hardlink
>
> # Import common functions.
> . ./common/filter
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-03 10:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 2:12 [PATCH v4 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
2026-07-30 2:12 ` [PATCH v4 1/2] generic/002: add test to hardlink group ChenXiaoSong
2026-08-03 10:44 ` Zorro Lang
2026-07-30 2:12 ` [PATCH v4 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong
2026-08-03 10:40 ` Zorro Lang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox