public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: fstests <fstests@vger.kernel.org>
Subject: Re: [PATCH] xfs: test that we can SEEK_HOLE/DATA data and holes that are in the CoW fork only
Date: Wed, 21 Jun 2017 18:13:10 +0800	[thread overview]
Message-ID: <20170621101310.GA23360@eguan.usersys.redhat.com> (raw)
In-Reply-To: <20170620195336.GC3787@birch.djwong.org>

On Tue, Jun 20, 2017 at 12:53:36PM -0700, Darrick J. Wong wrote:
> Create a file with a hole in the data fork and CoW reservations in the
> same region in the CoW fork.  Ensure that SEEK_HOLE/DATA find the data.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/xfs/901     |  150 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/901.out |   52 ++++++++++++++++++
>  tests/xfs/902     |  150 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/902.out |   52 ++++++++++++++++++
>  tests/xfs/group   |    2 +
>  5 files changed, 406 insertions(+)
>  create mode 100755 tests/xfs/901
>  create mode 100644 tests/xfs/901.out
>  create mode 100755 tests/xfs/902
>  create mode 100644 tests/xfs/902.out
> 
> diff --git a/tests/xfs/901 b/tests/xfs/901
> new file mode 100755
> index 0000000..ab99fb2
> --- /dev/null
> +++ b/tests/xfs/901
> @@ -0,0 +1,150 @@
> +#! /bin/bash
> +# FS QA Test No. 901
> +#
> +# Test SEEK_HOLE/SEEK_DATA into a region that is marked CoW'd for
> +# speculative preallocation in the CoW fork and isn't backed by
> +# data fork extents.
> +#
> +# - Set a huge cowextsize hint.
> +# - Create a file "DD      " (two data blocks, six hole blocks)
> +# - Reflink copy this file to a second file.
> +# - Write to the first block of the second file to create a single
> +#   large CoW reservation covering the whole file.
> +# - Write to block 3, which should be a hole in the data fork.
> +# - Display the SEEK_HOLE/SEEK_DATA info for the second file to confirm
> +#   that we see the data in blocks 0-1, the hole at block 2, the data
> +#   at block 3, and the hole for the rest of the file.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +
> +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 -rf $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_reflink
> +_require_cp_reflink
> +_require_xfs_io_command "fiemap"
> +_require_xfs_io_command "cowextsize"
> +_require_xfs_io_command "funshare"

I think you meant "fpunch" here? funshare is not used in both tests, but
fpunch is used.

> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +blksz=65536
> +nr=8
> +filesize=$((blksz * nr))
> +
> +echo "Create the original files"
> +$XFS_IO_PROG -c "cowextsize" $testdir >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize $filesize" $testdir >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir >> $seqres.full
> +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((blksz * 2))" -c "truncate $filesize" -c "fpunch $((blksz * 2)) $((blksz * (nr - 2) ))" $testdir/file1 >> $seqres.full
> +_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "pwrite -S 0 0 $filesize" -c "pwrite -S 0x61 0 $((blksz * 2))" $testdir/file3 >> $seqres.full
> +_scratch_cycle_mount

file3 is not mentioned in test description, there's no comments about it
either, it'd be good go have some. (I assume file3 is there only for
comparison with file2, right?)

It's not clear what's the purpose of setting cowextsize either, I can
see the explanation from the "simplify the Q_GETNEXTQUOTA
implementation" thread in xfs list, but it'd be good to have it in the
test too.

Thanks,
Eryu

> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "CoW the shared part then write into the empty part" | tee -a $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir/file1 >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -c "pwrite -S 0x63 0 $blksz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -c "pwrite -S 0x63 $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
> +
> +$XFS_IO_PROG -c "pwrite -S 0x63 0 $blksz" $testdir/file3 >> $seqres.full
> +$XFS_IO_PROG -c "pwrite -S 0x63 $((blksz * 3)) $blksz" $testdir/file3 >> $seqres.full
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "sync filesystem" | tee -a $seqres.full
> +sync
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "Remount" | tee -a $seqres.full
> +_scratch_cycle_mount
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/901.out b/tests/xfs/901.out
> new file mode 100644
> index 0000000..4a829e3
> --- /dev/null
> +++ b/tests/xfs/901.out
> @@ -0,0 +1,52 @@
> +QA output created by 901
> +Format and mount
> +Create the original files
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file1
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file2
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file3
> +CoW the shared part then write into the empty part
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file3
> +sync filesystem
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file3
> +Remount
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-901/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-901/file3
> diff --git a/tests/xfs/902 b/tests/xfs/902
> new file mode 100755
> index 0000000..e5271d9
> --- /dev/null
> +++ b/tests/xfs/902
> @@ -0,0 +1,150 @@
> +#! /bin/bash
> +# FS QA Test No. 902
> +#
> +# Test SEEK_HOLE/SEEK_DATA into a region that is marked CoW'd for
> +# speculative preallocation in the CoW fork and isn't backed by
> +# data fork extents.
> +#
> +# - Set a huge cowextsize hint.
> +# - Create a file "DD      " (two data blocks, six hole blocks)
> +# - Reflink copy this file to a second file.
> +# - dio write to the first block of the second file to create a single
> +#   large CoW reservation covering the whole file.
> +# - dio write to block 3, which should be a hole in the data fork.
> +# - Display the SEEK_HOLE/SEEK_DATA info for the second file to confirm
> +#   that we see the data in blocks 0-1, the hole at block 2, the data
> +#   at block 3, and the hole for the rest of the file.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +
> +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 -rf $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_reflink
> +_require_cp_reflink
> +_require_xfs_io_command "fiemap"
> +_require_xfs_io_command "cowextsize"
> +_require_xfs_io_command "funshare"
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs > $seqres.full 2>&1
> +_scratch_mount >> $seqres.full 2>&1
> +
> +testdir=$SCRATCH_MNT/test-$seq
> +mkdir $testdir
> +
> +blksz=65536
> +nr=8
> +filesize=$((blksz * nr))
> +
> +echo "Create the original files"
> +$XFS_IO_PROG -c "cowextsize" $testdir >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize $filesize" $testdir >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir >> $seqres.full
> +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((blksz * 2))" -c "truncate $filesize" -c "fpunch $((blksz * 2)) $((blksz * (nr - 2) ))" $testdir/file1 >> $seqres.full
> +_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -f -c "pwrite -S 0 0 $filesize" -c "pwrite -S 0x61 0 $((blksz * 2))" $testdir/file3 >> $seqres.full
> +_scratch_cycle_mount
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "CoW the shared part then write into the empty part" | tee -a $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir/file1 >> $seqres.full
> +$XFS_IO_PROG -c "cowextsize" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -d -c "pwrite -S 0x63 0 $blksz" $testdir/file2 >> $seqres.full
> +$XFS_IO_PROG -d -c "pwrite -S 0x63 $((blksz * 3)) $blksz" $testdir/file2 >> $seqres.full
> +
> +$XFS_IO_PROG -d -c "pwrite -S 0x63 0 $blksz" $testdir/file3 >> $seqres.full
> +$XFS_IO_PROG -d -c "pwrite -S 0x63 $((blksz * 3)) $blksz" $testdir/file3 >> $seqres.full
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "sync filesystem" | tee -a $seqres.full
> +sync
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +echo "Remount" | tee -a $seqres.full
> +_scratch_cycle_mount
> +
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file1 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file2 >> $seqres.full 2>&1
> +$XFS_IO_PROG -c "bmap -ev" -c "bmap -cv" $testdir/file3 >> $seqres.full 2>&1
> +
> +echo "Seek holes and data in file1"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file1
> +echo "Seek holes and data in file2"
> +$XFS_IO_PROG -c "seek -a -r 0" $testdir/file2
> +
> +echo "Compare files"
> +md5sum $testdir/file1 | _filter_scratch
> +md5sum $testdir/file2 | _filter_scratch
> +md5sum $testdir/file3 | _filter_scratch
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/902.out b/tests/xfs/902.out
> new file mode 100644
> index 0000000..d5b8eae
> --- /dev/null
> +++ b/tests/xfs/902.out
> @@ -0,0 +1,52 @@
> +QA output created by 902
> +Format and mount
> +Create the original files
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file1
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file2
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file3
> +CoW the shared part then write into the empty part
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file3
> +sync filesystem
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file3
> +Remount
> +Seek holes and data in file1
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +Seek holes and data in file2
> +Whence	Result
> +DATA	0
> +HOLE	131072
> +DATA	196608
> +HOLE	262144
> +Compare files
> +c2803804acc9936eef8aab42c119bfac  SCRATCH_MNT/test-902/file1
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file2
> +017c08a9320aad844ce86aa9631afb98  SCRATCH_MNT/test-902/file3
> diff --git a/tests/xfs/group b/tests/xfs/group
> index 5f37c5a..faf0095 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -417,3 +417,5 @@
>  417 dangerous_fuzzers dangerous_scrub dangerous_online_repair
>  418 dangerous_fuzzers dangerous_scrub dangerous_repair
>  701 auto quick
> +901 auto quick clone dedupe
> +902 auto quick clone dedupe

  reply	other threads:[~2017-06-21 10:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 19:53 [PATCH] xfs: test that we can SEEK_HOLE/DATA data and holes that are in the CoW fork only Darrick J. Wong
2017-06-21 10:13 ` Eryu Guan [this message]
2017-06-21 16:17   ` Darrick J. Wong

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=20170621101310.GA23360@eguan.usersys.redhat.com \
    --to=eguan@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@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