]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
generic/755: test that inode's ctime is updated on unlink
authorJeff Layton <jlayton@kernel.org>
Tue, 20 Aug 2024 19:48:25 +0000 (15:48 -0400)
committerZorro Lang <zlang@kernel.org>
Wed, 21 Aug 2024 18:55:06 +0000 (02:55 +0800)
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/20240812-btrfs-unlink-v1-1-ee5c2ef538eb@kernel.org/

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/755 [new file with mode: 0755]
tests/generic/755.out [new file with mode: 0644]

diff --git a/tests/generic/755 b/tests/generic/755
new file mode 100755 (executable)
index 0000000..a0c5abd
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024, Jeff Layton <jlayton@kernel.org>
+#
+# 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
+[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit 3bc2ac2f8f0b \
+       "btrfs: update target inode's ctime on unlink"
+
+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
diff --git a/tests/generic/755.out b/tests/generic/755.out
new file mode 100644 (file)
index 0000000..7c9ea51
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 755
+Silence is golden