From patchwork Wed Nov 11 19:26:56 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: 7597571 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0627BBF90C for ; Wed, 11 Nov 2015 19:32:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E04D82052C for ; Wed, 11 Nov 2015 19:32:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9667F2034C for ; Wed, 11 Nov 2015 19:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752758AbbKKTbV (ORCPT ); Wed, 11 Nov 2015 14:31:21 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:34635 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbbKKT1b (ORCPT ); Wed, 11 Nov 2015 14:27:31 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tABJR2w0030477 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 Nov 2015 19:27:02 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tABJR1N8029105 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 11 Nov 2015 19:27:02 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id tABJR1nh019850; Wed, 11 Nov 2015 19:27:01 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 11 Nov 2015 11:26:57 -0800 Subject: [PATCH 04/11] reflink: test CoW behaviors of reflinked files From: "Darrick J. Wong" To: hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Cc: fstests@vger.kernel.org, xfs@oss.sgi.com, tao.peng@primarydata.com, linux-ext4@vger.kernel.org, Anna.Schumaker@netapp.com, linux-btrfs@vger.kernel.org Date: Wed, 11 Nov 2015 11:26:56 -0800 Message-ID: <20151111192656.15056.46709.stgit@birch.djwong.org> In-Reply-To: <20151111192628.15056.6451.stgit@birch.djwong.org> References: <20151111192628.15056.6451.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/808.out | 19 ++++++ tests/generic/809 | 151 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/809.out | 19 ++++++ tests/generic/810 | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/810.out | 19 ++++++ tests/generic/837 | 91 +++++++++++++++++++++++++++++ tests/generic/837.out | 8 +++ tests/generic/838 | 91 +++++++++++++++++++++++++++++ tests/generic/838.out | 8 +++ tests/generic/group | 5 ++ 11 files changed, 715 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..3a3ec58 --- /dev/null +++ b/tests/generic/808 @@ -0,0 +1,152 @@ +#! /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 +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file1" >> "$seqres.full" +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_pwrite_byte 0x62 0 17 "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x62 0 17 "$TESTDIR/file3" >> "$seqres.full" + +_pwrite_byte 0x62 $((BLKSZ * 16 - 34)) 17 "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x62 $((BLKSZ * 16 - 34)) 17 "$TESTDIR/file3" >> "$seqres.full" + +_pwrite_byte 0x62 $((BLKSZ * 48 - 8)) 17 "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x62 $((BLKSZ * 48 - 8)) 17 "$TESTDIR/file3" >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 17 \ + || echo "Start sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 34)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 34)) 17 \ + || echo "Middle sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 8)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 8)) 17 \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +_compare_range "$TESTDIR/file2" 0 "$TESTDIR/file3" 0 17 \ + || echo "Start sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 34)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 34)) 17 \ + || echo "Middle sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 8)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 8)) 17 \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +_compare_range "$TESTDIR/file1" 18 "$TESTDIR/file2" 18 17 \ + || echo "Start sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" 18 "$TESTDIR/file3" 18 17 \ + || echo "Start sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 17)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 17)) 82 \ + || echo "Middle sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 17)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 17)) 82 \ + || echo "Middle sections of 2-3 do not match" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 108)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 108)) 100 \ + || echo "End sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 108)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 108)) 100 \ + || echo "End sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 14)) \ + "$TESTDIR/file2" $((BLKSZ * 14)) $BLKSZ \ + || echo "Untouched sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 14)) \ + "$TESTDIR/file3" $((BLKSZ * 14)) $BLKSZ \ + || 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..1e82e2d --- /dev/null +++ b/tests/generic/808.out @@ -0,0 +1,19 @@ +QA output created by 808 +Create the original files +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-808/file1 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-808/file2 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-808/file3 +pagecache CoW the second file +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-808/file1 +4a879c2f322121f6f4b8ebede1909a7c TEST_DIR/test-808/file2 +4a879c2f322121f6f4b8ebede1909a7c TEST_DIR/test-808/file3 +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..99e88f6 --- /dev/null +++ b/tests/generic/809 @@ -0,0 +1,151 @@ +#! /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 +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR=$TEST_DIR/test-$seq +rm -rf $TESTDIR +mkdir $TESTDIR + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file1" >> "$seqres.full" +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_pwrite_byte 0x62 0 $BLKSZ "$TESTDIR/file2" -d >> "$seqres.full" +_pwrite_byte 0x62 0 $BLKSZ "$TESTDIR/file3" -d >> "$seqres.full" + +_pwrite_byte 0x62 $((BLKSZ * 16 - 512)) 512 "$TESTDIR/file2" -d >> "$seqres.full" +_pwrite_byte 0x62 $((BLKSZ * 16 - 512)) 512 "$TESTDIR/file3" -d >> "$seqres.full" + +_pwrite_byte 0x62 $((BLKSZ * 48)) $BLKSZ "$TESTDIR/file2" -d >> "$seqres.full" +_pwrite_byte 0x62 $((BLKSZ * 48)) $BLKSZ "$TESTDIR/file3" -d >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 $BLKSZ \ + || echo "Start sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 512)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 512)) 512 \ + || echo "Middle sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 512)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 512)) $BLKSZ \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +_compare_range "$TESTDIR/file2" 0 "$TESTDIR/file3" 0 $BLKSZ \ + || echo "Start sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 512)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 512)) 512 \ + || echo "Middle sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 512)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 512)) $BLKSZ \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +_compare_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $BLKSZ 512 \ + || echo "Start sections of 1-2 do not match" +_compare_range "$TESTDIR/file2" $BLKSZ "$TESTDIR/file3" $BLKSZ 512 \ + || echo "Start sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 1024)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 1024)) 512 \ + || echo "Middle sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 1024)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 1024)) 512 \ + || echo "Middle sections of 2-3 do not match" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 1024)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 1024)) 512 \ + || echo "End sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 1024)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 1024)) 512 \ + || echo "End sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16)) \ + "$TESTDIR/file2" $((BLKSZ * 16)) 512 \ + || echo "Untouched sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16)) \ + "$TESTDIR/file3" $((BLKSZ * 16)) 512 \ + || 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..ad63e4e --- /dev/null +++ b/tests/generic/809.out @@ -0,0 +1,19 @@ +QA output created by 809 +Create the original files +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-809/file1 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-809/file2 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-809/file3 +directio CoW the second file +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-809/file1 +ff5626fb6c71b242d6b1a43de25c9a85 TEST_DIR/test-809/file2 +ff5626fb6c71b242d6b1a43de25c9a85 TEST_DIR/test-809/file3 +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..3b635f8 --- /dev/null +++ b/tests/generic/810 @@ -0,0 +1,152 @@ +#! /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 +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file1" >> "$seqres.full" +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_mwrite_byte 0x62 0 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file2" >> "$seqres.full" +_mwrite_byte 0x62 0 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" + +_mwrite_byte 0x62 $((BLKSZ * 16 - 34)) 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file2" >> "$seqres.full" +_mwrite_byte 0x62 $((BLKSZ * 16 - 34)) 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" + +_mwrite_byte 0x62 $((BLKSZ * 48 - 20)) 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file2" >> "$seqres.full" +_mwrite_byte 0x62 $((BLKSZ * 48 - 20)) 17 $((BLKSZ * 48 - 3)) "$TESTDIR/file3" >> "$seqres.full" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file3" | _filter_test_dir + +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" +_compare_range "$TESTDIR/file1" 0 "$TESTDIR/file2" 0 17 \ + || echo "Start sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 34)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 34)) 17 \ + || echo "Middle sections do not match (intentional)" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 20)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 20)) 17 \ + || echo "End sections do not match (intentional)" + +echo "Compare the CoW'd section to the after file" +_compare_range "$TESTDIR/file2" 0 "$TESTDIR/file3" 0 17 \ + || echo "Start sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 34)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 34)) 17 \ + || echo "Middle sections do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 20)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 20)) 17 \ + || echo "End sections do not match" + +echo "Compare the not CoW'd sections" +_compare_range "$TESTDIR/file1" 18 "$TESTDIR/file2" 18 17 \ + || echo "Start sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" 18 "$TESTDIR/file3" 18 17 \ + || echo "Start sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 16 - 17)) \ + "$TESTDIR/file2" $((BLKSZ * 16 - 17)) 82 \ + || echo "Middle sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 16 - 17)) \ + "$TESTDIR/file3" $((BLKSZ * 16 - 17)) 82 \ + || echo "Middle sections of 2-3 do not match" + +_compare_range "$TESTDIR/file1" $((BLKSZ * 48 - 120)) \ + "$TESTDIR/file2" $((BLKSZ * 48 - 120)) 100 \ + || echo "End sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 48 - 120)) \ + "$TESTDIR/file3" $((BLKSZ * 48 - 120)) 100 \ + || echo "End sections of 2-3 do not match" + + +_compare_range "$TESTDIR/file1" $((BLKSZ * 14)) \ + "$TESTDIR/file2" $((BLKSZ * 14)) $BLKSZ \ + || echo "Untouched sections of 1-2 do not match" + +_compare_range "$TESTDIR/file2" $((BLKSZ * 14)) \ + "$TESTDIR/file3" $((BLKSZ * 14)) $BLKSZ \ + || 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..8cc94ab --- /dev/null +++ b/tests/generic/810.out @@ -0,0 +1,19 @@ +QA output created by 810 +Create the original files +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-810/file1 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-810/file2 +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-810/file3 +mmap CoW the second file +Compare files +60ebe700450b6015c17fa15cacb9493b TEST_DIR/test-810/file1 +795ecfd281dbda4916431376228e4187 TEST_DIR/test-810/file2 +795ecfd281dbda4916431376228e4187 TEST_DIR/test-810/file3 +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..de5f233 --- /dev/null +++ b/tests/generic/837 @@ -0,0 +1,91 @@ +#! /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 +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original file blocks" +BLKSZ=65536 +NR=9 +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +csum="$(_md5_checksum "$TESTDIR/file1")" + +echo "Create the reflink copies" +seq 2 $NR | while read i; do + _cp_reflink "$TESTDIR/file1" "$TESTDIR/file$i" +done +_test_remount + +echo "Rewrite the copies" +seq 2 $NR | while read i; do + _pwrite_byte 0x62 0 $((BLKSZ * 256)) "$TESTDIR/file$i" >> "$seqres.full" +done +_test_remount + +echo "Examine original file" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir + +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..3f9c2e5 --- /dev/null +++ b/tests/generic/837.out @@ -0,0 +1,8 @@ +QA output created by 837 +Create the original file blocks +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-837/file1 +Create the reflink copies +Rewrite the copies +Examine original file +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-837/file1 +eb34153e9ed1e774db28cbbe4090a449 TEST_DIR/test-837/file2 diff --git a/tests/generic/838 b/tests/generic/838 new file mode 100755 index 0000000..1130a2c --- /dev/null +++ b/tests/generic/838 @@ -0,0 +1,91 @@ +#! /bin/bash +# FS QA Test No. 838 +# +# 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 w/ 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 +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original file blocks" +BLKSZ=65536 +NR=9 +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +csum="$(_md5_checksum "$TESTDIR/file1")" + +echo "Create the reflink copies" +seq 2 $NR | while read i; do + _cp_reflink "$TESTDIR/file1" "$TESTDIR/file$i" +done +_test_remount + +echo "Rewrite the copies" +seq 2 $NR | while read i; do + _pwrite_byte 0x62 0 $((BLKSZ * 256)) "$TESTDIR/file$i" -d >> "$seqres.full" +done +_test_remount + +echo "Examine original file" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir + +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..cc44815 --- /dev/null +++ b/tests/generic/838.out @@ -0,0 +1,8 @@ +QA output created by 838 +Create the original file blocks +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-838/file1 +Create the reflink copies +Rewrite the copies +Examine original file +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-838/file1 +eb34153e9ed1e774db28cbbe4090a449 TEST_DIR/test-838/file2 diff --git a/tests/generic/group b/tests/generic/group index 7f25037..a72d416 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -216,6 +216,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