generic/728: Add a test for xattr ctime updates
Subsystems (2)
Anna Schumaker
maintainerPATCH v3 1/1 generic/728: Add a test for xattr ctime updates
From: Anna Schumaker <[email protected]>
The NFS client wasn't updating ctime after a setxattr request. This is a test written while fixing the bug.
---
v3:
- Add a 2 second sleep before changing the xattr
v2:
- Move test to generic/
- Address comments from the mailing list
--- tests/generic/728 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/728.out | 2 ++ 2 files changed, 45 insertions(+) create mode 100755 tests/generic/728 create mode 100644 tests/generic/728.out
tests/generic/728 new file +43 -0
@@ -0,0 +1,43 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Netapp Inc., All Rights Reserved. +# +# FS QA Test 728 +# +# Test a bug where the NFS client wasn't sending a post-op GETATTR to the +# server after setting an xattr, resulting in `stat` reporting a stale ctime. +# +. ./common/preamble +_begin_fstest auto quick attr + +# Import common functions +. ./common/attr + +# real QA test starts here +_supported_fs generic +_require_test +_require_attrs + +rm -rf $TEST_DIR/testfile +touch $TEST_DIR/testfile + + +_check_xattr_op() +{ + what=$1 + shift 1 + + before_ctime=$(stat -c %z $TEST_DIR/testfile) + sleep 2 + $SETFATTR_PROG $* $TEST_DIR/testfile + after_ctime=$(stat -c %z $TEST_DIR/testfile) + + test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change after $what." +} + +_check_xattr_op setxattr -n user.foobar -v 123 +_check_xattr_op removexattr -x user.foobar + +echo "Silence is golden" +status=0 +exit
tests/generic/728.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 728 +Silence is golden
Signature · 1 line
2.40.1
Quoted 42 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
The NFS client wasn't updating ctime after a setxattr request. This is a test written while fixing the bug.
Signed-off-by Anna Schumaker <[email protected]>---
v3:
- Add a 2 second sleep before changing the xattrv2:
- Move test to generic/
- Address comments from the mailing list--- tests/generic/728 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/728.out | 2 ++ 2 files changed, 45 insertions(+) create mode 100755 tests/generic/728 create mode 100644 tests/generic/728.outtests/generic/728 new file +15
-0@@ -0,0 +1,43 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Netapp Inc., All Rights Reserved. +# +# FS QA Test 728 +# +# Test a bug where the NFS client wasn't sending a post-op GETATTR to the +# server after setting an xattr, resulting in `stat` reporting a stale ctime. +# +. ./common/preamble +_begin_fstest auto quick attr + +# Import common functions +. ./common/attr +
tests/generic/728 line 25
Quoted 10 lines
tests/generic/728 new file +10
-0+# real QA test starts here +_supported_fs generic +_require_test +_require_attrs + +rm -rf $TEST_DIR/testfile +touch $TEST_DIR/testfile + + +_check_xattr_op()
nit: only common/* functions are supposed to have a leading underscore in the name.
tests/generic/728 line 31
Quoted 6 lines
tests/generic/728 new file +6
-0+{ + what=$1 + shift 1 + + before_ctime=$(stat -c %z $TEST_DIR/testfile) + sleep 2
I think it would be useful to document that 2 seconds is the worst ctime granularity that we expect from any filesystem (fat) that might pass through fstests.
Just in case, you know, we /ever/ create a fsinfo call to export information like that, and need to refactor all these 'sleep 2'.
"sleep 2 # maximum known ctime granularity is 2s for fat"
With those two things fixed,
--D
Quoted 23 lines
tests/generic/728 new file +12
-0+ $SETFATTR_PROG $* $TEST_DIR/testfile + after_ctime=$(stat -c %z $TEST_DIR/testfile) + + test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change after $what." +} + +_check_xattr_op setxattr -n user.foobar -v 123 +_check_xattr_op removexattr -x user.foobar + +echo "Silence is golden" +status=0 +exittests/generic/728.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 728 +Silence is goldenSignature · 1 line
2.40.1
Quoted 4 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
The NFS client wasn't updating ctime after a setxattr request. This is a test written while fixing the bug.
You can include the '_fixed_by_kernel_commit' field for hints on unfixed kernels. With this and Darrick's suggestions, you can add my RB.
Quoted 48 lines · Darrick J. Wong
Quoted 47 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
The NFS client wasn't updating ctime after a setxattr request. This is a test written while fixing the bug.
Signed-off-by Anna Schumaker <[email protected]>---
v3:
- Add a 2 second sleep before changing the xattrv2:
- Move test to generic/
- Address comments from the mailing list--- tests/generic/728 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/728.out | 2 ++ 2 files changed, 45 insertions(+) create mode 100755 tests/generic/728 create mode 100644 tests/generic/728.outtests/generic/728 new file +20
-0@@ -0,0 +1,43 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Netapp Inc., All Rights Reserved. +# +# FS QA Test 728 +# +# Test a bug where the NFS client wasn't sending a post-op GETATTR to the +# server after setting an xattr, resulting in `stat` reporting a stale ctime. +# +. ./common/preamble +_begin_fstest auto quick attr + +# Import common functions +. ./common/attr + +# real QA test starts here +_supported_fs generic +_require_test +_require_attrs +
Quoted 8 lines
tests/generic/728 line 25
Quoted 5 lines
tests/generic/728 new file +5
-0+rm -rf $TEST_DIR/testfile +touch $TEST_DIR/testfile + + +_check_xattr_op()nit: only common/* functions are supposed to have a leading underscore in the name.
I can help to remove the leading underscore when I merge this patch.
Quoted 12 lines
tests/generic/728 line 31
Quoted 7 lines
tests/generic/728 new file +6
-0+{ + what=$1 + shift 1 + + before_ctime=$(stat -c %z $TEST_DIR/testfile) + sleep 2I think it would be useful to document that 2 seconds is the worst ctime granularity that we expect from any filesystem (fat) that might pass through fstests.
Quoted 4 lines
Just in case, you know, we /ever/ create a fsinfo call to export information like that, and need to refactor all these 'sleep 2'.
"sleep 2 # maximum known ctime granularity is 2s for fat"
Hi Anna, if you don't want to send a v4, you can reply this email to tell us what comment you'd like to write. I can add it when I merge this patch. Or you'd like to send a v4 by yourself :)
Thanks,
Zorro
Quoted 31 lines
With those two things fixed,
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 23 lines
tests/generic/728 new file +12
-0+ $SETFATTR_PROG $* $TEST_DIR/testfile + after_ctime=$(stat -c %z $TEST_DIR/testfile) + + test "$before_ctime" != "$after_ctime" || echo "Expected ctime to change after $what." +} + +_check_xattr_op setxattr -n user.foobar -v 123 +_check_xattr_op removexattr -x user.foobar + +echo "Silence is golden" +status=0 +exittests/generic/728.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 728 +Silence is goldenSignature · 1 line
2.40.1
Quoted 7 lines · Anand Jain
Quoted 4 lines · Anna Schumaker
From: Anna Schumaker <[email protected]>
The NFS client wasn't updating ctime after a setxattr request. This is a test written while fixing the bug.
You can include the '
_fixed_by_kernel_commit' field for hints
Anna said the related kernel commit hasn't been acked. I'm not sure what's the current status, if it's acked but not merged, Anna can use "xxxxxxxx" to replace the commit id temporarily, or add this later (just don't forget:)
Thanks,
Zorro
Quoted 6 lines
on unfixed kernels. With this and Darrick's suggestions, you can add my RB.
Reviewed-by Anand Jain <[email protected]>