public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 Christoph Hellwig <hch@infradead.org>,
	Jeff Layton <jlayton@kernel.org>
Subject: [PATCH fstests v2] generic/755: test that inode's ctime is updated on unlink
Date: Tue, 20 Aug 2024 15:48:25 -0400	[thread overview]
Message-ID: <20240820-master-v2-1-41703dddcc32@kernel.org> (raw)

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>
---
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/20240813-master-v1-1-862678cc4000@kernel.org
---
 tests/generic/755     | 38 ++++++++++++++++++++++++++++++++++++++
 tests/generic/755.out |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/tests/generic/755 b/tests/generic/755
new file mode 100755
index 000000000000..68da3b20073f
--- /dev/null
+++ b/tests/generic/755
@@ -0,0 +1,38 @@
+#! /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
+_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
diff --git a/tests/generic/755.out b/tests/generic/755.out
new file mode 100644
index 000000000000..7c9ea51cd298
--- /dev/null
+++ b/tests/generic/755.out
@@ -0,0 +1,2 @@
+QA output created by 755
+Silence is golden

---
base-commit: f5ada754d5838d29fd270257003d0d123a9d1cd2
change-id: 20240813-master-e3b46de630bd

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


             reply	other threads:[~2024-08-20 19:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-20 19:48 Jeff Layton [this message]
2024-08-21  6:39 ` [PATCH fstests v2] generic/755: test that inode's ctime is updated on unlink Christoph Hellwig
2024-08-21 18:46 ` Zorro Lang
2024-08-21 19:07   ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240820-master-v2-1-41703dddcc32@kernel.org \
    --to=jlayton@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox