From a49385587950074ae9d4c53a004238e67016fe8d Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Tue, 20 Aug 2024 15:48:25 -0400 Subject: [PATCH] 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/20240812-btrfs-unlink-v1-1-ee5c2ef538eb@kernel.org/ Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- tests/generic/755 | 39 +++++++++++++++++++++++++++++++++++++++ tests/generic/755.out | 2 ++ 2 files changed, 41 insertions(+) create mode 100755 tests/generic/755 create mode 100644 tests/generic/755.out diff --git a/tests/generic/755 b/tests/generic/755 new file mode 100755 index 000000000..a0c5abd42 --- /dev/null +++ b/tests/generic/755 @@ -0,0 +1,39 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024, Jeff Layton +# +# 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 index 000000000..7c9ea51cd --- /dev/null +++ b/tests/generic/755.out @@ -0,0 +1,2 @@ +QA output created by 755 +Silence is golden -- 2.49.0