From patchwork Wed Jun 26 22:40:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel de Perthuis X-Patchwork-Id: 2789161 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A4786C0AB1 for ; Wed, 26 Jun 2013 22:40:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9188B20304 for ; Wed, 26 Jun 2013 22:40:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CC16202ED for ; Wed, 26 Jun 2013 22:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753414Ab3FZWkf (ORCPT ); Wed, 26 Jun 2013 18:40:35 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:61166 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753022Ab3FZWke (ORCPT ); Wed, 26 Jun 2013 18:40:34 -0400 Received: by mail-we0-f174.google.com with SMTP id q58so24954wes.33 for ; Wed, 26 Jun 2013 15:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=T4RStoBEb3VOGulk2kbAEsk0vmbkEs+Dkf7xmqNuXHg=; b=exKOwfbnAxMVg6EVsdSic+Foh/+NjnLPatEm97d+8ySxEAIJi/jIeEuTirvFVVvF8j n+NABhBXL2zWyh/ZuPY6+2c5n/O0C6vx9sEUbglmIUDSB9+8b2YnvoHwt+sekMdF+bX+ SnTAyS9RwvGz3OASdFynfAkJxWIZ6ZozIL9B7t31N7+SP1Jcx0ih4kJzoiJbE2NZRO7R XKfC8zXmHyqXczM0ih7f/1MyC+Y5kDjOIL2OoYFdMiuJUu+1AwsC7dqpSg4OrVDr9OI3 oHGXjJnrL/PldJ20pcwk5mpEsYi1rt4sxrUXX0XOb/jSVFLOurqrUwdx1G/X6GvUQN3y uY/w== X-Received: by 10.180.188.36 with SMTP id fx4mr10977738wic.55.1372286432497; Wed, 26 Jun 2013 15:40:32 -0700 (PDT) Received: from ?IPv6:2a01:e35:8a2c:b230:252c:94df:b75a:adc4? ([2a01:e35:8a2c:b230:252c:94df:b75a:adc4]) by mx.google.com with ESMTPSA id fb2sm13808566wic.4.2013.06.26.15.40.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Jun 2013 15:40:31 -0700 (PDT) Message-ID: <51CB6DDE.8060509@gmail.com> Date: Thu, 27 Jun 2013 00:40:30 +0200 From: Gabriel de Perthuis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Josef Bacik , Eric Sandeen CC: Mark Fasheh , linux-xfs@vger.kernel.org, "linux-btrfs@vger.kernel.org" Subject: [XFSTESTS PATCH] btrfs: Test deduplication Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- 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 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) +} + +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 + +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 + +$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