* [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat()
@ 2026-07-24 3:12 ChenXiaoSong
2026-07-24 3:12 ` [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test ChenXiaoSong
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: ChenXiaoSong @ 2026-07-24 3:12 UTC (permalink / raw)
To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
senozhatsky, dhowells, metze, zlang
Cc: linux-cifs, fstests, ChenXiaoSong
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
v2->v3: use `xfs_io -c 'stat -r'` to call fstat().
v2: https://lore.kernel.org/linux-cifs/20260720163502.732454-1-chenxiaosong@chenxiaosong.com/
ChenXiaoSong (2):
generic/002: simplify the hardlink count test
generic: new test to check nlink returned by fstat()
tests/generic/002 | 16 +++++-------
tests/generic/002.out | 2 +-
tests/generic/798 | 60 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/798.out | 2 ++
4 files changed, 69 insertions(+), 11 deletions(-)
create mode 100755 tests/generic/798
create mode 100644 tests/generic/798.out
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test 2026-07-24 3:12 [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong @ 2026-07-24 3:12 ` ChenXiaoSong 2026-07-28 10:13 ` Zorro Lang 2026-07-24 3:12 ` [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong 2026-07-28 3:38 ` [PATCH v3 xfstests 0/2] " Christoph Hellwig 2 siblings, 1 reply; 6+ messages in thread From: ChenXiaoSong @ 2026-07-24 3:12 UTC (permalink / raw) To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, dhowells, metze, zlang Cc: linux-cifs, fstests, ChenXiaoSong From: ChenXiaoSong <chenxiaosong@kylinos.cn> Add the test to the hardlink group and replace the enumerated link counts with arithmetic loops. Clean up the test header, use "Silence is golden" success message, and return the test status explicitly. Suggested-by: Zorro Lang <zlang@kernel.org> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> --- tests/generic/002 | 16 ++++++---------- tests/generic/002.out | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/generic/002 b/tests/generic/002 index 6df57a7a..9b210705 100755 --- a/tests/generic/002 +++ b/tests/generic/002 @@ -2,12 +2,12 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. # -# FS QA Test No. 002 +# FS QA Test 002 # # 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 @@ -17,14 +17,11 @@ status=0 # success is the default! _require_test _require_hardlinks -echo "Silence is goodness ..." - # ensure target directory exists mkdir `dirname $TEST_DIR/tmp` 2>/dev/null touch $TEST_DIR/tmp.1 -for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -do +for ((l = 2; l <= 20; l++)); do ln $TEST_DIR/tmp.1 $TEST_DIR/tmp.$l x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ] @@ -35,8 +32,7 @@ do fi done -for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 -do +for ((l = 20; l >= 1; l--)); do x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ] then @@ -47,5 +43,5 @@ do rm -f $TEST_DIR/tmp.$l done -# success, all done -exit +echo "Silence is golden" +exit $status diff --git a/tests/generic/002.out b/tests/generic/002.out index 11426b54..61705c7c 100644 --- a/tests/generic/002.out +++ b/tests/generic/002.out @@ -1,2 +1,2 @@ QA output created by 002 -Silence is goodness ... +Silence is golden -- 2.43.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test 2026-07-24 3:12 ` [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test ChenXiaoSong @ 2026-07-28 10:13 ` Zorro Lang 0 siblings, 0 replies; 6+ messages in thread From: Zorro Lang @ 2026-07-28 10:13 UTC (permalink / raw) To: ChenXiaoSong Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, dhowells, metze, linux-cifs, fstests, ChenXiaoSong On Fri, Jul 24, 2026 at 03:12:09AM +0000, ChenXiaoSong wrote: > From: ChenXiaoSong <chenxiaosong@kylinos.cn> > > Add the test to the hardlink group and replace the enumerated link > counts with arithmetic loops. > > Clean up the test header, use "Silence is golden" success message, > and return the test status explicitly. > > Suggested-by: Zorro Lang <zlang@kernel.org> > Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> > --- generic/002 is quite an old test case, and some of its code differs from the current standard conventions in fstests. If you just want to add it to the "hardlink" group, updating the group is sufficient. However, if you'd like to take this opportunity to refactor some of the code, besides your changes, you can refer to the review points on [PATCH 2/2] as well as using _require_test_program "lstat64" Thanks, Zorro > tests/generic/002 | 16 ++++++---------- > tests/generic/002.out | 2 +- > 2 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/tests/generic/002 b/tests/generic/002 > index 6df57a7a..9b210705 100755 > --- a/tests/generic/002 > +++ b/tests/generic/002 > @@ -2,12 +2,12 @@ > # SPDX-License-Identifier: GPL-2.0 > # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. > # > -# FS QA Test No. 002 > +# FS QA Test 002 > # > # 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 > @@ -17,14 +17,11 @@ status=0 # success is the default! > _require_test > _require_hardlinks > > -echo "Silence is goodness ..." > - > # ensure target directory exists > mkdir `dirname $TEST_DIR/tmp` 2>/dev/null > > touch $TEST_DIR/tmp.1 > -for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > -do > +for ((l = 2; l <= 20; l++)); do > ln $TEST_DIR/tmp.1 $TEST_DIR/tmp.$l > x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` > if [ "$l" -ne $x ] > @@ -35,8 +32,7 @@ do > fi > done > > -for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 > -do > +for ((l = 20; l >= 1; l--)); do > x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` > if [ "$l" -ne $x ] > then > @@ -47,5 +43,5 @@ do > rm -f $TEST_DIR/tmp.$l > done > > -# success, all done > -exit > +echo "Silence is golden" > +exit $status > diff --git a/tests/generic/002.out b/tests/generic/002.out > index 11426b54..61705c7c 100644 > --- a/tests/generic/002.out > +++ b/tests/generic/002.out > @@ -1,2 +1,2 @@ > QA output created by 002 > -Silence is goodness ... > +Silence is golden > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() 2026-07-24 3:12 [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong 2026-07-24 3:12 ` [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test ChenXiaoSong @ 2026-07-24 3:12 ` ChenXiaoSong 2026-07-28 9:56 ` Zorro Lang 2026-07-28 3:38 ` [PATCH v3 xfstests 0/2] " Christoph Hellwig 2 siblings, 1 reply; 6+ messages in thread From: ChenXiaoSong @ 2026-07-24 3:12 UTC (permalink / raw) To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, dhowells, metze, zlang Cc: linux-cifs, fstests, ChenXiaoSong 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> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> --- tests/generic/798 | 60 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/798.out | 2 ++ 2 files changed, 62 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..e44bb10a --- /dev/null +++ b/tests/generic/798 @@ -0,0 +1,60 @@ +#! /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() +{ + $XFS_IO_PROG -c 'stat -r' "$1" | + sed -n 's/^stat\.nlink = //p' +} + +status=0 +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 + echo "Expected nlink $l after creating link $l, got ${nlink:-nothing}" + status=1 + fi +done + +for ((l = 20; l >= 1; l--)); do + nlink=$(_get_nlink "$testdir/tmp.1") + if [ "$nlink" != "$l" ]; then + echo "Expected nlink $l before removing link $l, got ${nlink:-nothing}" + status=1 + fi + rm -f "$testdir/tmp.$l" +done + +echo "Silence is golden" +exit $status 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] 6+ messages in thread
* Re: [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() 2026-07-24 3:12 ` [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong @ 2026-07-28 9:56 ` Zorro Lang 0 siblings, 0 replies; 6+ messages in thread From: Zorro Lang @ 2026-07-28 9:56 UTC (permalink / raw) To: ChenXiaoSong Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, dhowells, metze, linux-cifs, fstests, ChenXiaoSong On Fri, Jul 24, 2026 at 03:12:10AM +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> > Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> > --- > tests/generic/798 | 60 +++++++++++++++++++++++++++++++++++++++++++ > tests/generic/798.out | 2 ++ > 2 files changed, 62 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..e44bb10a > --- /dev/null > +++ b/tests/generic/798 > @@ -0,0 +1,60 @@ > +#! /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() > +{ > + $XFS_IO_PROG -c 'stat -r' "$1" | > + sed -n 's/^stat\.nlink = //p' > +} > + > +status=0 We set "status=1" in _begin_fstest. You can remove this line, and then ... > +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 > + echo "Expected nlink $l after creating link $l, got ${nlink:-nothing}" > + status=1 ... The current "echo" output is already sufficient to break the golden image and cause the test to fail, so set "status=1" isn't necessary. Alternatively, if you feel there's no need to continue the rest of the loop once a failure is detected, you can use "_fail" to replace "echo" instead. > + fi > +done > + > +for ((l = 20; l >= 1; l--)); do > + nlink=$(_get_nlink "$testdir/tmp.1") > + if [ "$nlink" != "$l" ]; then > + echo "Expected nlink $l before removing link $l, got ${nlink:-nothing}" > + status=1 Same here > + fi > + rm -f "$testdir/tmp.$l" > +done > + > +echo "Silence is golden" > +exit $status then you can write "_exit 0" at here. Thanks, Zorro > 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] 6+ messages in thread
* Re: [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat() 2026-07-24 3:12 [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong 2026-07-24 3:12 ` [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test ChenXiaoSong 2026-07-24 3:12 ` [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong @ 2026-07-28 3:38 ` Christoph Hellwig 2 siblings, 0 replies; 6+ messages in thread From: Christoph Hellwig @ 2026-07-28 3:38 UTC (permalink / raw) To: ChenXiaoSong Cc: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm, senozhatsky, dhowells, metze, zlang, linux-cifs, fstests, ChenXiaoSong Still looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-28 10:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-24 3:12 [PATCH v3 xfstests 0/2] generic: new test to check nlink returned by fstat() ChenXiaoSong 2026-07-24 3:12 ` [PATCH v3 xfstests 1/2] generic/002: simplify the hardlink count test ChenXiaoSong 2026-07-28 10:13 ` Zorro Lang 2026-07-24 3:12 ` [PATCH v3 xfstests 2/2] generic: new test to check nlink returned by fstat() ChenXiaoSong 2026-07-28 9:56 ` Zorro Lang 2026-07-28 3:38 ` [PATCH v3 xfstests 0/2] " Christoph Hellwig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox