All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-10-07  5:12 ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Hi all,

This is part of the third revision of an RFC for adding to XFS support
for tracking reverse-mappings of physical blocks to file and metadata;
and support for mapping multiple file logical blocks to the same
physical block, more commonly known as reflinking.

This patchset aims to make xfstests perform more rigorous testing of
the btrfs/XFS file clone, reflink, and dedupe ioctls.  There are now
tests of the basic functionality of the three ioctls; tests to ensure
that the filesystem exhibits the expected copy on write semantics;
tests to try to suss out race conditions in the new write paths; tests
to ensure that the ioctls peform basic disk accounting correctly;
tests of the interaction between reflink and the various fallocate
verbs (allocate, punch, collapse, insert zeroes); and some attempts to
test the upper limits of reflinking and ENOSPC behavior.  The tests
have been totally rewritten since the last posting to drop FIEMAP
usage; this should enable the tests to cover NFS and CIFS.

Issues: 

 * I think the race checks for dedupe could be a little sharper at
   finding mistakes.

 * I started the numbering really high to prevent the tests from
   colliding with whatever new tests might arrive; this will require
   some intervention to fix.

 * I don't have any interesting NFS/CIFS setups for test. :(

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
They should just work with the btrfs that's in 4.3.

Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux-xfs-dev/commits/master
[2] https://github.com/djwong/xfsprogs/commits/for-next
[3] https://github.com/djwong/xfstests/commits/master

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-10-07  5:12 ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Hi all,

This is part of the third revision of an RFC for adding to XFS support
for tracking reverse-mappings of physical blocks to file and metadata;
and support for mapping multiple file logical blocks to the same
physical block, more commonly known as reflinking.

This patchset aims to make xfstests perform more rigorous testing of
the btrfs/XFS file clone, reflink, and dedupe ioctls.  There are now
tests of the basic functionality of the three ioctls; tests to ensure
that the filesystem exhibits the expected copy on write semantics;
tests to try to suss out race conditions in the new write paths; tests
to ensure that the ioctls peform basic disk accounting correctly;
tests of the interaction between reflink and the various fallocate
verbs (allocate, punch, collapse, insert zeroes); and some attempts to
test the upper limits of reflinking and ENOSPC behavior.  The tests
have been totally rewritten since the last posting to drop FIEMAP
usage; this should enable the tests to cover NFS and CIFS.

Issues: 

 * I think the race checks for dedupe could be a little sharper at
   finding mistakes.

 * I started the numbering really high to prevent the tests from
   colliding with whatever new tests might arrive; this will require
   some intervention to fix.

 * I don't have any interesting NFS/CIFS setups for test. :(

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
They should just work with the btrfs that's in 4.3.

Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux-xfs-dev/commits/master
[2] https://github.com/djwong/xfsprogs/commits/for-next
[3] https://github.com/djwong/xfstests/commits/master

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH 01/12] xfs: fix merge errors in fuzzer tests
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/085.out |    2 --
 tests/xfs/098.out |    1 -
 tests/xfs/099.out |    2 +-
 tests/xfs/100.out |    2 +-
 tests/xfs/101.out |    2 +-
 tests/xfs/102.out |    2 +-
 6 files changed, 4 insertions(+), 7 deletions(-)


diff --git a/tests/xfs/085.out b/tests/xfs/085.out
index 6303081..ff3dccd 100644
--- a/tests/xfs/085.out
+++ b/tests/xfs/085.out
@@ -5,8 +5,6 @@ QA output created by 085
 + check fs
 + corrupt image
 + mount image
-+ modify files
-broken: 1
 + repair fs
 + mount image (2)
 + chattr -R -i
diff --git a/tests/xfs/098.out b/tests/xfs/098.out
index 84a2b4d..ef0554d 100644
--- a/tests/xfs/098.out
+++ b/tests/xfs/098.out
@@ -5,7 +5,6 @@ QA output created by 098
 + check fs
 + corrupt image
 + mount image
-broken: 1
 + repair fs
 + mount image (2)
 + chattr -R -i
diff --git a/tests/xfs/099.out b/tests/xfs/099.out
index 4426859..773200b 100644
--- a/tests/xfs/099.out
+++ b/tests/xfs/099.out
@@ -1,4 +1,4 @@
-QA output created by 016
+QA output created by 099
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/100.out b/tests/xfs/100.out
index 98d8dbc..97dba7c 100644
--- a/tests/xfs/100.out
+++ b/tests/xfs/100.out
@@ -1,4 +1,4 @@
-QA output created by 017
+QA output created by 100
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/101.out b/tests/xfs/101.out
index 49430f7..22ca620 100644
--- a/tests/xfs/101.out
+++ b/tests/xfs/101.out
@@ -1,4 +1,4 @@
-QA output created by 018
+QA output created by 101
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/102.out b/tests/xfs/102.out
index 58f493c..d8a8fa1 100644
--- a/tests/xfs/102.out
+++ b/tests/xfs/102.out
@@ -1,4 +1,4 @@
-QA output created by 019
+QA output created by 102
 + create scratch fs
 + mount fs image
 + make some files


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 01/12] xfs: fix merge errors in fuzzer tests
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/085.out |    2 --
 tests/xfs/098.out |    1 -
 tests/xfs/099.out |    2 +-
 tests/xfs/100.out |    2 +-
 tests/xfs/101.out |    2 +-
 tests/xfs/102.out |    2 +-
 6 files changed, 4 insertions(+), 7 deletions(-)


diff --git a/tests/xfs/085.out b/tests/xfs/085.out
index 6303081..ff3dccd 100644
--- a/tests/xfs/085.out
+++ b/tests/xfs/085.out
@@ -5,8 +5,6 @@ QA output created by 085
 + check fs
 + corrupt image
 + mount image
-+ modify files
-broken: 1
 + repair fs
 + mount image (2)
 + chattr -R -i
diff --git a/tests/xfs/098.out b/tests/xfs/098.out
index 84a2b4d..ef0554d 100644
--- a/tests/xfs/098.out
+++ b/tests/xfs/098.out
@@ -5,7 +5,6 @@ QA output created by 098
 + check fs
 + corrupt image
 + mount image
-broken: 1
 + repair fs
 + mount image (2)
 + chattr -R -i
diff --git a/tests/xfs/099.out b/tests/xfs/099.out
index 4426859..773200b 100644
--- a/tests/xfs/099.out
+++ b/tests/xfs/099.out
@@ -1,4 +1,4 @@
-QA output created by 016
+QA output created by 099
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/100.out b/tests/xfs/100.out
index 98d8dbc..97dba7c 100644
--- a/tests/xfs/100.out
+++ b/tests/xfs/100.out
@@ -1,4 +1,4 @@
-QA output created by 017
+QA output created by 100
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/101.out b/tests/xfs/101.out
index 49430f7..22ca620 100644
--- a/tests/xfs/101.out
+++ b/tests/xfs/101.out
@@ -1,4 +1,4 @@
-QA output created by 018
+QA output created by 101
 + create scratch fs
 + mount fs image
 + make some files
diff --git a/tests/xfs/102.out b/tests/xfs/102.out
index 58f493c..d8a8fa1 100644
--- a/tests/xfs/102.out
+++ b/tests/xfs/102.out
@@ -1,4 +1,4 @@
-QA output created by 019
+QA output created by 102
 + create scratch fs
 + mount fs image
 + make some files

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 02/12] btrfs: move btrfs reflink tests to generic
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Move the cp --reflink tests from btrfs/ to generic/ since xfs now
supports that ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/btrfs/026       |   92 -----------------------------------------
 tests/btrfs/026.out   |   16 -------
 tests/btrfs/027       |  109 -------------------------------------------------
 tests/btrfs/027.out   |   25 -----------
 tests/btrfs/028       |   83 -------------------------------------
 tests/btrfs/028.out   |    7 ---
 tests/btrfs/group     |    3 -
 tests/generic/800     |   92 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/800.out |   16 +++++++
 tests/generic/801     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/801.out |   25 +++++++++++
 tests/generic/802     |   83 +++++++++++++++++++++++++++++++++++++
 tests/generic/802.out |    7 +++
 tests/generic/group   |    3 +
 14 files changed, 335 insertions(+), 335 deletions(-)
 delete mode 100755 tests/btrfs/026
 delete mode 100644 tests/btrfs/026.out
 delete mode 100755 tests/btrfs/027
 delete mode 100644 tests/btrfs/027.out
 delete mode 100755 tests/btrfs/028
 delete mode 100644 tests/btrfs/028.out
 create mode 100755 tests/generic/800
 create mode 100644 tests/generic/800.out
 create mode 100755 tests/generic/801
 create mode 100644 tests/generic/801.out
 create mode 100755 tests/generic/802
 create mode 100644 tests/generic/802.out


diff --git a/tests/btrfs/026 b/tests/btrfs/026
deleted file mode 100755
index 7559ca2..0000000
--- a/tests/btrfs/026
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 026
-#
-# Tests file clone functionality of btrfs ("reflinks"):
-#   - Reflink a file
-#   - Reflink the reflinked file
-#   - Modify the original file
-#   - Modify the reflinked file
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. common/rc
-. common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-_checksum_files() {
-    for F in original copy1 copy2
-    do
-        md5sum $TESTDIR1/$F | _filter_test_dir
-    done
-}
-
-rm -f $seqres.full
-
-echo "Create the original file and reflink to copy1, copy2"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
-    >> $seqres.full 2>&1
-cp --reflink $TESTDIR1/original $TESTDIR1/copy1
-cp --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy1
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy2
-echo "Original md5sums:"
-_checksum_files
-
-echo "Overwrite original file with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $TESTDIR1/original \
-    >> $seqres.full 2>&1
-echo "md5sums after overwriting original:"
-_checksum_files
-
-echo "Overwrite copy1 with different new data"
-$XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $TESTDIR1/copy1 \
-    >> $seqres.full 2>&1
-echo "md5sums after overwriting copy1:"
-_checksum_files
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/026.out b/tests/btrfs/026.out
deleted file mode 100644
index 3b90ff0..0000000
--- a/tests/btrfs/026.out
+++ /dev/null
@@ -1,16 +0,0 @@
-QA output created by 026
-Create the original file and reflink to copy1, copy2
-Original md5sums:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/original
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
-Overwrite original file with new data
-md5sums after overwriting original:
-4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-026/original
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
-Overwrite copy1 with different new data
-md5sums after overwriting copy1:
-4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-026/original
-e271cd47d9f62ebc96cb4e67ae4d16db  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
diff --git a/tests/btrfs/027 b/tests/btrfs/027
deleted file mode 100755
index d2b812b..0000000
--- a/tests/btrfs/027
+++ /dev/null
@@ -1,109 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 027
-#
-# Tests file clone functionality of btrfs ("reflinks") on directory
-# trees.
-#   - Create directory and subdirectory, each having one file
-#   - Create 2 recursive reflinked copies of the tree
-#   - Modify the original files
-#   - Modify one of the copies
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. common/rc
-. common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-_checksum_files() {
-    for F in original/file1 original/subdir/file2 \
-                 copy1/file1 copy1/subdir/file2 \
-                 copy2/file1 copy2/subdir/file2
-        do
-            md5sum $TESTDIR1/$F | _filter_test_dir
-        done
-}
-
-rm -f $seqres.full
-
-mkdir $TESTDIR1/original
-mkdir $TESTDIR1/original/subdir
-
-echo "Create the original files and reflink dirs"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
-    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
-cp --recursive --reflink $TESTDIR1/original $TESTDIR1/copy1
-cp --recursive --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
-
-_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy1/file1
-_verify_reflink $TESTDIR1/original/subdir/file2 \
-    $TESTDIR1/copy1/subdir/file2
-_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy2/file1
-_verify_reflink $TESTDIR1/original/subdir/file2 \
-    $TESTDIR1/copy2/subdir/file2
-
-echo "Original md5sums:"
-_checksum_files
-
-echo "Overwrite original/file1 and original/subdir/file2 with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $TESTDIR1/original/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
-    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
-echo "md5sums now:"
-_checksum_files
-
-echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $TESTDIR1/copy1/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
-    $TESTDIR1/copy1/subdir/file2 >> $seqres.full 2>&1
-echo "md5sums now:"
-_checksum_files
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/027.out b/tests/btrfs/027.out
deleted file mode 100644
index 7b7e3bb..0000000
--- a/tests/btrfs/027.out
+++ /dev/null
@@ -1,25 +0,0 @@
-QA output created by 027
-Create the original files and reflink dirs
-Original md5sums:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/original/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/original/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy1/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
-Overwrite original/file1 and original/subdir/file2 with new data
-md5sums now:
-260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-027/original/file1
-b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-027/original/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy1/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
-Overwrite copy1/file1 and copy1/subdir/file2 with new data
-md5sums now:
-260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-027/original/file1
-b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-027/original/subdir/file2
-b20229a003e3985c4b0e6806abcd6642  TEST_DIR/test-027/copy1/file1
-b815b24069db14e0a3a07169fd563e93  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
diff --git a/tests/btrfs/028 b/tests/btrfs/028
deleted file mode 100755
index 7193337..0000000
--- a/tests/btrfs/028
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 028
-#
-# Moving and deleting cloned ("reflinked") files on btrfs:
-#   - Create a file and a reflink
-#   - Move both to a directory
-#   - Delete the original (moved) file, check that the copy still exists.
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-rm -f $seqres.full
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-echo "Create the original files and reflink dirs"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
-    >> $seqres.full
-cp --reflink $TESTDIR1/original $TESTDIR1/copy
-
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy
-
-echo "Move orig & reflink copy to subdir and md5sum:"
-mkdir $TESTDIR1/subdir
-mv $TESTDIR1/original $TESTDIR1/subdir/original_moved
-mv $TESTDIR1/copy $TESTDIR1/subdir/copy_moved
-_verify_reflink $TESTDIR1/subdir/original_moved \
-    $TESTDIR1/subdir/copy_moved
-
-md5sum $TESTDIR1/subdir/original_moved | _filter_test_dir
-md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
-
-echo "remove orig from subdir and md5sum reflink copy:"
-rm $TESTDIR1/subdir/original_moved
-md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
-rm -rf $TESTDIR1/subdir
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/028.out b/tests/btrfs/028.out
deleted file mode 100644
index f683fce..0000000
--- a/tests/btrfs/028.out
+++ /dev/null
@@ -1,7 +0,0 @@
-QA output created by 028
-Create the original files and reflink dirs
-Move orig & reflink copy to subdir and md5sum:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/original_moved
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/copy_moved
-remove orig from subdir and md5sum reflink copy:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/copy_moved
diff --git a/tests/btrfs/group b/tests/btrfs/group
index e92a65a..07c23c4 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -28,9 +28,6 @@
 023 auto
 024 auto quick compress
 025 auto quick send clone
-026 auto quick clone
-027 auto quick clone
-028 auto quick clone
 029 auto quick clone
 030 auto quick send
 031 auto quick subvol clone
diff --git a/tests/generic/800 b/tests/generic/800
new file mode 100755
index 0000000..a71f11a
--- /dev/null
+++ b/tests/generic/800
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test No. 800
+#
+# Tests file clone functionality of btrfs ("reflinks"):
+#   - Reflink a file
+#   - Reflink the reflinked file
+#   - Modify the original file
+#   - Modify the reflinked file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+_checksum_files() {
+    for F in original copy1 copy2
+    do
+        md5sum $TESTDIR1/$F | _filter_test_dir
+    done
+}
+
+rm -f $seqres.full
+
+echo "Create the original file and reflink to copy1, copy2"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
+    >> $seqres.full 2>&1
+cp --reflink $TESTDIR1/original $TESTDIR1/copy1
+cp --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy1
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy2
+echo "Original md5sums:"
+_checksum_files
+
+echo "Overwrite original file with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $TESTDIR1/original \
+    >> $seqres.full 2>&1
+echo "md5sums after overwriting original:"
+_checksum_files
+
+echo "Overwrite copy1 with different new data"
+$XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $TESTDIR1/copy1 \
+    >> $seqres.full 2>&1
+echo "md5sums after overwriting copy1:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/800.out b/tests/generic/800.out
new file mode 100644
index 0000000..6978d71
--- /dev/null
+++ b/tests/generic/800.out
@@ -0,0 +1,16 @@
+QA output created by 800
+Create the original file and reflink to copy1, copy2
+Original md5sums:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/original
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
+Overwrite original file with new data
+md5sums after overwriting original:
+4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-800/original
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
+Overwrite copy1 with different new data
+md5sums after overwriting copy1:
+4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-800/original
+e271cd47d9f62ebc96cb4e67ae4d16db  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
diff --git a/tests/generic/801 b/tests/generic/801
new file mode 100755
index 0000000..b21c44b
--- /dev/null
+++ b/tests/generic/801
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 801
+#
+# Tests file clone functionality of btrfs ("reflinks") on directory
+# trees.
+#   - Create directory and subdirectory, each having one file
+#   - Create 2 recursive reflinked copies of the tree
+#   - Modify the original files
+#   - Modify one of the copies
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+_checksum_files() {
+    for F in original/file1 original/subdir/file2 \
+                 copy1/file1 copy1/subdir/file2 \
+                 copy2/file1 copy2/subdir/file2
+        do
+            md5sum $TESTDIR1/$F | _filter_test_dir
+        done
+}
+
+rm -f $seqres.full
+
+mkdir $TESTDIR1/original
+mkdir $TESTDIR1/original/subdir
+
+echo "Create the original files and reflink dirs"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
+    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
+cp --recursive --reflink $TESTDIR1/original $TESTDIR1/copy1
+cp --recursive --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
+
+_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy1/file1
+_verify_reflink $TESTDIR1/original/subdir/file2 \
+    $TESTDIR1/copy1/subdir/file2
+_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy2/file1
+_verify_reflink $TESTDIR1/original/subdir/file2 \
+    $TESTDIR1/copy2/subdir/file2
+
+echo "Original md5sums:"
+_checksum_files
+
+echo "Overwrite original/file1 and original/subdir/file2 with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $TESTDIR1/original/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
+    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
+echo "md5sums now:"
+_checksum_files
+
+echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $TESTDIR1/copy1/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
+    $TESTDIR1/copy1/subdir/file2 >> $seqres.full 2>&1
+echo "md5sums now:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/801.out b/tests/generic/801.out
new file mode 100644
index 0000000..b8225cc
--- /dev/null
+++ b/tests/generic/801.out
@@ -0,0 +1,25 @@
+QA output created by 801
+Create the original files and reflink dirs
+Original md5sums:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/original/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/original/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy1/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
+Overwrite original/file1 and original/subdir/file2 with new data
+md5sums now:
+260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-801/original/file1
+b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-801/original/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy1/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
+Overwrite copy1/file1 and copy1/subdir/file2 with new data
+md5sums now:
+260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-801/original/file1
+b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-801/original/subdir/file2
+b20229a003e3985c4b0e6806abcd6642  TEST_DIR/test-801/copy1/file1
+b815b24069db14e0a3a07169fd563e93  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
diff --git a/tests/generic/802 b/tests/generic/802
new file mode 100755
index 0000000..afd8513
--- /dev/null
+++ b/tests/generic/802
@@ -0,0 +1,83 @@
+#! /bin/bash
+# FS QA Test No. 802
+#
+# Moving and deleting cloned ("reflinked") files on btrfs:
+#   - Create a file and a reflink
+#   - Move both to a directory
+#   - Delete the original (moved) file, check that the copy still exists.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+rm -f $seqres.full
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+echo "Create the original files and reflink dirs"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
+    >> $seqres.full
+cp --reflink $TESTDIR1/original $TESTDIR1/copy
+
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy
+
+echo "Move orig & reflink copy to subdir and md5sum:"
+mkdir $TESTDIR1/subdir
+mv $TESTDIR1/original $TESTDIR1/subdir/original_moved
+mv $TESTDIR1/copy $TESTDIR1/subdir/copy_moved
+_verify_reflink $TESTDIR1/subdir/original_moved \
+    $TESTDIR1/subdir/copy_moved
+
+md5sum $TESTDIR1/subdir/original_moved | _filter_test_dir
+md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
+
+echo "remove orig from subdir and md5sum reflink copy:"
+rm $TESTDIR1/subdir/original_moved
+md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
+rm -rf $TESTDIR1/subdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/802.out b/tests/generic/802.out
new file mode 100644
index 0000000..c20e16e
--- /dev/null
+++ b/tests/generic/802.out
@@ -0,0 +1,7 @@
+QA output created by 802
+Create the original files and reflink dirs
+Move orig & reflink copy to subdir and md5sum:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/original_moved
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/copy_moved
+remove orig from subdir and md5sum reflink copy:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/copy_moved
diff --git a/tests/generic/group b/tests/generic/group
index 4ae256f..d8b21ce 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -207,3 +207,6 @@
 323 auto aio stress
 324 auto fsr quick
 325 auto quick data log
+800 auto quick clone
+801 auto quick clone
+802 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 02/12] btrfs: move btrfs reflink tests to generic
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Move the cp --reflink tests from btrfs/ to generic/ since xfs now
supports that ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/btrfs/026       |   92 -----------------------------------------
 tests/btrfs/026.out   |   16 -------
 tests/btrfs/027       |  109 -------------------------------------------------
 tests/btrfs/027.out   |   25 -----------
 tests/btrfs/028       |   83 -------------------------------------
 tests/btrfs/028.out   |    7 ---
 tests/btrfs/group     |    3 -
 tests/generic/800     |   92 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/800.out |   16 +++++++
 tests/generic/801     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/801.out |   25 +++++++++++
 tests/generic/802     |   83 +++++++++++++++++++++++++++++++++++++
 tests/generic/802.out |    7 +++
 tests/generic/group   |    3 +
 14 files changed, 335 insertions(+), 335 deletions(-)
 delete mode 100755 tests/btrfs/026
 delete mode 100644 tests/btrfs/026.out
 delete mode 100755 tests/btrfs/027
 delete mode 100644 tests/btrfs/027.out
 delete mode 100755 tests/btrfs/028
 delete mode 100644 tests/btrfs/028.out
 create mode 100755 tests/generic/800
 create mode 100644 tests/generic/800.out
 create mode 100755 tests/generic/801
 create mode 100644 tests/generic/801.out
 create mode 100755 tests/generic/802
 create mode 100644 tests/generic/802.out


diff --git a/tests/btrfs/026 b/tests/btrfs/026
deleted file mode 100755
index 7559ca2..0000000
--- a/tests/btrfs/026
+++ /dev/null
@@ -1,92 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 026
-#
-# Tests file clone functionality of btrfs ("reflinks"):
-#   - Reflink a file
-#   - Reflink the reflinked file
-#   - Modify the original file
-#   - Modify the reflinked file
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. common/rc
-. common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-_checksum_files() {
-    for F in original copy1 copy2
-    do
-        md5sum $TESTDIR1/$F | _filter_test_dir
-    done
-}
-
-rm -f $seqres.full
-
-echo "Create the original file and reflink to copy1, copy2"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
-    >> $seqres.full 2>&1
-cp --reflink $TESTDIR1/original $TESTDIR1/copy1
-cp --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy1
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy2
-echo "Original md5sums:"
-_checksum_files
-
-echo "Overwrite original file with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $TESTDIR1/original \
-    >> $seqres.full 2>&1
-echo "md5sums after overwriting original:"
-_checksum_files
-
-echo "Overwrite copy1 with different new data"
-$XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $TESTDIR1/copy1 \
-    >> $seqres.full 2>&1
-echo "md5sums after overwriting copy1:"
-_checksum_files
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/026.out b/tests/btrfs/026.out
deleted file mode 100644
index 3b90ff0..0000000
--- a/tests/btrfs/026.out
+++ /dev/null
@@ -1,16 +0,0 @@
-QA output created by 026
-Create the original file and reflink to copy1, copy2
-Original md5sums:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/original
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
-Overwrite original file with new data
-md5sums after overwriting original:
-4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-026/original
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
-Overwrite copy1 with different new data
-md5sums after overwriting copy1:
-4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-026/original
-e271cd47d9f62ebc96cb4e67ae4d16db  TEST_DIR/test-026/copy1
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-026/copy2
diff --git a/tests/btrfs/027 b/tests/btrfs/027
deleted file mode 100755
index d2b812b..0000000
--- a/tests/btrfs/027
+++ /dev/null
@@ -1,109 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 027
-#
-# Tests file clone functionality of btrfs ("reflinks") on directory
-# trees.
-#   - Create directory and subdirectory, each having one file
-#   - Create 2 recursive reflinked copies of the tree
-#   - Modify the original files
-#   - Modify one of the copies
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. common/rc
-. common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-_checksum_files() {
-    for F in original/file1 original/subdir/file2 \
-                 copy1/file1 copy1/subdir/file2 \
-                 copy2/file1 copy2/subdir/file2
-        do
-            md5sum $TESTDIR1/$F | _filter_test_dir
-        done
-}
-
-rm -f $seqres.full
-
-mkdir $TESTDIR1/original
-mkdir $TESTDIR1/original/subdir
-
-echo "Create the original files and reflink dirs"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
-    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
-cp --recursive --reflink $TESTDIR1/original $TESTDIR1/copy1
-cp --recursive --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
-
-_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy1/file1
-_verify_reflink $TESTDIR1/original/subdir/file2 \
-    $TESTDIR1/copy1/subdir/file2
-_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy2/file1
-_verify_reflink $TESTDIR1/original/subdir/file2 \
-    $TESTDIR1/copy2/subdir/file2
-
-echo "Original md5sums:"
-_checksum_files
-
-echo "Overwrite original/file1 and original/subdir/file2 with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $TESTDIR1/original/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
-    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
-echo "md5sums now:"
-_checksum_files
-
-echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
-$XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $TESTDIR1/copy1/file1 \
-    >> $seqres.full 2>&1
-$XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
-    $TESTDIR1/copy1/subdir/file2 >> $seqres.full 2>&1
-echo "md5sums now:"
-_checksum_files
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/027.out b/tests/btrfs/027.out
deleted file mode 100644
index 7b7e3bb..0000000
--- a/tests/btrfs/027.out
+++ /dev/null
@@ -1,25 +0,0 @@
-QA output created by 027
-Create the original files and reflink dirs
-Original md5sums:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/original/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/original/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy1/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
-Overwrite original/file1 and original/subdir/file2 with new data
-md5sums now:
-260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-027/original/file1
-b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-027/original/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy1/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
-Overwrite copy1/file1 and copy1/subdir/file2 with new data
-md5sums now:
-260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-027/original/file1
-b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-027/original/subdir/file2
-b20229a003e3985c4b0e6806abcd6642  TEST_DIR/test-027/copy1/file1
-b815b24069db14e0a3a07169fd563e93  TEST_DIR/test-027/copy1/subdir/file2
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-027/copy2/file1
-ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-027/copy2/subdir/file2
diff --git a/tests/btrfs/028 b/tests/btrfs/028
deleted file mode 100755
index 7193337..0000000
--- a/tests/btrfs/028
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /bin/bash
-# FS QA Test No. 028
-#
-# Moving and deleting cloned ("reflinked") files on btrfs:
-#   - Create a file and a reflink
-#   - Move both to a directory
-#   - Delete the original (moved) file, check that the copy still exists.
-#
-#-----------------------------------------------------------------------
-# Copyright (c) 2014, 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 -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-
-# real QA test starts here
-_supported_fs btrfs
-_supported_os Linux
-
-_require_xfs_io_command "fiemap"
-_require_cp_reflink
-_require_test
-
-rm -f $seqres.full
-
-TESTDIR1=$TEST_DIR/test-$seq
-rm -rf $TESTDIR1
-mkdir $TESTDIR1
-
-echo "Create the original files and reflink dirs"
-$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
-    >> $seqres.full
-cp --reflink $TESTDIR1/original $TESTDIR1/copy
-
-_verify_reflink $TESTDIR1/original $TESTDIR1/copy
-
-echo "Move orig & reflink copy to subdir and md5sum:"
-mkdir $TESTDIR1/subdir
-mv $TESTDIR1/original $TESTDIR1/subdir/original_moved
-mv $TESTDIR1/copy $TESTDIR1/subdir/copy_moved
-_verify_reflink $TESTDIR1/subdir/original_moved \
-    $TESTDIR1/subdir/copy_moved
-
-md5sum $TESTDIR1/subdir/original_moved | _filter_test_dir
-md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
-
-echo "remove orig from subdir and md5sum reflink copy:"
-rm $TESTDIR1/subdir/original_moved
-md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
-rm -rf $TESTDIR1/subdir
-
-# success, all done
-status=0
-exit
diff --git a/tests/btrfs/028.out b/tests/btrfs/028.out
deleted file mode 100644
index f683fce..0000000
--- a/tests/btrfs/028.out
+++ /dev/null
@@ -1,7 +0,0 @@
-QA output created by 028
-Create the original files and reflink dirs
-Move orig & reflink copy to subdir and md5sum:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/original_moved
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/copy_moved
-remove orig from subdir and md5sum reflink copy:
-42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-028/subdir/copy_moved
diff --git a/tests/btrfs/group b/tests/btrfs/group
index e92a65a..07c23c4 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -28,9 +28,6 @@
 023 auto
 024 auto quick compress
 025 auto quick send clone
-026 auto quick clone
-027 auto quick clone
-028 auto quick clone
 029 auto quick clone
 030 auto quick send
 031 auto quick subvol clone
diff --git a/tests/generic/800 b/tests/generic/800
new file mode 100755
index 0000000..a71f11a
--- /dev/null
+++ b/tests/generic/800
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test No. 800
+#
+# Tests file clone functionality of btrfs ("reflinks"):
+#   - Reflink a file
+#   - Reflink the reflinked file
+#   - Modify the original file
+#   - Modify the reflinked file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+_checksum_files() {
+    for F in original copy1 copy2
+    do
+        md5sum $TESTDIR1/$F | _filter_test_dir
+    done
+}
+
+rm -f $seqres.full
+
+echo "Create the original file and reflink to copy1, copy2"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
+    >> $seqres.full 2>&1
+cp --reflink $TESTDIR1/original $TESTDIR1/copy1
+cp --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy1
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy2
+echo "Original md5sums:"
+_checksum_files
+
+echo "Overwrite original file with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $TESTDIR1/original \
+    >> $seqres.full 2>&1
+echo "md5sums after overwriting original:"
+_checksum_files
+
+echo "Overwrite copy1 with different new data"
+$XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $TESTDIR1/copy1 \
+    >> $seqres.full 2>&1
+echo "md5sums after overwriting copy1:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/800.out b/tests/generic/800.out
new file mode 100644
index 0000000..6978d71
--- /dev/null
+++ b/tests/generic/800.out
@@ -0,0 +1,16 @@
+QA output created by 800
+Create the original file and reflink to copy1, copy2
+Original md5sums:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/original
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
+Overwrite original file with new data
+md5sums after overwriting original:
+4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-800/original
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
+Overwrite copy1 with different new data
+md5sums after overwriting copy1:
+4a847a25439532bf48b68c9e9536ed5b  TEST_DIR/test-800/original
+e271cd47d9f62ebc96cb4e67ae4d16db  TEST_DIR/test-800/copy1
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-800/copy2
diff --git a/tests/generic/801 b/tests/generic/801
new file mode 100755
index 0000000..b21c44b
--- /dev/null
+++ b/tests/generic/801
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 801
+#
+# Tests file clone functionality of btrfs ("reflinks") on directory
+# trees.
+#   - Create directory and subdirectory, each having one file
+#   - Create 2 recursive reflinked copies of the tree
+#   - Modify the original files
+#   - Modify one of the copies
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+_checksum_files() {
+    for F in original/file1 original/subdir/file2 \
+                 copy1/file1 copy1/subdir/file2 \
+                 copy2/file1 copy2/subdir/file2
+        do
+            md5sum $TESTDIR1/$F | _filter_test_dir
+        done
+}
+
+rm -f $seqres.full
+
+mkdir $TESTDIR1/original
+mkdir $TESTDIR1/original/subdir
+
+echo "Create the original files and reflink dirs"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
+    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
+cp --recursive --reflink $TESTDIR1/original $TESTDIR1/copy1
+cp --recursive --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
+
+_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy1/file1
+_verify_reflink $TESTDIR1/original/subdir/file2 \
+    $TESTDIR1/copy1/subdir/file2
+_verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy2/file1
+_verify_reflink $TESTDIR1/original/subdir/file2 \
+    $TESTDIR1/copy2/subdir/file2
+
+echo "Original md5sums:"
+_checksum_files
+
+echo "Overwrite original/file1 and original/subdir/file2 with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $TESTDIR1/original/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
+    $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
+echo "md5sums now:"
+_checksum_files
+
+echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
+$XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $TESTDIR1/copy1/file1 \
+    >> $seqres.full 2>&1
+$XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
+    $TESTDIR1/copy1/subdir/file2 >> $seqres.full 2>&1
+echo "md5sums now:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/801.out b/tests/generic/801.out
new file mode 100644
index 0000000..b8225cc
--- /dev/null
+++ b/tests/generic/801.out
@@ -0,0 +1,25 @@
+QA output created by 801
+Create the original files and reflink dirs
+Original md5sums:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/original/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/original/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy1/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
+Overwrite original/file1 and original/subdir/file2 with new data
+md5sums now:
+260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-801/original/file1
+b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-801/original/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy1/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
+Overwrite copy1/file1 and copy1/subdir/file2 with new data
+md5sums now:
+260f6785c0537fd12582dcae28a3c1a9  TEST_DIR/test-801/original/file1
+b8d91fb600f6f2191f2ba66665374860  TEST_DIR/test-801/original/subdir/file2
+b20229a003e3985c4b0e6806abcd6642  TEST_DIR/test-801/copy1/file1
+b815b24069db14e0a3a07169fd563e93  TEST_DIR/test-801/copy1/subdir/file2
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-801/copy2/file1
+ca390545f0aedb54b808d6128c56a7dd  TEST_DIR/test-801/copy2/subdir/file2
diff --git a/tests/generic/802 b/tests/generic/802
new file mode 100755
index 0000000..afd8513
--- /dev/null
+++ b/tests/generic/802
@@ -0,0 +1,83 @@
+#! /bin/bash
+# FS QA Test No. 802
+#
+# Moving and deleting cloned ("reflinked") files on btrfs:
+#   - Create a file and a reflink
+#   - Move both to a directory
+#   - Delete the original (moved) file, check that the copy still exists.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_xfs_io_command "fiemap"
+_require_cp_reflink
+_require_test
+
+rm -f $seqres.full
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+echo "Create the original files and reflink dirs"
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
+    >> $seqres.full
+cp --reflink $TESTDIR1/original $TESTDIR1/copy
+
+_verify_reflink $TESTDIR1/original $TESTDIR1/copy
+
+echo "Move orig & reflink copy to subdir and md5sum:"
+mkdir $TESTDIR1/subdir
+mv $TESTDIR1/original $TESTDIR1/subdir/original_moved
+mv $TESTDIR1/copy $TESTDIR1/subdir/copy_moved
+_verify_reflink $TESTDIR1/subdir/original_moved \
+    $TESTDIR1/subdir/copy_moved
+
+md5sum $TESTDIR1/subdir/original_moved | _filter_test_dir
+md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
+
+echo "remove orig from subdir and md5sum reflink copy:"
+rm $TESTDIR1/subdir/original_moved
+md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
+rm -rf $TESTDIR1/subdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/802.out b/tests/generic/802.out
new file mode 100644
index 0000000..c20e16e
--- /dev/null
+++ b/tests/generic/802.out
@@ -0,0 +1,7 @@
+QA output created by 802
+Create the original files and reflink dirs
+Move orig & reflink copy to subdir and md5sum:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/original_moved
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/copy_moved
+remove orig from subdir and md5sum reflink copy:
+42d69d1a6d333a7ebdf64792a555e392  TEST_DIR/test-802/subdir/copy_moved
diff --git a/tests/generic/group b/tests/generic/group
index 4ae256f..d8b21ce 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -207,3 +207,6 @@
 323 auto aio stress
 324 auto fsr quick
 325 auto quick data log
+800 auto quick clone
+801 auto quick clone
+802 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Modify the reflink tests to support xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc         |   37 +++++++++++++++++++++++++++++++++++++
 tests/generic/800 |    2 +-
 tests/generic/801 |    2 +-
 tests/generic/802 |    2 +-
 4 files changed, 40 insertions(+), 3 deletions(-)


diff --git a/common/rc b/common/rc
index 3e97060..7e2f140 100644
--- a/common/rc
+++ b/common/rc
@@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
 	umount $SCRATCH_MNT
 }
 
+# this test requires the test fs support reflink...
+#
+_require_test_reflink()
+{
+    case $FSTYP in
+    xfs)
+	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
+	;;
+    btrfs)
+        true
+        ;;
+    *)
+        _notrun "Reflink not supported by this filesystem type: $FSTYP"
+        ;;
+    esac
+}
+
+# this test requires the scratch fs support reflink...
+#
+_require_scratch_reflink()
+{
+    case $FSTYP in
+    xfs)
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"
+	_scratch_unmount
+	;;
+    btrfs)
+        true
+        ;;
+    *)
+        _notrun "Reflink not supported by this filesystem type: $FSTYP"
+        ;;
+    esac
+}
+
 # this test requires the bigalloc feature to be available in mkfs.ext4
 #
 _require_ext4_mkfs_bigalloc()
diff --git a/tests/generic/800 b/tests/generic/800
index a71f11a..954f39d 100755
--- a/tests/generic/800
+++ b/tests/generic/800
@@ -45,7 +45,7 @@ _cleanup()
 . common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"
diff --git a/tests/generic/801 b/tests/generic/801
index b21c44b..aedb6e9 100755
--- a/tests/generic/801
+++ b/tests/generic/801
@@ -45,7 +45,7 @@ _cleanup()
 . common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"
diff --git a/tests/generic/802 b/tests/generic/802
index afd8513..51d3414 100755
--- a/tests/generic/802
+++ b/tests/generic/802
@@ -43,7 +43,7 @@ _cleanup()
 . ./common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Modify the reflink tests to support xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc         |   37 +++++++++++++++++++++++++++++++++++++
 tests/generic/800 |    2 +-
 tests/generic/801 |    2 +-
 tests/generic/802 |    2 +-
 4 files changed, 40 insertions(+), 3 deletions(-)


diff --git a/common/rc b/common/rc
index 3e97060..7e2f140 100644
--- a/common/rc
+++ b/common/rc
@@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
 	umount $SCRATCH_MNT
 }
 
+# this test requires the test fs support reflink...
+#
+_require_test_reflink()
+{
+    case $FSTYP in
+    xfs)
+	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
+	;;
+    btrfs)
+        true
+        ;;
+    *)
+        _notrun "Reflink not supported by this filesystem type: $FSTYP"
+        ;;
+    esac
+}
+
+# this test requires the scratch fs support reflink...
+#
+_require_scratch_reflink()
+{
+    case $FSTYP in
+    xfs)
+	_scratch_mkfs > /dev/null 2>&1
+	_scratch_mount
+	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"
+	_scratch_unmount
+	;;
+    btrfs)
+        true
+        ;;
+    *)
+        _notrun "Reflink not supported by this filesystem type: $FSTYP"
+        ;;
+    esac
+}
+
 # this test requires the bigalloc feature to be available in mkfs.ext4
 #
 _require_ext4_mkfs_bigalloc()
diff --git a/tests/generic/800 b/tests/generic/800
index a71f11a..954f39d 100755
--- a/tests/generic/800
+++ b/tests/generic/800
@@ -45,7 +45,7 @@ _cleanup()
 . common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"
diff --git a/tests/generic/801 b/tests/generic/801
index b21c44b..aedb6e9 100755
--- a/tests/generic/801
+++ b/tests/generic/801
@@ -45,7 +45,7 @@ _cleanup()
 . common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"
diff --git a/tests/generic/802 b/tests/generic/802
index afd8513..51d3414 100755
--- a/tests/generic/802
+++ b/tests/generic/802
@@ -43,7 +43,7 @@ _cleanup()
 . ./common/filter
 
 # real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
 _supported_os Linux
 
 _require_xfs_io_command "fiemap"

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 04/12] reflink: basic tests of the reflink and dedupe ioctls
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Test the operation of the btrfs (and now xfs) reflink and dedupe
ioctls at various file offsets and with matching and nonmatching
files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc             |    9 +++
 tests/generic/803     |   89 ++++++++++++++++++++++++++
 tests/generic/803.out |    4 +
 tests/generic/804     |   90 ++++++++++++++++++++++++++
 tests/generic/804.out |    7 ++
 tests/generic/805     |  171 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/805.out |   18 +++++
 tests/generic/806     |   89 ++++++++++++++++++++++++++
 tests/generic/806.out |    4 +
 tests/generic/807     |   89 ++++++++++++++++++++++++++
 tests/generic/807.out |    8 ++
 tests/generic/817     |  125 ++++++++++++++++++++++++++++++++++++
 tests/generic/817.out |    8 ++
 tests/generic/818     |  125 ++++++++++++++++++++++++++++++++++++
 tests/generic/818.out |    9 +++
 tests/generic/819     |  128 +++++++++++++++++++++++++++++++++++++
 tests/generic/819.out |    7 ++
 tests/generic/group   |    8 ++
 18 files changed, 988 insertions(+)
 create mode 100755 tests/generic/803
 create mode 100644 tests/generic/803.out
 create mode 100755 tests/generic/804
 create mode 100644 tests/generic/804.out
 create mode 100755 tests/generic/805
 create mode 100644 tests/generic/805.out
 create mode 100755 tests/generic/806
 create mode 100644 tests/generic/806.out
 create mode 100755 tests/generic/807
 create mode 100644 tests/generic/807.out
 create mode 100755 tests/generic/817
 create mode 100644 tests/generic/817.out
 create mode 100755 tests/generic/818
 create mode 100644 tests/generic/818.out
 create mode 100755 tests/generic/819
 create mode 100644 tests/generic/819.out


diff --git a/common/rc b/common/rc
index 7e2f140..639f355 100644
--- a/common/rc
+++ b/common/rc
@@ -82,6 +82,15 @@ _md5_checksum()
 	md5sum $1 | cut -d ' ' -f1
 }
 
+# Prints the md5 checksum of a part of a given file
+_md5_range_checksum() {
+	file="$1"
+	offset="$2"
+	len="$3"
+
+	md5sum <($XFS_IO_PROG -f -c "pread -q -v $offset $len" "$file" | sed -e 's/^.*:  //g') | cut -d ' ' -f 1
+}
+
 
 # ls -l w/ selinux sometimes puts a dot at the end:
 # -rwxrw-r--. id1 id2 file1
