* [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated
@ 2019-06-19 12:06 fdmanana
2019-06-21 10:36 ` Eryu Guan
0 siblings, 1 reply; 4+ messages in thread
From: fdmanana @ 2019-06-19 12:06 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, Filipe Manana
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated
2019-06-19 12:06 [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated fdmanana
@ 2019-06-21 10:36 ` Eryu Guan
2019-06-21 10:48 ` Filipe Manana
0 siblings, 1 reply; 4+ messages in thread
From: Eryu Guan @ 2019-06-21 10:36 UTC (permalink / raw)
To: fdmanana; +Cc: fstests, linux-btrfs, Filipe Manana
On Wed, Jun 19, 2019 at 01:06:24PM +0100, fdmanana@kernel.org wrote:
> 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
Is this supposed to be after recording the initial c/mtime? i.e. moving
it after c/mtime_before?
Thanks,
Eryu
> +
> +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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated
2019-06-21 10:36 ` Eryu Guan
@ 2019-06-21 10:48 ` Filipe Manana
2019-06-21 13:52 ` Eryu Guan
0 siblings, 1 reply; 4+ messages in thread
From: Filipe Manana @ 2019-06-21 10:48 UTC (permalink / raw)
To: Eryu Guan; +Cc: fstests, linux-btrfs, Filipe Manana
On Fri, Jun 21, 2019 at 11:36 AM Eryu Guan <guaneryu@gmail.com> wrote:
>
> On Wed, Jun 19, 2019 at 01:06:24PM +0100, fdmanana@kernel.org wrote:
> > 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
>
> Is this supposed to be after recording the initial c/mtime? i.e. moving
> it after c/mtime_before?
Either way is fine. Capturing the times right before or right after
the sleep, gives the same values as nothing changed the file.
Btw, I had noticed the other day that the second "echo" has
$mtime_after instead of $ctime_after (copy-paste mistake).
Do you want me to send a v2 fixing that typo, or you can do it
yourself when you pick the patch?
Thanks.
>
> Thanks,
> Eryu
>
> > +
> > +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
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated
2019-06-21 10:48 ` Filipe Manana
@ 2019-06-21 13:52 ` Eryu Guan
0 siblings, 0 replies; 4+ messages in thread
From: Eryu Guan @ 2019-06-21 13:52 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, Filipe Manana
On Fri, Jun 21, 2019 at 11:48:57AM +0100, Filipe Manana wrote:
> On Fri, Jun 21, 2019 at 11:36 AM Eryu Guan <guaneryu@gmail.com> wrote:
> >
> > On Wed, Jun 19, 2019 at 01:06:24PM +0100, fdmanana@kernel.org wrote:
> > > 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
> >
> > Is this supposed to be after recording the initial c/mtime? i.e. moving
> > it after c/mtime_before?
>
> Either way is fine. Capturing the times right before or right after
> the sleep, gives the same values as nothing changed the file.
Ah, you're right.
>
> Btw, I had noticed the other day that the second "echo" has
> $mtime_after instead of $ctime_after (copy-paste mistake).
> Do you want me to send a v2 fixing that typo, or you can do it
> yourself when you pick the patch?
I can fix it on commit, thanks for pointing it out!
Thanks,
Eryu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-21 13:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 12:06 [PATCH 2/2] generic/059: also test that the file's mtime and ctime are updated fdmanana
2019-06-21 10:36 ` Eryu Guan
2019-06-21 10:48 ` Filipe Manana
2019-06-21 13:52 ` Eryu Guan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).