fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: test that reflink forces the log if mounted with wsync
@ 2020-07-29  2:52 Darrick J. Wong
  2020-07-29  3:02 ` Yang Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2020-07-29  2:52 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

From: Darrick J. Wong <darrick.wong@oracle.com>

A code inspection revealed that reflink does not force the log to disk
even if the filesystem is mounted with wsync.  Add a regression test for
commit 5833112df7e9a ("xfs: reflink should force the log out if mounted
with wsync").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/914     |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/914.out |    7 ++++++
 tests/xfs/group   |    1 +
 3 files changed, 73 insertions(+)
 create mode 100755 tests/xfs/914
 create mode 100644 tests/xfs/914.out

diff --git a/tests/xfs/914 b/tests/xfs/914
new file mode 100755
index 00000000..b835394a
--- /dev/null
+++ b/tests/xfs/914
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# FS QA Test No. 914
+#
+# Make sure that reflink forces the log out if we mount with wsync.  We test
+# that it actually forced the log by immediately shutting down the fs without
+# flushing the log and then remounting to check file contents.
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+rm -f $seqres.full
+
+# Format filesystem and set up quota limits
+_scratch_mkfs > $seqres.full
+_scratch_mount -o wsync >> $seqres.full
+
+# Set up initial files
+$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full
+_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e
+_cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d
+touch $SCRATCH_MNT/b
+sync
+
+# Test that setting the reflink flag on the dest file forces the log
+echo "test reflink flag not set"
+$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/b >> $seqres.full
+_scratch_cycle_mount wsync
+md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
+
+# Test forcing the log even if both files are already reflinked
+echo "test reflink flag already set"
+$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/d >> $seqres.full
+_scratch_cycle_mount wsync
+md5sum $SCRATCH_MNT/a $SCRATCH_MNT/d | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/914.out b/tests/xfs/914.out
new file mode 100644
index 00000000..6b19fc65
--- /dev/null
+++ b/tests/xfs/914.out
@@ -0,0 +1,7 @@
+QA output created by 914
+test reflink flag not set
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/b
+test reflink flag already set
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
+310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/d
diff --git a/tests/xfs/group b/tests/xfs/group
index d6e8d1c3..a3d87124 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -518,3 +518,4 @@
 518 auto quick quota
 519 auto quick reflink
 520 auto quick reflink
+914 auto quick reflink

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: test that reflink forces the log if mounted with wsync
  2020-07-29  2:52 [PATCH] xfs: test that reflink forces the log if mounted with wsync Darrick J. Wong
@ 2020-07-29  3:02 ` Yang Xu
  2020-07-29  3:21   ` Darrick J. Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Yang Xu @ 2020-07-29  3:02 UTC (permalink / raw)
  To: Darrick J. Wong, Eryu Guan; +Cc: fstests

Hi Darrick

I remember this case has been merged into xfstests.

See
https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?id=06fd8dbbfe314410a2f55168f92e98ab93666013

Best Regards
Yang Xu

> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> A code inspection revealed that reflink does not force the log to disk
> even if the filesystem is mounted with wsync.  Add a regression test for
> commit 5833112df7e9a ("xfs: reflink should force the log out if mounted
> with wsync").
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   tests/xfs/914     |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>   tests/xfs/914.out |    7 ++++++
>   tests/xfs/group   |    1 +
>   3 files changed, 73 insertions(+)
>   create mode 100755 tests/xfs/914
>   create mode 100644 tests/xfs/914.out
> 
> diff --git a/tests/xfs/914 b/tests/xfs/914
> new file mode 100755
> index 00000000..b835394a
> --- /dev/null
> +++ b/tests/xfs/914
> @@ -0,0 +1,65 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# FS QA Test No. 914
> +#
> +# Make sure that reflink forces the log out if we mount with wsync.  We test
> +# that it actually forced the log by immediately shutting down the fs without
> +# flushing the log and then remounting to check file contents.
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1    # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_supported_os Linux
> +_require_scratch_reflink
> +_require_cp_reflink
> +
> +rm -f $seqres.full
> +
> +# Format filesystem and set up quota limits
> +_scratch_mkfs > $seqres.full
> +_scratch_mount -o wsync >> $seqres.full
> +
> +# Set up initial files
> +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
> +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full
> +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e
> +_cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d
> +touch $SCRATCH_MNT/b
> +sync
> +
> +# Test that setting the reflink flag on the dest file forces the log
> +echo "test reflink flag not set"
> +$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/b >> $seqres.full
> +_scratch_cycle_mount wsync
> +md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
> +
> +# Test forcing the log even if both files are already reflinked
> +echo "test reflink flag already set"
> +$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/d >> $seqres.full
> +_scratch_cycle_mount wsync
> +md5sum $SCRATCH_MNT/a $SCRATCH_MNT/d | _filter_scratch
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/914.out b/tests/xfs/914.out
> new file mode 100644
> index 00000000..6b19fc65
> --- /dev/null
> +++ b/tests/xfs/914.out
> @@ -0,0 +1,7 @@
> +QA output created by 914
> +test reflink flag not set
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/b
> +test reflink flag already set
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/d
> diff --git a/tests/xfs/group b/tests/xfs/group
> index d6e8d1c3..a3d87124 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -518,3 +518,4 @@
>   518 auto quick quota
>   519 auto quick reflink
>   520 auto quick reflink
> +914 auto quick reflink
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs: test that reflink forces the log if mounted with wsync
  2020-07-29  3:02 ` Yang Xu
