generic/755: test that inode's ctime is updated on unlink
Subsystems (2)
PATCH v2 1/1 generic/755: test that inode's ctime is updated on unlink
I recently found and fixed a bug in btrfs where it wasn't updating the citme on the target inode when unlinking [1]. Add a fstest for this.
[1]: https://lore.kernel.org/linux-btrfs/[email protected]/
---
HCH suggested I roll a fstest for this problem that I found in btrfs the other day. This just creates a file and a hardlink to it, statx's it and then unlinks the hardlink and statx's it again. The ctimes are then compared.
---
Changes in v2:
- Turn it into a shell script.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- tests/generic/755 | 38 ++++++++++++++++++++++++++++++++++++++ tests/generic/755.out | 2 ++ 2 files changed, 40 insertions(+)
tests/generic/755 new file +38 -0
@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024, Jeff Layton <[email protected]> +# +# FS QA Test No. 755 +# +# Create a file, stat it and then unlink it. Does the ctime of the +# target inode change? +# +. ./common/preamble +_begin_fstest auto quick + +_require_test +_require_test_program unlink-ctime + +testfile="$TEST_DIR/unlink-ctime1.$$" +testlink="$TEST_DIR/unlink-ctime2.$$" + +rm -f $testfile $testlink +touch $testfile +ln $testfile $testlink + +time1=$(stat -c "%Z" $testfile) + +sleep 2 +unlink $testlink + +time2=$(stat -c "%Z" $testfile) + +unlink $testfile + +if [ $time1 -eq $time2 ]; then + echo "Target's ctime did not change after unlink!" +fi + +echo Silence is golden +status=0 +exit
tests/generic/755.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 755 +Silence is golden
---
base-commit: f5ada754d5838d29fd270257003d0d123a9d1cd2
change-id: 20240813-master-e3b46de630bd
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Looks good:
Quoted 30 lines · Jeff Layton
I recently found and fixed a bug in btrfs where it wasn't updating the citme on the target inode when unlinking [1]. Add a fstest for this.
[1]: https://lore.kernel.org/linux-btrfs/[email protected]/
Signed-off-by Jeff Layton <[email protected]>---
HCH suggested I roll a fstest for this problem that I found in btrfs the other day. This just creates a file and a hardlink to it, statx's it and then unlinks the hardlink and statx's it again. The ctimes are then compared.
---
Changes in v2:
- Turn it into a shell script.
- Link to v1: https://lore.kernel.org/r/[email protected]--- tests/generic/755 | 38 ++++++++++++++++++++++++++++++++++++++ tests/generic/755.out | 2 ++ 2 files changed, 40 insertions(+)tests/generic/755 new file +4
-0@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024, Jeff Layton <[email protected]> +#
tests/generic/755 line 14
Quoted 10 lines
tests/generic/755 new file +10
-0+# FS QA Test No. 755 +# +# Create a file, stat it and then unlink it. Does the ctime of the +# target inode change? +# +. ./common/preamble +_begin_fstest auto quick + +_require_test +_require_test_program unlink-ctime
^^^^
This V2 shouldn't require this program, it's cause this case _notrun directly. The 3bc2ac2f8f0b ("btrfs: update target inode's ctime on unlink") has been merged,
I'll remove this "_require_test_program" line, and add:
[ "$FSTYP = btrfs"] && _fixed_by_kernel_commit 3bc2ac2f8f0b \
"btrfs: update target inode's ctime on unlink"
when I merge this patch. Others looks good to me.
Thanks,
Zorro
Quoted 42 lines
tests/generic/755 new file +24
-0+ +testfile="$TEST_DIR/unlink-ctime1.$$" +testlink="$TEST_DIR/unlink-ctime2.$$" + +rm -f $testfile $testlink +touch $testfile +ln $testfile $testlink + +time1=$(stat -c "%Z" $testfile) + +sleep 2 +unlink $testlink + +time2=$(stat -c "%Z" $testfile) + +unlink $testfile + +if [ $time1 -eq $time2 ]; then + echo "Target's ctime did not change after unlink!" +fi + +echo Silence is golden +status=0 +exittests/generic/755.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 755 +Silence is golden ---base-commit:
f5ada754d5838d29fd270257003d0d123a9d1cd2
change-id: 20240813-master-e3b46de630bdBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 42 lines · Zorro Lang
Quoted 41 lines · Jeff Layton
I recently found and fixed a bug in btrfs where it wasn't updating the
citme on the target inode when unlinking [1]. Add a fstest for this.[1]:
https://lore.kernel.org/linux-btrfs/[email protected]/Signed-off-by Jeff Layton <[email protected]>---
HCH suggested I roll a fstest for this problem that I found in btrfs the
other day. This just creates a file and a hardlink to it, statx's it and
then unlinks the hardlink and statx's it again. The ctimes are then compared.
---
Changes in v2:
- Turn it into a shell script.
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
tests/generic/755 | 38 ++++++++++++++++++++++++++++++++++++++ tests/generic/755.out | 2 ++2 files changed, 40 insertions(+)tests/generic/755 new file +9
-0@@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024, Jeff Layton <[email protected]> +# +# FS QA Test No. 755 +# +# Create a file, stat it and then unlink it. Does the ctime of the +# target inode change? +#
Quoted 8 lines
tests/generic/755 line 14
Quoted 5 lines
tests/generic/755 new file +5
-0+. ./common/preamble +_begin_fstest auto quick + +_require_test +_require_test_program unlink-ctime^^^^
This V2 shouldn't require this program, it's cause this case_notrundirectly.
Doh! I removed that line on my test box, but forgot to fix it in tree.
Quoted 11 lines
The
3bc2ac2f8f0b("btrfs: update target inode's ctime on unlink") has been merged,I'll remove this "
_require_test_program" line, and add:
[ "$FSTYP = btrfs"] &&_fixed_by_kernel_commit3bc2ac2f8f0b\
"btrfs: update target inode's ctime on unlink"when I merge this patch. Others looks good to me.
Reviewed-by Zorro Lang <[email protected]>
Thanks, that sounds great.
Quoted 44 lines
Quoted 42 lines
tests/generic/755 new file +24
-0+ +testfile="$TEST_DIR/unlink-ctime1.$$" +testlink="$TEST_DIR/unlink-ctime2.$$" + +rm -f $testfile $testlink +touch $testfile +ln $testfile $testlink + +time1=$(stat -c "%Z" $testfile) + +sleep 2 +unlink $testlink + +time2=$(stat -c "%Z" $testfile) + +unlink $testfile + +if [ $time1 -eq $time2 ]; then + echo "Target's ctime did not change after unlink!" +fi + +echo Silence is golden +status=0 +exittests/generic/755.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 755 +Silence is golden ---base-commit:
f5ada754d5838d29fd270257003d0d123a9d1cd2
change-id: 20240813-master-e3b46de630bdBest regards,
Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>