linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Gabriel de Perthuis <g2p.code@gmail.com>
Cc: Josef Bacik <jbacik@fusionio.com>,
	Eric Sandeen <sandeen@sandeen.net>, Mark Fasheh <mfasheh@suse.de>,
	<linux-xfs@vger.kernel.org>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [XFSTESTS PATCH] btrfs: Test deduplication
Date: Thu, 8 Aug 2013 16:55:46 -0400	[thread overview]
Message-ID: <20130808205546.GJ16712@localhost.localdomain> (raw)
In-Reply-To: <51CB6DDE.8060509@gmail.com>

On Thu, Jun 27, 2013 at 12:40:30AM +0200, Gabriel de Perthuis wrote:
> ---
> The matching kernel patch is here:
> https://github.com/g2p/linux/tree/v3.10%2Bextent-same (rebased on 3.10, fixing a small conflict)
> Requires the btrfs-extent-same command:
> 
> - http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26579
> - https://github.com/markfasheh/duperemove
> 

Sorry it took me so long to get to this, but I wanted to have the dedup patches
merged before I looked at this.  So first of all just copy btrfs-extent-same
into xfstests since it's not part of a normally installed package.

> 
>  tests/btrfs/313     | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/313.out | 25 ++++++++++++++
>  tests/btrfs/group   |  1 +
>  3 files changed, 119 insertions(+)
>  create mode 100755 tests/btrfs/313
>  create mode 100644 tests/btrfs/313.out
> 
> diff --git a/tests/btrfs/313 b/tests/btrfs/313
> new file mode 100755
> index 0000000..04e4ccb
> --- /dev/null
> +++ b/tests/btrfs/313
> @@ -0,0 +1,93 @@
> +#! /bin/bash
> +# FS QA Test No. 313
> +#
> +# Test the deduplication syscall
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2013 Red Hat, Inc.  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 -f $tmp.*
> +}
> +
> +. ./common/rc
> +. ./common/filter
> +
> +ESAME=`set_prog_path btrfs-extent-same`
> +
> +_need_to_be_root
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_command $ESAME
> +_require_command $XFS_IO_PROG
> +_require_scratch
> +
> +_scratch_mkfs &>/dev/null
> +_scratch_mount >>$seqres.full 2>&1
> +
> +fiemap() {
> +    xfs_io -r -c fiemap $1 |tail -n+2
> +}
> +
> +dedup() {
> +    ! diff -q <(fiemap $1) <(fiemap $2)
> +    $ESAME $(stat -c %s $1) $1 0 $2 0
> +    diff -u <(fiemap $1) <(fiemap $2)

These are spitting out the full path to SCRATCH, so you will want to use
something like _filter_scratch so that the output is consistent across people
running it.

> +}
> +
> +echo "Silence is golden"
> +set -e
> +
> +v1=$SCRATCH_MNT/v1
> +v2=$SCRATCH_MNT/v2
> +v3=$SCRATCH_MNT/v3
> +
> +$BTRFS_UTIL_PROG subvolume create $v1
> +$BTRFS_UTIL_PROG subvolume create $v2

Redirect the output of these commands to /dev/null

> +
> +dd bs=1M status=none if=/dev/urandom of=$v1/file1 count=1
> +dd bs=1M status=none if=/dev/urandom of=$v1/file2 count=1
> +dd bs=1M status=none if=$v1/file1 of=$v2/file3
> +dd bs=1M status=none if=$v1/file1 of=$v2/file4
> +

status=none doesn't work on my copy of dd, so don't use this, just do

dd > $seqres.full 2>&1

or to /dev/null.

> +$BTRFS_UTIL_PROG subvolume snapshot -r $v2 $v3
> +
> +# identical, multiple volumes
> +dedup $v1/file1 $v2/file3
> +
> +# not identical, same volume
> +! $ESAME $((2**20)) $v1/file1 0 $v1/file2 0
> +
> +# identical, second file on a frozen volume
> +dedup $v1/file1 $v3/file4
> +
> +_scratch_unmount
> +_check_scratch_fs
> +status=0
> +exit
> diff --git a/tests/btrfs/313.out b/tests/btrfs/313.out
> new file mode 100644
> index 0000000..eabe6be
> --- /dev/null
> +++ b/tests/btrfs/313.out
> @@ -0,0 +1,25 @@
> +QA output created by 313
> +Silence is golden
> +Create subvolume 'sdir/v1'
> +Create subvolume 'sdir/v2'
> +Create a readonly snapshot of 'sdir/v2' in 'sdir/v3'
> +Files /dev/fd/63 and /dev/fd/62 differ
> +Deduping 2 total files
> +(0, 1048576): sdir/v1/file1
> +(0, 1048576): sdir/v2/file3
> +1 files asked to be deduped
> +i: 0, status: 0, bytes_deduped: 1048576
> +1048576 total bytes deduped in this operation
> +Deduping 2 total files
> +(0, 1048576): sdir/v1/file1
> +(0, 1048576): sdir/v1/file2
> +1 files asked to be deduped
> +i: 0, status: 1, bytes_deduped: 0
> +0 total bytes deduped in this operation
> +Files /dev/fd/63 and /dev/fd/62 differ
> +Deduping 2 total files
> +(0, 1048576): sdir/v1/file1
> +(0, 1048576): sdir/v3/file4
> +1 files asked to be deduped
> +i: 0, status: 0, bytes_deduped: 1048576
> +1048576 total bytes deduped in this operation
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index bc6c256..4c868c8 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -7,5 +7,6 @@
>  264 auto
>  265 auto
>  276 auto rw metadata
>  284 auto
>  307 auto quick
> +313 auto

This is pretty quick, so add it to the quick group too.  Thanks,

Josef

      reply	other threads:[~2013-08-08 20:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 22:40 [XFSTESTS PATCH] btrfs: Test deduplication Gabriel de Perthuis
2013-08-08 20:55 ` Josef Bacik [this message]

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=20130808205546.GJ16712@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=g2p.code@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mfasheh@suse.de \
    --cc=sandeen@sandeen.net \
    /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;
as well as URLs for NNTP newsgroup(s).