diff --git a/tests/generic/803 b/tests/generic/803
new file mode 100755
index 0000000..d5595ed
--- /dev/null
+++ b/tests/generic/803
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 803
+#
+# Ensure that we can reflink parts of two identical files:
+#   - Reflink identical parts of two identical files
+#   - Check that we still have identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/803.out b/tests/generic/803.out
new file mode 100644
index 0000000..1108990
--- /dev/null
+++ b/tests/generic/803.out
@@ -0,0 +1,4 @@
+QA output created by 803
+Create the original files
+Reflink the middle blocks together
+Compare sections
diff --git a/tests/generic/804 b/tests/generic/804
new file mode 100755
index 0000000..cc39e4d
--- /dev/null
+++ b/tests/generic/804
@@ -0,0 +1,90 @@
+#! /bin/bash
+# FS QA Test No. 804
+#
+# Ensuring that we can reflink non-matching parts of files:
+#   - Reflink identical ranges of two different files
+#   - Check that the non-linked ranges still do not match
+#   - Check that we end up with identical contents in the linked ranges
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match (intentional)"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/804.out b/tests/generic/804.out
new file mode 100644
index 0000000..df0a551
--- /dev/null
+++ b/tests/generic/804.out
@@ -0,0 +1,7 @@
+QA output created by 804
+Create the original files
+Files do not match (intentional)
+Reflink the middle blocks together
+Compare sections
+Start sections do not match (intentional)
+End sections do not match (intentional)
diff --git a/tests/generic/805 b/tests/generic/805
new file mode 100755
index 0000000..f926fb7
--- /dev/null
+++ b/tests/generic/805
@@ -0,0 +1,171 @@
+#! /bin/bash
+# FS QA Test No. 805
+#
+# Reflinking two sets of files together:
+#   - Reflink identical parts of two identical files
+#   - Reflink identical parts of two other identical files
+#   - Reflink identical parts of all four files
+#   - Check that we end up with identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 8))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * 8))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKSZ * 8))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x64 0 $((BLKSZ * 8))" $TESTDIR/file4 >> $seqres.full
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files 1-2 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file3) \
+       || echo "Files 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file4) \
+       || echo "Files 1-4 do not match (intentional)"
+
+echo "Reflink the first blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 4))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file3 0 0 $((BLKSZ * 4))" $TESTDIR/file4 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Sections of file 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file4) \
+       || echo "Sections of file 3-4 do not match"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 2))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 2))" $TESTDIR/file4 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of files 1-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of files 1-4 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of files 2-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of files 2-4 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of files 3-4 do not match"
+
+echo "Compare previously reflinked sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of file 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of file 3-4 do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/805.out b/tests/generic/805.out
new file mode 100644
index 0000000..5c9629e
--- /dev/null
+++ b/tests/generic/805.out
@@ -0,0 +1,18 @@
+QA output created by 805
+Create the original files
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Reflink the first blocks together
+Compare sections
+Sections of file 1-3 do not match (intentional)
+Sections of file 1-4 do not match (intentional)
+Sections of file 2-3 do not match (intentional)
+Sections of file 2-4 do not match (intentional)
+Reflink the middle blocks together
+Compare sections
+Compare previously reflinked sections
+Sections of file 1-3 do not match (intentional)
+Sections of file 1-4 do not match (intentional)
+Sections of file 2-3 do not match (intentional)
+Sections of file 2-4 do not match (intentional)
diff --git a/tests/generic/806 b/tests/generic/806
new file mode 100755
index 0000000..defcc20
--- /dev/null
+++ b/tests/generic/806
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 806
+#
+# Ensure that we can dedupe parts of two files:
+#   - Dedupe identical parts of two identical files
+#   - Check that still have identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "dedupe"
+_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 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match"
+
+echo "Dedupe the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/806.out b/tests/generic/806.out
new file mode 100644
index 0000000..7c0fbf2
--- /dev/null
+++ b/tests/generic/806.out
@@ -0,0 +1,4 @@
+QA output created by 806
+Create the original files
+Dedupe the middle blocks together
+Compare sections
diff --git a/tests/generic/807 b/tests/generic/807
new file mode 100755
index 0000000..e86339d
--- /dev/null
+++ b/tests/generic/807
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 807
+#
+# Ensuring that we cannot dedupe non-matching parts of files:
+#   - Fail to dedupe non-identical parts of two different files
+#   - Check that nothing changes in either 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_xfs_io_command "dedupe"
+_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 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match (intentional)"
+
+echo "(Fail to) dedupe the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/807.out b/tests/generic/807.out
new file mode 100644
index 0000000..9422bc1
--- /dev/null
+++ b/tests/generic/807.out
@@ -0,0 +1,8 @@
+QA output created by 807
+Create the original files
+Files do not match (intentional)
+(Fail to) dedupe the middle blocks together
+Compare sections
+Start sections do not match (intentional)
+Middle sections do not match (intentional)
+End sections do not match (intentional)
diff --git a/tests/generic/817 b/tests/generic/817
new file mode 100755
index 0000000..109a9d8
--- /dev/null
+++ b/tests/generic/817
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 817
+#
+# Ensure that we can reflink the last block of a file whose size isn't
+# block-aligned.
+#   - Create two 'a' files file whose size isn't block-aligned.
+#   - Create two 'b' files file whose size isn't block-aligned.
+#   - Reflink the last block of file1 to the last block in file2 and file3.
+#   - Check that files 1-2 match, 3-4 don't match, and that nothing matches 3.
+#   - Check that the ends of 1-3 match, and 1-3 do not match the end of file4.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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 + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file4 >> $seqres.full
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Reflink the last blocks together"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file3 >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+echo "Compare files"
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should match"
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       || echo "End sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 1-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 2-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 3-4 do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/817.out b/tests/generic/817.out
new file mode 100644
index 0000000..3574727
--- /dev/null
+++ b/tests/generic/817.out
@@ -0,0 +1,8 @@
+QA output created by 817
+Create the original files
+Reflink the last blocks together
+Compare files
+Compare sections
+End sections of files 1-4 do not match (intentional)
+End sections of files 2-4 do not match (intentional)
+End sections of files 3-4 do not match (intentional)
diff --git a/tests/generic/818 b/tests/generic/818
new file mode 100755
index 0000000..0a99768
--- /dev/null
+++ b/tests/generic/818
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 818
+#
+# Ensure that we can dedupe the last block of a file whose size isn't
+# block-aligned.
+#   - Create two 'a' files file whose size isn't block-aligned.
+#   - Create two 'b' files file whose size isn't block-aligned.
+#   - Dedupe the last block of file1 to the last block in file2 and file3.
+#   - Check that files 1-2 match, and that 3-4 match.
+#   - Check that the ends of 1-2 and 3-4 match, and that 1-3 don't match.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "dedupe"
+_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 + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file4 >> $seqres.full
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Dedupe the last blocks together"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file3 >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+echo "Compare files"
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       || echo "End sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 3-4 do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/818.out b/tests/generic/818.out
new file mode 100644
index 0000000..242dc8c
--- /dev/null
+++ b/tests/generic/818.out
@@ -0,0 +1,9 @@
+QA output created by 818
+Create the original files
+Dedupe the last blocks together
+Compare files
+Compare sections
+End sections of files 1-3 do not match (intentional)
+End sections of files 1-4 do not match (intentional)
+End sections of files 2-3 do not match (intentional)
+End sections of files 2-4 do not match (intentional)
diff --git a/tests/generic/819 b/tests/generic/819
new file mode 100755
index 0000000..08bc374
--- /dev/null
+++ b/tests/generic/819
@@ -0,0 +1,128 @@
+#! /bin/bash
+# FS QA Test No. 819
+#
+# Ensure that we can reflink and dedupe blocks within the same file...
+#   - Create a file with three distinct blocks ABB
+#   - Reflink block zero to the multiple-of-three blocks
+#   - Reflink block one to the multiple-of-five blocks
+#   - Dedupe block two to the multiple-of-seven blocks
+#   - Check that we successfully avoid deduping with holes, unwritten
+#     extents, and non-matches; but actually dedupe real matches.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
+_require_xfs_io_command "falloc"
+_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')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $((BLKSZ * 2))" $TESTDIR/file1 >> $seqres.full
+
+NR_BLKS=1024
+
+echo "fallocate half the file"
+$XFS_IO_PROG -f -c "falloc $((NR_BLKS * BLKSZ / 2)) $((NR_BLKS * BLKSZ / 2))" $TESTDIR/file1 >> $seqres.full
+
+echo "Reflink block zero to the threes"
+seq 1 $((NR_BLKS / 3)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 $((nr * 3 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+echo "Reflink block one to the fives"
+seq 1 $((NR_BLKS / 5)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $((nr * 5 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+echo "Dedupe block two to the sevens"
+seq 1 $((NR_BLKS / 7)) | while read nr; do
+	$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 2)) $((nr * 7 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+_test_remount
+
+echo "Check block mappings"
+crcZ=$(_md5_range_checksum /dev/zero 0 $BLKSZ)
+crc0=$(_md5_range_checksum $TESTDIR/file1 0 $BLKSZ)
+crc1=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $BLKSZ)
+crc2=$(_md5_range_checksum $TESTDIR/file1 $((BLKSZ * 2)) $BLKSZ)
+
+check_block() {
+	lblk="$1"
+	rem7=$((lblk % 7))
+	rem5=$((lblk % 5))
+	rem3=$((lblk % 3))
+
+	crc=$(_md5_range_checksum $TESTDIR/file1 $((lblk * BLKSZ)) $BLKSZ)
+
+	if [ $rem7 -eq 0 ]; then
+		if [ $rem5 -eq 0 ]; then
+			test $crc2 = $crc || echo "lblk $lblk doesn't match block 2"
+		elif [ $rem3 -eq 0 ]; then
+			test $crc0 = $crc || echo "lblk $lblk doesn't match block 0"
+		elif [ $lblk -lt $((NR_BLKS / 2)) ]; then
+			test $crcZ = $crc || echo "lblk $lblk isn't zeroed"
+		fi
+	elif [ $rem5 -eq 0 ]; then
+		test $crc1 = $crc || echo "lblk $lblk doesn't match block 1"
+	elif [ $rem3 -eq 0 ]; then
+		test $crc0 = $crc || echo "lblk $lblk doesn't match block 0"
+	elif [ $lblk -lt $((NR_BLKS / 2)) ]; then
+		test $crcZ = $crc || echo "lblk $lblk isn't zeroed"
+	fi
+}
+
+seq 3 $((NR_BLKS - 1)) | while read lblk; do
+	err="$(check_block $lblk)"
+	test -n "$err" && echo "$lblk: $err"
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/819.out b/tests/generic/819.out
new file mode 100644
index 0000000..0ee5b14
--- /dev/null
+++ b/tests/generic/819.out
@@ -0,0 +1,7 @@
+QA output created by 819
+Create the original file blocks
+fallocate half the file
+Reflink block zero to the threes
+Reflink block one to the fives
+Dedupe block two to the sevens
+Check block mappings
diff --git a/tests/generic/group b/tests/generic/group
index d8b21ce..25cffa7 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -210,3 +210,11 @@
 800 auto quick clone
 801 auto quick clone
 802 auto quick clone
+803 auto quick clone
+804 auto quick clone
+805 auto quick clone
+806 auto quick clone
+807 auto quick clone
+817 auto quick clone
+818 auto quick clone
+819 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 04/12] reflink: basic tests of the reflink and dedupe ioctls
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Test the operation of the btrfs (and now xfs) reflink and dedupe
ioctls at various file offsets and with matching and nonmatching
files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc             |    9 +++
 tests/generic/803     |   89 ++++++++++++++++++++++++++
 tests/generic/803.out |    4 +
 tests/generic/804     |   90 ++++++++++++++++++++++++++
 tests/generic/804.out |    7 ++
 tests/generic/805     |  171 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/805.out |   18 +++++
 tests/generic/806     |   89 ++++++++++++++++++++++++++
 tests/generic/806.out |    4 +
 tests/generic/807     |   89 ++++++++++++++++++++++++++
 tests/generic/807.out |    8 ++
 tests/generic/817     |  125 ++++++++++++++++++++++++++++++++++++
 tests/generic/817.out |    8 ++
 tests/generic/818     |  125 ++++++++++++++++++++++++++++++++++++
 tests/generic/818.out |    9 +++
 tests/generic/819     |  128 +++++++++++++++++++++++++++++++++++++
 tests/generic/819.out |    7 ++
 tests/generic/group   |    8 ++
 18 files changed, 988 insertions(+)
 create mode 100755 tests/generic/803
 create mode 100644 tests/generic/803.out
 create mode 100755 tests/generic/804
 create mode 100644 tests/generic/804.out
 create mode 100755 tests/generic/805
 create mode 100644 tests/generic/805.out
 create mode 100755 tests/generic/806
 create mode 100644 tests/generic/806.out
 create mode 100755 tests/generic/807
 create mode 100644 tests/generic/807.out
 create mode 100755 tests/generic/817
 create mode 100644 tests/generic/817.out
 create mode 100755 tests/generic/818
 create mode 100644 tests/generic/818.out
 create mode 100755 tests/generic/819
 create mode 100644 tests/generic/819.out


diff --git a/common/rc b/common/rc
index 7e2f140..639f355 100644
--- a/common/rc
+++ b/common/rc
@@ -82,6 +82,15 @@ _md5_checksum()
 	md5sum $1 | cut -d ' ' -f1
 }
 
+# Prints the md5 checksum of a part of a given file
+_md5_range_checksum() {
+	file="$1"
+	offset="$2"
+	len="$3"
+
+	md5sum <($XFS_IO_PROG -f -c "pread -q -v $offset $len" "$file" | sed -e 's/^.*:  //g') | cut -d ' ' -f 1
+}
+
 
 # ls -l w/ selinux sometimes puts a dot at the end:
 # -rwxrw-r--. id1 id2 file1
diff --git a/tests/generic/803 b/tests/generic/803
new file mode 100755
index 0000000..d5595ed
--- /dev/null
+++ b/tests/generic/803
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 803
+#
+# Ensure that we can reflink parts of two identical files:
+#   - Reflink identical parts of two identical files
+#   - Check that we still have identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/803.out b/tests/generic/803.out
new file mode 100644
index 0000000..1108990
--- /dev/null
+++ b/tests/generic/803.out
@@ -0,0 +1,4 @@
+QA output created by 803
+Create the original files
+Reflink the middle blocks together
+Compare sections
diff --git a/tests/generic/804 b/tests/generic/804
new file mode 100755
index 0000000..cc39e4d
--- /dev/null
+++ b/tests/generic/804
@@ -0,0 +1,90 @@
+#! /bin/bash
+# FS QA Test No. 804
+#
+# Ensuring that we can reflink non-matching parts of files:
+#   - Reflink identical ranges of two different files
+#   - Check that the non-linked ranges still do not match
+#   - Check that we end up with identical contents in the linked ranges
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match (intentional)"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/804.out b/tests/generic/804.out
new file mode 100644
index 0000000..df0a551
--- /dev/null
+++ b/tests/generic/804.out
@@ -0,0 +1,7 @@
+QA output created by 804
+Create the original files
+Files do not match (intentional)
+Reflink the middle blocks together
+Compare sections
+Start sections do not match (intentional)
+End sections do not match (intentional)
diff --git a/tests/generic/805 b/tests/generic/805
new file mode 100755
index 0000000..f926fb7
--- /dev/null
+++ b/tests/generic/805
@@ -0,0 +1,171 @@
+#! /bin/bash
+# FS QA Test No. 805
+#
+# Reflinking two sets of files together:
+#   - Reflink identical parts of two identical files
+#   - Reflink identical parts of two other identical files
+#   - Reflink identical parts of all four files
+#   - Check that we end up with identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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') * 64))"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 8))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * 8))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKSZ * 8))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x64 0 $((BLKSZ * 8))" $TESTDIR/file4 >> $seqres.full
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files 1-2 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file3) \
+       || echo "Files 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file4) \
+       || echo "Files 1-4 do not match (intentional)"
+
+echo "Reflink the first blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 4))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file3 0 0 $((BLKSZ * 4))" $TESTDIR/file4 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Sections of file 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       || echo "Sections of file 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 4))" $TESTDIR/file4) \
+       || echo "Sections of file 3-4 do not match"
+
+echo "Reflink the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 2))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $((BLKSZ * 2))" $TESTDIR/file4 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of files 1-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of files 1-4 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of files 2-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of files 2-4 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of files 3-4 do not match"
+
+echo "Compare previously reflinked sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Sections of file 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       || echo "Sections of file 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 2)) $((BLKSZ * 2))" $TESTDIR/file4) \
+       || echo "Sections of file 3-4 do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/805.out b/tests/generic/805.out
new file mode 100644
index 0000000..5c9629e
--- /dev/null
+++ b/tests/generic/805.out
@@ -0,0 +1,18 @@
+QA output created by 805
+Create the original files
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Reflink the first blocks together
+Compare sections
+Sections of file 1-3 do not match (intentional)
+Sections of file 1-4 do not match (intentional)
+Sections of file 2-3 do not match (intentional)
+Sections of file 2-4 do not match (intentional)
+Reflink the middle blocks together
+Compare sections
+Compare previously reflinked sections
+Sections of file 1-3 do not match (intentional)
+Sections of file 1-4 do not match (intentional)
+Sections of file 2-3 do not match (intentional)
+Sections of file 2-4 do not match (intentional)
diff --git a/tests/generic/806 b/tests/generic/806
new file mode 100755
index 0000000..defcc20
--- /dev/null
+++ b/tests/generic/806
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 806
+#
+# Ensure that we can dedupe parts of two files:
+#   - Dedupe identical parts of two identical files
+#   - Check that still have identical contents
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "dedupe"
+_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 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match"
+
+echo "Dedupe the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/806.out b/tests/generic/806.out
new file mode 100644
index 0000000..7c0fbf2
--- /dev/null
+++ b/tests/generic/806.out
@@ -0,0 +1,4 @@
+QA output created by 806
+Create the original files
+Dedupe the middle blocks together
+Compare sections
diff --git a/tests/generic/807 b/tests/generic/807
new file mode 100755
index 0000000..e86339d
--- /dev/null
+++ b/tests/generic/807
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 807
+#
+# Ensuring that we cannot dedupe non-matching parts of files:
+#   - Fail to dedupe non-identical parts of two different files
+#   - Check that nothing changes in either 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_xfs_io_command "dedupe"
+_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 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $((BLKSZ * 2)) $((BLKSZ * 6))" $TESTDIR/file2 >> $seqres.full
+sync
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v 0 $((BLKSZ * 8))" $TESTDIR/file2) \
+       || echo "Files do not match (intentional)"
+
+echo "(Fail to) dedupe the middle blocks together"
+free_before="$(stat -f -c '%a' $TESTDIR)"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 4)) $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2 >> $seqres.full
+_test_remount
+free_after="$(stat -f -c '%a' $TESTDIR)"
+echo "freesp changed by $free_before -> $free_after" >> $seqres.full
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 0)) $((BLKSZ * 4))" $TESTDIR/file2) \
+       || echo "Start sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 4)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "Middle sections do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $((BLKSZ * 6)) $((BLKSZ * 2))" $TESTDIR/file2) \
+       || echo "End sections do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/807.out b/tests/generic/807.out
new file mode 100644
index 0000000..9422bc1
--- /dev/null
+++ b/tests/generic/807.out
@@ -0,0 +1,8 @@
+QA output created by 807
+Create the original files
+Files do not match (intentional)
+(Fail to) dedupe the middle blocks together
+Compare sections
+Start sections do not match (intentional)
+Middle sections do not match (intentional)
+End sections do not match (intentional)
diff --git a/tests/generic/817 b/tests/generic/817
new file mode 100755
index 0000000..109a9d8
--- /dev/null
+++ b/tests/generic/817
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 817
+#
+# Ensure that we can reflink the last block of a file whose size isn't
+# block-aligned.
+#   - Create two 'a' files file whose size isn't block-aligned.
+#   - Create two 'b' files file whose size isn't block-aligned.
+#   - Reflink the last block of file1 to the last block in file2 and file3.
+#   - Check that files 1-2 match, 3-4 don't match, and that nothing matches 3.
+#   - Check that the ends of 1-3 match, and 1-3 do not match the end of file4.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "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 + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file4 >> $seqres.full
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Reflink the last blocks together"
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file3 >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+echo "Compare files"
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should match"
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       || echo "End sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 1-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 2-3 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 3-4 do not match (intentional)"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/817.out b/tests/generic/817.out
new file mode 100644
index 0000000..3574727
--- /dev/null
+++ b/tests/generic/817.out
@@ -0,0 +1,8 @@
+QA output created by 817
+Create the original files
+Reflink the last blocks together
+Compare files
+Compare sections
+End sections of files 1-4 do not match (intentional)
+End sections of files 2-4 do not match (intentional)
+End sections of files 3-4 do not match (intentional)
diff --git a/tests/generic/818 b/tests/generic/818
new file mode 100755
index 0000000..0a99768
--- /dev/null
+++ b/tests/generic/818
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 818
+#
+# Ensure that we can dedupe the last block of a file whose size isn't
+# block-aligned.
+#   - Create two 'a' files file whose size isn't block-aligned.
+#   - Create two 'b' files file whose size isn't block-aligned.
+#   - Dedupe the last block of file1 to the last block in file2 and file3.
+#   - Check that files 1-2 match, and that 3-4 match.
+#   - Check that the ends of 1-2 and 3-4 match, and that 1-3 don't match.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "dedupe"
+_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 + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ + 37))" $TESTDIR/file4 >> $seqres.full
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Dedupe the last blocks together"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $BLKSZ $BLKSZ 37" $TESTDIR/file3 >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+echo "Compare files"
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "Compare sections"
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       || echo "End sections of files 1-2 do not match"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 1-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file1) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 1-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       || echo "End sections of files 2-3 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file2) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 2-4 do not match (intentional)"
+
+cmp -s <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file3) \
+       <($XFS_IO_PROG -f -c "pread -q -v $BLKSZ 37" $TESTDIR/file4) \
+       || echo "End sections of files 3-4 do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/818.out b/tests/generic/818.out
new file mode 100644
index 0000000..242dc8c
--- /dev/null
+++ b/tests/generic/818.out
@@ -0,0 +1,9 @@
+QA output created by 818
+Create the original files
+Dedupe the last blocks together
+Compare files
+Compare sections
+End sections of files 1-3 do not match (intentional)
+End sections of files 1-4 do not match (intentional)
+End sections of files 2-3 do not match (intentional)
+End sections of files 2-4 do not match (intentional)
diff --git a/tests/generic/819 b/tests/generic/819
new file mode 100755
index 0000000..08bc374
--- /dev/null
+++ b/tests/generic/819
@@ -0,0 +1,128 @@
+#! /bin/bash
+# FS QA Test No. 819
+#
+# Ensure that we can reflink and dedupe blocks within the same file...
+#   - Create a file with three distinct blocks ABB
+#   - Reflink block zero to the multiple-of-three blocks
+#   - Reflink block one to the multiple-of-five blocks
+#   - Dedupe block two to the multiple-of-seven blocks
+#   - Check that we successfully avoid deduping with holes, unwritten
+#     extents, and non-matches; but actually dedupe real matches.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
+_require_xfs_io_command "falloc"
+_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')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $((BLKSZ * 2))" $TESTDIR/file1 >> $seqres.full
+
+NR_BLKS=1024
+
+echo "fallocate half the file"
+$XFS_IO_PROG -f -c "falloc $((NR_BLKS * BLKSZ / 2)) $((NR_BLKS * BLKSZ / 2))" $TESTDIR/file1 >> $seqres.full
+
+echo "Reflink block zero to the threes"
+seq 1 $((NR_BLKS / 3)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 $((nr * 3 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+echo "Reflink block one to the fives"
+seq 1 $((NR_BLKS / 5)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $BLKSZ $((nr * 5 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+echo "Dedupe block two to the sevens"
+seq 1 $((NR_BLKS / 7)) | while read nr; do
+	$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((BLKSZ * 2)) $((nr * 7 * BLKSZ)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+done
+
+_test_remount
+
+echo "Check block mappings"
+crcZ=$(_md5_range_checksum /dev/zero 0 $BLKSZ)
+crc0=$(_md5_range_checksum $TESTDIR/file1 0 $BLKSZ)
+crc1=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $BLKSZ)
+crc2=$(_md5_range_checksum $TESTDIR/file1 $((BLKSZ * 2)) $BLKSZ)
+
+check_block() {
+	lblk="$1"
+	rem7=$((lblk % 7))
+	rem5=$((lblk % 5))
+	rem3=$((lblk % 3))
+
+	crc=$(_md5_range_checksum $TESTDIR/file1 $((lblk * BLKSZ)) $BLKSZ)
+
+	if [ $rem7 -eq 0 ]; then
+		if [ $rem5 -eq 0 ]; then
+			test $crc2 = $crc || echo "lblk $lblk doesn't match block 2"
+		elif [ $rem3 -eq 0 ]; then
+			test $crc0 = $crc || echo "lblk $lblk doesn't match block 0"
+		elif [ $lblk -lt $((NR_BLKS / 2)) ]; then
+			test $crcZ = $crc || echo "lblk $lblk isn't zeroed"
+		fi
+	elif [ $rem5 -eq 0 ]; then
+		test $crc1 = $crc || echo "lblk $lblk doesn't match block 1"
+	elif [ $rem3 -eq 0 ]; then
+		test $crc0 = $crc || echo "lblk $lblk doesn't match block 0"
+	elif [ $lblk -lt $((NR_BLKS / 2)) ]; then
+		test $crcZ = $crc || echo "lblk $lblk isn't zeroed"
+	fi
+}
+
+seq 3 $((NR_BLKS - 1)) | while read lblk; do
+	err="$(check_block $lblk)"
+	test -n "$err" && echo "$lblk: $err"
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/819.out b/tests/generic/819.out
new file mode 100644
index 0000000..0ee5b14
--- /dev/null
+++ b/tests/generic/819.out
@@ -0,0 +1,7 @@
+QA output created by 819
+Create the original file blocks
+fallocate half the file
+Reflink block zero to the threes
+Reflink block one to the fives
+Dedupe block two to the sevens
+Check block mappings
diff --git a/tests/generic/group b/tests/generic/group
index d8b21ce..25cffa7 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -210,3 +210,11 @@
 800 auto quick clone
 801 auto quick clone
 802 auto quick clone
+803 auto quick clone
+804 auto quick clone
+805 auto quick clone
+806 auto quick clone
+807 auto quick clone
+817 auto quick clone
+818 auto quick clone
+819 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 05/12] reflink: test CoW behaviors of reflinked files
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Ensure that CoW happens correctly with buffered, directio, and mmap writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 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


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


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 05/12] reflink: test CoW behaviors of reflinked files
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Ensure that CoW happens correctly with buffered, directio, and mmap writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 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


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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 06/12] reflink: test the various fallocate modes
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Check that the variants of fallocate (allocate, punch, zero range,
collapse range, insert range) do the right thing when they're run
against a range of reflinked blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/811     |  126 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/811.out |    6 ++
 tests/generic/812     |  116 +++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/812.out |    5 ++
 tests/generic/813     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/813.out |    5 ++
 tests/generic/814     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/814.out |    5 ++
 tests/generic/815     |  103 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/815.out |    5 ++
 tests/generic/816     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/816.out |    5 ++
 tests/generic/group   |    6 ++
 13 files changed, 718 insertions(+)
 create mode 100755 tests/generic/811
 create mode 100644 tests/generic/811.out
 create mode 100755 tests/generic/812
 create mode 100644 tests/generic/812.out
 create mode 100755 tests/generic/813
 create mode 100644 tests/generic/813.out
 create mode 100755 tests/generic/814
 create mode 100644 tests/generic/814.out
 create mode 100755 tests/generic/815
 create mode 100644 tests/generic/815.out
 create mode 100755 tests/generic/816
 create mode 100644 tests/generic/816.out


diff --git a/tests/generic/811 b/tests/generic/811
new file mode 100755
index 0000000..8d3aa90
--- /dev/null
+++ b/tests/generic/811
@@ -0,0 +1,126 @@
+#! /bin/bash
+# FS QA Test No. 811
+#
+# Ensure that fallocate steps around reflinked ranges:
+#   - Reflink parts of two files together
+#   - Fallocate all the other sparse space.
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "reflink"
+_require_xfs_io_command "falloc"
+_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 "truncate $((BLKSZ * 5))" -c "pwrite -S 0x61 0 $(( (BLKSZ * 5) + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ $(( (BLKSZ * 4) + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 0 0 $BLKSZ" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR/file4 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $((BLKSZ * 3)) $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file4 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file5
+_test_remount
+
+echo "Compare sections"
+c0=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $(( BLKSZ * 4 + 37 )))
+c1=$(_md5_range_checksum $TESTDIR/file2 $BLKSZ $(( BLKSZ * 4 + 37 )))
+test $c0 = $c1 || echo "shared parts of files 1-2 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 0 $BLKSZ)
+c1=$(_md5_range_checksum $TESTDIR/file3 0 $BLKSZ)
+test $c0 = $c1 || echo "shared parts of files 1-3 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $BLKSZ)
+c1=$(_md5_range_checksum $TESTDIR/file4 $BLKSZ $BLKSZ)
+test $c0 = $c1 || echo "shared parts of files 1-4 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 0 $((BLKSZ * 5 + 37)))
+c1=$(_md5_range_checksum $TESTDIR/file5 0 $((BLKSZ * 5 + 37)))
+test $c0 = $c1 || echo "shared parts of files 1-5 changed"
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+C5="$(_md5_checksum $TESTDIR/file5)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C1}"  = "${C5}" || echo "file1 and file5 should match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C2}" != "${C5}" || echo "file2 and file5 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+test "${C3}" != "${C5}" || echo "file3 and file5 should not match"
+test "${C4}" != "${C5}" || echo "file4 and file5 should not match"
+
+echo "falloc everything"
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+D1="$(_md5_checksum $TESTDIR/file1)"
+D2="$(_md5_checksum $TESTDIR/file2)"
+D3="$(_md5_checksum $TESTDIR/file3)"
+D4="$(_md5_checksum $TESTDIR/file4)"
+D5="$(_md5_checksum $TESTDIR/file5)"
+
+test "${C1}" = "${D1}" || echo "file1 should not change"
+test "${C2}" = "${D2}" || echo "file2 should not change"
+test "${C3}" = "${D3}" || echo "file3 should not change"
+test "${C4}" = "${D4}" || echo "file4 should not change"
+test "${C5}" = "${D5}" || echo "file2 should not change"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/811.out b/tests/generic/811.out
new file mode 100644
index 0000000..d9fa011
--- /dev/null
+++ b/tests/generic/811.out
@@ -0,0 +1,6 @@
+QA output created by 811
+Create the original files
+Compare sections
+Compare files
+falloc everything
+Compare files
diff --git a/tests/generic/812 b/tests/generic/812
new file mode 100755
index 0000000..0564ec3
--- /dev/null
+++ b/tests/generic/812
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 812
+#
+# Ensure that collapse range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Collapse the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fcollapse"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file1
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" -c "pwrite -S 0x63 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x63 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fcollapse files"
+$XFS_IO_PROG -f -c "fcollapse 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fcollapse $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/812.out b/tests/generic/812.out
new file mode 100644
index 0000000..6f3e403
--- /dev/null
+++ b/tests/generic/812.out
@@ -0,0 +1,5 @@
+QA output created by 812
+Create the original files
+fcollapse files
+Compare files
+Compare against check files
diff --git a/tests/generic/813 b/tests/generic/813
new file mode 100755
index 0000000..ee399fc
--- /dev/null
+++ b/tests/generic/813
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 813
+#
+# Ensure that punch-hole steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Punch the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fpunch"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fpunch files"
+$XFS_IO_PROG -f -c "fpunch 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fpunch $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fpunch $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/813.out b/tests/generic/813.out
new file mode 100644
index 0000000..c4de817
--- /dev/null
+++ b/tests/generic/813.out
@@ -0,0 +1,5 @@
+QA output created by 813
+Create the original files
+fpunch files
+Compare files
+Compare against check files
diff --git a/tests/generic/814 b/tests/generic/814
new file mode 100755
index 0000000..55ac879
--- /dev/null
+++ b/tests/generic/814
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 814
+#
+# Ensure that insert range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Insert into the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "finsert"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x61 $BLKSZ $BLKSZ" -c "pwrite -S 0x62 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x62 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "finsert files"
+$XFS_IO_PROG -f -c "finsert 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "finsert $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "finsert $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/814.out b/tests/generic/814.out
new file mode 100644
index 0000000..c80eccb
--- /dev/null
+++ b/tests/generic/814.out
@@ -0,0 +1,5 @@
+QA output created by 814
+Create the original files
+finsert files
+Compare files
+Compare against check files
diff --git a/tests/generic/815 b/tests/generic/815
new file mode 100755
index 0000000..eb835ef
--- /dev/null
+++ b/tests/generic/815
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 815
+#
+# Ensure that truncating the last block in a reflinked file CoWs appropriately:
+#   - Create a file that doesn't end on a block boundary
+#   - Create two reflink clones of the file
+#   - Shorten one of the clones with truncate
+#   - Lengthen the other clone with truncate
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "truncate"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 37" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 34" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 37" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x00 $((BLKSZ + 37)) 3" $TESTDIR/file3.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+
+echo "truncate files"
+$XFS_IO_PROG -f -c "truncate $((BLKSZ + 34))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "truncate $((BLKSZ + 40))" $TESTDIR/file3
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/815.out b/tests/generic/815.out
new file mode 100644
index 0000000..1804af5
--- /dev/null
+++ b/tests/generic/815.out
@@ -0,0 +1,5 @@
+QA output created by 815
+Create the original files
+truncate files
+Compare files
+Compare against check files
diff --git a/tests/generic/816 b/tests/generic/816
new file mode 100755
index 0000000..121cde0
--- /dev/null
+++ b/tests/generic/816
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 816
+#
+# Ensure that zero-range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Zero-range the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fzero"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fzero files"
+$XFS_IO_PROG -f -c "fzero 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fzero $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fzero $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/816.out b/tests/generic/816.out
new file mode 100644
index 0000000..2071d87
--- /dev/null
+++ b/tests/generic/816.out
@@ -0,0 +1,5 @@
+QA output created by 816
+Create the original files
+fzero files
+Compare files
+Compare against check files
diff --git a/tests/generic/group b/tests/generic/group
index 6734822..b4ba56a 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -218,6 +218,12 @@
 808 auto quick clone
 809 auto quick clone
 810 auto quick clone
+811 auto quick clone
+812 auto quick clone
+813 auto quick clone
+814 auto quick clone
+815 auto quick clone
+816 auto quick clone
 817 auto quick clone
 818 auto quick clone
 819 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 06/12] reflink: test the various fallocate modes
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Check that the variants of fallocate (allocate, punch, zero range,
collapse range, insert range) do the right thing when they're run
against a range of reflinked blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/811     |  126 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/811.out |    6 ++
 tests/generic/812     |  116 +++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/812.out |    5 ++
 tests/generic/813     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/813.out |    5 ++
 tests/generic/814     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/814.out |    5 ++
 tests/generic/815     |  103 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/815.out |    5 ++
 tests/generic/816     |  112 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/816.out |    5 ++
 tests/generic/group   |    6 ++
 13 files changed, 718 insertions(+)
 create mode 100755 tests/generic/811
 create mode 100644 tests/generic/811.out
 create mode 100755 tests/generic/812
 create mode 100644 tests/generic/812.out
 create mode 100755 tests/generic/813
 create mode 100644 tests/generic/813.out
 create mode 100755 tests/generic/814
 create mode 100644 tests/generic/814.out
 create mode 100755 tests/generic/815
 create mode 100644 tests/generic/815.out
 create mode 100755 tests/generic/816
 create mode 100644 tests/generic/816.out


diff --git a/tests/generic/811 b/tests/generic/811
new file mode 100755
index 0000000..8d3aa90
--- /dev/null
+++ b/tests/generic/811
@@ -0,0 +1,126 @@
+#! /bin/bash
+# FS QA Test No. 811
+#
+# Ensure that fallocate steps around reflinked ranges:
+#   - Reflink parts of two files together
+#   - Fallocate all the other sparse space.
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "reflink"
+_require_xfs_io_command "falloc"
+_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 "truncate $((BLKSZ * 5))" -c "pwrite -S 0x61 0 $(( (BLKSZ * 5) + 37))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ $(( (BLKSZ * 4) + 37))" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 0 0 $BLKSZ" $TESTDIR/file3 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR/file4 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $((BLKSZ * 5))" -c "reflink $TESTDIR/file1 $((BLKSZ * 3)) $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file4 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file5
+_test_remount
+
+echo "Compare sections"
+c0=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $(( BLKSZ * 4 + 37 )))
+c1=$(_md5_range_checksum $TESTDIR/file2 $BLKSZ $(( BLKSZ * 4 + 37 )))
+test $c0 = $c1 || echo "shared parts of files 1-2 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 0 $BLKSZ)
+c1=$(_md5_range_checksum $TESTDIR/file3 0 $BLKSZ)
+test $c0 = $c1 || echo "shared parts of files 1-3 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 $BLKSZ $BLKSZ)
+c1=$(_md5_range_checksum $TESTDIR/file4 $BLKSZ $BLKSZ)
+test $c0 = $c1 || echo "shared parts of files 1-4 changed"
+
+c0=$(_md5_range_checksum $TESTDIR/file1 0 $((BLKSZ * 5 + 37)))
+c1=$(_md5_range_checksum $TESTDIR/file5 0 $((BLKSZ * 5 + 37)))
+test $c0 = $c1 || echo "shared parts of files 1-5 changed"
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+C5="$(_md5_checksum $TESTDIR/file5)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C1}"  = "${C5}" || echo "file1 and file5 should match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C2}" != "${C5}" || echo "file2 and file5 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+test "${C3}" != "${C5}" || echo "file3 and file5 should not match"
+test "${C4}" != "${C5}" || echo "file4 and file5 should not match"
+
+echo "falloc everything"
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 5))" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+D1="$(_md5_checksum $TESTDIR/file1)"
+D2="$(_md5_checksum $TESTDIR/file2)"
+D3="$(_md5_checksum $TESTDIR/file3)"
+D4="$(_md5_checksum $TESTDIR/file4)"
+D5="$(_md5_checksum $TESTDIR/file5)"
+
+test "${C1}" = "${D1}" || echo "file1 should not change"
+test "${C2}" = "${D2}" || echo "file2 should not change"
+test "${C3}" = "${D3}" || echo "file3 should not change"
+test "${C4}" = "${D4}" || echo "file4 should not change"
+test "${C5}" = "${D5}" || echo "file2 should not change"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/811.out b/tests/generic/811.out
new file mode 100644
index 0000000..d9fa011
--- /dev/null
+++ b/tests/generic/811.out
@@ -0,0 +1,6 @@
+QA output created by 811
+Create the original files
+Compare sections
+Compare files
+falloc everything
+Compare files
diff --git a/tests/generic/812 b/tests/generic/812
new file mode 100755
index 0000000..0564ec3
--- /dev/null
+++ b/tests/generic/812
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 812
+#
+# Ensure that collapse range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Collapse the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fcollapse"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file1
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "falloc 0 $((BLKSZ * 4))" $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" -c "pwrite -S 0x63 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x63 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fcollapse files"
+$XFS_IO_PROG -f -c "fcollapse 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fcollapse $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/812.out b/tests/generic/812.out
new file mode 100644
index 0000000..6f3e403
--- /dev/null
+++ b/tests/generic/812.out
@@ -0,0 +1,5 @@
+QA output created by 812
+Create the original files
+fcollapse files
+Compare files
+Compare against check files
diff --git a/tests/generic/813 b/tests/generic/813
new file mode 100755
index 0000000..ee399fc
--- /dev/null
+++ b/tests/generic/813
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 813
+#
+# Ensure that punch-hole steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Punch the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fpunch"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fpunch files"
+$XFS_IO_PROG -f -c "fpunch 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fpunch $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fpunch $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/813.out b/tests/generic/813.out
new file mode 100644
index 0000000..c4de817
--- /dev/null
+++ b/tests/generic/813.out
@@ -0,0 +1,5 @@
+QA output created by 813
+Create the original files
+fpunch files
+Compare files
+Compare against check files
diff --git a/tests/generic/814 b/tests/generic/814
new file mode 100755
index 0000000..55ac879
--- /dev/null
+++ b/tests/generic/814
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 814
+#
+# Ensure that insert range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Insert into the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "finsert"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x61 $BLKSZ $BLKSZ" -c "pwrite -S 0x62 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x62 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 3)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "finsert files"
+$XFS_IO_PROG -f -c "finsert 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "finsert $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "finsert $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/814.out b/tests/generic/814.out
new file mode 100644
index 0000000..c80eccb
--- /dev/null
+++ b/tests/generic/814.out
@@ -0,0 +1,5 @@
+QA output created by 814
+Create the original files
+finsert files
+Compare files
+Compare against check files
diff --git a/tests/generic/815 b/tests/generic/815
new file mode 100755
index 0000000..eb835ef
--- /dev/null
+++ b/tests/generic/815
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 815
+#
+# Ensure that truncating the last block in a reflinked file CoWs appropriately:
+#   - Create a file that doesn't end on a block boundary
+#   - Create two reflink clones of the file
+#   - Shorten one of the clones with truncate
+#   - Lengthen the other clone with truncate
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "truncate"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 37" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 34" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ 37" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x00 $((BLKSZ + 37)) 3" $TESTDIR/file3.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+
+echo "truncate files"
+$XFS_IO_PROG -f -c "truncate $((BLKSZ + 34))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "truncate $((BLKSZ + 40))" $TESTDIR/file3
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/815.out b/tests/generic/815.out
new file mode 100644
index 0000000..1804af5
--- /dev/null
+++ b/tests/generic/815.out
@@ -0,0 +1,5 @@
+QA output created by 815
+Create the original files
+truncate files
+Compare files
+Compare against check files
diff --git a/tests/generic/816 b/tests/generic/816
new file mode 100755
index 0000000..121cde0
--- /dev/null
+++ b/tests/generic/816
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 816
+#
+# Ensure that zero-range steps around reflinked ranges:
+#   - Create three reflink clones of a file
+#   - Zero-range the start, middle, and end of the reflink range of each
+#     of the three files, respectively
+#   - Check that the reflinked areas are still there.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fzero"
+_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" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file4
+
+$XFS_IO_PROG -f -c "pwrite -S 0x00 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file2.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x00 $BLKSZ $BLKSZ" -c "pwrite -S 0x63 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file3.chk >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" -c "pwrite -S 0x62 $BLKSZ $BLKSZ" -c "pwrite -S 0x00 $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4.chk >> $seqres.full
+_test_remount
+
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" = "${C2}" || echo "file1 and file2 should match"
+test "${C1}" = "${C3}" || echo "file1 and file3 should match"
+test "${C1}" = "${C4}" || echo "file1 and file4 should match"
+test "${C2}" = "${C3}" || echo "file2 and file3 should match"
+test "${C2}" = "${C4}" || echo "file2 and file4 should match"
+test "${C3}" = "${C4}" || echo "file3 and file4 should match"
+
+echo "fzero files"
+$XFS_IO_PROG -f -c "fzero 0 $BLKSZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fzero $BLKSZ $BLKSZ" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fzero $((BLKSZ * 2)) $BLKSZ" $TESTDIR/file4
+_test_remount
+
+echo "Compare files"
+C1="$(_md5_checksum $TESTDIR/file1)"
+C2="$(_md5_checksum $TESTDIR/file2)"
+C3="$(_md5_checksum $TESTDIR/file3)"
+C4="$(_md5_checksum $TESTDIR/file4)"
+
+test "${C1}" != "${C2}" || echo "file1 and file2 should not match"
+test "${C1}" != "${C3}" || echo "file1 and file3 should not match"
+test "${C1}" != "${C4}" || echo "file1 and file4 should not match"
+test "${C2}" != "${C3}" || echo "file2 and file3 should not match"
+test "${C2}" != "${C4}" || echo "file2 and file4 should not match"
+test "${C3}" != "${C4}" || echo "file3 and file4 should not match"
+
+echo "Compare against check files"
+cmp -s $TESTDIR/file2 $TESTDIR/file2.chk || echo "file2 and file2.chk do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file3.chk || echo "file3 and file3.chk do not match"
+cmp -s $TESTDIR/file4 $TESTDIR/file4.chk || echo "file4 and file4.chk do not match"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/816.out b/tests/generic/816.out
new file mode 100644
index 0000000..2071d87
--- /dev/null
+++ b/tests/generic/816.out
@@ -0,0 +1,5 @@
+QA output created by 816
+Create the original files
+fzero files
+Compare files
+Compare against check files
diff --git a/tests/generic/group b/tests/generic/group
index 6734822..b4ba56a 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -218,6 +218,12 @@
 808 auto quick clone
 809 auto quick clone
 810 auto quick clone
+811 auto quick clone
+812 auto quick clone
+813 auto quick clone
+814 auto quick clone
+815 auto quick clone
+816 auto quick clone
 817 auto quick clone
 818 auto quick clone
 819 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 07/12] reflink: concurrent operations tests
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Make sure that running reflink ops while other IO is ongoing doesn't
break the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/821     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/821.out |    6 +++
 tests/generic/822     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/822.out |    6 +++
 tests/generic/823     |   94 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/823.out |    6 +++
 tests/generic/824     |   95 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/824.out |    6 +++
 tests/generic/825     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/825.out |    7 +++
 tests/generic/826     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/826.out |    7 +++
 tests/generic/827     |   98 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/827.out |    7 +++
 tests/generic/828     |   98 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/828.out |    7 +++
 tests/generic/829     |   84 ++++++++++++++++++++++++++++++++++++++
 tests/generic/829.out |    6 +++
 tests/generic/group   |    9 ++++
 19 files changed, 944 insertions(+)
 create mode 100755 tests/generic/821
 create mode 100644 tests/generic/821.out
 create mode 100755 tests/generic/822
 create mode 100644 tests/generic/822.out
 create mode 100755 tests/generic/823
 create mode 100644 tests/generic/823.out
 create mode 100755 tests/generic/824
 create mode 100644 tests/generic/824.out
 create mode 100755 tests/generic/825
 create mode 100644 tests/generic/825.out
 create mode 100755 tests/generic/826
 create mode 100644 tests/generic/826.out
 create mode 100755 tests/generic/827
 create mode 100644 tests/generic/827.out
 create mode 100755 tests/generic/828
 create mode 100644 tests/generic/828.out
 create mode 100755 tests/generic/829
 create mode 100644 tests/generic/829.out


diff --git a/tests/generic/821 b/tests/generic/821
new file mode 100755
index 0000000..77393cb
--- /dev/null
+++ b/tests/generic/821
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 821
+#
+# Test for race between direct I/O and reflink
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+
+# Direct I/O overwriter...
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=/dev/zero of=$TESTDIR/file2 oflag=direct bs=$iosize count=$loops conv=notrunc 2> /dev/null
+	done
+}
+
+echo "Reflink and dio write the target"
+overwrite &
+start=`expr $loops - 1`
+for i in `seq $start -1 0`
+do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+	[ $? -ne 0 ] && exit
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/821.out b/tests/generic/821.out
new file mode 100644
index 0000000..ca6bc53
--- /dev/null
+++ b/tests/generic/821.out
@@ -0,0 +1,6 @@
+QA output created by 821
+Format and mount
+Initialize files
+Reflink and dio write the target
+Check for damage
+Done
diff --git a/tests/generic/822 b/tests/generic/822
new file mode 100755
index 0000000..6ee7a8c
--- /dev/null
+++ b/tests/generic/822
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 822
+#
+# Test for race between buffered I/O and reflink
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+
+# Buffered I/O overwriter...
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=/dev/zero of=$TESTDIR/file2 bs=$iosize count=$loops conv=notrunc 2> /dev/null
+	done
+}
+
+echo "reflink while overwriting target"
+overwrite &
+start=`expr $loops - 1`
+for i in `seq $start -1 0`
+do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+	[ $? -ne 0 ] && exit
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/822.out b/tests/generic/822.out
new file mode 100644
index 0000000..4c86f97
--- /dev/null
+++ b/tests/generic/822.out
@@ -0,0 +1,6 @@
+QA output created by 822
+Format and mount
+Initialize file
+reflink while overwriting target
+Check for damage
+Done
diff --git a/tests/generic/823 b/tests/generic/823
new file mode 100755
index 0000000..bf3a712
--- /dev/null
+++ b/tests/generic/823
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 823
+#
+# Test for race between buffered I/O while creating reflink snapshots
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e $TESTDIR/finished ]; do
+		cp --reflink=always $TESTDIR/file1 $TESTDIR/snap_$n || break
+		n=$((n + 1))
+	done
+}
+
+echo "Snapshot a file undergoing buffered rewrite"
+snappy &
+for i in `seq 1 5`; do
+	dd if=/dev/zero of=$TESTDIR/file1 bs=$iosize count=$loops conv=notrunc 2> /dev/null
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/823.out b/tests/generic/823.out
new file mode 100644
index 0000000..ef3e209
--- /dev/null
+++ b/tests/generic/823.out
@@ -0,0 +1,6 @@
+QA output created by 823
+Format and mount
+Initialize file
+Snapshot a file undergoing buffered rewrite
+Check for damage
+Done
diff --git a/tests/generic/824 b/tests/generic/824
new file mode 100755
index 0000000..38737c6
--- /dev/null
+++ b/tests/generic/824
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 824
+#
+# Test for race between direct I/O while creating reflink snapshots
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e $TESTDIR/finished ]; do
+		cp --reflink=always $TESTDIR/file1 $TESTDIR/snap_$n || break
+		n=$((n + 1))
+	done
+}
+
+echo "Snapshot a file while directio rewriting it"
+snappy &
+touch $TESTDIR/running
+for i in `seq 1 5`; do
+	dd if=/dev/zero of=$TESTDIR/file1 oflag=direct bs=$iosize count=$loops conv=notrunc 2> /dev/null
+done
+mv $TESTDIR/running $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/824.out b/tests/generic/824.out
new file mode 100644
index 0000000..27c9bc0
--- /dev/null
+++ b/tests/generic/824.out
@@ -0,0 +1,6 @@
+QA output created by 824
+Format and mount
+Initialize file
+Snapshot a file while directio rewriting it
+Check for damage
+Done
diff --git a/tests/generic/825 b/tests/generic/825
new file mode 100755
index 0000000..476527a
--- /dev/null
+++ b/tests/generic/825
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 825
+#
+# Test for race between reflink and direct I/O reading the target file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+sync
+
+reader() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=$TESTDIR/file3 iflag=direct 2> /dev/null | od -tx1 -Ax | while read addr rest; do
+				test -n "$rest" && echo "$rest"
+		done | egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+	done
+}
+
+echo "Reflink and dio reread the files!"
+reader &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file2 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished reflinking"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/825.out b/tests/generic/825.out
new file mode 100644
index 0000000..1e2f36c
--- /dev/null
+++ b/tests/generic/825.out
@@ -0,0 +1,7 @@
+QA output created by 825
+Format and mount
+Initialize files
+Reflink and dio reread the files!
+Finished reflinking
+Check fs
+Done
diff --git a/tests/generic/826 b/tests/generic/826
new file mode 100755
index 0000000..1739778
--- /dev/null
+++ b/tests/generic/826
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 826
+#
+# Test for race between reflink and buffered I/O reading the target file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+sync
+
+reader() {
+	while [ ! -e $TESTDIR/finished ]; do
+		cat $TESTDIR/file3 | od -tx1 -Ax | while read addr rest; do
+				test -n "$rest" && echo "$rest"
+		done | egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+	done
+}
+
+echo "Reflink and reread the files!"
+reader &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file2 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished reflinking"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/826.out b/tests/generic/826.out
new file mode 100644
index 0000000..144f4bc
--- /dev/null
+++ b/tests/generic/826.out
@@ -0,0 +1,7 @@
+QA output created by 826
+Format and mount
+Initialize files
+Reflink and reread the files!
+Finished reflinking
+Check fs
+Done
diff --git a/tests/generic/827 b/tests/generic/827
new file mode 100755
index 0000000..fa2ba2e
--- /dev/null
+++ b/tests/generic/827
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 827
+#
+# Test for race between dedupe and writing the source file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+sync
+
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+	done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished dedupeing"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/827.out b/tests/generic/827.out
new file mode 100644
index 0000000..1b05f59
--- /dev/null
+++ b/tests/generic/827.out
@@ -0,0 +1,7 @@
+QA output created by 827
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
diff --git a/tests/generic/828 b/tests/generic/828
new file mode 100755
index 0000000..43b1682
--- /dev/null
+++ b/tests/generic/828
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 828
+#
+# Test for race between dedupe and writing the dest file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+sync
+
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+	done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished dedupeing"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/828.out b/tests/generic/828.out
new file mode 100644
index 0000000..fb31777
--- /dev/null
+++ b/tests/generic/828.out
@@ -0,0 +1,7 @@
+QA output created by 828
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
diff --git a/tests/generic/829 b/tests/generic/829
new file mode 100755
index 0000000..76fe937
--- /dev/null
+++ b/tests/generic/829
@@ -0,0 +1,84 @@
+#! /bin/bash
+# FS QA Test No. 829
+#
+# Test for race between delete a file while rewriting its reflinked twin
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=4096
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+sync
+
+echo "Delete while rewriting"
+rm -rf $TESTDIR/file1 &
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/829.out b/tests/generic/829.out
new file mode 100644
index 0000000..9cee8ba
--- /dev/null
+++ b/tests/generic/829.out
@@ -0,0 +1,6 @@
+QA output created by 829
+Format and mount
+Initialize files
+Delete while rewriting
+Check fs
+Done
diff --git a/tests/generic/group b/tests/generic/group
index b4ba56a..7f70690 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -227,5 +227,14 @@
 817 auto quick clone
 818 auto quick clone
 819 auto quick clone
+821 auto quick clone
+822 auto quick clone
+823 auto quick clone
+824 auto quick clone
+825 auto quick clone
+826 auto quick clone
+827 auto quick clone
+828 auto quick clone
+829 auto quick clone
 837 auto quick clone
 838 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 07/12] reflink: concurrent operations tests
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Make sure that running reflink ops while other IO is ongoing doesn't
break the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/821     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/821.out |    6 +++
 tests/generic/822     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/822.out |    6 +++
 tests/generic/823     |   94 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/823.out |    6 +++
 tests/generic/824     |   95 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/824.out |    6 +++
 tests/generic/825     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/825.out |    7 +++
 tests/generic/826     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/826.out |    7 +++
 tests/generic/827     |   98 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/827.out |    7 +++
 tests/generic/828     |   98 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/828.out |    7 +++
 tests/generic/829     |   84 ++++++++++++++++++++++++++++++++++++++
 tests/generic/829.out |    6 +++
 tests/generic/group   |    9 ++++
 19 files changed, 944 insertions(+)
 create mode 100755 tests/generic/821
 create mode 100644 tests/generic/821.out
 create mode 100755 tests/generic/822
 create mode 100644 tests/generic/822.out
 create mode 100755 tests/generic/823
 create mode 100644 tests/generic/823.out
 create mode 100755 tests/generic/824
 create mode 100644 tests/generic/824.out
 create mode 100755 tests/generic/825
 create mode 100644 tests/generic/825.out
 create mode 100755 tests/generic/826
 create mode 100644 tests/generic/826.out
 create mode 100755 tests/generic/827
 create mode 100644 tests/generic/827.out
 create mode 100755 tests/generic/828
 create mode 100644 tests/generic/828.out
 create mode 100755 tests/generic/829
 create mode 100644 tests/generic/829.out


diff --git a/tests/generic/821 b/tests/generic/821
new file mode 100755
index 0000000..77393cb
--- /dev/null
+++ b/tests/generic/821
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 821
+#
+# Test for race between direct I/O and reflink
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+
+# Direct I/O overwriter...
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=/dev/zero of=$TESTDIR/file2 oflag=direct bs=$iosize count=$loops conv=notrunc 2> /dev/null
+	done
+}
+
+echo "Reflink and dio write the target"
+overwrite &
+start=`expr $loops - 1`
+for i in `seq $start -1 0`
+do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+	[ $? -ne 0 ] && exit
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/821.out b/tests/generic/821.out
new file mode 100644
index 0000000..ca6bc53
--- /dev/null
+++ b/tests/generic/821.out
@@ -0,0 +1,6 @@
+QA output created by 821
+Format and mount
+Initialize files
+Reflink and dio write the target
+Check for damage
+Done
diff --git a/tests/generic/822 b/tests/generic/822
new file mode 100755
index 0000000..6ee7a8c
--- /dev/null
+++ b/tests/generic/822
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 822
+#
+# Test for race between buffered I/O and reflink
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+
+# Buffered I/O overwriter...
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=/dev/zero of=$TESTDIR/file2 bs=$iosize count=$loops conv=notrunc 2> /dev/null
+	done
+}
+
+echo "reflink while overwriting target"
+overwrite &
+start=`expr $loops - 1`
+for i in `seq $start -1 0`
+do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+	[ $? -ne 0 ] && exit
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/822.out b/tests/generic/822.out
new file mode 100644
index 0000000..4c86f97
--- /dev/null
+++ b/tests/generic/822.out
@@ -0,0 +1,6 @@
+QA output created by 822
+Format and mount
+Initialize file
+reflink while overwriting target
+Check for damage
+Done
diff --git a/tests/generic/823 b/tests/generic/823
new file mode 100755
index 0000000..bf3a712
--- /dev/null
+++ b/tests/generic/823
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 823
+#
+# Test for race between buffered I/O while creating reflink snapshots
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e $TESTDIR/finished ]; do
+		cp --reflink=always $TESTDIR/file1 $TESTDIR/snap_$n || break
+		n=$((n + 1))
+	done
+}
+
+echo "Snapshot a file undergoing buffered rewrite"
+snappy &
+for i in `seq 1 5`; do
+	dd if=/dev/zero of=$TESTDIR/file1 bs=$iosize count=$loops conv=notrunc 2> /dev/null
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/823.out b/tests/generic/823.out
new file mode 100644
index 0000000..ef3e209
--- /dev/null
+++ b/tests/generic/823.out
@@ -0,0 +1,6 @@
+QA output created by 823
+Format and mount
+Initialize file
+Snapshot a file undergoing buffered rewrite
+Check for damage
+Done
diff --git a/tests/generic/824 b/tests/generic/824
new file mode 100755
index 0000000..38737c6
--- /dev/null
+++ b/tests/generic/824
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 824
+#
+# Test for race between direct I/O while creating reflink snapshots
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=1024
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize file"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e $TESTDIR/finished ]; do
+		cp --reflink=always $TESTDIR/file1 $TESTDIR/snap_$n || break
+		n=$((n + 1))
+	done
+}
+
+echo "Snapshot a file while directio rewriting it"
+snappy &
+touch $TESTDIR/running
+for i in `seq 1 5`; do
+	dd if=/dev/zero of=$TESTDIR/file1 oflag=direct bs=$iosize count=$loops conv=notrunc 2> /dev/null
+done
+mv $TESTDIR/running $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/824.out b/tests/generic/824.out
new file mode 100644
index 0000000..27c9bc0
--- /dev/null
+++ b/tests/generic/824.out
@@ -0,0 +1,6 @@
+QA output created by 824
+Format and mount
+Initialize file
+Snapshot a file while directio rewriting it
+Check for damage
+Done
diff --git a/tests/generic/825 b/tests/generic/825
new file mode 100755
index 0000000..476527a
--- /dev/null
+++ b/tests/generic/825
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 825
+#
+# Test for race between reflink and direct I/O reading the target file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+sync
+
+reader() {
+	while [ ! -e $TESTDIR/finished ]; do
+		dd if=$TESTDIR/file3 iflag=direct 2> /dev/null | od -tx1 -Ax | while read addr rest; do
+				test -n "$rest" && echo "$rest"
+		done | egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+	done
+}
+
+echo "Reflink and dio reread the files!"
+reader &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file2 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished reflinking"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/825.out b/tests/generic/825.out
new file mode 100644
index 0000000..1e2f36c
--- /dev/null
+++ b/tests/generic/825.out
@@ -0,0 +1,7 @@
+QA output created by 825
+Format and mount
+Initialize files
+Reflink and dio reread the files!
+Finished reflinking
+Check fs
+Done
diff --git a/tests/generic/826 b/tests/generic/826
new file mode 100755
index 0000000..1739778
--- /dev/null
+++ b/tests/generic/826
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 826
+#
+# Test for race between reflink and buffered I/O reading the target file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file3
+sync
+
+reader() {
+	while [ ! -e $TESTDIR/finished ]; do
+		cat $TESTDIR/file3 | od -tx1 -Ax | while read addr rest; do
+				test -n "$rest" && echo "$rest"
+		done | egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+	done
+}
+
+echo "Reflink and reread the files!"
+reader &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "reflink $TESTDIR/file2 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file3 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished reflinking"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/826.out b/tests/generic/826.out
new file mode 100644
index 0000000..144f4bc
--- /dev/null
+++ b/tests/generic/826.out
@@ -0,0 +1,7 @@
+QA output created by 826
+Format and mount
+Initialize files
+Reflink and reread the files!
+Finished reflinking
+Check fs
+Done
diff --git a/tests/generic/827 b/tests/generic/827
new file mode 100755
index 0000000..fa2ba2e
--- /dev/null
+++ b/tests/generic/827
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 827
+#
+# Test for race between dedupe and writing the source file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+sync
+
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+	done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished dedupeing"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/827.out b/tests/generic/827.out
new file mode 100644
index 0000000..1b05f59
--- /dev/null
+++ b/tests/generic/827.out
@@ -0,0 +1,7 @@
+QA output created by 827
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
diff --git a/tests/generic/828 b/tests/generic/828
new file mode 100755
index 0000000..43b1682
--- /dev/null
+++ b/tests/generic/828
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 828
+#
+# Test for race between dedupe and writing the dest file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=512
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+sync
+
+overwrite() {
+	while [ ! -e $TESTDIR/finished ]; do
+		$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file2 >> $seqres.full
+	done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+	start=`expr $loops - 1`
+	for i in `seq $start -1 0`
+	do
+		$XFS_IO_PROG -f -c "dedupe $TESTDIR/file1 $((i * iosize)) $((i * iosize)) $iosize" $TESTDIR/file2 >> $seqres.full
+		[ $? -ne 0 ] && break
+	done
+done
+echo "Finished dedupeing"
+touch $TESTDIR/finished
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/828.out b/tests/generic/828.out
new file mode 100644
index 0000000..fb31777
--- /dev/null
+++ b/tests/generic/828.out
@@ -0,0 +1,7 @@
+QA output created by 828
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
diff --git a/tests/generic/829 b/tests/generic/829
new file mode 100755
index 0000000..76fe937
--- /dev/null
+++ b/tests/generic/829
@@ -0,0 +1,84 @@
+#! /bin/bash
+# FS QA Test No. 829
+#
+# Test for race between delete a file while rewriting its reflinked twin
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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 7 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+    wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "reflink"
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+loops=4096
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+iosize=$((BLKSZ * 16))
+
+echo "Initialize files"
+echo > $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+sync
+
+echo "Delete while rewriting"
+rm -rf $TESTDIR/file1 &
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((loops * iosize))" $TESTDIR/file1 >> $seqres.full
+wait
+
+echo "Check fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
diff --git a/tests/generic/829.out b/tests/generic/829.out
new file mode 100644
index 0000000..9cee8ba
--- /dev/null
+++ b/tests/generic/829.out
@@ -0,0 +1,6 @@
+QA output created by 829
+Format and mount
+Initialize files
+Delete while rewriting
+Check fs
+Done
diff --git a/tests/generic/group b/tests/generic/group
index b4ba56a..7f70690 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -227,5 +227,14 @@
 817 auto quick clone
 818 auto quick clone
 819 auto quick clone
+821 auto quick clone
+822 auto quick clone
+823 auto quick clone
+824 auto quick clone
+825 auto quick clone
+826 auto quick clone
+827 auto quick clone
+828 auto quick clone
+829 auto quick clone
 837 auto quick clone
 838 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 08/12] reflink: test accuracy of free block counts
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Check that the free block counts seem to be handled correctly in
the reflink operation and subsequent attempts to rewrite reflinked
copies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/830     |   79 +++++++++++++++++++++++++++
 tests/generic/830.out |    4 +
 tests/generic/831     |   99 ++++++++++++++++++++++++++++++++++
 tests/generic/831.out |    8 +++
 tests/generic/832     |  116 +++++++++++++++++++++++++++++++++++++++
 tests/generic/832.out |   14 +++++
 tests/generic/833     |  116 +++++++++++++++++++++++++++++++++++++++
 tests/generic/833.out |   14 +++++
 tests/generic/834     |  122 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/834.out |   17 ++++++
 tests/generic/835     |  127 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/835.out |   17 ++++++
 tests/generic/836     |  144 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/836.out |   32 +++++++++++
 tests/generic/group   |    7 ++
 15 files changed, 916 insertions(+)
 create mode 100755 tests/generic/830
 create mode 100644 tests/generic/830.out
 create mode 100755 tests/generic/831
 create mode 100644 tests/generic/831.out
 create mode 100755 tests/generic/832
 create mode 100644 tests/generic/832.out
 create mode 100755 tests/generic/833
 create mode 100644 tests/generic/833.out
 create mode 100755 tests/generic/834
 create mode 100644 tests/generic/834.out
 create mode 100755 tests/generic/835
 create mode 100644 tests/generic/835.out
 create mode 100755 tests/generic/836
 create mode 100644 tests/generic/836.out


