From patchwork Wed Oct 7 05:13:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 7342711 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6A3ED9F1B9 for ; Wed, 7 Oct 2015 05:20:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D9FE2060D for ; Wed, 7 Oct 2015 05:20:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CB9A20695 for ; Wed, 7 Oct 2015 05:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753348AbbJGFRc (ORCPT ); Wed, 7 Oct 2015 01:17:32 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:40750 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbbJGFNp (ORCPT ); Wed, 7 Oct 2015 01:13:45 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t975Dep9020855 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Oct 2015 05:13:40 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t975Dd89012264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 7 Oct 2015 05:13:40 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t975DdbH026963; Wed, 7 Oct 2015 05:13:39 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 06 Oct 2015 22:13:38 -0700 Subject: [PATCH 05/12] reflink: test CoW behaviors of reflinked files From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: Anna.Schumaker@netapp.com, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org, xfs@oss.sgi.com Date: Tue, 06 Oct 2015 22:13:37 -0700 Message-ID: <20151007051337.3260.59500.stgit@birch.djwong.org> In-Reply-To: <20151007051257.3260.73072.stgit@birch.djwong.org> References: <20151007051257.3260.73072.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Ensure that CoW happens correctly with buffered, directio, and mmap writes. Signed-off-by: Darrick J. Wong --- tests/generic/808 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/808.out | 13 +++++ tests/generic/809 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/809.out | 13 +++++ tests/generic/810 | 139 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/810.out | 13 +++++ tests/generic/837 | 87 +++++++++++++++++++++++++++++++ tests/generic/837.out | 5 ++ tests/generic/838 | 87 +++++++++++++++++++++++++++++++ tests/generic/838.out | 5 ++ tests/generic/group | 5 ++ 11 files changed, 645 insertions(+) create mode 100755 tests/generic/808 create mode 100644 tests/generic/808.out create mode 100755 tests/generic/809 create mode 100644 tests/generic/809.out create mode 100755 tests/generic/810 create mode 100644 tests/generic/810.out create mode 100755 tests/generic/837 create mode 100644 tests/generic/837.out create mode 100755 tests/generic/838 create mode 100644 tests/generic/838.out -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tests/generic/808 b/tests/generic/808 new file mode 100755 index 0000000..8275bd9 --- /dev/null +++ b/tests/generic/808 @@ -0,0 +1,139 @@ +#! /bin/bash +# FS QA Test No. 808 +# +# Ensuring that copy on write through the page cache works: +# - Reflink two files together +# - Write to the beginning, middle, and end +# - Check that the files are now different where we say they're different. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, 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.* $TESTDIR +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_require_test_reflink +_supported_os Linux + +_require_cp_reflink +_require_test + +rm -f $seqres.full + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original files" +BLKSZ="$(stat -f $TESTDIR -c '%S')" +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file1 >> $seqres.full +cp --reflink $TESTDIR/file1 $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 do not match" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 do not match" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match" + +echo "pagecache CoW the second file" +$XFS_IO_PROG -f -c "pwrite -S 0x62 0 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 0 17" $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 16 - 34)) 17" $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 48 - 8)) 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 48 - 8)) 17" $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 do not match (intentional)" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 do not match (intentional)" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match" + +echo "Compare the CoW'd section to the before file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file2) \ + || echo "Start sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2) \ + || echo "Middle sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 8)) 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 8)) 17" $TESTDIR/file2) \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file3) \ + || echo "Start sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file3) \ + || echo "Middle sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 8)) 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 8)) 17" $TESTDIR/file3) \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file2) \ + || echo "Start sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file3) \ + || echo "Start sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file2) \ + || echo "Middle sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file3) \ + || echo "Middle sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 108)) 100" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 108)) 100" $TESTDIR/file2) \ + || echo "End sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 108)) 100" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 108)) 100" $TESTDIR/file3) \ + || echo "End sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file2) \ + || echo "Untouched sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file3) \ + || echo "Untouched sections of 2-3 do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/808.out b/tests/generic/808.out new file mode 100644 index 0000000..ef13e62 --- /dev/null +++ b/tests/generic/808.out @@ -0,0 +1,13 @@ +QA output created by 808 +Create the original files +Compare files +pagecache CoW the second file +Compare files +Files 1-2 do not match (intentional) +Files 1-3 do not match (intentional) +Compare the CoW'd section to the before file +Start sections do not match (intentional) +Middle sections do not match (intentional) +End sections do not match (intentional) +Compare the CoW'd section to the after file +Compare the not CoW'd sections diff --git a/tests/generic/809 b/tests/generic/809 new file mode 100755 index 0000000..09aac9b --- /dev/null +++ b/tests/generic/809 @@ -0,0 +1,139 @@ +#! /bin/bash +# FS QA Test No. 809 +# +# Ensuring that copy on write in direct-io mode works: +# - Reflink two files together +# - Write to the beginning, middle, and end in direct-io mode +# - Check that the files are now different where we say they're different. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, 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.* $TESTDIR +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_require_test_reflink +_supported_os Linux + +_require_cp_reflink +_require_test + +rm -f $seqres.full + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original files" +BLKSZ="$(stat -f $TESTDIR -c '%S')" +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file1 >> $seqres.full +cp --reflink $TESTDIR/file1 $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 should match" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 should match" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 should match" + +echo "directio CoW the second file" +$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" -d $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" -d $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 16 - 512)) 512" -d $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 16 - 512)) 512" -d $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 48)) $BLKSZ" -d $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 48)) $BLKSZ" -d $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 should not match (intentional)" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 should not match (intentional)" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 should match" + +echo "Compare the CoW'd section to the before file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $BLKSZ" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 $BLKSZ" $TESTDIR/file2) \ + || echo "Start sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 512)) 512" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 512)) 512" $TESTDIR/file2) \ + || echo "Middle sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 512)) $BLKSZ" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 512)) $BLKSZ" $TESTDIR/file2) \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $BLKSZ" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 $BLKSZ" $TESTDIR/file3) \ + || echo "Start sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 512)) 512" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 512)) 512" $TESTDIR/file3) \ + || echo "Middle sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 512)) $BLKSZ" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 512)) $BLKSZ" $TESTDIR/file3) \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 512" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 512" $TESTDIR/file2) \ + || echo "Start sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 512" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 512" $TESTDIR/file3) \ + || echo "Start sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 1024)) 512" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 1024)) 512" $TESTDIR/file2) \ + || echo "Middle sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 1024)) 512" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 1024)) 512" $TESTDIR/file3) \ + || echo "Middle sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 1024)) 512" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 1024)) 512" $TESTDIR/file2) \ + || echo "End sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 1024)) 512" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 1024)) 512" $TESTDIR/file3) \ + || echo "End sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16)) 512" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16)) 512" $TESTDIR/file2) \ + || echo "Untouched sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16)) 512" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16)) 512" $TESTDIR/file3) \ + || echo "Untouched sections of 2-3 do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/809.out b/tests/generic/809.out new file mode 100644 index 0000000..ce91ee2 --- /dev/null +++ b/tests/generic/809.out @@ -0,0 +1,13 @@ +QA output created by 809 +Create the original files +Compare files +directio CoW the second file +Compare files +Files 1-2 should not match (intentional) +Files 1-3 should not match (intentional) +Compare the CoW'd section to the before file +Start sections do not match (intentional) +Middle sections do not match (intentional) +End sections do not match (intentional) +Compare the CoW'd section to the after file +Compare the not CoW'd sections diff --git a/tests/generic/810 b/tests/generic/810 new file mode 100755 index 0000000..3de0b69 --- /dev/null +++ b/tests/generic/810 @@ -0,0 +1,139 @@ +#! /bin/bash +# FS QA Test No. 810 +# +# Ensuring that mmap copy on write through the page cache works: +# - Reflink two files together +# - Write to the beginning, middle, and end +# - Check that the files are now different where we say they're different. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, 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.* $TESTDIR +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_require_test_reflink +_supported_os Linux + +_require_cp_reflink +_require_test + +rm -f $seqres.full + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original files" +BLKSZ="$(stat -f $TESTDIR -c '%S')" +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file1 >> $seqres.full +cp --reflink $TESTDIR/file1 $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 48 - 3))" $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 do not match" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 do not match" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match" + +echo "mmap CoW the second file" +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 0 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 0 17" $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 $((BLKSZ * 16 - 34)) 17" $TESTDIR/file3 >> $seqres.full + +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 $((BLKSZ * 48 - 20)) 17" $TESTDIR/file2 >> $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * 48 - 3))" -c "mwrite -S 0x62 $((BLKSZ * 48 - 20)) 17" $TESTDIR/file3 >> $seqres.full +_test_remount + +echo "Compare files" +cmp -s $TESTDIR/file1 $TESTDIR/file2 || echo "Files 1-2 do not match (intentional)" +cmp -s $TESTDIR/file1 $TESTDIR/file3 || echo "Files 1-3 do not match (intentional)" +cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match" + +echo "Compare the CoW'd section to the before file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file2) \ + || echo "Start sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2) \ + || echo "Middle sections do not match (intentional)" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 20)) 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 20)) 17" $TESTDIR/file2) \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v 0 17" $TESTDIR/file3) \ + || echo "Start sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 34)) 17" $TESTDIR/file3) \ + || echo "Middle sections do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 20)) 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 20)) 17" $TESTDIR/file3) \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file2) \ + || echo "Start sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v 18 17" $TESTDIR/file3) \ + || echo "Start sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file2) \ + || echo "Middle sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 16 - 17)) 82" $TESTDIR/file3) \ + || echo "Middle sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 120)) 100" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 120)) 100" $TESTDIR/file2) \ + || echo "End sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 120)) 100" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 48 - 120)) 100" $TESTDIR/file3) \ + || echo "End sections of 2-3 do not match" + +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file1) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file2) \ + || echo "Untouched sections of 1-2 do not match" +cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file2) \ + <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 14)) $BLKSZ" $TESTDIR/file3) \ + || echo "Untouched sections of 2-3 do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/810.out b/tests/generic/810.out new file mode 100644 index 0000000..6434e03 --- /dev/null +++ b/tests/generic/810.out @@ -0,0 +1,13 @@ +QA output created by 810 +Create the original files +Compare files +mmap CoW the second file +Compare files +Files 1-2 do not match (intentional) +Files 1-3 do not match (intentional) +Compare the CoW'd section to the before file +Start sections do not match (intentional) +Middle sections do not match (intentional) +End sections do not match (intentional) +Compare the CoW'd section to the after file +Compare the not CoW'd sections diff --git a/tests/generic/837 b/tests/generic/837 new file mode 100755 index 0000000..1824ee0 --- /dev/null +++ b/tests/generic/837 @@ -0,0 +1,87 @@ +#! /bin/bash +# FS QA Test No. 837 +# +# Ensure that reflinking a file N times and CoWing the copies leaves the +# original intact. +# - Create a file and record its hash +# - Create some reflink copies +# - Rewrite all the reflink copies +# - Compare the contents of the original file +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, 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.* $TESTDIR +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_require_test_reflink +_supported_os Linux + +_require_cp_reflink +_require_test + +rm -f $seqres.full + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original file blocks" +BLKSZ="$(stat -f $TESTDIR -c '%S')" +NR=9 +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 256))" $TESTDIR/file1 >> $seqres.full +csum="$(_md5_checksum $TESTDIR/file1)" + +echo "Create the reflink copies" +for i in `seq 2 $NR`; do + cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i +done +_test_remount + +echo "Rewrite the copies" +for i in `seq 2 $NR`; do + $XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * 256))" $TESTDIR/file$i >> $seqres.full + sync +done +_test_remount + +echo "Examine original file" +mod_csum="$(_md5_checksum $TESTDIR/file2)" +new_csum="$(_md5_checksum $TESTDIR/file1)" +test "${csum}" != "${mod_csum}" || echo "checksums do not match" +test "${csum}" = "${new_csum}" || echo "checksums do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/837.out b/tests/generic/837.out new file mode 100644 index 0000000..dd45df8 --- /dev/null +++ b/tests/generic/837.out @@ -0,0 +1,5 @@ +QA output created by 837 +Create the original file blocks +Create the reflink copies +Rewrite the copies +Examine original file diff --git a/tests/generic/838 b/tests/generic/838 new file mode 100755 index 0000000..00977e5 --- /dev/null +++ b/tests/generic/838 @@ -0,0 +1,87 @@ +#! /bin/bash +# FS QA Test No. 837 +# +# Ensure that reflinking a file N times and DIO CoWing the copies leaves the +# original intact. +# - Create a file and record its hash +# - Create some reflink copies +# - Rewrite all the reflink copies with directio +# - Compare the contents of the original file +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, 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.* $TESTDIR +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_require_test_reflink +_supported_os Linux + +_require_cp_reflink +_require_test + +rm -f $seqres.full + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original file blocks" +BLKSZ="$(stat -f $TESTDIR -c '%S')" +NR=9 +$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 256))" $TESTDIR/file1 >> $seqres.full +csum="$(_md5_checksum $TESTDIR/file1)" + +echo "Create the reflink copies" +for i in `seq 2 $NR`; do + cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i +done +_test_remount + +echo "Rewrite the copies" +for i in `seq 2 $NR`; do + $XFS_IO_PROG -d -f -c "pwrite -S 0x62 0 $((BLKSZ * 256))" $TESTDIR/file$i >> $seqres.full + sync +done +_test_remount + +echo "Examine original file" +mod_csum="$(_md5_checksum $TESTDIR/file2)" +new_csum="$(_md5_checksum $TESTDIR/file1)" +test "${csum}" != "${mod_csum}" || echo "checksums do not match" +test "${csum}" = "${new_csum}" || echo "checksums do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/838.out b/tests/generic/838.out new file mode 100644 index 0000000..d1a862e --- /dev/null +++ b/tests/generic/838.out @@ -0,0 +1,5 @@ +QA output created by 838 +Create the original file blocks +Create the reflink copies +Rewrite the copies +Examine original file diff --git a/tests/generic/group b/tests/generic/group index 25cffa7..6734822 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -215,6 +215,11 @@ 805 auto quick clone 806 auto quick clone 807 auto quick clone +808 auto quick clone +809 auto quick clone +810 auto quick clone 817 auto quick clone 818 auto quick clone 819 auto quick clone +837 auto quick clone +838 auto quick clone