From: fdmanana@kernel.org
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated
Date: Wed, 19 Jun 2019 13:06:24 +0100 [thread overview]
Message-ID: <20190619120624.9922-1-fdmanana@kernel.org> (raw)
From: Filipe Manana <fdmanana@suse.com>
Test as well that hole punch operations that affect a single file block
also update the file's mtime and ctime.
This is motivated by a bug a found in btrfs which is fixed by the
following patch for the linux kernel:
"Btrfs: add missing inode version, ctime and mtime updates when
punching hole"
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
tests/generic/059 | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/generic/059 b/tests/generic/059
index e8cb93d8..fd44b2ea 100755
--- a/tests/generic/059
+++ b/tests/generic/059
@@ -18,6 +18,9 @@
#
# Btrfs: add missing inode update when punching hole
#
+# Also test the mtime and ctime properties of the file change after punching
+# holes with ranges that operate only on a single block of the file.
+#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
@@ -68,6 +71,13 @@ $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
# fsync log.
sync
+# Sleep for 1 second, because we want to check that the next punch operations we
+# do update the file's mtime and ctime.
+sleep 1
+
+mtime_before=$(stat -c %Y $SCRATCH_MNT/foo)
+ctime_before=$(stat -c %Z $SCRATCH_MNT/foo)
+
# Punch a hole in our file. This small range affects only 1 page.
# This made the btrfs hole punching implementation write only some zeroes in
# one page, but it did not update the btrfs inode fields used to determine if
@@ -94,5 +104,13 @@ _flakey_drop_and_remount
echo "File content after:"
od -t x1 $SCRATCH_MNT/foo
+mtime_after=$(stat -c %Y $SCRATCH_MNT/foo)
+ctime_after=$(stat -c %Z $SCRATCH_MNT/foo)
+
+[ $mtime_after -gt $mtime_before ] || \
+ echo "mtime did not increase (before: $mtime_before after: $mtime_after"
+[ $ctime_after -gt $ctime_before ] || \
+ echo "ctime did not increase (before: $ctime_before after: $mtime_after"
+
status=0
exit
--
2.11.0
next reply other threads:[~2019-06-19 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 12:06 fdmanana [this message]
2019-06-21 10:36 ` [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated Eryu Guan
2019-06-21 10:48 ` Filipe Manana
2019-06-21 13:52 ` Eryu Guan
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=20190619120624.9922-1-fdmanana@kernel.org \
--to=fdmanana@kernel.org \
--cc=fdmanana@suse.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.