diff --git a/tests/generic/830 b/tests/generic/830
new file mode 100755
index 0000000..2d9a7af
--- /dev/null
+++ b/tests/generic/830
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 830
+#
+# Ensure that reflinking a file N times doesn't eat a lot of blocks
+#   - Create a file and record fs block usage
+#   - Create some reflink copies
+#   - Compare fs block usage to before
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+NR=7
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file.$i
+done
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/830.out b/tests/generic/830.out
new file mode 100644
index 0000000..76e2f1d
--- /dev/null
+++ b/tests/generic/830.out
@@ -0,0 +1,4 @@
+QA output created by 830
+Create the original file blocks
+Create the reflink copies
+free blocks after reflink is in range
diff --git a/tests/generic/831 b/tests/generic/831
new file mode 100755
index 0000000..cbf9723
--- /dev/null
+++ b/tests/generic/831
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 831
+#
+# Ensure that deleting all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Delete some copies of the file
+#   - Record fs block usage (2)
+#   - Delete all copies of the file
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=7
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file.$i
+done
+cp --reflink=always $TESTDIR/file1 $TESTDIR/survivor
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Delete most of the files"
+rm -rf $TESTDIR/file*
+_test_remount
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Delete all the files"
+rm -rf $TESTDIR/*
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after deleting some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after deleting all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/831.out b/tests/generic/831.out
new file mode 100644
index 0000000..88e0a23
--- /dev/null
+++ b/tests/generic/831.out
@@ -0,0 +1,8 @@
+QA output created by 831
+Create the original file blocks
+Create the reflink copies
+Delete most of the files
+Delete all the files
+free blocks after reflink is in range
+free blocks after deleting some reflink copies is in range
+free blocks after deleting all copies is in range
diff --git a/tests/generic/832 b/tests/generic/832
new file mode 100755
index 0000000..3b1e7d2
--- /dev/null
+++ b/tests/generic/832
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 832
+#
+# Ensure that punching all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Punch some blocks of the copies
+#   - Record fs block usage (2)
+#   - Punch all blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fpunch"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Punch most of the blocks"
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fpunch $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Punch all the files"
+for i in `seq 2 $NR`; do
+	$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file$i
+done
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file1
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after punching some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after punching all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/832.out b/tests/generic/832.out
new file mode 100644
index 0000000..c99c6fc
--- /dev/null
+++ b/tests/generic/832.out
@@ -0,0 +1,14 @@
+QA output created by 832
+Create the original file blocks
+Create the reflink copies
+Punch most of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Punch all the files
+free blocks after reflink is in range
+free blocks after punching some reflink copies is in range
+free blocks after punching all copies is in range
diff --git a/tests/generic/833 b/tests/generic/833
new file mode 100755
index 0000000..bd635d7
--- /dev/null
+++ b/tests/generic/833
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 833
+#
+# Ensure that collapse-range on all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Collapse-range some blocks of the copies
+#   - Record fs block usage (2)
+#   - Truncate all blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fcollapse"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Collapse most of the blocks"
+$XFS_IO_PROG -f -c "fcollapse 0 $(((BLKS - 1) * BLKSZ))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fcollapse 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse $((BLKS / 2 * BLKSZ)) $(( ((BLKS / 2) - 1) * BLKSZ))" $TESTDIR/file4
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Collpase nearly all the files"
+$XFS_IO_PROG -f -c "fcollapse 0 $(( ((BLKS / 2) - 1) * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse 0 $(( (BLKS / 2) * BLKSZ))" $TESTDIR/file4
+$XFS_IO_PROG -f -c "fcollapse 0 $(( (BLKS - 1) * BLKSZ))" $TESTDIR/file1
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after fcollapsing some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after fcollapsing all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/833.out b/tests/generic/833.out
new file mode 100644
index 0000000..bdbd36f
--- /dev/null
+++ b/tests/generic/833.out
@@ -0,0 +1,14 @@
+QA output created by 833
+Create the original file blocks
+Create the reflink copies
+Collapse most of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Collpase nearly all the files
+free blocks after reflink is in range
+free blocks after fcollapsing some reflink copies is in range
+free blocks after fcollapsing all copies is in range
diff --git a/tests/generic/834 b/tests/generic/834
new file mode 100755
index 0000000..598cf8a
--- /dev/null
+++ b/tests/generic/834
@@ -0,0 +1,122 @@
+#! /bin/bash
+# FS QA Test No. 834
+#
+# Ensure that CoW on all copies of a file reflinked N times increases block count
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - CoW some blocks of the copies
+#   - Record fs block usage (2)
+#   - CoW all the rest of the blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=2000
+MARGIN=100
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKS * BLKSZ))" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite some of the blocks"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x64 $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite all the files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKS * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x64 0 $((BLKS * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after partially CoWing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after CoWing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/834.out b/tests/generic/834.out
new file mode 100644
index 0000000..23fb663
--- /dev/null
+++ b/tests/generic/834.out
@@ -0,0 +1,17 @@
+QA output created by 834
+Create the original file blocks
+Create the reflink copies
+Rewrite some of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Rewrite all the files
+Rewrite the original file
+free blocks after reflinking is in range
+free blocks after partially CoWing some copies is in range
+free blocks after CoWing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/835 b/tests/generic/835
new file mode 100755
index 0000000..22bd768
--- /dev/null
+++ b/tests/generic/835
@@ -0,0 +1,127 @@
+#! /bin/bash
+# FS QA Test No. 835
+#
+# Ensure that CoW on all copies of a file reflinked N times increases block count
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - CoW some blocks of the copies
+#   - Record fs block usage (2)
+#   - CoW all the rest of the blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+# The main difference from 834 is that we use zero range, directio, and
+# mmap to mix things up a bit.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fzero"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite some of the blocks"
+$XFS_IO_PROG -f -c "fzero 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -d -f -c "pwrite -S 0x63 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKS * BLKSZ))" -c "mwrite -S 0x64 $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite all the files"
+$XFS_IO_PROG -d -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKS * BLKSZ))" -c "mwrite -S 0x63 0 $((BLKS * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "fzero 0 $((BLKS * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after partially CoWing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after CoWing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/835.out b/tests/generic/835.out
new file mode 100644
index 0000000..a601ee2
--- /dev/null
+++ b/tests/generic/835.out
@@ -0,0 +1,17 @@
+QA output created by 835
+Create the original file blocks
+Create the reflink copies
+Rewrite some of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Rewrite all the files
+Rewrite the original file
+free blocks after reflinking is in range
+free blocks after partially CoWing some copies is in range
+free blocks after CoWing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/836 b/tests/generic/836
new file mode 100755
index 0000000..9bc81c5
--- /dev/null
+++ b/tests/generic/836
@@ -0,0 +1,144 @@
+#! /bin/bash
+# FS QA Test No. 836
+#
+# Ensure that funshare on reflinked files actually CoWs the files and
+# removes the inode flag.
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - funshare the copies
+#   - chattr +C the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#   - Compare the extent lists of the copies
+#
+#-----------------------------------------------------------------------
+# 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/attr
+
+if [ $FSTYP = "btrfs" ]; then
+	_notrun "btrfs doesn't handle funshare"
+fi
+
+# real QA test starts here
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "funshare"
+_require_cp_reflink
+_require_test
+_require_attrs
+
+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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare part of a file"
+$XFS_IO_PROG -f -c "funshare 0 $((SZ / 2))" $TESTDIR/file2
+_test_remount
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare some of the copies"
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file3
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare the rest of the files"
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file4
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file1
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after nocow'ing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after nocow'ing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/836.out b/tests/generic/836.out
new file mode 100644
index 0000000..45f7750
--- /dev/null
+++ b/tests/generic/836.out
@@ -0,0 +1,32 @@
+QA output created by 836
+Create the original file blocks
+Create the reflink copies
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          ---
+TEST_DIR/test-836/file3          ---
+TEST_DIR/test-836/file4          ---
+funshare part of a file
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          ---
+TEST_DIR/test-836/file3          ---
+TEST_DIR/test-836/file4          ---
+funshare some of the copies
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          ---
+funshare the rest of the files
+TEST_DIR/test-836/file1          No_COW
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          No_COW
+Rewrite the original file
+TEST_DIR/test-836/file1          No_COW
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          No_COW
+free blocks after reflinking is in range
+free blocks after nocow'ing some copies is in range
+free blocks after nocow'ing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/group b/tests/generic/group
index 7f70690..353e23c 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -236,5 +236,12 @@
 827 auto quick clone
 828 auto quick clone
 829 auto quick clone
+830 auto quick clone
+831 auto quick clone
+832 auto quick clone
+833 auto quick clone
+834 auto quick clone
+835 auto quick clone
+836 auto quick clone
 837 auto quick clone
 838 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 08/12] reflink: test accuracy of free block counts
@ 2015-10-07  5:13   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Check that the free block counts seem to be handled correctly in
the reflink operation and subsequent attempts to rewrite reflinked
copies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/830     |   79 +++++++++++++++++++++++++++
 tests/generic/830.out |    4 +
 tests/generic/831     |   99 ++++++++++++++++++++++++++++++++++
 tests/generic/831.out |    8 +++
 tests/generic/832     |  116 +++++++++++++++++++++++++++++++++++++++
 tests/generic/832.out |   14 +++++
 tests/generic/833     |  116 +++++++++++++++++++++++++++++++++++++++
 tests/generic/833.out |   14 +++++
 tests/generic/834     |  122 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/834.out |   17 ++++++
 tests/generic/835     |  127 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/835.out |   17 ++++++
 tests/generic/836     |  144 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/836.out |   32 +++++++++++
 tests/generic/group   |    7 ++
 15 files changed, 916 insertions(+)
 create mode 100755 tests/generic/830
 create mode 100644 tests/generic/830.out
 create mode 100755 tests/generic/831
 create mode 100644 tests/generic/831.out
 create mode 100755 tests/generic/832
 create mode 100644 tests/generic/832.out
 create mode 100755 tests/generic/833
 create mode 100644 tests/generic/833.out
 create mode 100755 tests/generic/834
 create mode 100644 tests/generic/834.out
 create mode 100755 tests/generic/835
 create mode 100644 tests/generic/835.out
 create mode 100755 tests/generic/836
 create mode 100644 tests/generic/836.out


diff --git a/tests/generic/830 b/tests/generic/830
new file mode 100755
index 0000000..2d9a7af
--- /dev/null
+++ b/tests/generic/830
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 830
+#
+# Ensure that reflinking a file N times doesn't eat a lot of blocks
+#   - Create a file and record fs block usage
+#   - Create some reflink copies
+#   - Compare fs block usage to before
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+NR=7
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file.$i
+done
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/830.out b/tests/generic/830.out
new file mode 100644
index 0000000..76e2f1d
--- /dev/null
+++ b/tests/generic/830.out
@@ -0,0 +1,4 @@
+QA output created by 830
+Create the original file blocks
+Create the reflink copies
+free blocks after reflink is in range
diff --git a/tests/generic/831 b/tests/generic/831
new file mode 100755
index 0000000..cbf9723
--- /dev/null
+++ b/tests/generic/831
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 831
+#
+# Ensure that deleting all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Delete some copies of the file
+#   - Record fs block usage (2)
+#   - Delete all copies of the file
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=7
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file.$i
+done
+cp --reflink=always $TESTDIR/file1 $TESTDIR/survivor
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Delete most of the files"
+rm -rf $TESTDIR/file*
+_test_remount
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Delete all the files"
+rm -rf $TESTDIR/*
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after deleting some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after deleting all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/831.out b/tests/generic/831.out
new file mode 100644
index 0000000..88e0a23
--- /dev/null
+++ b/tests/generic/831.out
@@ -0,0 +1,8 @@
+QA output created by 831
+Create the original file blocks
+Create the reflink copies
+Delete most of the files
+Delete all the files
+free blocks after reflink is in range
+free blocks after deleting some reflink copies is in range
+free blocks after deleting all copies is in range
diff --git a/tests/generic/832 b/tests/generic/832
new file mode 100755
index 0000000..3b1e7d2
--- /dev/null
+++ b/tests/generic/832
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 832
+#
+# Ensure that punching all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Punch some blocks of the copies
+#   - Record fs block usage (2)
+#   - Punch all blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fpunch"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+sync
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Punch most of the blocks"
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fpunch $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Punch all the files"
+for i in `seq 2 $NR`; do
+	$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file$i
+done
+$XFS_IO_PROG -f -c "fpunch 0 $((BLKS * BLKSZ))" $TESTDIR/file1
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after punching some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after punching all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/832.out b/tests/generic/832.out
new file mode 100644
index 0000000..c99c6fc
--- /dev/null
+++ b/tests/generic/832.out
@@ -0,0 +1,14 @@
+QA output created by 832
+Create the original file blocks
+Create the reflink copies
+Punch most of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Punch all the files
+free blocks after reflink is in range
+free blocks after punching some reflink copies is in range
+free blocks after punching all copies is in range
diff --git a/tests/generic/833 b/tests/generic/833
new file mode 100755
index 0000000..bd635d7
--- /dev/null
+++ b/tests/generic/833
@@ -0,0 +1,116 @@
+#! /bin/bash
+# FS QA Test No. 833
+#
+# Ensure that collapse-range on all copies of a file reflinked N times releases the blocks
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - Collapse-range some blocks of the copies
+#   - Record fs block usage (2)
+#   - Truncate all blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fcollapse"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Collapse most of the blocks"
+$XFS_IO_PROG -f -c "fcollapse 0 $(((BLKS - 1) * BLKSZ))" $TESTDIR/file2
+$XFS_IO_PROG -f -c "fcollapse 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse $((BLKS / 2 * BLKSZ)) $(( ((BLKS / 2) - 1) * BLKSZ))" $TESTDIR/file4
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Collpase nearly all the files"
+$XFS_IO_PROG -f -c "fcollapse 0 $(( ((BLKS / 2) - 1) * BLKSZ))" $TESTDIR/file3
+$XFS_IO_PROG -f -c "fcollapse 0 $(( (BLKS / 2) * BLKSZ))" $TESTDIR/file4
+$XFS_IO_PROG -f -c "fcollapse 0 $(( (BLKS - 1) * BLKSZ))" $TESTDIR/file1
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after reflink" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after fcollapsing some reflink copies" $FREE_BLOCKS2 $FREE_BLOCKS1 $MARGIN -v
+
+_within_tolerance "free blocks after fcollapsing all copies" $FREE_BLOCKS3 $FREE_BLOCKS0 $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/833.out b/tests/generic/833.out
new file mode 100644
index 0000000..bdbd36f
--- /dev/null
+++ b/tests/generic/833.out
@@ -0,0 +1,14 @@
+QA output created by 833
+Create the original file blocks
+Create the reflink copies
+Collapse most of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Collpase nearly all the files
+free blocks after reflink is in range
+free blocks after fcollapsing some reflink copies is in range
+free blocks after fcollapsing all copies is in range
diff --git a/tests/generic/834 b/tests/generic/834
new file mode 100755
index 0000000..598cf8a
--- /dev/null
+++ b/tests/generic/834
@@ -0,0 +1,122 @@
+#! /bin/bash
+# FS QA Test No. 834
+#
+# Ensure that CoW on all copies of a file reflinked N times increases block count
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - CoW some blocks of the copies
+#   - Record fs block usage (2)
+#   - CoW all the rest of the blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+#-----------------------------------------------------------------------
+# 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')"
+BLKS=2000
+MARGIN=100
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKS * BLKSZ))" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite some of the blocks"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x64 $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite all the files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((BLKS * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "pwrite -S 0x64 0 $((BLKS * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after partially CoWing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after CoWing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/834.out b/tests/generic/834.out
new file mode 100644
index 0000000..23fb663
--- /dev/null
+++ b/tests/generic/834.out
@@ -0,0 +1,17 @@
+QA output created by 834
+Create the original file blocks
+Create the reflink copies
+Rewrite some of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Rewrite all the files
+Rewrite the original file
+free blocks after reflinking is in range
+free blocks after partially CoWing some copies is in range
+free blocks after CoWing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/835 b/tests/generic/835
new file mode 100755
index 0000000..22bd768
--- /dev/null
+++ b/tests/generic/835
@@ -0,0 +1,127 @@
+#! /bin/bash
+# FS QA Test No. 835
+#
+# Ensure that CoW on all copies of a file reflinked N times increases block count
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - CoW some blocks of the copies
+#   - Record fs block usage (2)
+#   - CoW all the rest of the blocks of the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#
+# The main difference from 834 is that we use zero range, directio, and
+# mmap to mix things up a bit.
+#
+#-----------------------------------------------------------------------
+# 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_xfs_io_command "fzero"
+_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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite some of the blocks"
+$XFS_IO_PROG -f -c "fzero 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -d -f -c "pwrite -S 0x63 0 $((BLKS / 2 * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKS * BLKSZ))" -c "mwrite -S 0x64 $((BLKS / 2 * BLKSZ)) $((BLKS / 2 * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match (intentional)"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match (intentional)"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match (intentional)"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite all the files"
+$XFS_IO_PROG -d -f -c "pwrite -S 0x62 0 $((BLKS * BLKSZ))" $TESTDIR/file2 > /dev/null
+$XFS_IO_PROG -f -c "mmap -rw 0 $((BLKS * BLKSZ))" -c "mwrite -S 0x63 0 $((BLKS * BLKSZ))" $TESTDIR/file3 > /dev/null
+$XFS_IO_PROG -f -c "fzero 0 $((BLKS * BLKSZ))" $TESTDIR/file4 > /dev/null
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after partially CoWing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after CoWing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/835.out b/tests/generic/835.out
new file mode 100644
index 0000000..a601ee2
--- /dev/null
+++ b/tests/generic/835.out
@@ -0,0 +1,17 @@
+QA output created by 835
+Create the original file blocks
+Create the reflink copies
+Rewrite some of the blocks
+Files 1-2 do not match (intentional)
+Files 1-3 do not match (intentional)
+Files 1-4 do not match (intentional)
+Files 2-3 do not match (intentional)
+Files 2-4 do not match (intentional)
+Files 3-4 do not match (intentional)
+Rewrite all the files
+Rewrite the original file
+free blocks after reflinking is in range
+free blocks after partially CoWing some copies is in range
+free blocks after CoWing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/836 b/tests/generic/836
new file mode 100755
index 0000000..9bc81c5
--- /dev/null
+++ b/tests/generic/836
@@ -0,0 +1,144 @@
+#! /bin/bash
+# FS QA Test No. 836
+#
+# Ensure that funshare on reflinked files actually CoWs the files and
+# removes the inode flag.
+#   - Record fs block usage (0)
+#   - Create a file and some reflink copies
+#   - Record fs block usage (1)
+#   - funshare the copies
+#   - chattr +C the copies
+#   - Compare fs block usage to (2), (1), and (0)
+#   - Compare the extent lists of the copies
+#
+#-----------------------------------------------------------------------
+# 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/attr
+
+if [ $FSTYP = "btrfs" ]; then
+	_notrun "btrfs doesn't handle funshare"
+fi
+
+# real QA test starts here
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "funshare"
+_require_cp_reflink
+_require_test
+_require_attrs
+
+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')"
+BLKS=2000
+MARGIN=100
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR/file1 >> $seqres.full
+_test_remount
+
+echo "Create the reflink copies"
+for i in `seq 2 $NR`; do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file$i
+done
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare part of a file"
+$XFS_IO_PROG -f -c "funshare 0 $((SZ / 2))" $TESTDIR/file2
+_test_remount
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare some of the copies"
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file2
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file3
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "funshare the rest of the files"
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file4
+$XFS_IO_PROG -f -c "funshare 0 $SZ" $TESTDIR/file1
+_test_remount
+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/file1 $TESTDIR/file4 || echo "Files 1-4 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file3 || echo "Files 2-3 do not match"
+cmp -s $TESTDIR/file2 $TESTDIR/file4 || echo "Files 2-4 do not match"
+cmp -s $TESTDIR/file3 $TESTDIR/file4 || echo "Files 3-4 do not match"
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+
+echo "Rewrite the original file"
+$XFS_IO_PROG -f -c "pwrite -S 0x65 0 $((BLKS * BLKSZ))" $TESTDIR/file1 > /dev/null
+_test_remount
+FREE_BLOCKS4=$(stat -f $TESTDIR -c '%f')
+lsattr -l $TESTDIR/ | _filter_test_dir
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3 $FREE_BLOCKS4
+
+_within_tolerance "free blocks after reflinking" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after nocow'ing some copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - (2 * BLKS))) $MARGIN -v
+
+_within_tolerance "free blocks after nocow'ing all copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - BLKS)) $MARGIN -v
+
+_within_tolerance "free blocks after overwriting original" $FREE_BLOCKS4 $FREE_BLOCKS3 $MARGIN -v
+
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS4 $((FREE_BLOCKS0 - (4 * BLKS))) $MARGIN -v
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/836.out b/tests/generic/836.out
new file mode 100644
index 0000000..45f7750
--- /dev/null
+++ b/tests/generic/836.out
@@ -0,0 +1,32 @@
+QA output created by 836
+Create the original file blocks
+Create the reflink copies
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          ---
+TEST_DIR/test-836/file3          ---
+TEST_DIR/test-836/file4          ---
+funshare part of a file
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          ---
+TEST_DIR/test-836/file3          ---
+TEST_DIR/test-836/file4          ---
+funshare some of the copies
+TEST_DIR/test-836/file1          ---
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          ---
+funshare the rest of the files
+TEST_DIR/test-836/file1          No_COW
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          No_COW
+Rewrite the original file
+TEST_DIR/test-836/file1          No_COW
+TEST_DIR/test-836/file2          No_COW
+TEST_DIR/test-836/file3          No_COW
+TEST_DIR/test-836/file4          No_COW
+free blocks after reflinking is in range
+free blocks after nocow'ing some copies is in range
+free blocks after nocow'ing all copies is in range
+free blocks after overwriting original is in range
+free blocks after all tests is in range
diff --git a/tests/generic/group b/tests/generic/group
index 7f70690..353e23c 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -236,5 +236,12 @@
 827 auto quick clone
 828 auto quick clone
 829 auto quick clone
+830 auto quick clone
+831 auto quick clone
+832 auto quick clone
+833 auto quick clone
+834 auto quick clone
+835 auto quick clone
+836 auto quick clone
 837 auto quick clone
 838 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 09/12] reflink: test error conditions due to bad inputs
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Check that we can feed bad inputs to reflink and it'll reject them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/839     |  122 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/839.out |   30 ++++++++++++
 tests/generic/group   |    1 
 3 files changed, 153 insertions(+)
 create mode 100755 tests/generic/839
 create mode 100644 tests/generic/839.out


diff --git a/tests/generic/839 b/tests/generic/839
new file mode 100755
index 0000000..fe32cfb
--- /dev/null
+++ b/tests/generic/839
@@ -0,0 +1,122 @@
+#! /bin/bash
+# FS QA Test No. 839
+#
+# Check that cross-device reflink and dedupe are rejected
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_test
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+TESTDIR2=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR2
+mkdir $TESTDIR2
+
+echo "Create the original files"
+BLKSZ="$(stat -f $TESTDIR1 -c '%S')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR1 -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR1/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR1/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR2/file1 >> $seqres.full
+sync
+
+echo "Try cross-device reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR2/file1
+echo "Try cross-device dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR2/file1
+
+echo "Try unaligned reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 37 59 23" $TESTDIR1/file2
+echo "Try unaligned dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 37 59 23" $TESTDIR1/file2
+
+echo "Try overlapping reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file1
+echo "Try overlapping dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file2 0 0 $BLKSZ" $TESTDIR1/file2
+
+echo "Try reflink past EOF"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 $(( (BLKS + 1000) * BLKSZ)) 0 $BLKSZ" $TESTDIR1/file1
+echo "Try dedupe past EOF"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file2 $(( (BLKS + 1000) * BLKSZ)) 0 $BLKSZ" $TESTDIR1/file2
+
+chattr +i $TESTDIR1/file1 $TESTDIR1/file2
+echo "Try reflink on immutable files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file2 > $seqres.full
+echo "Try dedupe on immutable files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR1/file2 > $seqres.full
+chattr -i $TESTDIR1/file1 $TESTDIR1/file2
+
+echo "Reflink two files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file2 > $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR2/file1 0 0 $BLKSZ" $TESTDIR2/file2 > $seqres.full
+echo "Dedupe two files"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR1/file2 > $seqres.full
+$XFS_IO_PROG -f -c "dedupe $TESTDIR2/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR2/file2 > $seqres.full
+
+lsattr -l $TESTDIR1/ | _filter_test_dir
+lsattr -l $TESTDIR2/ | sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/839.out b/tests/generic/839.out
new file mode 100644
index 0000000..542a5b3
--- /dev/null
+++ b/tests/generic/839.out
@@ -0,0 +1,30 @@
+QA output created by 839
+Format and mount
+Create the original files
+Try cross-device reflink
+XFS_IOC_CLONE_RANGE: Invalid cross-device link
+Try cross-device dedupe
+dedupe: Invalid cross-device link
+Try unaligned reflink
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try unaligned dedupe
+dedupe: Invalid argument
+Try overlapping reflink
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try overlapping dedupe
+dedupe: Invalid argument
+Try reflink past EOF
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try dedupe past EOF
+dedupe: Invalid argument
+Try reflink on immutable files
+/mnt/test-839/file2: Permission denied
+Try dedupe on immutable files
+/mnt/test-839/file2: Permission denied
+Reflink two files
+Dedupe two files
+TEST_DIR/test-839/file1          ---
+TEST_DIR/test-839/file2          ---
+SCRATCH_MNT/test-839/file1          ---
+SCRATCH_MNT/test-839/file2          ---
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index 353e23c..daaf23a 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -245,3 +245,4 @@
 836 auto quick clone
 837 auto quick clone
 838 auto quick clone
+839 auto quick clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 09/12] reflink: test error conditions due to bad inputs
@ 2015-10-07  5:14   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Check that we can feed bad inputs to reflink and it'll reject them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/839     |  122 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/839.out |   30 ++++++++++++
 tests/generic/group   |    1 
 3 files changed, 153 insertions(+)
 create mode 100755 tests/generic/839
 create mode 100644 tests/generic/839.out


diff --git a/tests/generic/839 b/tests/generic/839
new file mode 100755
index 0000000..fe32cfb
--- /dev/null
+++ b/tests/generic/839
@@ -0,0 +1,122 @@
+#! /bin/bash
+# FS QA Test No. 839
+#
+# Check that cross-device reflink and dedupe are rejected
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_test
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf $TESTDIR1
+mkdir $TESTDIR1
+
+TESTDIR2=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR2
+mkdir $TESTDIR2
+
+echo "Create the original files"
+BLKSZ="$(stat -f $TESTDIR1 -c '%S')"
+BLKS=1000
+MARGIN=50
+SZ=$((BLKSZ * BLKS))
+FREE_BLOCKS0=$(stat -f $TESTDIR1 -c '%f')
+NR=4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR1/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR1/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $SZ" $TESTDIR2/file1 >> $seqres.full
+sync
+
+echo "Try cross-device reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR2/file1
+echo "Try cross-device dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR2/file1
+
+echo "Try unaligned reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 37 59 23" $TESTDIR1/file2
+echo "Try unaligned dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 37 59 23" $TESTDIR1/file2
+
+echo "Try overlapping reflink"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file1
+echo "Try overlapping dedupe"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file2 0 0 $BLKSZ" $TESTDIR1/file2
+
+echo "Try reflink past EOF"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 $(( (BLKS + 1000) * BLKSZ)) 0 $BLKSZ" $TESTDIR1/file1
+echo "Try dedupe past EOF"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file2 $(( (BLKS + 1000) * BLKSZ)) 0 $BLKSZ" $TESTDIR1/file2
+
+chattr +i $TESTDIR1/file1 $TESTDIR1/file2
+echo "Try reflink on immutable files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file2 > $seqres.full
+echo "Try dedupe on immutable files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR1/file2 > $seqres.full
+chattr -i $TESTDIR1/file1 $TESTDIR1/file2
+
+echo "Reflink two files"
+$XFS_IO_PROG -f -c "reflink $TESTDIR1/file1 0 0 $BLKSZ" $TESTDIR1/file2 > $seqres.full
+$XFS_IO_PROG -f -c "reflink $TESTDIR2/file1 0 0 $BLKSZ" $TESTDIR2/file2 > $seqres.full
+echo "Dedupe two files"
+$XFS_IO_PROG -f -c "dedupe $TESTDIR1/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR1/file2 > $seqres.full
+$XFS_IO_PROG -f -c "dedupe $TESTDIR2/file1 $BLKSZ $BLKSZ $BLKSZ" $TESTDIR2/file2 > $seqres.full
+
+lsattr -l $TESTDIR1/ | _filter_test_dir
+lsattr -l $TESTDIR2/ | sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/839.out b/tests/generic/839.out
new file mode 100644
index 0000000..542a5b3
--- /dev/null
+++ b/tests/generic/839.out
@@ -0,0 +1,30 @@
+QA output created by 839
+Format and mount
+Create the original files
+Try cross-device reflink
+XFS_IOC_CLONE_RANGE: Invalid cross-device link
+Try cross-device dedupe
+dedupe: Invalid cross-device link
+Try unaligned reflink
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try unaligned dedupe
+dedupe: Invalid argument
+Try overlapping reflink
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try overlapping dedupe
+dedupe: Invalid argument
+Try reflink past EOF
+XFS_IOC_CLONE_RANGE: Invalid argument
+Try dedupe past EOF
+dedupe: Invalid argument
+Try reflink on immutable files
+/mnt/test-839/file2: Permission denied
+Try dedupe on immutable files
+/mnt/test-839/file2: Permission denied
+Reflink two files
+Dedupe two files
+TEST_DIR/test-839/file1          ---
+TEST_DIR/test-839/file2          ---
+SCRATCH_MNT/test-839/file1          ---
+SCRATCH_MNT/test-839/file2          ---
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index 353e23c..daaf23a 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -245,3 +245,4 @@
 836 auto quick clone
 837 auto quick clone
 838 auto quick clone
+839 auto quick clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 10/12] xfs: test xfs-specific reflink pieces
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Check that growfs and xfs_fsr still work properly on reflinked fses.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/800     |   77 +++++++++++++++++++++++++++++++
 tests/xfs/800.out |    5 ++
 tests/xfs/801     |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/801.out |   15 ++++++
 tests/xfs/802     |   89 +++++++++++++++++++++++++++++++++++
 tests/xfs/802.out |    6 ++
 tests/xfs/803     |  104 +++++++++++++++++++++++++++++++++++++++++
 tests/xfs/803.out |   13 +++++
 tests/xfs/group   |    4 ++
 9 files changed, 446 insertions(+)
 create mode 100755 tests/xfs/800
 create mode 100644 tests/xfs/800.out
 create mode 100755 tests/xfs/801
 create mode 100644 tests/xfs/801.out
 create mode 100755 tests/xfs/802
 create mode 100644 tests/xfs/802.out
 create mode 100755 tests/xfs/803
 create mode 100644 tests/xfs/803.out


diff --git a/tests/xfs/800 b/tests/xfs/800
new file mode 100755
index 0000000..58059f7
--- /dev/null
+++ b/tests/xfs/800
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FS QA Test No. 800
+#
+# Tests xfs_growfs on a reflinked filesystem
+#
+#-----------------------------------------------------------------------
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create the original file and reflink to copy1, copy2"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 14 + 71))" $TESTDIR/original \
+    >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/original $TESTDIR/copy1
+cp --reflink=always $TESTDIR/copy1 $TESTDIR/copy2
+
+echo "Grow fs"
+$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 |  _filter_growfs >> $seqres.full
+
+xfs_info $SCRATCH_MNT >> $seqres.full
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/800.out b/tests/xfs/800.out
new file mode 100644
index 0000000..280daa5
--- /dev/null
+++ b/tests/xfs/800.out
@@ -0,0 +1,5 @@
+QA output created by 800
+Format and mount
+Create the original file and reflink to copy1, copy2
+Grow fs
+Check scratch fs
diff --git a/tests/xfs/801 b/tests/xfs/801
new file mode 100755
index 0000000..96a47e4
--- /dev/null
+++ b/tests/xfs/801
@@ -0,0 +1,133 @@
+#! /bin/bash
+# FS QA Test No. 801
+#
+# Ensure that xfs_fsr un-reflinks files while defragmenting
+#
+#-----------------------------------------------------------------------
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+
+echo "Create the original file and reflink to file2, file3"
+BLKS=2000
+MARGIN=100
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKS * BLKSZ))" $TESTDIR/file1 \
+    >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file2 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file3 $TESTDIR/file4
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+C01=$(_md5_checksum $TESTDIR/file1)
+C02=$(_md5_checksum $TESTDIR/file2)
+C03=$(_md5_checksum $TESTDIR/file3)
+C04=$(_md5_checksum $TESTDIR/file4)
+
+echo "CoW the reflink copies"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $(( BLKSZ * (BLKS - 1) )) $BLKSZ" $TESTDIR/file3 >> $seqres.full
+_test_remount
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+C11=$(_md5_checksum $TESTDIR/file1)
+C12=$(_md5_checksum $TESTDIR/file2)
+C13=$(_md5_checksum $TESTDIR/file3)
+C14=$(_md5_checksum $TESTDIR/file4)
+
+echo "Defragment"
+lsattr -l $TESTDIR/ | sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
+xfs_fsr -v -d $TESTDIR/file1 >> $seqres.full
+xfs_fsr -v -d $TESTDIR/file2 >> $seqres.full # fsr probably breaks the link
+xfs_fsr -v -d $TESTDIR/file3 >> $seqres.full # fsr probably breaks the link
+xfs_fsr -v -d $TESTDIR/file4 >> $seqres.full # fsr probably ignores this file
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+C21=$(_md5_checksum $TESTDIR/file1)
+C22=$(_md5_checksum $TESTDIR/file2)
+C23=$(_md5_checksum $TESTDIR/file3)
+C24=$(_md5_checksum $TESTDIR/file4)
+
+echo "Check files"
+test $C01 = $C02 || echo "Files 1-2 do not match"
+test $C01 = $C03 || echo "Files 1-3 do not match"
+test $C01 = $C04 || echo "Files 1-4 do not match"
+test $C02 = $C03 || echo "Files 2-3 do not match"
+test $C02 = $C04 || echo "Files 2-4 do not match"
+test $C03 = $C04 || echo "Files 3-4 do not match"
+
+test $C01 = $C11 || echo "File1 should not be different after CoW"
+test $C02 != $C12 || echo "File2 should be different after CoW"
+test $C03 != $C13 || echo "File3 should be different after CoW"
+test $C04 = $C14 || echo "File4 should not be different after CoW"
+
+test $C11 = $C21 || echo "File1 changed by defrag"
+test $C12 = $C22 || echo "File2 changed by defrag"
+test $C13 = $C23 || echo "File3 changed by defrag"
+test $C14 = $C24 || echo "File4 changed by defrag"
+
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after creating some reflink copies" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+_within_tolerance "free blocks after CoW some reflink copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - 2)) $MARGIN -v
+_within_tolerance "free blocks after defragging all reflink copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - (BLKS * 2))) $MARGIN -v
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS3 $((FREE_BLOCKS0 - (BLKS * 3))) $MARGIN -v
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/801.out b/tests/xfs/801.out
new file mode 100644
index 0000000..9e5f4ca
--- /dev/null
+++ b/tests/xfs/801.out
@@ -0,0 +1,15 @@
+QA output created by 801
+Format and mount
+Create the original file and reflink to file2, file3
+CoW the reflink copies
+Defragment
+SCRATCH_MNT/test-801/file1          ---
+SCRATCH_MNT/test-801/file2          ---
+SCRATCH_MNT/test-801/file3          ---
+SCRATCH_MNT/test-801/file4          ---
+Check files
+free blocks after creating some reflink copies is in range
+free blocks after CoW some reflink copies is in range
+free blocks after defragging all reflink copies is in range
+free blocks after all tests is in range
+Check scratch fs
diff --git a/tests/xfs/802 b/tests/xfs/802
new file mode 100755
index 0000000..05c5004
--- /dev/null
+++ b/tests/xfs/802
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 802
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree, and that metadump will successfully copy
+# said block.
+#
+#-----------------------------------------------------------------------
+# 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 $METADUMP_FILE
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_test
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
+
+echo "Create the original file blocks"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=$((4 * BLKSZ / 12))
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/file1 >> $seqres.full
+
+echo "Reflink every other block"
+touch $TESTDIR/file2
+seq 1 $((NR_BLKS / 2)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((nr * 2 * BLKSZ)) $((nr * 2 * BLKSZ)) $BLKSZ" $TESTDIR/file2 >> $seqres.full
+done
+
+echo "Create metadump file"
+_scratch_unmount
+_scratch_metadump $METADUMP_FILE
+
+# Now restore the obfuscated one back and take a look around
+echo "Restore metadump"
+xfs_mdrestore "${METADUMP_FILE}" "${SCRATCH_DEV}"
+_scratch_mount
+_scratch_unmount
+
+echo "Check restored fs"
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/802.out b/tests/xfs/802.out
new file mode 100644
index 0000000..ad2ef03
--- /dev/null
+++ b/tests/xfs/802.out
@@ -0,0 +1,6 @@
+QA output created by 802
+Create the original file blocks
+Reflink every other block
+Create metadump file
+Restore metadump
+Check restored fs
diff --git a/tests/xfs/803 b/tests/xfs/803
new file mode 100755
index 0000000..62a9246
--- /dev/null
+++ b/tests/xfs/803
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 803
+#
+# Create and populate an XFS filesystem, corrupt the refcount btree,
+# then see how the kernel and xfs_repair deal with it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
+_require_attrs
+
+rm -f $seqres.full
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * 64))" "${SCRATCH_MNT}/file0" >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((blksz * 64))" "${SCRATCH_MNT}/file1" >> $seqres.full
+cp --reflink=always "${SCRATCH_MNT}/file0" "${SCRATCH_MNT}/file2"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file3"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr refcntroot" -c "stack" -c "blocktrash -x 4096 -y 4096 -z -n 8 -3" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ reflink more"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file4" 2> /dev/null && _fail "should not be able to reflink with busted refcount btree"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ reflink more (2)"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file5" || _fail "modified refcount tree"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+status=0
+exit
diff --git a/tests/xfs/803.out b/tests/xfs/803.out
new file mode 100644
index 0000000..582682d
--- /dev/null
+++ b/tests/xfs/803.out
@@ -0,0 +1,13 @@
+QA output created by 803
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ reflink more
++ repair fs
++ mount image (2)
++ chattr -R -i
++ reflink more (2)
++ check fs (2)
diff --git a/tests/xfs/group b/tests/xfs/group
index 8261f86..cbbd810 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -220,3 +220,7 @@
 303 auto quick quota
 304 auto quick quota
 305 auto quota
+800 auto quick clone
+801 auto quick clone
+802 auto quick clone
+803 fuzzers


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 10/12] xfs: test xfs-specific reflink pieces
@ 2015-10-07  5:14   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Check that growfs and xfs_fsr still work properly on reflinked fses.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/800     |   77 +++++++++++++++++++++++++++++++
 tests/xfs/800.out |    5 ++
 tests/xfs/801     |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/801.out |   15 ++++++
 tests/xfs/802     |   89 +++++++++++++++++++++++++++++++++++
 tests/xfs/802.out |    6 ++
 tests/xfs/803     |  104 +++++++++++++++++++++++++++++++++++++++++
 tests/xfs/803.out |   13 +++++
 tests/xfs/group   |    4 ++
 9 files changed, 446 insertions(+)
 create mode 100755 tests/xfs/800
 create mode 100644 tests/xfs/800.out
 create mode 100755 tests/xfs/801
 create mode 100644 tests/xfs/801.out
 create mode 100755 tests/xfs/802
 create mode 100644 tests/xfs/802.out
 create mode 100755 tests/xfs/803
 create mode 100644 tests/xfs/803.out


diff --git a/tests/xfs/800 b/tests/xfs/800
new file mode 100755
index 0000000..58059f7
--- /dev/null
+++ b/tests/xfs/800
@@ -0,0 +1,77 @@
+#! /bin/bash
+# FS QA Test No. 800
+#
+# Tests xfs_growfs on a reflinked filesystem
+#
+#-----------------------------------------------------------------------
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create the original file and reflink to copy1, copy2"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * 14 + 71))" $TESTDIR/original \
+    >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/original $TESTDIR/copy1
+cp --reflink=always $TESTDIR/copy1 $TESTDIR/copy2
+
+echo "Grow fs"
+$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 |  _filter_growfs >> $seqres.full
+
+xfs_info $SCRATCH_MNT >> $seqres.full
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/800.out b/tests/xfs/800.out
new file mode 100644
index 0000000..280daa5
--- /dev/null
+++ b/tests/xfs/800.out
@@ -0,0 +1,5 @@
+QA output created by 800
+Format and mount
+Create the original file and reflink to copy1, copy2
+Grow fs
+Check scratch fs
diff --git a/tests/xfs/801 b/tests/xfs/801
new file mode 100755
index 0000000..96a47e4
--- /dev/null
+++ b/tests/xfs/801
@@ -0,0 +1,133 @@
+#! /bin/bash
+# FS QA Test No. 801
+#
+# Ensure that xfs_fsr un-reflinks files while defragmenting
+#
+#-----------------------------------------------------------------------
+# 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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. common/rc
+. common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+FREE_BLOCKS0=$(stat -f $TESTDIR -c '%f')
+
+echo "Create the original file and reflink to file2, file3"
+BLKS=2000
+MARGIN=100
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKS * BLKSZ))" $TESTDIR/file1 \
+    >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/file1 $TESTDIR/file2
+cp --reflink=always $TESTDIR/file2 $TESTDIR/file3
+cp --reflink=always $TESTDIR/file3 $TESTDIR/file4
+_test_remount
+FREE_BLOCKS1=$(stat -f $TESTDIR -c '%f')
+
+C01=$(_md5_checksum $TESTDIR/file1)
+C02=$(_md5_checksum $TESTDIR/file2)
+C03=$(_md5_checksum $TESTDIR/file3)
+C04=$(_md5_checksum $TESTDIR/file4)
+
+echo "CoW the reflink copies"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 $BLKSZ $BLKSZ" $TESTDIR/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x63 $(( BLKSZ * (BLKS - 1) )) $BLKSZ" $TESTDIR/file3 >> $seqres.full
+_test_remount
+FREE_BLOCKS2=$(stat -f $TESTDIR -c '%f')
+
+C11=$(_md5_checksum $TESTDIR/file1)
+C12=$(_md5_checksum $TESTDIR/file2)
+C13=$(_md5_checksum $TESTDIR/file3)
+C14=$(_md5_checksum $TESTDIR/file4)
+
+echo "Defragment"
+lsattr -l $TESTDIR/ | sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
+xfs_fsr -v -d $TESTDIR/file1 >> $seqres.full
+xfs_fsr -v -d $TESTDIR/file2 >> $seqres.full # fsr probably breaks the link
+xfs_fsr -v -d $TESTDIR/file3 >> $seqres.full # fsr probably breaks the link
+xfs_fsr -v -d $TESTDIR/file4 >> $seqres.full # fsr probably ignores this file
+_test_remount
+FREE_BLOCKS3=$(stat -f $TESTDIR -c '%f')
+
+C21=$(_md5_checksum $TESTDIR/file1)
+C22=$(_md5_checksum $TESTDIR/file2)
+C23=$(_md5_checksum $TESTDIR/file3)
+C24=$(_md5_checksum $TESTDIR/file4)
+
+echo "Check files"
+test $C01 = $C02 || echo "Files 1-2 do not match"
+test $C01 = $C03 || echo "Files 1-3 do not match"
+test $C01 = $C04 || echo "Files 1-4 do not match"
+test $C02 = $C03 || echo "Files 2-3 do not match"
+test $C02 = $C04 || echo "Files 2-4 do not match"
+test $C03 = $C04 || echo "Files 3-4 do not match"
+
+test $C01 = $C11 || echo "File1 should not be different after CoW"
+test $C02 != $C12 || echo "File2 should be different after CoW"
+test $C03 != $C13 || echo "File3 should be different after CoW"
+test $C04 = $C14 || echo "File4 should not be different after CoW"
+
+test $C11 = $C21 || echo "File1 changed by defrag"
+test $C12 = $C22 || echo "File2 changed by defrag"
+test $C13 = $C23 || echo "File3 changed by defrag"
+test $C14 = $C24 || echo "File4 changed by defrag"
+
+#echo $FREE_BLOCKS0 $FREE_BLOCKS1 $FREE_BLOCKS2 $FREE_BLOCKS3
+
+_within_tolerance "free blocks after creating some reflink copies" $FREE_BLOCKS1 $((FREE_BLOCKS0 - BLKS)) $MARGIN -v
+_within_tolerance "free blocks after CoW some reflink copies" $FREE_BLOCKS2 $((FREE_BLOCKS1 - 2)) $MARGIN -v
+_within_tolerance "free blocks after defragging all reflink copies" $FREE_BLOCKS3 $((FREE_BLOCKS2 - (BLKS * 2))) $MARGIN -v
+_within_tolerance "free blocks after all tests" $FREE_BLOCKS3 $((FREE_BLOCKS0 - (BLKS * 3))) $MARGIN -v
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/801.out b/tests/xfs/801.out
new file mode 100644
index 0000000..9e5f4ca
--- /dev/null
+++ b/tests/xfs/801.out
@@ -0,0 +1,15 @@
+QA output created by 801
+Format and mount
+Create the original file and reflink to file2, file3
+CoW the reflink copies
+Defragment
+SCRATCH_MNT/test-801/file1          ---
+SCRATCH_MNT/test-801/file2          ---
+SCRATCH_MNT/test-801/file3          ---
+SCRATCH_MNT/test-801/file4          ---
+Check files
+free blocks after creating some reflink copies is in range
+free blocks after CoW some reflink copies is in range
+free blocks after defragging all reflink copies is in range
+free blocks after all tests is in range
+Check scratch fs
diff --git a/tests/xfs/802 b/tests/xfs/802
new file mode 100755
index 0000000..05c5004
--- /dev/null
+++ b/tests/xfs/802
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 802
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree, and that metadump will successfully copy
+# said block.
+#
+#-----------------------------------------------------------------------
+# 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 $METADUMP_FILE
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs xfs
+_require_test
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+TESTDIR=$SCRATCH_MNT/test-$seq
+rm -rf $TESTDIR
+mkdir $TESTDIR
+METADUMP_FILE="${TEST_DIR}/${seq}_metadump"
+
+echo "Create the original file blocks"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=$((4 * BLKSZ / 12))
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/file1 >> $seqres.full
+
+echo "Reflink every other block"
+touch $TESTDIR/file2
+seq 1 $((NR_BLKS / 2)) | while read nr; do
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 $((nr * 2 * BLKSZ)) $((nr * 2 * BLKSZ)) $BLKSZ" $TESTDIR/file2 >> $seqres.full
+done
+
+echo "Create metadump file"
+_scratch_unmount
+_scratch_metadump $METADUMP_FILE
+
+# Now restore the obfuscated one back and take a look around
+echo "Restore metadump"
+xfs_mdrestore "${METADUMP_FILE}" "${SCRATCH_DEV}"
+_scratch_mount
+_scratch_unmount
+
+echo "Check restored fs"
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/802.out b/tests/xfs/802.out
new file mode 100644
index 0000000..ad2ef03
--- /dev/null
+++ b/tests/xfs/802.out
@@ -0,0 +1,6 @@
+QA output created by 802
+Create the original file blocks
+Reflink every other block
+Create metadump file
+Restore metadump
+Check restored fs
diff --git a/tests/xfs/803 b/tests/xfs/803
new file mode 100755
index 0000000..62a9246
--- /dev/null
+++ b/tests/xfs/803
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 803
+#
+# Create and populate an XFS filesystem, corrupt the refcount btree,
+# then see how the kernel and xfs_repair deal with it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, 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.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+
+_require_scratch
+_require_scratch_reflink
+test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
+_require_attrs
+
+rm -f $seqres.full
+
+echo "+ create scratch fs"
+_scratch_mkfs_xfs > /dev/null
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
+agcount="$(xfs_info "${SCRATCH_MNT}" | grep agcount= | sed -e 's/^.*agcount=\([0-9]*\),.*$/\1/g')"
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((blksz * 64))" "${SCRATCH_MNT}/file0" >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((blksz * 64))" "${SCRATCH_MNT}/file1" >> $seqres.full
+cp --reflink=always "${SCRATCH_MNT}/file0" "${SCRATCH_MNT}/file2"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file3"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+echo "+ corrupt image"
+for ag in $(seq 1 $((agcount - 1))) 0; do
+	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr refcntroot" -c "stack" -c "blocktrash -x 4096 -y 4096 -z -n 8 -3" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+done
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ reflink more"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file4" 2> /dev/null && _fail "should not be able to reflink with busted refcount btree"
+umount "${SCRATCH_MNT}"
+
+echo "+ repair fs"
+_scratch_xfs_repair >> $seqres.full 2>&1
+_scratch_xfs_repair >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ chattr -R -i"
+chattr -R -f -i "${SCRATCH_MNT}/"
+
+echo "+ reflink more (2)"
+cp --reflink=always "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file5" || _fail "modified refcount tree"
+umount "${SCRATCH_MNT}"
+
+echo "+ check fs (2)"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
+
+status=0
+exit
diff --git a/tests/xfs/803.out b/tests/xfs/803.out
new file mode 100644
index 0000000..582682d
--- /dev/null
+++ b/tests/xfs/803.out
@@ -0,0 +1,13 @@
+QA output created by 803
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ reflink more
++ repair fs
++ mount image (2)
++ chattr -R -i
++ reflink more (2)
++ check fs (2)
diff --git a/tests/xfs/group b/tests/xfs/group
index 8261f86..cbbd810 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -220,3 +220,7 @@
 303 auto quick quota
 304 auto quick quota
 305 auto quota
+800 auto quick clone
+801 auto quick clone
+802 auto quick clone
+803 fuzzers

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 11/12] reflink: test what happens when we hit resource limits
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Add a few horrible opt-in stress tests to see what happens if we try
to reflink the same block billions of times, and what happens if we
run out of space while reflinking a file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/840     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/840.out |    0 
 tests/generic/841     |   85 +++++++++++++++++++++++++++++++++++++++
 tests/generic/841.out |    5 ++
 tests/generic/group   |    2 +
 5 files changed, 198 insertions(+)
 create mode 100755 tests/generic/840
 create mode 100644 tests/generic/840.out
 create mode 100755 tests/generic/841
 create mode 100644 tests/generic/841.out


diff --git a/tests/generic/840 b/tests/generic/840
new file mode 100755
index 0000000..50ccae9
--- /dev/null
+++ b/tests/generic/840
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 840
+#
+# Try to hit the maximum reference count (eek!)
+#
+# This test runs extremely slowly, so it's not automatically run anywhere.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_test
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+# Well let's hope the maximum reflink count is (less than (ha!)) 2^32...
+
+echo "Create a one block file"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" $TESTDIR/file2 >> $seqres.full
+
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $BLKSZ" $TESTDIR/file2 >> $seqres.full
+
+nr=32
+fnr=32
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $(( (2 ** i) * BLKSZ)) bytes" | tee -a $seqres.full
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 $(( (2 ** i) * BLKSZ)) $(( (2 ** i) * BLKSZ ))" $TESTDIR/file1 >> $seqres.full || break
+done
+
+nrf=$((nr - fnr))
+echo "Clone $((2 ** nrf)) files"
+for i in $(seq 0 $((2 ** nrf)) ); do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file1-$i
+done
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+$XFS_DB_PROG -c 'agf 0' -c 'addr rlroot' -c p $SCRATCH_DEV
+_check_scratch_fs
+
+echo "Remove big file and recheck"
+_scratch_mount >> $seqres.full 2>&1
+#rm -rf $TESTDIR/file1
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Remove all files and recheck"
+_scratch_mount >> $seqres.full 2>&1
+#rm -rf $TESTDIR/file2
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/840.out b/tests/generic/840.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/generic/841 b/tests/generic/841
new file mode 100755
index 0000000..5cc534e
--- /dev/null
+++ b/tests/generic/841
@@ -0,0 +1,85 @@
+#! /bin/bash
+# FS QA Test No. 841
+#
+# Try to run out of space while cloning?
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+echo "Create a big file"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/bigfile >> $seqres.full 2>&1
+_scratch_remount
+sz="$(stat -c '%s' $TESTDIR/bigfile)"
+
+blks="$((sz / BLKSZ))"
+echo "Try to reflink"
+seq 0 $blks | while read lblk; do
+	fname="$TESTDIR/file$((lblk % 2))"
+	out="$($XFS_IO_PROG -f -c "reflink $TESTDIR/bigfile $((lblk * BLKSZ)) $((lblk * BLKSZ)) $BLKSZ" $fname 2>&1)"
+	echo "$out" >> $seqres.full
+	test "$out" = "reflink: No space left on device" && break
+done
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/841.out b/tests/generic/841.out
new file mode 100644
index 0000000..33c46fd
--- /dev/null
+++ b/tests/generic/841.out
@@ -0,0 +1,5 @@
+QA output created by 841
+Format and mount
+Create a big file
+Try to reflink
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index daaf23a..d4f05a9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -246,3 +246,5 @@
 837 auto quick clone
 838 auto quick clone
 839 auto quick clone
+840 clone_stress
+841 clone_stress


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 11/12] reflink: test what happens when we hit resource limits
@ 2015-10-07  5:14   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Add a few horrible opt-in stress tests to see what happens if we try
to reflink the same block billions of times, and what happens if we
run out of space while reflinking a file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/840     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/840.out |    0 
 tests/generic/841     |   85 +++++++++++++++++++++++++++++++++++++++
 tests/generic/841.out |    5 ++
 tests/generic/group   |    2 +
 5 files changed, 198 insertions(+)
 create mode 100755 tests/generic/840
 create mode 100644 tests/generic/840.out
 create mode 100755 tests/generic/841
 create mode 100644 tests/generic/841.out


diff --git a/tests/generic/840 b/tests/generic/840
new file mode 100755
index 0000000..50ccae9
--- /dev/null
+++ b/tests/generic/840
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 840
+#
+# Try to hit the maximum reference count (eek!)
+#
+# This test runs extremely slowly, so it's not automatically run anywhere.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_test
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+# Well let's hope the maximum reflink count is (less than (ha!)) 2^32...
+
+echo "Create a one block file"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $BLKSZ" $TESTDIR/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 0 $BLKSZ" $TESTDIR/file2 >> $seqres.full
+
+$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 0 $BLKSZ" $TESTDIR/file2 >> $seqres.full
+
+nr=32
+fnr=32
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $(( (2 ** i) * BLKSZ)) bytes" | tee -a $seqres.full
+	$XFS_IO_PROG -f -c "reflink $TESTDIR/file1 0 $(( (2 ** i) * BLKSZ)) $(( (2 ** i) * BLKSZ ))" $TESTDIR/file1 >> $seqres.full || break
+done
+
+nrf=$((nr - fnr))
+echo "Clone $((2 ** nrf)) files"
+for i in $(seq 0 $((2 ** nrf)) ); do
+	cp --reflink=always $TESTDIR/file1 $TESTDIR/file1-$i
+done
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+$XFS_DB_PROG -c 'agf 0' -c 'addr rlroot' -c p $SCRATCH_DEV
+_check_scratch_fs
+
+echo "Remove big file and recheck"
+_scratch_mount >> $seqres.full 2>&1
+#rm -rf $TESTDIR/file1
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Remove all files and recheck"
+_scratch_mount >> $seqres.full 2>&1
+#rm -rf $TESTDIR/file2
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/840.out b/tests/generic/840.out
new file mode 100644
index 0000000..e69de29
diff --git a/tests/generic/841 b/tests/generic/841
new file mode 100755
index 0000000..5cc534e
--- /dev/null
+++ b/tests/generic/841
@@ -0,0 +1,85 @@
+#! /bin/bash
+# FS QA Test No. 841
+#
+# Try to run out of space while cloning?
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_require_test_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+echo "Create a big file"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/bigfile >> $seqres.full 2>&1
+_scratch_remount
+sz="$(stat -c '%s' $TESTDIR/bigfile)"
+
+blks="$((sz / BLKSZ))"
+echo "Try to reflink"
+seq 0 $blks | while read lblk; do
+	fname="$TESTDIR/file$((lblk % 2))"
+	out="$($XFS_IO_PROG -f -c "reflink $TESTDIR/bigfile $((lblk * BLKSZ)) $((lblk * BLKSZ)) $BLKSZ" $fname 2>&1)"
+	echo "$out" >> $seqres.full
+	test "$out" = "reflink: No space left on device" && break
+done
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/841.out b/tests/generic/841.out
new file mode 100644
index 0000000..33c46fd
--- /dev/null
+++ b/tests/generic/841.out
@@ -0,0 +1,5 @@
+QA output created by 841
+Format and mount
+Create a big file
+Try to reflink
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index daaf23a..d4f05a9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -246,3 +246,5 @@
 837 auto quick clone
 838 auto quick clone
 839 auto quick clone
+840 clone_stress
+841 clone_stress

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 12/12] reflink: test that CoW writes fail when we're out of space
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-10-07  5:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

Ensure that copy-on-writing a reflinked file when there's no free disk
space reflects the desired ENOSPC back to userspace during the write
call.  Tests the buffered IO, direct IO, and mmap write paths.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/842     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/842.out |   10 ++++
 tests/generic/843     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/843.out |   10 ++++
 tests/generic/844     |  112 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/844.out |    9 ++++
 tests/generic/845     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/845.out |   10 ++++
 tests/generic/group   |    4 ++
 9 files changed, 485 insertions(+)
 create mode 100755 tests/generic/842
 create mode 100644 tests/generic/842.out
 create mode 100755 tests/generic/843
 create mode 100644 tests/generic/843.out
 create mode 100755 tests/generic/844
 create mode 100644 tests/generic/844.out
 create mode 100755 tests/generic/845
 create mode 100644 tests/generic/845.out


diff --git a/tests/generic/842 b/tests/generic/842
new file mode 100755
index 0000000..9e46b6e
--- /dev/null
+++ b/tests/generic/842
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 842
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via the page cache.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/842.out b/tests/generic/842.out
new file mode 100644
index 0000000..df58025
--- /dev/null
+++ b/tests/generic/842.out
@@ -0,0 +1,10 @@
+QA output created by 842
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/843 b/tests/generic/843
new file mode 100755
index 0000000..9349af1
--- /dev/null
+++ b/tests/generic/843
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 843
+#
+# Reflink a file that uses more than half the space, then try to run out of
+# space while copy-on-writing.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 3 / 2 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/843.out b/tests/generic/843.out
new file mode 100644
index 0000000..43c1cf6
--- /dev/null
+++ b/tests/generic/843.out
@@ -0,0 +1,10 @@
+QA output created by 843
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/844 b/tests/generic/844
new file mode 100755
index 0000000..ee834b3
--- /dev/null
+++ b/tests/generic/844
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 844
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via mmap.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "mmap CoW the big file"
+out="$($XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * NR_BLKS))" -c "mwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+err="$?"
+if [ "$err" -lt 128 ]; then
+	echo "mmap CoW should have failed with SIGBUS, got SIG$(kill -l $err)"
+fi
+sync
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/844.out b/tests/generic/844.out
new file mode 100644
index 0000000..f74f5bf
--- /dev/null
+++ b/tests/generic/844.out
@@ -0,0 +1,9 @@
+QA output created by 844
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+mmap CoW the big file
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/845 b/tests/generic/845
new file mode 100755
index 0000000..5587687
--- /dev/null
+++ b/tests/generic/845
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 845
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via direct-io.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -d -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/845.out b/tests/generic/845.out
new file mode 100644
index 0000000..d367a73
--- /dev/null
+++ b/tests/generic/845.out
@@ -0,0 +1,10 @@
+QA output created by 845
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index d4f05a9..2ff60a8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -248,3 +248,7 @@
 839 auto quick clone
 840 clone_stress
 841 clone_stress
+842 auto quick dangerous_clone
+843 auto quick dangerous_clone
+844 auto quick dangerous_clone
+845 auto quick dangerous_clone


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH 12/12] reflink: test that CoW writes fail when we're out of space
@ 2015-10-07  5:14   ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-07  5:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

Ensure that copy-on-writing a reflinked file when there's no free disk
space reflects the desired ENOSPC back to userspace during the write
call.  Tests the buffered IO, direct IO, and mmap write paths.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/842     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/842.out |   10 ++++
 tests/generic/843     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/843.out |   10 ++++
 tests/generic/844     |  112 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/844.out |    9 ++++
 tests/generic/845     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/845.out |   10 ++++
 tests/generic/group   |    4 ++
 9 files changed, 485 insertions(+)
 create mode 100755 tests/generic/842
 create mode 100644 tests/generic/842.out
 create mode 100755 tests/generic/843
 create mode 100644 tests/generic/843.out
 create mode 100755 tests/generic/844
 create mode 100644 tests/generic/844.out
 create mode 100755 tests/generic/845
 create mode 100644 tests/generic/845.out


diff --git a/tests/generic/842 b/tests/generic/842
new file mode 100755
index 0000000..9e46b6e
--- /dev/null
+++ b/tests/generic/842
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 842
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via the page cache.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/842.out b/tests/generic/842.out
new file mode 100644
index 0000000..df58025
--- /dev/null
+++ b/tests/generic/842.out
@@ -0,0 +1,10 @@
+QA output created by 842
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/843 b/tests/generic/843
new file mode 100755
index 0000000..9349af1
--- /dev/null
+++ b/tests/generic/843
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 843
+#
+# Reflink a file that uses more than half the space, then try to run out of
+# space while copy-on-writing.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 3 / 2 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/843.out b/tests/generic/843.out
new file mode 100644
index 0000000..43c1cf6
--- /dev/null
+++ b/tests/generic/843.out
@@ -0,0 +1,10 @@
+QA output created by 843
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/844 b/tests/generic/844
new file mode 100755
index 0000000..ee834b3
--- /dev/null
+++ b/tests/generic/844
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. 844
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via mmap.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "mmap CoW the big file"
+out="$($XFS_IO_PROG -f -c "mmap -rw 0 $((BLKSZ * NR_BLKS))" -c "mwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+err="$?"
+if [ "$err" -lt 128 ]; then
+	echo "mmap CoW should have failed with SIGBUS, got SIG$(kill -l $err)"
+fi
+sync
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/844.out b/tests/generic/844.out
new file mode 100644
index 0000000..f74f5bf
--- /dev/null
+++ b/tests/generic/844.out
@@ -0,0 +1,9 @@
+QA output created by 844
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+mmap CoW the big file
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/845 b/tests/generic/845
new file mode 100755
index 0000000..5587687
--- /dev/null
+++ b/tests/generic/845
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 845
+#
+# Reflink a file, use up the rest of the space, then try to observe ENOSPC
+# while copy-on-writing the file via direct-io.
+#
+#-----------------------------------------------------------------------
+# 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.* $TESTDIR1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_require_scratch
+_require_scratch_reflink
+_supported_os Linux
+
+_require_xfs_io_command "reflink"
+_require_cp_reflink
+
+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
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Reformat with appropriate size"
+BLKSZ="$(stat -f $TESTDIR -c '%S')"
+NR_BLKS=10240
+umount $SCRATCH_MNT
+SZ_BYTES="$((NR_BLKS * 8 * BLKSZ))"
+if [ $SZ_BYTES -lt $((32 * 1048576)) ]; then
+	SZ_BYTES=$((32 * 1048576))
+fi
+_scratch_mkfs_sized $SZ_BYTES >> $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+rm -rf $TESTDIR
+mkdir $TESTDIR
+
+echo "Create a big file and reflink it"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile >> $seqres.full 2>&1
+cp --reflink=always $TESTDIR/bigfile $TESTDIR/clonefile
+sync
+
+echo "Allocate the rest of the space"
+NR_FREE="$(stat -f -c '%f' $TESTDIR)"
+touch $TESTDIR/file0 $TESTDIR/file1
+$XFS_IO_PROG -f -c "pwrite -S 0x61 0 $((BLKSZ * NR_FREE))" $TESTDIR/eat_my_space >> $seqres.full 2>&1
+sync
+
+echo "CoW the big file"
+out="$($XFS_IO_PROG -d -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+echo "Remount and try CoW again"
+umount $SCRATCH_MNT
+_scratch_mount
+
+out="$($XFS_IO_PROG -f -c "pwrite -S 0x62 0 $((BLKSZ * NR_BLKS))" $TESTDIR/bigfile 2>&1)"
+test "$(echo "${out}" | grep -c "No space left on device")" -eq 1 || echo "CoW should have failed with ENOSPC"
+echo "${out}" >> $seqres.full 2>&1
+echo "${out}"
+
+#filefrag -v $TESTDIR/bigfile
+#filefrag -v $TESTDIR/clonefile
+
+echo "Check scratch fs"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/845.out b/tests/generic/845.out
new file mode 100644
index 0000000..d367a73
--- /dev/null
+++ b/tests/generic/845.out
@@ -0,0 +1,10 @@
+QA output created by 845
+Format and mount
+Reformat with appropriate size
+Create a big file and reflink it
+Allocate the rest of the space
+CoW the big file
+pwrite64: No space left on device
+Remount and try CoW again
+pwrite64: No space left on device
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index d4f05a9..2ff60a8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -248,3 +248,7 @@
 839 auto quick clone
 840 clone_stress
 841 clone_stress
+842 auto quick dangerous_clone
+843 auto quick dangerous_clone
+844 auto quick dangerous_clone
+845 auto quick dangerous_clone

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
       [not found] ` <9163f8156b2742a0b003ba9fa0a26258@nebula-exfe-01.nebula.local>
@ 2015-10-08 12:33     ` Ari Sundholm
  0 siblings, 0 replies; 42+ messages in thread
From: Ari Sundholm @ 2015-10-08 12:33 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: david, Anna.Schumaker, linux-ext4, linux-btrfs, fstests, xfs

On Wed, 2015-10-07 at 05:13 +0000, Darrick J. Wong wrote:
> Modify the reflink tests to support xfs.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc         |   37 +++++++++++++++++++++++++++++++++++++
>  tests/generic/800 |    2 +-
>  tests/generic/801 |    2 +-
>  tests/generic/802 |    2 +-
>  4 files changed, 40 insertions(+), 3 deletions(-)
> 
> 
> diff --git a/common/rc b/common/rc
> index 3e97060..7e2f140 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
>  	umount $SCRATCH_MNT
>  }
>  
> +# this test requires the test fs support reflink...
> +#
> +_require_test_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac
> +}
> +
> +# this test requires the scratch fs support reflink...
> +#
> +_require_scratch_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	_scratch_mkfs > /dev/null 2>&1
> +	_scratch_mount
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"

${SCRATCH_MNT}?

> +	_scratch_unmount
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac
> +}
> +
>  # this test requires the bigalloc feature to be available in mkfs.ext4
>  #
>  _require_ext4_mkfs_bigalloc()
> diff --git a/tests/generic/800 b/tests/generic/800
> index a71f11a..954f39d 100755
> --- a/tests/generic/800
> +++ b/tests/generic/800
> @@ -45,7 +45,7 @@ _cleanup()
>  . common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> diff --git a/tests/generic/801 b/tests/generic/801
> index b21c44b..aedb6e9 100755
> --- a/tests/generic/801
> +++ b/tests/generic/801
> @@ -45,7 +45,7 @@ _cleanup()
>  . common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> diff --git a/tests/generic/802 b/tests/generic/802
> index afd8513..51d3414 100755
> --- a/tests/generic/802
> +++ b/tests/generic/802
> @@ -43,7 +43,7 @@ _cleanup()
>  . ./common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
@ 2015-10-08 12:33     ` Ari Sundholm
  0 siblings, 0 replies; 42+ messages in thread
From: Ari Sundholm @ 2015-10-08 12:33 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

On Wed, 2015-10-07 at 05:13 +0000, Darrick J. Wong wrote:
> Modify the reflink tests to support xfs.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc         |   37 +++++++++++++++++++++++++++++++++++++
>  tests/generic/800 |    2 +-
>  tests/generic/801 |    2 +-
>  tests/generic/802 |    2 +-
>  4 files changed, 40 insertions(+), 3 deletions(-)
> 
> 
> diff --git a/common/rc b/common/rc
> index 3e97060..7e2f140 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
>  	umount $SCRATCH_MNT
>  }
>  
> +# this test requires the test fs support reflink...
> +#
> +_require_test_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac
> +}
> +
> +# this test requires the scratch fs support reflink...
> +#
> +_require_scratch_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	_scratch_mkfs > /dev/null 2>&1
> +	_scratch_mount
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"

${SCRATCH_MNT}?

> +	_scratch_unmount
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac
> +}
> +
>  # this test requires the bigalloc feature to be available in mkfs.ext4
>  #
>  _require_ext4_mkfs_bigalloc()
> diff --git a/tests/generic/800 b/tests/generic/800
> index a71f11a..954f39d 100755
> --- a/tests/generic/800
> +++ b/tests/generic/800
> @@ -45,7 +45,7 @@ _cleanup()
>  . common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> diff --git a/tests/generic/801 b/tests/generic/801
> index b21c44b..aedb6e9 100755
> --- a/tests/generic/801
> +++ b/tests/generic/801
> @@ -45,7 +45,7 @@ _cleanup()
>  . common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> diff --git a/tests/generic/802 b/tests/generic/802
> index afd8513..51d3414 100755
> --- a/tests/generic/802
> +++ b/tests/generic/802
> @@ -43,7 +43,7 @@ _cleanup()
>  . ./common/filter
>  
>  # real QA test starts here
> -_supported_fs btrfs
> +_require_test_reflink
>  _supported_os Linux
>  
>  _require_xfs_io_command "fiemap"
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
  2015-10-08 12:33     ` Ari Sundholm
@ 2015-10-09 18:58       ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-09 18:58 UTC (permalink / raw)
  To: Ari Sundholm; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

On Thu, Oct 08, 2015 at 03:33:59PM +0300, Ari Sundholm wrote:
> On Wed, 2015-10-07 at 05:13 +0000, Darrick J. Wong wrote:
> > Modify the reflink tests to support xfs.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/rc         |   37 +++++++++++++++++++++++++++++++++++++
> >  tests/generic/800 |    2 +-
> >  tests/generic/801 |    2 +-
> >  tests/generic/802 |    2 +-
> >  4 files changed, 40 insertions(+), 3 deletions(-)
> > 
> > 
> > diff --git a/common/rc b/common/rc
> > index 3e97060..7e2f140 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
> >  	umount $SCRATCH_MNT
> >  }
> >  
> > +# this test requires the test fs support reflink...
> > +#
> > +_require_test_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> > +}
> > +
> > +# this test requires the scratch fs support reflink...
> > +#
> > +_require_scratch_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	_scratch_mkfs > /dev/null 2>&1
> > +	_scratch_mount
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"
> 
> ${SCRATCH_MNT}?

Oops!  Thank you for catching this. :)

--D

> 
> > +	_scratch_unmount
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> > +}
> > +
> >  # this test requires the bigalloc feature to be available in mkfs.ext4
> >  #
> >  _require_ext4_mkfs_bigalloc()
> > diff --git a/tests/generic/800 b/tests/generic/800
> > index a71f11a..954f39d 100755
> > --- a/tests/generic/800
> > +++ b/tests/generic/800
> > @@ -45,7 +45,7 @@ _cleanup()
> >  . common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > diff --git a/tests/generic/801 b/tests/generic/801
> > index b21c44b..aedb6e9 100755
> > --- a/tests/generic/801
> > +++ b/tests/generic/801
> > @@ -45,7 +45,7 @@ _cleanup()
> >  . common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > diff --git a/tests/generic/802 b/tests/generic/802
> > index afd8513..51d3414 100755
> > --- a/tests/generic/802
> > +++ b/tests/generic/802
> > @@ -43,7 +43,7 @@ _cleanup()
> >  . ./common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
@ 2015-10-09 18:58       ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-09 18:58 UTC (permalink / raw)
  To: Ari Sundholm; +Cc: linux-btrfs, linux-ext4, Anna.Schumaker, fstests, xfs

On Thu, Oct 08, 2015 at 03:33:59PM +0300, Ari Sundholm wrote:
> On Wed, 2015-10-07 at 05:13 +0000, Darrick J. Wong wrote:
> > Modify the reflink tests to support xfs.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/rc         |   37 +++++++++++++++++++++++++++++++++++++
> >  tests/generic/800 |    2 +-
> >  tests/generic/801 |    2 +-
> >  tests/generic/802 |    2 +-
> >  4 files changed, 40 insertions(+), 3 deletions(-)
> > 
> > 
> > diff --git a/common/rc b/common/rc
> > index 3e97060..7e2f140 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -1429,6 +1429,43 @@ _require_scratch_xfs_crc()
> >  	umount $SCRATCH_MNT
> >  }
> >  
> > +# this test requires the test fs support reflink...
> > +#
> > +_require_test_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> > +}
> > +
> > +# this test requires the scratch fs support reflink...
> > +#
> > +_require_scratch_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	_scratch_mkfs > /dev/null 2>&1
> > +	_scratch_mount
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "$FSTYP does not support reflink"
> 
> ${SCRATCH_MNT}?

Oops!  Thank you for catching this. :)

--D

> 
> > +	_scratch_unmount
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> > +}
> > +
> >  # this test requires the bigalloc feature to be available in mkfs.ext4
> >  #
> >  _require_ext4_mkfs_bigalloc()
> > diff --git a/tests/generic/800 b/tests/generic/800
> > index a71f11a..954f39d 100755
> > --- a/tests/generic/800
> > +++ b/tests/generic/800
> > @@ -45,7 +45,7 @@ _cleanup()
> >  . common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > diff --git a/tests/generic/801 b/tests/generic/801
> > index b21c44b..aedb6e9 100755
> > --- a/tests/generic/801
> > +++ b/tests/generic/801
> > @@ -45,7 +45,7 @@ _cleanup()
> >  . common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > diff --git a/tests/generic/802 b/tests/generic/802
> > index afd8513..51d3414 100755
> > --- a/tests/generic/802
> > +++ b/tests/generic/802
> > @@ -43,7 +43,7 @@ _cleanup()
> >  . ./common/filter
> >  
> >  # real QA test starts here
> > -_supported_fs btrfs
> > +_require_test_reflink
> >  _supported_os Linux
> >  
> >  _require_xfs_io_command "fiemap"
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
  2015-10-07  5:13   ` Darrick J. Wong
@ 2015-10-15  9:19     ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-10-15  9:19 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: david, fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

> +# this test requires the test fs support reflink...
> +#
> +_require_test_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac

I don't think that's a good test - we need to check if it's supported by
trying it.  That'll automatically get us coverage for other file systems
like xfs.

Note that dedup should get it's own feature check, as currently hacking
nfs into this check will also run dedup tests that can't really be
supported.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
@ 2015-10-15  9:19     ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-10-15  9:19 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

> +# this test requires the test fs support reflink...
> +#
> +_require_test_reflink()
> +{
> +    case $FSTYP in
> +    xfs)
> +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +	;;
> +    btrfs)
> +        true
> +        ;;
> +    *)
> +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> +        ;;
> +    esac

I don't think that's a good test - we need to check if it's supported by
trying it.  That'll automatically get us coverage for other file systems
like xfs.

Note that dedup should get it's own feature check, as currently hacking
nfs into this check will also run dedup tests that can't really be
supported.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
  2015-10-15  9:19     ` Christoph Hellwig
@ 2015-10-15 14:41       ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-15 14:41 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: david, fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

On Thu, Oct 15, 2015 at 02:19:44AM -0700, Christoph Hellwig wrote:
> > +# this test requires the test fs support reflink...
> > +#
> > +_require_test_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> 
> I don't think that's a good test - we need to check if it's supported by
> trying it.  That'll automatically get us coverage for other file systems
> like xfs.
> 
> Note that dedup should get it's own feature check, as currently hacking
> nfs into this check will also run dedup tests that can't really be
> supported.

Good point.  I'll throw that in while I rework the tests.

--D

> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs
@ 2015-10-15 14:41       ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-10-15 14:41 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

On Thu, Oct 15, 2015 at 02:19:44AM -0700, Christoph Hellwig wrote:
> > +# this test requires the test fs support reflink...
> > +#
> > +_require_test_reflink()
> > +{
> > +    case $FSTYP in
> > +    xfs)
> > +	xfs_info "${TEST_DIR}" | grep reflink=1 -c -q || _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +	;;
> > +    btrfs)
> > +        true
> > +        ;;
> > +    *)
> > +        _notrun "Reflink not supported by this filesystem type: $FSTYP"
> > +        ;;
> > +    esac
> 
> I don't think that's a good test - we need to check if it's supported by
> trying it.  That'll automatically get us coverage for other file systems
> like xfs.
> 
> Note that dedup should get it's own feature check, as currently hacking
> nfs into this check will also run dedup tests that can't really be
> supported.

Good point.  I'll throw that in while I rework the tests.

--D

> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
  2015-10-07  5:12 ` Darrick J. Wong
@ 2015-11-09  7:59   ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-11-09  7:59 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: david, fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
>  * I don't have any interesting NFS/CIFS setups for test. :(

I have a banrch with client and server support for NFSv4.2 CLONE
support:

http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone

For now you want to use btrfs on the server, as using reflinks on XFS
seems to be a little unstable over NFS.

> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> They should just work with the btrfs that's in 4.3.
> 
> Comments and questions are, as always, welcome.

Any reason the groups are called clone?  I don't really have an opinion
on clone vs reflink but given that the xfs_io command is reflink I'd
rather be consistent.

Otherwise I'd say get it merged ASAP, we can still fix up various
details later.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-11-09  7:59   ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-11-09  7:59 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
>  * I don't have any interesting NFS/CIFS setups for test. :(

I have a banrch with client and server support for NFSv4.2 CLONE
support:

http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone

For now you want to use btrfs on the server, as using reflinks on XFS
seems to be a little unstable over NFS.

> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> They should just work with the btrfs that's in 4.3.
> 
> Comments and questions are, as always, welcome.

Any reason the groups are called clone?  I don't really have an opinion
on clone vs reflink but given that the xfs_io command is reflink I'd
rather be consistent.

Otherwise I'd say get it merged ASAP, we can still fix up various
details later.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
  2015-11-09  7:59   ` Christoph Hellwig
@ 2015-11-09 18:49     ` Darrick J. Wong
  -1 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-11-09 18:49 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: david, fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

On Sun, Nov 08, 2015 at 11:59:26PM -0800, Christoph Hellwig wrote:
> On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
> >  * I don't have any interesting NFS/CIFS setups for test. :(
> 
> I have a banrch with client and server support for NFSv4.2 CLONE
> support:
> 
> http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone
> 
> For now you want to use btrfs on the server, as using reflinks on XFS
> seems to be a little unstable over NFS.

I found a few more bugs in the kernel-side implementation, which might explain
that.  I'm about to start working on making CoW less crappy, but I'll push all
the patches out to github.  (I wasn't planning on patchbombing again until
December.)

> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > They should just work with the btrfs that's in 4.3.
> > 
> > Comments and questions are, as always, welcome.
> 
> Any reason the groups are called clone?  I don't really have an opinion
> on clone vs reflink but given that the xfs_io command is reflink I'd
> rather be consistent.

The existing btrfs reflink tests were tagged in the 'clone' group prior to my
patchset.

> Otherwise I'd say get it merged ASAP, we can still fix up various
> details later.

I'll merge your patch and repost the whole pile of tests.  I'm almost ready to
send a pile of updates for the XFS on-disk structure document which add stuff
about the v5 format, rmapbt, and reflink.

--D

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-11-09 18:49     ` Darrick J. Wong
  0 siblings, 0 replies; 42+ messages in thread
From: Darrick J. Wong @ 2015-11-09 18:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: fstests, xfs, linux-ext4, Anna.Schumaker, linux-btrfs

On Sun, Nov 08, 2015 at 11:59:26PM -0800, Christoph Hellwig wrote:
> On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
> >  * I don't have any interesting NFS/CIFS setups for test. :(
> 
> I have a banrch with client and server support for NFSv4.2 CLONE
> support:
> 
> http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone
> 
> For now you want to use btrfs on the server, as using reflinks on XFS
> seems to be a little unstable over NFS.

I found a few more bugs in the kernel-side implementation, which might explain
that.  I'm about to start working on making CoW less crappy, but I'll push all
the patches out to github.  (I wasn't planning on patchbombing again until
December.)

> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > They should just work with the btrfs that's in 4.3.
> > 
> > Comments and questions are, as always, welcome.
> 
> Any reason the groups are called clone?  I don't really have an opinion
> on clone vs reflink but given that the xfs_io command is reflink I'd
> rather be consistent.

The existing btrfs reflink tests were tagged in the 'clone' group prior to my
patchset.

> Otherwise I'd say get it merged ASAP, we can still fix up various
> details later.

I'll merge your patch and repost the whole pile of tests.  I'm almost ready to
send a pile of updates for the XFS on-disk structure document which add stuff
about the v5 format, rmapbt, and reflink.

--D

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
  2015-11-09 18:49     ` Darrick J. Wong
@ 2015-11-11 13:56       ` Christoph Hellwig
  -1 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-11-11 13:56 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, david, fstests, linux-ext4, Anna.Schumaker,
	linux-btrfs, xfs

On Mon, Nov 09, 2015 at 10:49:13AM -0800, Darrick J. Wong wrote:
> I found a few more bugs in the kernel-side implementation, which might explain
> that.  I'm about to start working on making CoW less crappy, but I'll push all
> the patches out to github.  (I wasn't planning on patchbombing again until
> December.)

Yes, please push your WIP code out as often as possible!

Btw, here is another additional fixup, as two tests were wrongly
tagged as needing reflink instead of dedupe:


diff --git a/tests/generic/827 b/tests/generic/827
index cc1bc52..c8ce7cf 100755
--- a/tests/generic/827
+++ b/tests/generic/827
@@ -47,7 +47,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_scratch
-_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
diff --git a/tests/generic/828 b/tests/generic/828
index 1757985..f5b7298 100755
--- a/tests/generic/828
+++ b/tests/generic/828
@@ -47,7 +47,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_scratch
-_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-11-11 13:56       ` Christoph Hellwig
  0 siblings, 0 replies; 42+ messages in thread
From: Christoph Hellwig @ 2015-11-11 13:56 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: fstests, xfs, Christoph Hellwig, linux-ext4, Anna.Schumaker, linux-btrfs

On Mon, Nov 09, 2015 at 10:49:13AM -0800, Darrick J. Wong wrote:
> I found a few more bugs in the kernel-side implementation, which might explain
> that.  I'm about to start working on making CoW less crappy, but I'll push all
> the patches out to github.  (I wasn't planning on patchbombing again until
> December.)

Yes, please push your WIP code out as often as possible!

Btw, here is another additional fixup, as two tests were wrongly
tagged as needing reflink instead of dedupe:


diff --git a/tests/generic/827 b/tests/generic/827
index cc1bc52..c8ce7cf 100755
--- a/tests/generic/827
+++ b/tests/generic/827
@@ -47,7 +47,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_scratch
-_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1
diff --git a/tests/generic/828 b/tests/generic/828
index 1757985..f5b7298 100755
--- a/tests/generic/828
+++ b/tests/generic/828
@@ -47,7 +47,7 @@ _supported_fs generic
 _supported_os Linux
 
 _require_scratch
-_require_xfs_io_command "reflink"
+_require_xfs_io_command "dedupe"
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
  2015-11-09 18:49     ` Darrick J. Wong
@ 2015-11-12  0:41       ` Dave Chinner
  -1 siblings, 0 replies; 42+ messages in thread
From: Dave Chinner @ 2015-11-12  0:41 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, fstests, linux-ext4, Anna.Schumaker, linux-btrfs, xfs

On Mon, Nov 09, 2015 at 10:49:13AM -0800, Darrick J. Wong wrote:
> On Sun, Nov 08, 2015 at 11:59:26PM -0800, Christoph Hellwig wrote:
> > On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
> > >  * I don't have any interesting NFS/CIFS setups for test. :(
> > 
> > I have a banrch with client and server support for NFSv4.2 CLONE
> > support:
> > 
> > http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone
> > 
> > For now you want to use btrfs on the server, as using reflinks on XFS
> > seems to be a little unstable over NFS.
> 
> I found a few more bugs in the kernel-side implementation, which might explain
> that.  I'm about to start working on making CoW less crappy, but I'll push all
> the patches out to github.  (I wasn't planning on patchbombing again until
> December.)
> 
> > > If you're going to start using this mess, you probably ought to just
> > > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > > They should just work with the btrfs that's in 4.3.
> > > 
> > > Comments and questions are, as always, welcome.
> > 
> > Any reason the groups are called clone?  I don't really have an opinion
> > on clone vs reflink but given that the xfs_io command is reflink I'd
> > rather be consistent.
> 
> The existing btrfs reflink tests were tagged in the 'clone' group prior to my
> patchset.
> 
> > Otherwise I'd say get it merged ASAP, we can still fix up various
> > details later.
> 
> I'll merge your patch and repost the whole pile of tests.  I'm almost ready to
> send a pile of updates for the XFS on-disk structure document which add stuff
> about the v5 format, rmapbt, and reflink.

Darrick, can you renumber the xfstests against what is currently at
the head of the repo? If both you an Christoph need them working,
you may as well both patch against the main xfstests repo...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls
@ 2015-11-12  0:41       ` Dave Chinner
  0 siblings, 0 replies; 42+ messages in thread
From: Dave Chinner @ 2015-11-12  0:41 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: fstests, xfs, Christoph Hellwig, linux-ext4, Anna.Schumaker, linux-btrfs

On Mon, Nov 09, 2015 at 10:49:13AM -0800, Darrick J. Wong wrote:
> On Sun, Nov 08, 2015 at 11:59:26PM -0800, Christoph Hellwig wrote:
> > On Tue, Oct 06, 2015 at 10:12:57PM -0700, Darrick J. Wong wrote:
> > >  * I don't have any interesting NFS/CIFS setups for test. :(
> > 
> > I have a banrch with client and server support for NFSv4.2 CLONE
> > support:
> > 
> > http://git.infradead.org/users/hch/pnfs.git/shortlog/refs/heads/reflink+clone
> > 
> > For now you want to use btrfs on the server, as using reflinks on XFS
> > seems to be a little unstable over NFS.
> 
> I found a few more bugs in the kernel-side implementation, which might explain
> that.  I'm about to start working on making CoW less crappy, but I'll push all
> the patches out to github.  (I wasn't planning on patchbombing again until
> December.)
> 
> > > If you're going to start using this mess, you probably ought to just
> > > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > > They should just work with the btrfs that's in 4.3.
> > > 
> > > Comments and questions are, as always, welcome.
> > 
> > Any reason the groups are called clone?  I don't really have an opinion
> > on clone vs reflink but given that the xfs_io command is reflink I'd
> > rather be consistent.
> 
> The existing btrfs reflink tests were tagged in the 'clone' group prior to my
> patchset.
> 
> > Otherwise I'd say get it merged ASAP, we can still fix up various
> > details later.
> 
> I'll merge your patch and repost the whole pile of tests.  I'm almost ready to
> send a pile of updates for the XFS on-disk structure document which add stuff
> about the v5 format, rmapbt, and reflink.

Darrick, can you renumber the xfstests against what is currently at
the head of the repo? If both you an Christoph need them working,
you may as well both patch against the main xfstests repo...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2015-11-12  0:42 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-07  5:12 [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls Darrick J. Wong
2015-10-07  5:12 ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 01/12] xfs: fix merge errors in fuzzer tests Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 02/12] btrfs: move btrfs reflink tests to generic Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-15  9:19   ` Christoph Hellwig
2015-10-15  9:19     ` Christoph Hellwig
2015-10-15 14:41     ` Darrick J. Wong
2015-10-15 14:41       ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 04/12] reflink: basic tests of the reflink and dedupe ioctls Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 05/12] reflink: test CoW behaviors of reflinked files Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 06/12] reflink: test the various fallocate modes Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 07/12] reflink: concurrent operations tests Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:13 ` [PATCH 08/12] reflink: test accuracy of free block counts Darrick J. Wong
2015-10-07  5:13   ` Darrick J. Wong
2015-10-07  5:14 ` [PATCH 09/12] reflink: test error conditions due to bad inputs Darrick J. Wong
2015-10-07  5:14   ` Darrick J. Wong
2015-10-07  5:14 ` [PATCH 10/12] xfs: test xfs-specific reflink pieces Darrick J. Wong
2015-10-07  5:14   ` Darrick J. Wong
2015-10-07  5:14 ` [PATCH 11/12] reflink: test what happens when we hit resource limits Darrick J. Wong
2015-10-07  5:14   ` Darrick J. Wong
2015-10-07  5:14 ` [PATCH 12/12] reflink: test that CoW writes fail when we're out of space Darrick J. Wong
2015-10-07  5:14   ` Darrick J. Wong
     [not found] ` <9163f8156b2742a0b003ba9fa0a26258@nebula-exfe-01.nebula.local>
2015-10-08 12:33   ` [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs Ari Sundholm
2015-10-08 12:33     ` Ari Sundholm
2015-10-09 18:58     ` Darrick J. Wong
2015-10-09 18:58       ` Darrick J. Wong
2015-11-09  7:59 ` [RFCv3 00/12] xfstests: test the btrfs/xfs reflink/dedupe ioctls Christoph Hellwig
2015-11-09  7:59   ` Christoph Hellwig
2015-11-09 18:49   ` Darrick J. Wong
2015-11-09 18:49     ` Darrick J. Wong
2015-11-11 13:56     ` Christoph Hellwig
2015-11-11 13:56       ` Christoph Hellwig
2015-11-12  0:41     ` Dave Chinner
2015-11-12  0:41       ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.