@ 2020-07-29  3:21   ` Darrick J. Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2020-07-29  3:21 UTC (permalink / raw)
  To: Yang Xu; +Cc: Eryu Guan, fstests

On Wed, Jul 29, 2020 at 11:02:09AM +0800, Yang Xu wrote:
> Hi Darrick
> 
> I remember this case has been merged into xfstests.
> 
> See
> https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?id=06fd8dbbfe314410a2f55168f92e98ab93666013

DOH.  You're right, sorry about that.  self-NAK.

--D

> Best Regards
> Yang Xu
> 
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > A code inspection revealed that reflink does not force the log to disk
> > even if the filesystem is mounted with wsync.  Add a regression test for
> > commit 5833112df7e9a ("xfs: reflink should force the log out if mounted
> > with wsync").
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >   tests/xfs/914     |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >   tests/xfs/914.out |    7 ++++++
> >   tests/xfs/group   |    1 +
> >   3 files changed, 73 insertions(+)
> >   create mode 100755 tests/xfs/914
> >   create mode 100644 tests/xfs/914.out
> > 
> > diff --git a/tests/xfs/914 b/tests/xfs/914
> > new file mode 100755
> > index 00000000..b835394a
> > --- /dev/null
> > +++ b/tests/xfs/914
> > @@ -0,0 +1,65 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +# Copyright (c) 2020, Oracle and/or its affiliates.  All Rights Reserved.
> > +#
> > +# FS QA Test No. 914
> > +#
> > +# Make sure that reflink forces the log out if we mount with wsync.  We test
> > +# that it actually forced the log by immediately shutting down the fs without
> > +# flushing the log and then remounting to check file contents.
> > +
> > +seq=`basename $0`
> > +seqres=$RESULT_DIR/$seq
> > +echo "QA output created by $seq"
> > +
> > +here=`pwd`
> > +tmp=/tmp/$$
> > +status=1    # failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +	cd /
> > +	rm -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/reflink
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_supported_os Linux
> > +_require_scratch_reflink
> > +_require_cp_reflink
> > +
> > +rm -f $seqres.full
> > +
> > +# Format filesystem and set up quota limits
> > +_scratch_mkfs > $seqres.full
> > +_scratch_mount -o wsync >> $seqres.full
> > +
> > +# Set up initial files
> > +$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
> > +$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 1m -b 1m' $SCRATCH_MNT/c >> $seqres.full
> > +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e
> > +_cp_reflink $SCRATCH_MNT/c $SCRATCH_MNT/d
> > +touch $SCRATCH_MNT/b
> > +sync
> > +
> > +# Test that setting the reflink flag on the dest file forces the log
> > +echo "test reflink flag not set"
> > +$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/b >> $seqres.full
> > +_scratch_cycle_mount wsync
> > +md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch
> > +
> > +# Test forcing the log even if both files are already reflinked
> > +echo "test reflink flag already set"
> > +$XFS_IO_PROG -x -c "reflink $SCRATCH_MNT/a" -c 'shutdown' $SCRATCH_MNT/d >> $seqres.full
> > +_scratch_cycle_mount wsync
> > +md5sum $SCRATCH_MNT/a $SCRATCH_MNT/d | _filter_scratch
> > +
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/914.out b/tests/xfs/914.out
> > new file mode 100644
> > index 00000000..6b19fc65
> > --- /dev/null
> > +++ b/tests/xfs/914.out
> > @@ -0,0 +1,7 @@
> > +QA output created by 914
> > +test reflink flag not set
> > +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> > +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/b
> > +test reflink flag already set
> > +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/a
> > +310f146ce52077fcd3308dcbe7632bb2  SCRATCH_MNT/d
> > diff --git a/tests/xfs/group b/tests/xfs/group
> > index d6e8d1c3..a3d87124 100644
> > --- a/tests/xfs/group
> > +++ b/tests/xfs/group
> > @@ -518,3 +518,4 @@
> >   518 auto quick quota
> >   519 auto quick reflink
> >   520 auto quick reflink
> > +914 auto quick reflink
> > 
> > 
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-29  3:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29  2:52 [PATCH] xfs: test that reflink forces the log if mounted with wsync Darrick J. Wong
2020-07-29  3:02 ` Yang Xu
2020-07-29  3:21   ` Darrick J. Wong

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).