All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
@ 2016-02-09  1:11 ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Happy New Year!

Dave Chinner: I've renumbered the new tests and pushed to github[3] if
you'd like to pull.

This is a (no longer) small patch set against the reflink/dedupe test
cases in xfstests.  The first four patches fix errors in the existing
reflink tests, some of which are from Christoph Hellwig.

Patches 5-6 refactor the dmerror code so that we can use it to
simulate transient IO errors, then use this code to test that
unwritten extent conversion does NOT happen after a directio write to
an unwritten extent hits a disk error.   Due to a bug in the VFS
directio code, ext4 can disclose stale disk contents if an aio dio
write fails; XFS suffers this problem for any failing dio write to an
unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
directio updates to ease COW handling V2" (and a separate ext4 warning
cleanup) is needed to fix this.

Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
of the copy on write behavior that are necessary to support shared
blocks.  The earlier patches focus on correct CoW behavior in the
presence of IO errors during the copy-write, and the later patches
focus on XFS' new cow-extent-size hint that greatly reduces
fragmentation due to copy on write behavior by encouraging the
allocator to allocate larger extents of replacement blocks.

Patches 10-12 and 14 perform stress testing on reflink and CoW to
check the behaviors when we get close to maximum refcount, when we
specify obnxiously large offsets and lengths, and when we try to
reflink millions of extents at a time.

Patch 16 tests quota accounting behavior when reflink is enabled.

Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
that things like metadump and growfs work correctly.

Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
extents as having shared blocks.  XFS now follows btrfs and ocfs2
FIEMAP behavior such that if any blocks of a file's extent are shared,
the whole extent is marked shared.  This is in contrast to earlier
XFS-only behavior that reported shared and non-shared regions as
separate extents.

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
to run the cp_reflink tests) seemed to have a quota bug and crashes
hard in 284 (but was otherwise fine).

Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/for-dave
[2] https://github.com/djwong/xfsprogs/tree/for-dave
[3] https://github.com/djwong/xfstests/tree/for-dave
[4] https://github.com/djwong/xfs-documentation/tree/for-dave
[5] https://github.com/djwong/man-pages/commits/for-mtk

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

* [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
@ 2016-02-09  1:11 ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Happy New Year!

Dave Chinner: I've renumbered the new tests and pushed to github[3] if
you'd like to pull.

This is a (no longer) small patch set against the reflink/dedupe test
cases in xfstests.  The first four patches fix errors in the existing
reflink tests, some of which are from Christoph Hellwig.

Patches 5-6 refactor the dmerror code so that we can use it to
simulate transient IO errors, then use this code to test that
unwritten extent conversion does NOT happen after a directio write to
an unwritten extent hits a disk error.   Due to a bug in the VFS
directio code, ext4 can disclose stale disk contents if an aio dio
write fails; XFS suffers this problem for any failing dio write to an
unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
directio updates to ease COW handling V2" (and a separate ext4 warning
cleanup) is needed to fix this.

Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
of the copy on write behavior that are necessary to support shared
blocks.  The earlier patches focus on correct CoW behavior in the
presence of IO errors during the copy-write, and the later patches
focus on XFS' new cow-extent-size hint that greatly reduces
fragmentation due to copy on write behavior by encouraging the
allocator to allocate larger extents of replacement blocks.

Patches 10-12 and 14 perform stress testing on reflink and CoW to
check the behaviors when we get close to maximum refcount, when we
specify obnxiously large offsets and lengths, and when we try to
reflink millions of extents at a time.

Patch 16 tests quota accounting behavior when reflink is enabled.

Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
that things like metadump and growfs work correctly.

Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
extents as having shared blocks.  XFS now follows btrfs and ocfs2
FIEMAP behavior such that if any blocks of a file's extent are shared,
the whole extent is marked shared.  This is in contrast to earlier
XFS-only behavior that reported shared and non-shared regions as
separate extents.

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
to run the cp_reflink tests) seemed to have a quota bug and crashes
hard in 284 (but was otherwise fine).

Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/for-dave
[2] https://github.com/djwong/xfsprogs/tree/for-dave
[3] https://github.com/djwong/xfstests/tree/for-dave
[4] https://github.com/djwong/xfs-documentation/tree/for-dave
[5] https://github.com/djwong/man-pages/commits/for-mtk

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

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

* [PATCH 01/23] generic/182: this is a dedupe test, check for dedupe
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:11   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Since this test examines dedupe behavior, the documentation should
say 'dedupe', not 'reflink'.  Furthermore, the feature checks must
look for working dedupe functionality, not reflink functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: add the test for dedupe support]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/182 |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)


diff --git a/tests/generic/182 b/tests/generic/182
index bf5cd38..ef10af8 100755
--- a/tests/generic/182
+++ b/tests/generic/182
@@ -1,10 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 182
 #
-# Test the convention that reflink with length == 0 means "to the end of fileA"
+# Test the convention that dedupe with length == 0 means "to the end of fileA"
 #   - Create a file.
-#   - Try to reflink "zero" bytes (which means reflink to EOF).
-#   - Check that the reflink happened.
+#   - Try to dedupe "zero" bytes (which means dedupe to EOF).
+#   - Check that the dedupe happened.
 #
 #-----------------------------------------------------------------------
 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
@@ -45,8 +45,7 @@ _cleanup()
 
 # real QA test starts here
 _supported_os Linux
-_require_test_reflink
-_require_cp_reflink
+_require_test_dedupe
 
 rm -f "$seqres.full"
 


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

* [PATCH 01/23] generic/182: this is a dedupe test, check for dedupe
@ 2016-02-09  1:11   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Since this test examines dedupe behavior, the documentation should
say 'dedupe', not 'reflink'.  Furthermore, the feature checks must
look for working dedupe functionality, not reflink functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: add the test for dedupe support]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/182 |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)


diff --git a/tests/generic/182 b/tests/generic/182
index bf5cd38..ef10af8 100755
--- a/tests/generic/182
+++ b/tests/generic/182
@@ -1,10 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 182
 #
-# Test the convention that reflink with length == 0 means "to the end of fileA"
+# Test the convention that dedupe with length == 0 means "to the end of fileA"
 #   - Create a file.
-#   - Try to reflink "zero" bytes (which means reflink to EOF).
-#   - Check that the reflink happened.
+#   - Try to dedupe "zero" bytes (which means dedupe to EOF).
+#   - Check that the dedupe happened.
 #
 #-----------------------------------------------------------------------
 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
@@ -45,8 +45,7 @@ _cleanup()
 
 # real QA test starts here
 _supported_os Linux
-_require_test_reflink
-_require_cp_reflink
+_require_test_dedupe
 
 rm -f "$seqres.full"
 

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

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

* [PATCH 02/23] xfstests: filter whitespace in 128 and 132
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:11   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Seems either I have a different lsattr version, or different mount points
cause differences in the golden output.  Send the lsattr output through
the whitespaces filter so that it works everywhere.

The lsattr output /does/ change depending on mountpoints.  Ick.  I'd
actually changed it to the long format output because line length in
the short format changes every time the flags change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[darrick.wong@oracle.com: update changelog]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128     |    2 +-
 tests/xfs/128.out |    8 ++++----
 tests/xfs/132     |   10 +++++-----
 tests/xfs/132.out |   40 ++++++++++++++++++++--------------------
 4 files changed, 30 insertions(+), 30 deletions(-)


diff --git a/tests/xfs/128 b/tests/xfs/128
index a96291a..c9547fb 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -97,7 +97,7 @@ c13=$(_md5_checksum "$testdir/file3")
 c14=$(_md5_checksum "$testdir/file4")
 
 echo "Defragment"
-lsattr -l "$testdir/" | _filter_scratch
+lsattr -l "$testdir/" | _filter_scratch | _filter_spaces
 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
diff --git a/tests/xfs/128.out b/tests/xfs/128.out
index 7e72dcd..0ac06db 100644
--- a/tests/xfs/128.out
+++ b/tests/xfs/128.out
@@ -11,10 +11,10 @@ c650f1cf6c9f07b22e3e21ec7d49ded5  SCRATCH_MNT/test-128/file2
 56ed2f712c91e035adeeb26ed105a982  SCRATCH_MNT/test-128/file3
 b81534f439aac5c34ce3ed60a03eba70  SCRATCH_MNT/test-128/file4
 Defragment
-SCRATCH_MNT/test-128/file1          ---
-SCRATCH_MNT/test-128/file2          ---
-SCRATCH_MNT/test-128/file3          ---
-SCRATCH_MNT/test-128/file4          ---
+SCRATCH_MNT/test-128/file1 ---
+SCRATCH_MNT/test-128/file2 ---
+SCRATCH_MNT/test-128/file3 ---
+SCRATCH_MNT/test-128/file4 ---
 b81534f439aac5c34ce3ed60a03eba70  SCRATCH_MNT/test-128/file1
 c650f1cf6c9f07b22e3e21ec7d49ded5  SCRATCH_MNT/test-128/file2
 56ed2f712c91e035adeeb26ed105a982  SCRATCH_MNT/test-128/file3
diff --git a/tests/xfs/132 b/tests/xfs/132
index 79a6d57..9c57c3b 100755
--- a/tests/xfs/132
+++ b/tests/xfs/132
@@ -87,32 +87,32 @@ for i in `seq 2 $nr`; do
 done
 _test_remount
 free_blocks1=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare part of a file"
 "$XFS_IO_PROG" -f -c "falloc 0 $((sz / 2))" "$testdir/file2"
 _test_remount
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare some of the copies"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file2"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file3"
 _test_remount
 free_blocks2=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare the rest of the files"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file4"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file1"
 _test_remount
 free_blocks3=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "Rewrite the original file"
 _pwrite_byte 0x65 0 $sz "$testdir/file1" >> "$seqres.full"
 _test_remount
 free_blocks4=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 #echo $free_blocks0 $free_blocks1 $free_blocks2 $free_blocks3 $free_blocks4
 
 _within_tolerance "free blocks after reflinking" $free_blocks1 $((free_blocks0 - blks)) $margin -v
diff --git a/tests/xfs/132.out b/tests/xfs/132.out
index fd2b7bd..f32db7d 100644
--- a/tests/xfs/132.out
+++ b/tests/xfs/132.out
@@ -1,30 +1,30 @@
 QA output created by 132
 Create the original file blocks
 Create the reflink copies
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          ---
-TEST_DIR/test-132/file3          ---
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 ---
+TEST_DIR/test-132/file3 ---
+TEST_DIR/test-132/file4 ---
 funshare part of a file
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          ---
-TEST_DIR/test-132/file3          ---
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 ---
+TEST_DIR/test-132/file3 ---
+TEST_DIR/test-132/file4 ---
 funshare some of the copies
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/file4 ---
 funshare the rest of the files
-TEST_DIR/test-132/file1          No_COW
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          No_COW
+TEST_DIR/test-132/file1 No_COW
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/file4 No_COW
 Rewrite the original file
-TEST_DIR/test-132/file1          No_COW
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          No_COW
+TEST_DIR/test-132/file1 No_COW
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/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


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

* [PATCH 02/23] xfstests: filter whitespace in 128 and 132
@ 2016-02-09  1:11   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:11 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Seems either I have a different lsattr version, or different mount points
cause differences in the golden output.  Send the lsattr output through
the whitespaces filter so that it works everywhere.

The lsattr output /does/ change depending on mountpoints.  Ick.  I'd
actually changed it to the long format output because line length in
the short format changes every time the flags change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[darrick.wong@oracle.com: update changelog]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128     |    2 +-
 tests/xfs/128.out |    8 ++++----
 tests/xfs/132     |   10 +++++-----
 tests/xfs/132.out |   40 ++++++++++++++++++++--------------------
 4 files changed, 30 insertions(+), 30 deletions(-)


diff --git a/tests/xfs/128 b/tests/xfs/128
index a96291a..c9547fb 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -97,7 +97,7 @@ c13=$(_md5_checksum "$testdir/file3")
 c14=$(_md5_checksum "$testdir/file4")
 
 echo "Defragment"
-lsattr -l "$testdir/" | _filter_scratch
+lsattr -l "$testdir/" | _filter_scratch | _filter_spaces
 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
diff --git a/tests/xfs/128.out b/tests/xfs/128.out
index 7e72dcd..0ac06db 100644
--- a/tests/xfs/128.out
+++ b/tests/xfs/128.out
@@ -11,10 +11,10 @@ c650f1cf6c9f07b22e3e21ec7d49ded5  SCRATCH_MNT/test-128/file2
 56ed2f712c91e035adeeb26ed105a982  SCRATCH_MNT/test-128/file3
 b81534f439aac5c34ce3ed60a03eba70  SCRATCH_MNT/test-128/file4
 Defragment
-SCRATCH_MNT/test-128/file1          ---
-SCRATCH_MNT/test-128/file2          ---
-SCRATCH_MNT/test-128/file3          ---
-SCRATCH_MNT/test-128/file4          ---
+SCRATCH_MNT/test-128/file1 ---
+SCRATCH_MNT/test-128/file2 ---
+SCRATCH_MNT/test-128/file3 ---
+SCRATCH_MNT/test-128/file4 ---
 b81534f439aac5c34ce3ed60a03eba70  SCRATCH_MNT/test-128/file1
 c650f1cf6c9f07b22e3e21ec7d49ded5  SCRATCH_MNT/test-128/file2
 56ed2f712c91e035adeeb26ed105a982  SCRATCH_MNT/test-128/file3
diff --git a/tests/xfs/132 b/tests/xfs/132
index 79a6d57..9c57c3b 100755
--- a/tests/xfs/132
+++ b/tests/xfs/132
@@ -87,32 +87,32 @@ for i in `seq 2 $nr`; do
 done
 _test_remount
 free_blocks1=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare part of a file"
 "$XFS_IO_PROG" -f -c "falloc 0 $((sz / 2))" "$testdir/file2"
 _test_remount
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare some of the copies"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file2"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file3"
 _test_remount
 free_blocks2=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "funshare the rest of the files"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file4"
 "$XFS_IO_PROG" -f -c "falloc 0 $sz" "$testdir/file1"
 _test_remount
 free_blocks3=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 
 echo "Rewrite the original file"
 _pwrite_byte 0x65 0 $sz "$testdir/file1" >> "$seqres.full"
 _test_remount
 free_blocks4=$(stat -f "$testdir" -c '%f')
-lsattr -l $testdir/ | _filter_test_dir
+lsattr -l $testdir/ | _filter_test_dir | _filter_spaces
 #echo $free_blocks0 $free_blocks1 $free_blocks2 $free_blocks3 $free_blocks4
 
 _within_tolerance "free blocks after reflinking" $free_blocks1 $((free_blocks0 - blks)) $margin -v
diff --git a/tests/xfs/132.out b/tests/xfs/132.out
index fd2b7bd..f32db7d 100644
--- a/tests/xfs/132.out
+++ b/tests/xfs/132.out
@@ -1,30 +1,30 @@
 QA output created by 132
 Create the original file blocks
 Create the reflink copies
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          ---
-TEST_DIR/test-132/file3          ---
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 ---
+TEST_DIR/test-132/file3 ---
+TEST_DIR/test-132/file4 ---
 funshare part of a file
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          ---
-TEST_DIR/test-132/file3          ---
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 ---
+TEST_DIR/test-132/file3 ---
+TEST_DIR/test-132/file4 ---
 funshare some of the copies
-TEST_DIR/test-132/file1          ---
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          ---
+TEST_DIR/test-132/file1 ---
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/file4 ---
 funshare the rest of the files
-TEST_DIR/test-132/file1          No_COW
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          No_COW
+TEST_DIR/test-132/file1 No_COW
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/file4 No_COW
 Rewrite the original file
-TEST_DIR/test-132/file1          No_COW
-TEST_DIR/test-132/file2          No_COW
-TEST_DIR/test-132/file3          No_COW
-TEST_DIR/test-132/file4          No_COW
+TEST_DIR/test-132/file1 No_COW
+TEST_DIR/test-132/file2 No_COW
+TEST_DIR/test-132/file3 No_COW
+TEST_DIR/test-132/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

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

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

* [PATCH 03/23] xfstests: make _scratch_mkfs_blocksized usable
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

The default mkfs.xfs options contain -b size=4096, so all tests
using _scratch_mkfs_blocksized won't actually run unless those
options are changed.  As we're trying to specificly test 1k
blocks we should always override the default option.

v2: Move the function to common/rc

Signed-off-by: Christoph Hellwig <hch@lst.de>
[darrick.wong@oracle.com: move function to common/rc]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc      |   24 ++++++++++++++++++++++++
 common/reflink |   30 ------------------------------
 2 files changed, 24 insertions(+), 30 deletions(-)


diff --git a/common/rc b/common/rc
index f08cb3a..863d4b3 100644
--- a/common/rc
+++ b/common/rc
@@ -881,6 +881,30 @@ _scratch_mkfs_geom()
     _scratch_mkfs
 }
 
+# Create fs of certain blocksize on scratch device
+# _scratch_mkfs_blocksized blocksize
+_scratch_mkfs_blocksized()
+{
+    blocksize=$1
+
+    re='^[0-9]+$'
+    if ! [[ $blocksize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+    fi
+
+    case $FSTYP in
+    xfs)
+	_scratch_mkfs_xfs $MKFS_OPTIONS -b size=$blocksize
+	;;
+    ext2|ext3|ext4|ocfs2)
+	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+	;;
+    *)
+	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
+	;;
+    esac
+}
+
 _scratch_resvblks()
 {
 	case $FSTYP in
diff --git a/common/reflink b/common/reflink
index 8638aba..3d6a8c1 100644
--- a/common/reflink
+++ b/common/reflink
@@ -187,33 +187,3 @@ _dedupe_range() {
 
 	"$XFS_IO_PROG" $xfs_io_args -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2"
 }
-
-# Create fs of certain blocksize on scratch device
-# _scratch_mkfs_blocksized blocksize
-_scratch_mkfs_blocksized()
-{
-    blocksize=$1
-
-    re='^[0-9]+$'
-    if ! [[ $blocksize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
-    fi
-
-    case $FSTYP in
-    xfs)
-	# don't override MKFS_OPTIONS that set a block size.
-	echo $MKFS_OPTIONS |egrep -q "b?size="
-	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs
-	else
-		_scratch_mkfs_xfs -b size=$blocksize
-	fi
-	;;
-    ext2|ext3|ext4|ocfs2)
-	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
-	;;
-    *)
-	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
-	;;
-    esac
-}


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

* [PATCH 03/23] xfstests: make _scratch_mkfs_blocksized usable
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

The default mkfs.xfs options contain -b size=4096, so all tests
using _scratch_mkfs_blocksized won't actually run unless those
options are changed.  As we're trying to specificly test 1k
blocks we should always override the default option.

v2: Move the function to common/rc

Signed-off-by: Christoph Hellwig <hch@lst.de>
[darrick.wong@oracle.com: move function to common/rc]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc      |   24 ++++++++++++++++++++++++
 common/reflink |   30 ------------------------------
 2 files changed, 24 insertions(+), 30 deletions(-)


diff --git a/common/rc b/common/rc
index f08cb3a..863d4b3 100644
--- a/common/rc
+++ b/common/rc
@@ -881,6 +881,30 @@ _scratch_mkfs_geom()
     _scratch_mkfs
 }
 
+# Create fs of certain blocksize on scratch device
+# _scratch_mkfs_blocksized blocksize
+_scratch_mkfs_blocksized()
+{
+    blocksize=$1
+
+    re='^[0-9]+$'
+    if ! [[ $blocksize =~ $re ]] ; then
+        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
+    fi
+
+    case $FSTYP in
+    xfs)
+	_scratch_mkfs_xfs $MKFS_OPTIONS -b size=$blocksize
+	;;
+    ext2|ext3|ext4|ocfs2)
+	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
+	;;
+    *)
+	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
+	;;
+    esac
+}
+
 _scratch_resvblks()
 {
 	case $FSTYP in
diff --git a/common/reflink b/common/reflink
index 8638aba..3d6a8c1 100644
--- a/common/reflink
+++ b/common/reflink
@@ -187,33 +187,3 @@ _dedupe_range() {
 
 	"$XFS_IO_PROG" $xfs_io_args -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2"
 }
-
-# Create fs of certain blocksize on scratch device
-# _scratch_mkfs_blocksized blocksize
-_scratch_mkfs_blocksized()
-{
-    blocksize=$1
-
-    re='^[0-9]+$'
-    if ! [[ $blocksize =~ $re ]] ; then
-        _notrun "error: _scratch_mkfs_sized: block size \"$blocksize\" not an integer."
-    fi
-
-    case $FSTYP in
-    xfs)
-	# don't override MKFS_OPTIONS that set a block size.
-	echo $MKFS_OPTIONS |egrep -q "b?size="
-	if [ $? -eq 0 ]; then
-		_scratch_mkfs_xfs
-	else
-		_scratch_mkfs_xfs -b size=$blocksize
-	fi
-	;;
-    ext2|ext3|ext4|ocfs2)
-	${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV
-	;;
-    *)
-	_notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized"
-	;;
-    esac
-}

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

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

* [PATCH 04/23] reflink: remove redundant filesystem checks from the end of the tests
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Turns out that check already runs _check_filesystems after each test,
so we don't need to do this at the end of each test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/157 |    1 -
 tests/generic/158 |    1 -
 tests/generic/161 |    1 -
 tests/generic/162 |    1 -
 tests/generic/163 |    1 -
 tests/generic/164 |    1 -
 tests/generic/165 |    1 -
 tests/generic/166 |    1 -
 tests/generic/167 |    1 -
 tests/generic/168 |    1 -
 tests/generic/170 |    1 -
 tests/generic/171 |    1 -
 tests/generic/172 |    1 -
 tests/generic/173 |    1 -
 tests/generic/174 |    1 -
 tests/generic/175 |    1 -
 tests/generic/176 |    1 -
 tests/generic/183 |    1 -
 tests/generic/185 |    1 -
 tests/generic/186 |    1 -
 tests/generic/187 |    1 -
 tests/generic/188 |    1 -
 tests/generic/189 |    1 -
 tests/generic/190 |    1 -
 tests/generic/191 |    1 -
 tests/generic/194 |    1 -
 tests/generic/195 |    1 -
 tests/generic/196 |    1 -
 tests/generic/197 |    1 -
 tests/generic/199 |    1 -
 tests/generic/200 |    1 -
 tests/generic/201 |    1 -
 tests/generic/202 |    1 -
 tests/generic/203 |    1 -
 tests/generic/205 |    1 -
 tests/generic/206 |    1 -
 tests/generic/216 |    1 -
 tests/generic/217 |    1 -
 tests/generic/218 |    1 -
 tests/generic/220 |    1 -
 tests/generic/222 |    1 -
 tests/generic/227 |    1 -
 tests/generic/229 |    1 -
 tests/generic/238 |    1 -
 tests/generic/242 |    1 -
 tests/generic/243 |    1 -
 tests/xfs/127     |    1 -
 tests/xfs/128     |    1 -
 tests/xfs/131     |    1 -
 tests/xfs/139     |    1 -
 tests/xfs/140     |    1 -
 51 files changed, 51 deletions(-)


diff --git a/tests/generic/157 b/tests/generic/157
index 0150866..74314d8 100755
--- a/tests/generic/157
+++ b/tests/generic/157
@@ -123,7 +123,6 @@ _reflink_range "$testdir2/file1" 0 "$testdir2/file2" 0 $blksz >> "$seqres.full"
 
 echo "Check scratch fs"
 _scratch_unmount
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/158 b/tests/generic/158
index 807c247..779d55e 100755
--- a/tests/generic/158
+++ b/tests/generic/158
@@ -124,7 +124,6 @@ _dedupe_range "$testdir2/file1" 0 "$testdir2/file2" 0 $blksz >> "$seqres.full"
 
 echo "Check scratch fs"
 _scratch_unmount
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/161 b/tests/generic/161
index 7fb8963..b271936 100755
--- a/tests/generic/161
+++ b/tests/generic/161
@@ -71,7 +71,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/162 b/tests/generic/162
index 2fb947a..30c761b 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -87,7 +87,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/163 b/tests/generic/163
index 0186443..f2ea334 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -87,7 +87,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/164 b/tests/generic/164
index 087c6ba..e97ac13 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -97,7 +97,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/165 b/tests/generic/165
index 6bd15e1..b305079 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -97,7 +97,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/166 b/tests/generic/166
index 6cfb821..2c2ff4e 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -84,7 +84,6 @@ wait
 
 echo "Check for damage"
 _scratch_unmount
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/167 b/tests/generic/167
index fc5a86c..b80b481 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -84,7 +84,6 @@ wait
 
 echo "Check for damage"
 _scratch_unmount
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/168 b/tests/generic/168
index ee3848d..0d620da 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -88,7 +88,6 @@ wait
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/170 b/tests/generic/170
index 6d27810..78ed63d 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -88,7 +88,6 @@ wait
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/171 b/tests/generic/171
index ec3729d..4b4f141 100755
--- a/tests/generic/171
+++ b/tests/generic/171
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/172 b/tests/generic/172
index 1988c8d..98eb97f 100755
--- a/tests/generic/172
+++ b/tests/generic/172
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/173 b/tests/generic/173
index 5bb9ce6..e26f5a9 100755
--- a/tests/generic/173
+++ b/tests/generic/173
@@ -102,7 +102,6 @@ fi
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/174 b/tests/generic/174
index a8e0bb5..1749a1c 100755
--- a/tests/generic/174
+++ b/tests/generic/174
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/175 b/tests/generic/175
index b37ff66..ac2f54f 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -92,7 +92,6 @@ _check_scratch_fs
 echo "Remove all files and recheck"
 _scratch_mount >> "$seqres.full" 2>&1
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/176 b/tests/generic/176
index 0ca0b17..e32f94f 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -74,7 +74,6 @@ done
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/183 b/tests/generic/183
index 8141f38..27179fd 100755
--- a/tests/generic/183
+++ b/tests/generic/183
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/185 b/tests/generic/185
index 1d6dff2..368260d 100755
--- a/tests/generic/185
+++ b/tests/generic/185
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/186 b/tests/generic/186
index 9aac966..67e52b5 100755
--- a/tests/generic/186
+++ b/tests/generic/186
@@ -139,7 +139,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/187 b/tests/generic/187
index b3f1542..c993394 100755
--- a/tests/generic/187
+++ b/tests/generic/187
@@ -139,7 +139,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/188 b/tests/generic/188
index c67b847..9e63388 100755
--- a/tests/generic/188
+++ b/tests/generic/188
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/189 b/tests/generic/189
index 1954235..661129c 100755
--- a/tests/generic/189
+++ b/tests/generic/189
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/190 b/tests/generic/190
index d3d573b..4e272c2 100755
--- a/tests/generic/190
+++ b/tests/generic/190
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/191 b/tests/generic/191
index 8b19084..5aadded 100755
--- a/tests/generic/191
+++ b/tests/generic/191
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/194 b/tests/generic/194
index 1fc2cd7..a17debc 100755
--- a/tests/generic/194
+++ b/tests/generic/194
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/195 b/tests/generic/195
index 087275c..f49d0c2 100755
--- a/tests/generic/195
+++ b/tests/generic/195
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/196 b/tests/generic/196
index d815232..4da9c76 100755
--- a/tests/generic/196
+++ b/tests/generic/196
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/197 b/tests/generic/197
index 54005ae..54ee5ab 100755
--- a/tests/generic/197
+++ b/tests/generic/197
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/199 b/tests/generic/199
index eb567e4..5e4bca8 100755
--- a/tests/generic/199
+++ b/tests/generic/199
@@ -118,7 +118,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/200 b/tests/generic/200
index 991fed0..f0521ae 100755
--- a/tests/generic/200
+++ b/tests/generic/200
@@ -118,7 +118,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/201 b/tests/generic/201
index ffc1ce4..db77a5e 100755
--- a/tests/generic/201
+++ b/tests/generic/201
@@ -79,7 +79,6 @@ rm "$testdir/file3"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/202 b/tests/generic/202
index 375b65f..91f2d9b 100755
--- a/tests/generic/202
+++ b/tests/generic/202
@@ -79,7 +79,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/203 b/tests/generic/203
index 549f2ba..86a672b 100755
--- a/tests/generic/203
+++ b/tests/generic/203
@@ -79,7 +79,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/205 b/tests/generic/205
index 8f0ec45..8fed955 100755
--- a/tests/generic/205
+++ b/tests/generic/205
@@ -95,7 +95,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/206 b/tests/generic/206
index f2c4ecc..10b5285 100755
--- a/tests/generic/206
+++ b/tests/generic/206
@@ -95,7 +95,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/216 b/tests/generic/216
index 3789cb0..671f0c1 100755
--- a/tests/generic/216
+++ b/tests/generic/216
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/217 b/tests/generic/217
index 4ae603f..e4d40c7 100755
--- a/tests/generic/217
+++ b/tests/generic/217
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/218 b/tests/generic/218
index d63c06f..eb52fea 100755
--- a/tests/generic/218
+++ b/tests/generic/218
@@ -90,7 +90,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/220 b/tests/generic/220
index ccdb32e..fb5ecda 100755
--- a/tests/generic/220
+++ b/tests/generic/220
@@ -90,7 +90,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/222 b/tests/generic/222
index cb5a788..ab3f65f 100755
--- a/tests/generic/222
+++ b/tests/generic/222
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/227 b/tests/generic/227
index d200424..387c714 100755
--- a/tests/generic/227
+++ b/tests/generic/227
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/229 b/tests/generic/229
index cdaddaf..eb105a3 100755
--- a/tests/generic/229
+++ b/tests/generic/229
@@ -156,7 +156,6 @@ runtest delalloc regular "$testdir/d-r"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/238 b/tests/generic/238
index 98530e0..02057ad 100755
--- a/tests/generic/238
+++ b/tests/generic/238
@@ -156,7 +156,6 @@ runtest delalloc regular "$testdir/d-r"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/242 b/tests/generic/242
index a5a17c3..3023ac7 100755
--- a/tests/generic/242
+++ b/tests/generic/242
@@ -92,7 +92,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/243 b/tests/generic/243
index b7ca466..e65347f 100755
--- a/tests/generic/243
+++ b/tests/generic/243
@@ -92,7 +92,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/127 b/tests/xfs/127
index c31cd17..63d5890 100755
--- a/tests/xfs/127
+++ b/tests/xfs/127
@@ -72,7 +72,6 @@ xfs_info "$SCRATCH_MNT" >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/128 b/tests/xfs/128
index c9547fb..2e1da3f 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -142,7 +142,6 @@ _within_tolerance "free blocks after all tests" $free_blocks3 $((free_blocks0 -
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/131 b/tests/xfs/131
index 8442821..adab31f 100755
--- a/tests/xfs/131
+++ b/tests/xfs/131
@@ -69,7 +69,6 @@ test -s "$testdir/file2" && _fail "Should not be able to reflink a realtime file
 
 echo "Check restored fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/139 b/tests/xfs/139
index 51c903e..feb55bd 100755
--- a/tests/xfs/139
+++ b/tests/xfs/139
@@ -75,7 +75,6 @@ md5sum "$testdir/file2" | _filter_scratch
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/140 b/tests/xfs/140
index 133bb72..309b284 100644
--- a/tests/xfs/140
+++ b/tests/xfs/140
@@ -82,7 +82,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || echo "file2 and file2.chk do not
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0


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

* [PATCH 04/23] reflink: remove redundant filesystem checks from the end of the tests
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Turns out that check already runs _check_filesystems after each test,
so we don't need to do this at the end of each test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/157 |    1 -
 tests/generic/158 |    1 -
 tests/generic/161 |    1 -
 tests/generic/162 |    1 -
 tests/generic/163 |    1 -
 tests/generic/164 |    1 -
 tests/generic/165 |    1 -
 tests/generic/166 |    1 -
 tests/generic/167 |    1 -
 tests/generic/168 |    1 -
 tests/generic/170 |    1 -
 tests/generic/171 |    1 -
 tests/generic/172 |    1 -
 tests/generic/173 |    1 -
 tests/generic/174 |    1 -
 tests/generic/175 |    1 -
 tests/generic/176 |    1 -
 tests/generic/183 |    1 -
 tests/generic/185 |    1 -
 tests/generic/186 |    1 -
 tests/generic/187 |    1 -
 tests/generic/188 |    1 -
 tests/generic/189 |    1 -
 tests/generic/190 |    1 -
 tests/generic/191 |    1 -
 tests/generic/194 |    1 -
 tests/generic/195 |    1 -
 tests/generic/196 |    1 -
 tests/generic/197 |    1 -
 tests/generic/199 |    1 -
 tests/generic/200 |    1 -
 tests/generic/201 |    1 -
 tests/generic/202 |    1 -
 tests/generic/203 |    1 -
 tests/generic/205 |    1 -
 tests/generic/206 |    1 -
 tests/generic/216 |    1 -
 tests/generic/217 |    1 -
 tests/generic/218 |    1 -
 tests/generic/220 |    1 -
 tests/generic/222 |    1 -
 tests/generic/227 |    1 -
 tests/generic/229 |    1 -
 tests/generic/238 |    1 -
 tests/generic/242 |    1 -
 tests/generic/243 |    1 -
 tests/xfs/127     |    1 -
 tests/xfs/128     |    1 -
 tests/xfs/131     |    1 -
 tests/xfs/139     |    1 -
 tests/xfs/140     |    1 -
 51 files changed, 51 deletions(-)


diff --git a/tests/generic/157 b/tests/generic/157
index 0150866..74314d8 100755
--- a/tests/generic/157
+++ b/tests/generic/157
@@ -123,7 +123,6 @@ _reflink_range "$testdir2/file1" 0 "$testdir2/file2" 0 $blksz >> "$seqres.full"
 
 echo "Check scratch fs"
 _scratch_unmount
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/158 b/tests/generic/158
index 807c247..779d55e 100755
--- a/tests/generic/158
+++ b/tests/generic/158
@@ -124,7 +124,6 @@ _dedupe_range "$testdir2/file1" 0 "$testdir2/file2" 0 $blksz >> "$seqres.full"
 
 echo "Check scratch fs"
 _scratch_unmount
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/161 b/tests/generic/161
index 7fb8963..b271936 100755
--- a/tests/generic/161
+++ b/tests/generic/161
@@ -71,7 +71,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/162 b/tests/generic/162
index 2fb947a..30c761b 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -87,7 +87,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/163 b/tests/generic/163
index 0186443..f2ea334 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -87,7 +87,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/164 b/tests/generic/164
index 087c6ba..e97ac13 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -97,7 +97,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/165 b/tests/generic/165
index 6bd15e1..b305079 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -97,7 +97,6 @@ wait
 
 echo "Check fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 # success, all done
diff --git a/tests/generic/166 b/tests/generic/166
index 6cfb821..2c2ff4e 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -84,7 +84,6 @@ wait
 
 echo "Check for damage"
 _scratch_unmount
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/167 b/tests/generic/167
index fc5a86c..b80b481 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -84,7 +84,6 @@ wait
 
 echo "Check for damage"
 _scratch_unmount
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/168 b/tests/generic/168
index ee3848d..0d620da 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -88,7 +88,6 @@ wait
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/170 b/tests/generic/170
index 6d27810..78ed63d 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -88,7 +88,6 @@ wait
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 echo "Done"
 
diff --git a/tests/generic/171 b/tests/generic/171
index ec3729d..4b4f141 100755
--- a/tests/generic/171
+++ b/tests/generic/171
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/172 b/tests/generic/172
index 1988c8d..98eb97f 100755
--- a/tests/generic/172
+++ b/tests/generic/172
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/173 b/tests/generic/173
index 5bb9ce6..e26f5a9 100755
--- a/tests/generic/173
+++ b/tests/generic/173
@@ -102,7 +102,6 @@ fi
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/174 b/tests/generic/174
index a8e0bb5..1749a1c 100755
--- a/tests/generic/174
+++ b/tests/generic/174
@@ -100,7 +100,6 @@ echo "${out}"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/175 b/tests/generic/175
index b37ff66..ac2f54f 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -92,7 +92,6 @@ _check_scratch_fs
 echo "Remove all files and recheck"
 _scratch_mount >> "$seqres.full" 2>&1
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/176 b/tests/generic/176
index 0ca0b17..e32f94f 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -74,7 +74,6 @@ done
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/183 b/tests/generic/183
index 8141f38..27179fd 100755
--- a/tests/generic/183
+++ b/tests/generic/183
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/185 b/tests/generic/185
index 1d6dff2..368260d 100755
--- a/tests/generic/185
+++ b/tests/generic/185
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/186 b/tests/generic/186
index 9aac966..67e52b5 100755
--- a/tests/generic/186
+++ b/tests/generic/186
@@ -139,7 +139,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/187 b/tests/generic/187
index b3f1542..c993394 100755
--- a/tests/generic/187
+++ b/tests/generic/187
@@ -139,7 +139,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/188 b/tests/generic/188
index c67b847..9e63388 100755
--- a/tests/generic/188
+++ b/tests/generic/188
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/189 b/tests/generic/189
index 1954235..661129c 100755
--- a/tests/generic/189
+++ b/tests/generic/189
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/190 b/tests/generic/190
index d3d573b..4e272c2 100755
--- a/tests/generic/190
+++ b/tests/generic/190
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/191 b/tests/generic/191
index 8b19084..5aadded 100755
--- a/tests/generic/191
+++ b/tests/generic/191
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/194 b/tests/generic/194
index 1fc2cd7..a17debc 100755
--- a/tests/generic/194
+++ b/tests/generic/194
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/195 b/tests/generic/195
index 087275c..f49d0c2 100755
--- a/tests/generic/195
+++ b/tests/generic/195
@@ -94,7 +94,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/196 b/tests/generic/196
index d815232..4da9c76 100755
--- a/tests/generic/196
+++ b/tests/generic/196
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/197 b/tests/generic/197
index 54005ae..54ee5ab 100755
--- a/tests/generic/197
+++ b/tests/generic/197
@@ -89,7 +89,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/199 b/tests/generic/199
index eb567e4..5e4bca8 100755
--- a/tests/generic/199
+++ b/tests/generic/199
@@ -118,7 +118,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/200 b/tests/generic/200
index 991fed0..f0521ae 100755
--- a/tests/generic/200
+++ b/tests/generic/200
@@ -118,7 +118,6 @@ md5sum "$testdir/file3.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/201 b/tests/generic/201
index ffc1ce4..db77a5e 100755
--- a/tests/generic/201
+++ b/tests/generic/201
@@ -79,7 +79,6 @@ rm "$testdir/file3"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/202 b/tests/generic/202
index 375b65f..91f2d9b 100755
--- a/tests/generic/202
+++ b/tests/generic/202
@@ -79,7 +79,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/203 b/tests/generic/203
index 549f2ba..86a672b 100755
--- a/tests/generic/203
+++ b/tests/generic/203
@@ -79,7 +79,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/205 b/tests/generic/205
index 8f0ec45..8fed955 100755
--- a/tests/generic/205
+++ b/tests/generic/205
@@ -95,7 +95,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/206 b/tests/generic/206
index f2c4ecc..10b5285 100755
--- a/tests/generic/206
+++ b/tests/generic/206
@@ -95,7 +95,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/216 b/tests/generic/216
index 3789cb0..671f0c1 100755
--- a/tests/generic/216
+++ b/tests/generic/216
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/217 b/tests/generic/217
index 4ae603f..e4d40c7 100755
--- a/tests/generic/217
+++ b/tests/generic/217
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/218 b/tests/generic/218
index d63c06f..eb52fea 100755
--- a/tests/generic/218
+++ b/tests/generic/218
@@ -90,7 +90,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/220 b/tests/generic/220
index ccdb32e..fb5ecda 100755
--- a/tests/generic/220
+++ b/tests/generic/220
@@ -90,7 +90,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/222 b/tests/generic/222
index cb5a788..ab3f65f 100755
--- a/tests/generic/222
+++ b/tests/generic/222
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/227 b/tests/generic/227
index d200424..387c714 100755
--- a/tests/generic/227
+++ b/tests/generic/227
@@ -96,7 +96,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || _fail "file2 and file2.chk don't
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/229 b/tests/generic/229
index cdaddaf..eb105a3 100755
--- a/tests/generic/229
+++ b/tests/generic/229
@@ -156,7 +156,6 @@ runtest delalloc regular "$testdir/d-r"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/238 b/tests/generic/238
index 98530e0..02057ad 100755
--- a/tests/generic/238
+++ b/tests/generic/238
@@ -156,7 +156,6 @@ runtest delalloc regular "$testdir/d-r"
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/242 b/tests/generic/242
index a5a17c3..3023ac7 100755
--- a/tests/generic/242
+++ b/tests/generic/242
@@ -92,7 +92,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/generic/243 b/tests/generic/243
index b7ca466..e65347f 100755
--- a/tests/generic/243
+++ b/tests/generic/243
@@ -92,7 +92,6 @@ md5sum "$testdir/file2.chk" | _filter_scratch
 
 echo "Check for damage"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/127 b/tests/xfs/127
index c31cd17..63d5890 100755
--- a/tests/xfs/127
+++ b/tests/xfs/127
@@ -72,7 +72,6 @@ xfs_info "$SCRATCH_MNT" >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/128 b/tests/xfs/128
index c9547fb..2e1da3f 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -142,7 +142,6 @@ _within_tolerance "free blocks after all tests" $free_blocks3 $((free_blocks0 -
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/131 b/tests/xfs/131
index 8442821..adab31f 100755
--- a/tests/xfs/131
+++ b/tests/xfs/131
@@ -69,7 +69,6 @@ test -s "$testdir/file2" && _fail "Should not be able to reflink a realtime file
 
 echo "Check restored fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/139 b/tests/xfs/139
index 51c903e..feb55bd 100755
--- a/tests/xfs/139
+++ b/tests/xfs/139
@@ -75,7 +75,6 @@ md5sum "$testdir/file2" | _filter_scratch
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0
diff --git a/tests/xfs/140 b/tests/xfs/140
index 133bb72..309b284 100644
--- a/tests/xfs/140
+++ b/tests/xfs/140
@@ -82,7 +82,6 @@ cmp -s "$testdir/file2" "$testdir/file2.chk" || echo "file2 and file2.chk do not
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
 
 # success, all done
 status=0

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

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

* [PATCH 05/23] common/dmerror: add some more dmerror routines
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Add functions to the dmerror routine so that we can load both the
error table and the linear table.  This will help us with EIO testing
of copy-on-write.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/dmerror  |   27 +++++++++++++++++++++++++--
 tests/btrfs/100 |    2 +-
 tests/btrfs/101 |    2 +-
 3 files changed, 27 insertions(+), 4 deletions(-)


diff --git a/common/dmerror b/common/dmerror
index 3900a4e..004530d 100644
--- a/common/dmerror
+++ b/common/dmerror
@@ -46,15 +46,23 @@ _dmerror_mount()
 	_mount -t $FSTYP `_dmerror_mount_options $*`
 }
 
+_dmerror_unmount()
+{
+	umount $SCRATCH_MNT
+}
+
 _dmerror_cleanup()
 {
 	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
 	$DMSETUP_PROG remove error-test > /dev/null 2>&1
 }
 
-_dmerror_load_table()
+_dmerror_load_error_table()
 {
-	$DMSETUP_PROG suspend error-test
+	suspend_opt="--nolockfs"
+	[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+	$DMSETUP_PROG suspend $suspend_opt error-test
 	[ $? -ne 0 ] && _fail  "dmsetup suspend failed"
 
 	$DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
@@ -63,3 +71,18 @@ _dmerror_load_table()
 	$DMSETUP_PROG resume error-test
 	[ $? -ne 0 ] && _fail  "dmsetup resume failed"
 }
+
+_dmerror_load_working_table()
+{
+	suspend_opt="--nolockfs"
+	[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+	$DMSETUP_PROG suspend $suspend_opt error-test
+	[ $? -ne 0 ] && _fail  "dmsetup suspend failed"
+
+	$DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
+	[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
+
+	$DMSETUP_PROG resume error-test
+	[ $? -ne 0 ] && _fail  "dmsetup resume failed"
+}
diff --git a/tests/btrfs/100 b/tests/btrfs/100
index 080d0ae..cd385e1 100755
--- a/tests/btrfs/100
+++ b/tests/btrfs/100
@@ -69,7 +69,7 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
 							"$snapshot_cmd" -X 50
 
 # now load the error into the DMERROR_DEV
-_dmerror_load_table
+_dmerror_load_error_table
 
 _run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
 
diff --git a/tests/btrfs/101 b/tests/btrfs/101
index 0824de1..8d7af85 100755
--- a/tests/btrfs/101
+++ b/tests/btrfs/101
@@ -70,7 +70,7 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
 							"$snapshot_cmd" -X 50
 
 # now load the error into the DMERROR_DEV
-_dmerror_load_table
+_dmerror_load_error_table
 
 _run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
 


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

* [PATCH 05/23] common/dmerror: add some more dmerror routines
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Add functions to the dmerror routine so that we can load both the
error table and the linear table.  This will help us with EIO testing
of copy-on-write.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/dmerror  |   27 +++++++++++++++++++++++++--
 tests/btrfs/100 |    2 +-
 tests/btrfs/101 |    2 +-
 3 files changed, 27 insertions(+), 4 deletions(-)


diff --git a/common/dmerror b/common/dmerror
index 3900a4e..004530d 100644
--- a/common/dmerror
+++ b/common/dmerror
@@ -46,15 +46,23 @@ _dmerror_mount()
 	_mount -t $FSTYP `_dmerror_mount_options $*`
 }
 
+_dmerror_unmount()
+{
+	umount $SCRATCH_MNT
+}
+
 _dmerror_cleanup()
 {
 	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
 	$DMSETUP_PROG remove error-test > /dev/null 2>&1
 }
 
-_dmerror_load_table()
+_dmerror_load_error_table()
 {
-	$DMSETUP_PROG suspend error-test
+	suspend_opt="--nolockfs"
+	[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+	$DMSETUP_PROG suspend $suspend_opt error-test
 	[ $? -ne 0 ] && _fail  "dmsetup suspend failed"
 
 	$DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
@@ -63,3 +71,18 @@ _dmerror_load_table()
 	$DMSETUP_PROG resume error-test
 	[ $? -ne 0 ] && _fail  "dmsetup resume failed"
 }
+
+_dmerror_load_working_table()
+{
+	suspend_opt="--nolockfs"
+	[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+	$DMSETUP_PROG suspend $suspend_opt error-test
+	[ $? -ne 0 ] && _fail  "dmsetup suspend failed"
+
+	$DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
+	[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
+
+	$DMSETUP_PROG resume error-test
+	[ $? -ne 0 ] && _fail  "dmsetup resume failed"
+}
diff --git a/tests/btrfs/100 b/tests/btrfs/100
index 080d0ae..cd385e1 100755
--- a/tests/btrfs/100
+++ b/tests/btrfs/100
@@ -69,7 +69,7 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
 							"$snapshot_cmd" -X 50
 
 # now load the error into the DMERROR_DEV
-_dmerror_load_table
+_dmerror_load_error_table
 
 _run_btrfs_util_prog replace start -B $error_devid $dev2 $SCRATCH_MNT
 
diff --git a/tests/btrfs/101 b/tests/btrfs/101
index 0824de1..8d7af85 100755
--- a/tests/btrfs/101
+++ b/tests/btrfs/101
@@ -70,7 +70,7 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n 200 -p 8 $FSSTRESS_AVOID -x \
 							"$snapshot_cmd" -X 50
 
 # now load the error into the DMERROR_DEV
-_dmerror_load_table
+_dmerror_load_error_table
 
 _run_btrfs_util_prog device delete $error_devid $SCRATCH_MNT
 

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

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

* [PATCH 06/23] dio unwritten conversion bug tests
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Check that we don't expose old disk contents when a directio write to
an unwritten extent fails due to IO errors.  This primarily affects
XFS and ext4.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 .gitignore                  |    1 
 src/aio-dio-regress/aiocp.c |  489 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/250           |  104 +++++++++
 tests/generic/250.out       |   10 +
 tests/generic/252           |  107 +++++++++
 tests/generic/252.out       |   10 +
 tests/generic/group         |    2 
 7 files changed, 723 insertions(+)
 create mode 100644 src/aio-dio-regress/aiocp.c
 create mode 100755 tests/generic/250
 create mode 100644 tests/generic/250.out
 create mode 100755 tests/generic/252
 create mode 100644 tests/generic/252.out


diff --git a/.gitignore b/.gitignore
index a6f47d3..bbe7c1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@
 /src/aio-dio-regress/aio-free-ring-with-bogus-nr-pages
 /src/aio-dio-regress/aio-io-setup-with-nonwritable-context-pointer
 /src/aio-dio-regress/aio-last-ref-held-by-io
+/src/aio-dio-regress/aiocp
 /src/aio-dio-regress/aiodio_sparse2
 /src/aio-dio-regress/aio-dio-eof-race
 /src/cloner
diff --git a/src/aio-dio-regress/aiocp.c b/src/aio-dio-regress/aiocp.c
new file mode 100644
index 0000000..1abff9c
--- /dev/null
+++ b/src/aio-dio-regress/aiocp.c
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2004 Daniel McNeil <daniel@osdl.org>
+ *               2004 Open Source Development Lab
+ *   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; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will 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 to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Module: .c
+ */
+
+/*
+ * Change History:
+ *
+ *
+ * version of copy command using async i/o
+ * From:	Stephen Hemminger <shemminger@osdl.org>
+ * Modified by Daniel McNeil <daniel@osdl.org> for testing aio.
+ *	- added -a alignment
+ *	- added -b blksize option 
+ *	_ added -s size	option
+ *	- added -f open_flag option
+ *	- added -w (no write) option (reads from source only)
+ *	- added -n (num aio) option 
+ *	- added -z (zero dest) opton (writes zeros to dest only)
+ *	- added -D delay_ms option
+ *  - 2/2004  Marty Ridgeway (mridge@us.ibm.com) Changes to adapt to LTP
+ *
+ * Copy file by using a async I/O state machine.
+ * 1. Start read request
+ * 2. When read completes turn it into a write request
+ * 3. When write completes decrement counter and free resources
+ *
+ *
+ * Usage: aiocp [-b blksize] -n [num_aio] [-w] [-z] [-s filesize] 
+ *		[-f DIRECT|TRUNC|CREAT|SYNC|LARGEFILE] src dest
+ */
+
+//#define _GNU_SOURCE
+//#define DEBUG 1
+#undef DEBUG
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/select.h>
+
+#include <libaio.h>
+
+#define AIO_BLKSIZE	(64*1024)
+#define AIO_MAXIO	32
+
+static int aio_blksize = AIO_BLKSIZE;
+static int aio_maxio = AIO_MAXIO;
+
+static int busy = 0;		// # of I/O's in flight
+static int tocopy = 0;		// # of blocks left to copy
+static int srcfd;		// source fd
+static int dstfd = -1;		// destination file descriptor
+static const char *dstname = NULL;
+static const char *srcname = NULL;
+static int source_open_flag = O_RDONLY;	/* open flags on source file */
+static int dest_open_flag = O_WRONLY;	/* open flags on dest file */
+static int no_write;			/* do not write */
+static int zero;			/* write zero's only */
+
+static int debug;
+static int count_io_q_waits;	/* how many time io_queue_wait called */
+
+struct iocb **iocb_free;	/* array of pointers to iocb */
+int iocb_free_count;		/* current free count */
+int alignment = 512;		/* buffer alignment */
+
+struct timeval delay;		/* delay between i/o */
+
+int init_iocb(int n, int iosize)
+{
+	void *buf;
+	int i;
+
+	if ((iocb_free = malloc(n * sizeof(struct iocb *))) == 0) {
+		return -1;
+	}
+
+	for (i = 0; i < n; i++) {
+		if (!(iocb_free[i] = (struct iocb *) malloc(sizeof(struct iocb))))
+			return -1;
+		if (posix_memalign(&buf, alignment, iosize))
+			return -1;
+		if (debug > 1) {
+			printf("buf allocated at 0x%p, align:%d\n",
+					buf, alignment);
+		}
+		if (zero) {
+			/*
+			 * We are writing zero's to dstfd
+			 */
+			memset(buf, 0, iosize);
+		}
+		io_prep_pread(iocb_free[i], -1, buf, iosize, 0);
+	}
+	iocb_free_count = i;
+	return 0;
+}
+
+struct iocb *alloc_iocb()
+{
+	if (!iocb_free_count)
+		return 0;
+	return iocb_free[--iocb_free_count];
+}
+
+void free_iocb(struct iocb *io)
+{
+	iocb_free[iocb_free_count++] = io;
+}
+
+/*
+ * io_wait_run() - wait for an io_event and then call the callback.
+ */
+int io_wait_run(io_context_t ctx, struct timespec *to)
+{
+	struct io_event events[aio_maxio];
+	struct io_event *ep;
+	int ret, n;
+
+	/*
+	 * get up to aio_maxio events at a time.
+	 */
+	ret = n = io_getevents(ctx, 1, aio_maxio, events, to);
+
+	/*
+	 * Call the callback functions for each event.
+	 */
+	for (ep = events; n-- > 0; ep++) {
+		io_callback_t cb = (io_callback_t)ep->data;
+		struct iocb *iocb = (struct iocb *)ep->obj;
+
+		cb(ctx, iocb, ep->res, ep->res2);
+	}
+	return ret;
+}
+
+/* Fatal error handler */
+static void io_error(const char *func, int rc)
+{
+	if (rc == -ENOSYS)
+		fprintf(stderr, "AIO not in this kernel\n");
+	else if (rc < 0)
+		fprintf(stderr, "%s: %s\n", func, strerror(-rc));
+	else
+		fprintf(stderr, "%s: error %d\n", func, rc);
+
+	if (dstfd > 0)
+		close(dstfd);
+	if (dstname && dest_open_flag & O_CREAT)
+		unlink(dstname);
+	exit(1);
+}
+
+/*
+ * Write complete callback.
+ * Adjust counts and free resources
+ */
+static void wr_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
+{
+	if (res2 != 0) {
+		io_error("aio write", res2);
+	}
+	if (res != iocb->u.c.nbytes) {
+		fprintf(stderr, "write missed bytes expect %lu got %ld\n",
+			iocb->u.c.nbytes, res2);
+		exit(1);
+	}
+	--tocopy;
+	--busy;
+	free_iocb(iocb);
+	if (debug)
+		write(2, "w", 1);
+}
+
+/*
+ * Read complete callback.
+ * Change read iocb into a write iocb and start it.
+ */
+static void rd_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
+{
+	/* library needs accessors to look at iocb? */
+	int iosize = iocb->u.c.nbytes;
+	char *buf = iocb->u.c.buf;
+	off_t offset = iocb->u.c.offset;
+
+	if (res2 != 0)
+		io_error("aio read", res2);
+	if (res != iosize) {
+		fprintf(stderr, "read missing bytes expect %lu got %ld\n",
+			iocb->u.c.nbytes, res);
+		exit(1);
+	}
+
+
+	/* turn read into write */
+	if (no_write) {
+		--tocopy;
+		--busy;
+		free_iocb(iocb);
+	} else {
+		io_prep_pwrite(iocb, dstfd, buf, iosize, offset);
+		io_set_callback(iocb, wr_done);
+		if (1 != (res = io_submit(ctx, 1, &iocb)))
+			io_error("io_submit write", res);
+	}
+	if (debug)
+		write(2, "r", 1);
+	if (debug > 1)
+		printf("%d", iosize);
+}
+
+void usage()
+{
+	fprintf(stderr,
+		"Usage: aiocp [-a align] [-s size] [-b blksize] [-n num_io]"
+		" [-f open_flag] SOURCE DEST\n"
+		"This copies from SOURCE to DEST using AIO.\n\n"
+		"Usage: aiocp [options] -w SOURCE\n"
+		"This does sequential AIO reads (no writes).\n\n"
+		"Usage: aiocp [options] -z DEST\n"
+		"This does sequential AIO writes of zeros.\n");
+		
+	exit(1);
+}
+
+/*
+ * Scale value by kilo, mega, or giga.
+ */
+long long scale_by_kmg(long long value, char scale)
+{
+	switch (scale) {
+	case 'g':
+	case 'G':
+		value *= 1024;
+	case 'm':
+	case 'M':
+		value *= 1024;
+	case 'k':
+	case 'K':
+		value *= 1024;
+		break;
+	case '\0':
+		break;
+	default:
+		usage();
+		break;
+	}
+	return value;
+}
+
+int main(int argc, char *const *argv)
+{
+	struct stat st;
+	off_t length = 0, offset = 0;
+	io_context_t myctx;
+	int c;
+	extern char *optarg;
+	extern int optind, opterr, optopt;
+
+	while ((c = getopt(argc, argv, "a:b:df:n:s:wzD:")) != -1) {
+		char *endp;
+
+		switch (c) {
+		case 'a':	/* alignment of data buffer */
+			alignment = strtol(optarg, &endp, 0);
+			alignment = (long)scale_by_kmg((long long)alignment,
+							*endp);
+			break;
+		case 'f':	/* use these open flags */
+			if (strcmp(optarg, "LARGEFILE") == 0 ||
+			    strcmp(optarg, "O_LARGEFILE") == 0) {
+				source_open_flag |= O_LARGEFILE;
+				dest_open_flag |= O_LARGEFILE;
+			} else if (strcmp(optarg, "TRUNC") == 0 ||
+			           strcmp(optarg, "O_TRUNC") == 0) {
+				dest_open_flag |= O_TRUNC;
+			} else if (strcmp(optarg, "SYNC") == 0 ||
+				   strcmp(optarg, "O_SYNC") == 0) {
+				dest_open_flag |= O_SYNC | O_NONBLOCK;
+			} else if (strcmp(optarg, "DIRECT") == 0 ||
+				   strcmp(optarg, "O_DIRECT") == 0) {
+				source_open_flag |= O_DIRECT;
+				dest_open_flag |= O_DIRECT;
+			} else if (strncmp(optarg, "CREAT", 5) == 0 ||
+				   strncmp(optarg, "O_CREAT", 5) == 0) {
+				dest_open_flag |= O_CREAT;
+			}
+			break;
+		case 'd':
+			debug++;
+			break;
+		case 'D':
+			delay.tv_usec = atoi(optarg);
+			break;
+		case 'b':	/* block size */
+			aio_blksize = strtol(optarg, &endp, 0);
+			aio_blksize = (long)scale_by_kmg((long long)aio_blksize, *endp);
+			break;
+
+		case 'n':	/* num io */
+			aio_maxio = strtol(optarg, &endp, 0);
+			break;
+		case 's':	/* size to transfer */
+			length = strtoll(optarg, &endp, 0);
+			length = scale_by_kmg(length, *endp);
+			break;
+		case 'w':	/* no write */
+			no_write = 1;
+			break;
+		case 'z':	/* write zero's */
+			zero = 1;
+			break;
+
+		default:
+			usage();
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+	
+#ifndef DEBUG
+	if (argc < 1) {
+		usage();
+	}
+#else
+    source_open_flag |= O_DIRECT;
+    dest_open_flag |= O_DIRECT;
+    aio_blksize = 1;
+    aio_maxio=1;
+    srcname = "junkdata";
+    dstname = "ff2";
+#endif
+	if (!zero) {
+#ifndef DEBUG
+	       	if ((srcfd = open(srcname = *argv, source_open_flag)) < 0) {
+#else
+                if ((srcfd = open(srcname, source_open_flag)) < 0) {
+#endif
+			perror(srcname);
+			exit(1);
+		}
+		argv++;
+		argc--;
+		if (fstat(srcfd, &st) < 0) {
+			perror("fstat");
+			exit(1);
+		}
+		if (length == 0)
+			length = st.st_size;
+	}
+
+	if (!no_write) {
+		/*
+		 * We are either copying or writing zeros to dstname
+		 */
+#ifndef DEBUG
+		if (argc < 1) {
+			usage();
+		}
+		if ((dstfd = open(dstname = *argv, dest_open_flag, 0666)) < 0) {
+#else
+            if ((dstfd = open(dstname, dest_open_flag, 0666)) < 0) {
+#endif
+			perror(dstname);
+			exit(1);
+		}
+		if (zero) {
+			/*
+			 * get size of dest, if we are zeroing it.
+			 * TODO: handle devices.
+			 */
+			if (fstat(dstfd, &st) < 0) {
+				perror("fstat");
+				exit(1);
+			}
+			if (length == 0)
+				length = st.st_size;
+		}
+	}
+
+	/* initialize state machine */
+	memset(&myctx, 0, sizeof(myctx));
+	io_queue_init(aio_maxio, &myctx);
+	tocopy = howmany(length, aio_blksize);
+printf("tocopy=%d len=%d blk=%d\n", tocopy, length, aio_blksize);
+	if (init_iocb(aio_maxio, aio_blksize) < 0) {
+		fprintf(stderr, "Error allocating the i/o buffers\n");
+		exit(1);
+	}
+
+	while (tocopy > 0) {
+		int i, rc;
+		/* Submit as many reads as once as possible upto aio_maxio */
+		int n = MIN(MIN(aio_maxio - busy, aio_maxio),
+				howmany(length - offset, aio_blksize));
+		if (n > 0) {
+			struct iocb *ioq[n];
+
+			for (i = 0; i < n; i++) {
+				struct iocb *io = alloc_iocb();
+				int iosize = MIN(length - offset, aio_blksize);
+
+				if (zero) {
+					/*
+					 * We are writing zero's to dstfd
+					 */
+					io_prep_pwrite(io, dstfd, io->u.c.buf,
+							iosize, offset);
+					io_set_callback(io, wr_done);
+				} else {
+					io_prep_pread(io, srcfd, io->u.c.buf,
+							iosize, offset);
+					io_set_callback(io, rd_done);
+				}
+				ioq[i] = io;
+				offset += iosize;
+			}
+
+			rc = io_submit(myctx, n, ioq);
+			if (rc < 0)
+				io_error("io_submit", rc);
+
+			busy += n;
+			if (debug > 1)
+				printf("io_submit(%d) busy:%d\n", n, busy);
+			if (delay.tv_usec) {
+				struct timeval t = delay;
+				(void)select(0,0,0,0,&t);
+			}
+		}
+
+		/*
+		 * We have submitted all the i/o requests. Wait for at least one to complete
+		 * and call the callbacks.
+		 */
+		count_io_q_waits++;
+		rc = io_wait_run(myctx, 0);
+		if (rc < 0)
+			io_error("io_wait_run", rc);
+
+		if (debug > 1) {
+			printf("io_wait_run: rc == %d\n", rc);
+			printf("busy:%d aio_maxio:%d tocopy:%d\n",
+					busy, aio_maxio, tocopy);
+		}
+	}
+
+	if (srcfd != -1)
+		close(srcfd);
+	if (dstfd != -1)
+		close(dstfd);
+	exit(0);
+}
+
+/* 
+ * Results look like:
+ * [alanm@toolbox ~/MOT3]$ ../taio -d kernel-source-2.4.8-0.4g.ppc.rpm abc
+ * rrrrrrrrrrrrrrrwwwrwrrwwrrwrwwrrwrwrwwrrwrwrrrrwwrwwwrrwrrrwwwwwwwwwwwwwwwww
+ * rrrrrrrrrrrrrrwwwrrwrwrwrwrrwwwwwwwwwwwwwwrrrrrrrrrrrrrrrrrrwwwwrwrwwrwrwrwr
+ * wrrrrrrrwwwwwwwwwwwwwrrrwrrrwrrwrwwwwwwwwwwrrrrwwrwrrrrrrrrrrrwwwwwwwwwwwrww
+ * wwwrrrrrrrrwwrrrwwrwrwrwwwrrrrrrrwwwrrwwwrrwrwwwwwwwwrrrrrrrwwwrrrrrrrwwwwww
+ * wwwwwwwrwrrrrrrrrwrrwrrwrrwrwrrrwrrrwrrrwrwwwwwwwwwwwwwwwwwwrrrwwwrrrrrrrrrr
+ * rrwrrrrrrwrrwwwwwwwwwwwwwwwwrwwwrrwrwwrrrrrrrrrrrrrrrrrrrwwwwwwwwwwwwwwwwwww
+ * rrrrrwrrwrwrwrrwrrrwwwwwwwwrrrrwrrrwrwwrwrrrwrrwrrrrwwwwwwwrwrwwwwrwwrrrwrrr
+ * rrrwwwwwwwrrrrwwrrrrrrrrrrrrwrwrrrrwwwwwwwwwwwwwwrwrrrrwwwwrwrrrrwrwwwrrrwww
+ * rwwrrrrrrrwrrrrrrrrrrrrwwwwrrrwwwrwrrwwwwwwwwwwwwwwwwwwwwwrrrrrrrwwwwwwwrw
+ */
diff --git a/tests/generic/250 b/tests/generic/250
new file mode 100755
index 0000000..0953e26
--- /dev/null
+++ b/tests/generic/250
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 250
+#
+# Create an unwritten extent, set up dm-error, try a DIO write, then
+# make sure we can't read back old disk contents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch
+_require_dm_target error
+_require_xfs_io_command "falloc"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+"$XFS_IO_PROG" -d -c "pwrite -S 0x69 -b 1048576 0 $((64 * 1048576))" "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mkfs_sized $((64 * 1048576)) > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+#"$XFS_IO_PROG" -c "extsize $((blksz * bsz))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/250.out b/tests/generic/250.out
new file mode 100644
index 0000000..710c80e
--- /dev/null
+++ b/tests/generic/250.out
@@ -0,0 +1,10 @@
+QA output created by 250
+Format and mount
+Create the original files
+Compare files
+ec8bb3b24d5b0f1b5bdf8c8f0f541ee6  SCRATCH_MNT/test-250/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+3ed86318f4ff8da26c1c2a6e3041f9be  SCRATCH_MNT/test-250/file2
+Check for damage
diff --git a/tests/generic/252 b/tests/generic/252
new file mode 100755
index 0000000..535b34b
--- /dev/null
+++ b/tests/generic/252
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 252
+#
+# Create an unwritten extent, set up dm-error, try an AIO DIO write, then
+# make sure we can't read back old disk contents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch
+_require_dm_target error
+_require_xfs_io_command "falloc"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+"$XFS_IO_PROG" -d -c "pwrite -S 0x69 -b 1048576 0 $((64 * 1048576))" "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mkfs_sized $((64 * 1048576)) > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+#"$XFS_IO_PROG" -c "extsize $((blksz * bsz))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/252.out b/tests/generic/252.out
new file mode 100644
index 0000000..3bc78c2
--- /dev/null
+++ b/tests/generic/252.out
@@ -0,0 +1,10 @@
+QA output created by 252
+Format and mount
+Create the original files
+Compare files
+ec8bb3b24d5b0f1b5bdf8c8f0f541ee6  SCRATCH_MNT/test-252/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+3ed86318f4ff8da26c1c2a6e3041f9be  SCRATCH_MNT/test-252/file2
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 860ff4a..1767484 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -252,7 +252,9 @@
 247 auto quick rw
 248 auto quick rw
 249 auto quick rw
+250 auto quick
 251 ioctl trim
+252 auto quick
 255 auto quick prealloc
 256 auto quick
 257 dir auto quick


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

* [PATCH 06/23] dio unwritten conversion bug tests
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Check that we don't expose old disk contents when a directio write to
an unwritten extent fails due to IO errors.  This primarily affects
XFS and ext4.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 .gitignore                  |    1 
 src/aio-dio-regress/aiocp.c |  489 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/250           |  104 +++++++++
 tests/generic/250.out       |   10 +
 tests/generic/252           |  107 +++++++++
 tests/generic/252.out       |   10 +
 tests/generic/group         |    2 
 7 files changed, 723 insertions(+)
 create mode 100644 src/aio-dio-regress/aiocp.c
 create mode 100755 tests/generic/250
 create mode 100644 tests/generic/250.out
 create mode 100755 tests/generic/252
 create mode 100644 tests/generic/252.out


diff --git a/.gitignore b/.gitignore
index a6f47d3..bbe7c1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@
 /src/aio-dio-regress/aio-free-ring-with-bogus-nr-pages
 /src/aio-dio-regress/aio-io-setup-with-nonwritable-context-pointer
 /src/aio-dio-regress/aio-last-ref-held-by-io
+/src/aio-dio-regress/aiocp
 /src/aio-dio-regress/aiodio_sparse2
 /src/aio-dio-regress/aio-dio-eof-race
 /src/cloner
diff --git a/src/aio-dio-regress/aiocp.c b/src/aio-dio-regress/aiocp.c
new file mode 100644
index 0000000..1abff9c
--- /dev/null
+++ b/src/aio-dio-regress/aiocp.c
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2004 Daniel McNeil <daniel@osdl.org>
+ *               2004 Open Source Development Lab
+ *   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; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will 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 to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Module: .c
+ */
+
+/*
+ * Change History:
+ *
+ *
+ * version of copy command using async i/o
+ * From:	Stephen Hemminger <shemminger@osdl.org>
+ * Modified by Daniel McNeil <daniel@osdl.org> for testing aio.
+ *	- added -a alignment
+ *	- added -b blksize option 
+ *	_ added -s size	option
+ *	- added -f open_flag option
+ *	- added -w (no write) option (reads from source only)
+ *	- added -n (num aio) option 
+ *	- added -z (zero dest) opton (writes zeros to dest only)
+ *	- added -D delay_ms option
+ *  - 2/2004  Marty Ridgeway (mridge@us.ibm.com) Changes to adapt to LTP
+ *
+ * Copy file by using a async I/O state machine.
+ * 1. Start read request
+ * 2. When read completes turn it into a write request
+ * 3. When write completes decrement counter and free resources
+ *
+ *
+ * Usage: aiocp [-b blksize] -n [num_aio] [-w] [-z] [-s filesize] 
+ *		[-f DIRECT|TRUNC|CREAT|SYNC|LARGEFILE] src dest
+ */
+
+//#define _GNU_SOURCE
+//#define DEBUG 1
+#undef DEBUG
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/select.h>
+
+#include <libaio.h>
+
+#define AIO_BLKSIZE	(64*1024)
+#define AIO_MAXIO	32
+
+static int aio_blksize = AIO_BLKSIZE;
+static int aio_maxio = AIO_MAXIO;
+
+static int busy = 0;		// # of I/O's in flight
+static int tocopy = 0;		// # of blocks left to copy
+static int srcfd;		// source fd
+static int dstfd = -1;		// destination file descriptor
+static const char *dstname = NULL;
+static const char *srcname = NULL;
+static int source_open_flag = O_RDONLY;	/* open flags on source file */
+static int dest_open_flag = O_WRONLY;	/* open flags on dest file */
+static int no_write;			/* do not write */
+static int zero;			/* write zero's only */
+
+static int debug;
+static int count_io_q_waits;	/* how many time io_queue_wait called */
+
+struct iocb **iocb_free;	/* array of pointers to iocb */
+int iocb_free_count;		/* current free count */
+int alignment = 512;		/* buffer alignment */
+
+struct timeval delay;		/* delay between i/o */
+
+int init_iocb(int n, int iosize)
+{
+	void *buf;
+	int i;
+
+	if ((iocb_free = malloc(n * sizeof(struct iocb *))) == 0) {
+		return -1;
+	}
+
+	for (i = 0; i < n; i++) {
+		if (!(iocb_free[i] = (struct iocb *) malloc(sizeof(struct iocb))))
+			return -1;
+		if (posix_memalign(&buf, alignment, iosize))
+			return -1;
+		if (debug > 1) {
+			printf("buf allocated at 0x%p, align:%d\n",
+					buf, alignment);
+		}
+		if (zero) {
+			/*
+			 * We are writing zero's to dstfd
+			 */
+			memset(buf, 0, iosize);
+		}
+		io_prep_pread(iocb_free[i], -1, buf, iosize, 0);
+	}
+	iocb_free_count = i;
+	return 0;
+}
+
+struct iocb *alloc_iocb()
+{
+	if (!iocb_free_count)
+		return 0;
+	return iocb_free[--iocb_free_count];
+}
+
+void free_iocb(struct iocb *io)
+{
+	iocb_free[iocb_free_count++] = io;
+}
+
+/*
+ * io_wait_run() - wait for an io_event and then call the callback.
+ */
+int io_wait_run(io_context_t ctx, struct timespec *to)
+{
+	struct io_event events[aio_maxio];
+	struct io_event *ep;
+	int ret, n;
+
+	/*
+	 * get up to aio_maxio events at a time.
+	 */
+	ret = n = io_getevents(ctx, 1, aio_maxio, events, to);
+
+	/*
+	 * Call the callback functions for each event.
+	 */
+	for (ep = events; n-- > 0; ep++) {
+		io_callback_t cb = (io_callback_t)ep->data;
+		struct iocb *iocb = (struct iocb *)ep->obj;
+
+		cb(ctx, iocb, ep->res, ep->res2);
+	}
+	return ret;
+}
+
+/* Fatal error handler */
+static void io_error(const char *func, int rc)
+{
+	if (rc == -ENOSYS)
+		fprintf(stderr, "AIO not in this kernel\n");
+	else if (rc < 0)
+		fprintf(stderr, "%s: %s\n", func, strerror(-rc));
+	else
+		fprintf(stderr, "%s: error %d\n", func, rc);
+
+	if (dstfd > 0)
+		close(dstfd);
+	if (dstname && dest_open_flag & O_CREAT)
+		unlink(dstname);
+	exit(1);
+}
+
+/*
+ * Write complete callback.
+ * Adjust counts and free resources
+ */
+static void wr_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
+{
+	if (res2 != 0) {
+		io_error("aio write", res2);
+	}
+	if (res != iocb->u.c.nbytes) {
+		fprintf(stderr, "write missed bytes expect %lu got %ld\n",
+			iocb->u.c.nbytes, res2);
+		exit(1);
+	}
+	--tocopy;
+	--busy;
+	free_iocb(iocb);
+	if (debug)
+		write(2, "w", 1);
+}
+
+/*
+ * Read complete callback.
+ * Change read iocb into a write iocb and start it.
+ */
+static void rd_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
+{
+	/* library needs accessors to look at iocb? */
+	int iosize = iocb->u.c.nbytes;
+	char *buf = iocb->u.c.buf;
+	off_t offset = iocb->u.c.offset;
+
+	if (res2 != 0)
+		io_error("aio read", res2);
+	if (res != iosize) {
+		fprintf(stderr, "read missing bytes expect %lu got %ld\n",
+			iocb->u.c.nbytes, res);
+		exit(1);
+	}
+
+
+	/* turn read into write */
+	if (no_write) {
+		--tocopy;
+		--busy;
+		free_iocb(iocb);
+	} else {
+		io_prep_pwrite(iocb, dstfd, buf, iosize, offset);
+		io_set_callback(iocb, wr_done);
+		if (1 != (res = io_submit(ctx, 1, &iocb)))
+			io_error("io_submit write", res);
+	}
+	if (debug)
+		write(2, "r", 1);
+	if (debug > 1)
+		printf("%d", iosize);
+}
+
+void usage()
+{
+	fprintf(stderr,
+		"Usage: aiocp [-a align] [-s size] [-b blksize] [-n num_io]"
+		" [-f open_flag] SOURCE DEST\n"
+		"This copies from SOURCE to DEST using AIO.\n\n"
+		"Usage: aiocp [options] -w SOURCE\n"
+		"This does sequential AIO reads (no writes).\n\n"
+		"Usage: aiocp [options] -z DEST\n"
+		"This does sequential AIO writes of zeros.\n");
+		
+	exit(1);
+}
+
+/*
+ * Scale value by kilo, mega, or giga.
+ */
+long long scale_by_kmg(long long value, char scale)
+{
+	switch (scale) {
+	case 'g':
+	case 'G':
+		value *= 1024;
+	case 'm':
+	case 'M':
+		value *= 1024;
+	case 'k':
+	case 'K':
+		value *= 1024;
+		break;
+	case '\0':
+		break;
+	default:
+		usage();
+		break;
+	}
+	return value;
+}
+
+int main(int argc, char *const *argv)
+{
+	struct stat st;
+	off_t length = 0, offset = 0;
+	io_context_t myctx;
+	int c;
+	extern char *optarg;
+	extern int optind, opterr, optopt;
+
+	while ((c = getopt(argc, argv, "a:b:df:n:s:wzD:")) != -1) {
+		char *endp;
+
+		switch (c) {
+		case 'a':	/* alignment of data buffer */
+			alignment = strtol(optarg, &endp, 0);
+			alignment = (long)scale_by_kmg((long long)alignment,
+							*endp);
+			break;
+		case 'f':	/* use these open flags */
+			if (strcmp(optarg, "LARGEFILE") == 0 ||
+			    strcmp(optarg, "O_LARGEFILE") == 0) {
+				source_open_flag |= O_LARGEFILE;
+				dest_open_flag |= O_LARGEFILE;
+			} else if (strcmp(optarg, "TRUNC") == 0 ||
+			           strcmp(optarg, "O_TRUNC") == 0) {
+				dest_open_flag |= O_TRUNC;
+			} else if (strcmp(optarg, "SYNC") == 0 ||
+				   strcmp(optarg, "O_SYNC") == 0) {
+				dest_open_flag |= O_SYNC | O_NONBLOCK;
+			} else if (strcmp(optarg, "DIRECT") == 0 ||
+				   strcmp(optarg, "O_DIRECT") == 0) {
+				source_open_flag |= O_DIRECT;
+				dest_open_flag |= O_DIRECT;
+			} else if (strncmp(optarg, "CREAT", 5) == 0 ||
+				   strncmp(optarg, "O_CREAT", 5) == 0) {
+				dest_open_flag |= O_CREAT;
+			}
+			break;
+		case 'd':
+			debug++;
+			break;
+		case 'D':
+			delay.tv_usec = atoi(optarg);
+			break;
+		case 'b':	/* block size */
+			aio_blksize = strtol(optarg, &endp, 0);
+			aio_blksize = (long)scale_by_kmg((long long)aio_blksize, *endp);
+			break;
+
+		case 'n':	/* num io */
+			aio_maxio = strtol(optarg, &endp, 0);
+			break;
+		case 's':	/* size to transfer */
+			length = strtoll(optarg, &endp, 0);
+			length = scale_by_kmg(length, *endp);
+			break;
+		case 'w':	/* no write */
+			no_write = 1;
+			break;
+		case 'z':	/* write zero's */
+			zero = 1;
+			break;
+
+		default:
+			usage();
+		}
+	}
+
+	argc -= optind;
+	argv += optind;
+	
+#ifndef DEBUG
+	if (argc < 1) {
+		usage();
+	}
+#else
+    source_open_flag |= O_DIRECT;
+    dest_open_flag |= O_DIRECT;
+    aio_blksize = 1;
+    aio_maxio=1;
+    srcname = "junkdata";
+    dstname = "ff2";
+#endif
+	if (!zero) {
+#ifndef DEBUG
+	       	if ((srcfd = open(srcname = *argv, source_open_flag)) < 0) {
+#else
+                if ((srcfd = open(srcname, source_open_flag)) < 0) {
+#endif
+			perror(srcname);
+			exit(1);
+		}
+		argv++;
+		argc--;
+		if (fstat(srcfd, &st) < 0) {
+			perror("fstat");
+			exit(1);
+		}
+		if (length == 0)
+			length = st.st_size;
+	}
+
+	if (!no_write) {
+		/*
+		 * We are either copying or writing zeros to dstname
+		 */
+#ifndef DEBUG
+		if (argc < 1) {
+			usage();
+		}
+		if ((dstfd = open(dstname = *argv, dest_open_flag, 0666)) < 0) {
+#else
+            if ((dstfd = open(dstname, dest_open_flag, 0666)) < 0) {
+#endif
+			perror(dstname);
+			exit(1);
+		}
+		if (zero) {
+			/*
+			 * get size of dest, if we are zeroing it.
+			 * TODO: handle devices.
+			 */
+			if (fstat(dstfd, &st) < 0) {
+				perror("fstat");
+				exit(1);
+			}
+			if (length == 0)
+				length = st.st_size;
+		}
+	}
+
+	/* initialize state machine */
+	memset(&myctx, 0, sizeof(myctx));
+	io_queue_init(aio_maxio, &myctx);
+	tocopy = howmany(length, aio_blksize);
+printf("tocopy=%d len=%d blk=%d\n", tocopy, length, aio_blksize);
+	if (init_iocb(aio_maxio, aio_blksize) < 0) {
+		fprintf(stderr, "Error allocating the i/o buffers\n");
+		exit(1);
+	}
+
+	while (tocopy > 0) {
+		int i, rc;
+		/* Submit as many reads as once as possible upto aio_maxio */
+		int n = MIN(MIN(aio_maxio - busy, aio_maxio),
+				howmany(length - offset, aio_blksize));
+		if (n > 0) {
+			struct iocb *ioq[n];
+
+			for (i = 0; i < n; i++) {
+				struct iocb *io = alloc_iocb();
+				int iosize = MIN(length - offset, aio_blksize);
+
+				if (zero) {
+					/*
+					 * We are writing zero's to dstfd
+					 */
+					io_prep_pwrite(io, dstfd, io->u.c.buf,
+							iosize, offset);
+					io_set_callback(io, wr_done);
+				} else {
+					io_prep_pread(io, srcfd, io->u.c.buf,
+							iosize, offset);
+					io_set_callback(io, rd_done);
+				}
+				ioq[i] = io;
+				offset += iosize;
+			}
+
+			rc = io_submit(myctx, n, ioq);
+			if (rc < 0)
+				io_error("io_submit", rc);
+
+			busy += n;
+			if (debug > 1)
+				printf("io_submit(%d) busy:%d\n", n, busy);
+			if (delay.tv_usec) {
+				struct timeval t = delay;
+				(void)select(0,0,0,0,&t);
+			}
+		}
+
+		/*
+		 * We have submitted all the i/o requests. Wait for at least one to complete
+		 * and call the callbacks.
+		 */
+		count_io_q_waits++;
+		rc = io_wait_run(myctx, 0);
+		if (rc < 0)
+			io_error("io_wait_run", rc);
+
+		if (debug > 1) {
+			printf("io_wait_run: rc == %d\n", rc);
+			printf("busy:%d aio_maxio:%d tocopy:%d\n",
+					busy, aio_maxio, tocopy);
+		}
+	}
+
+	if (srcfd != -1)
+		close(srcfd);
+	if (dstfd != -1)
+		close(dstfd);
+	exit(0);
+}
+
+/* 
+ * Results look like:
+ * [alanm@toolbox ~/MOT3]$ ../taio -d kernel-source-2.4.8-0.4g.ppc.rpm abc
+ * rrrrrrrrrrrrrrrwwwrwrrwwrrwrwwrrwrwrwwrrwrwrrrrwwrwwwrrwrrrwwwwwwwwwwwwwwwww
+ * rrrrrrrrrrrrrrwwwrrwrwrwrwrrwwwwwwwwwwwwwwrrrrrrrrrrrrrrrrrrwwwwrwrwwrwrwrwr
+ * wrrrrrrrwwwwwwwwwwwwwrrrwrrrwrrwrwwwwwwwwwwrrrrwwrwrrrrrrrrrrrwwwwwwwwwwwrww
+ * wwwrrrrrrrrwwrrrwwrwrwrwwwrrrrrrrwwwrrwwwrrwrwwwwwwwwrrrrrrrwwwrrrrrrrwwwwww
+ * wwwwwwwrwrrrrrrrrwrrwrrwrrwrwrrrwrrrwrrrwrwwwwwwwwwwwwwwwwwwrrrwwwrrrrrrrrrr
+ * rrwrrrrrrwrrwwwwwwwwwwwwwwwwrwwwrrwrwwrrrrrrrrrrrrrrrrrrrwwwwwwwwwwwwwwwwwww
+ * rrrrrwrrwrwrwrrwrrrwwwwwwwwrrrrwrrrwrwwrwrrrwrrwrrrrwwwwwwwrwrwwwwrwwrrrwrrr
+ * rrrwwwwwwwrrrrwwrrrrrrrrrrrrwrwrrrrwwwwwwwwwwwwwwrwrrrrwwwwrwrrrrwrwwwrrrwww
+ * rwwrrrrrrrwrrrrrrrrrrrrwwwwrrrwwwrwrrwwwwwwwwwwwwwwwwwwwwwrrrrrrrwwwwwwwrw
+ */
diff --git a/tests/generic/250 b/tests/generic/250
new file mode 100755
index 0000000..0953e26
--- /dev/null
+++ b/tests/generic/250
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 250
+#
+# Create an unwritten extent, set up dm-error, try a DIO write, then
+# make sure we can't read back old disk contents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch
+_require_dm_target error
+_require_xfs_io_command "falloc"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+"$XFS_IO_PROG" -d -c "pwrite -S 0x69 -b 1048576 0 $((64 * 1048576))" "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mkfs_sized $((64 * 1048576)) > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+#"$XFS_IO_PROG" -c "extsize $((blksz * bsz))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/250.out b/tests/generic/250.out
new file mode 100644
index 0000000..710c80e
--- /dev/null
+++ b/tests/generic/250.out
@@ -0,0 +1,10 @@
+QA output created by 250
+Format and mount
+Create the original files
+Compare files
+ec8bb3b24d5b0f1b5bdf8c8f0f541ee6  SCRATCH_MNT/test-250/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+3ed86318f4ff8da26c1c2a6e3041f9be  SCRATCH_MNT/test-250/file2
+Check for damage
diff --git a/tests/generic/252 b/tests/generic/252
new file mode 100755
index 0000000..535b34b
--- /dev/null
+++ b/tests/generic/252
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 252
+#
+# Create an unwritten extent, set up dm-error, try an AIO DIO write, then
+# make sure we can't read back old disk contents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch
+_require_dm_target error
+_require_xfs_io_command "falloc"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+"$XFS_IO_PROG" -d -c "pwrite -S 0x69 -b 1048576 0 $((64 * 1048576))" "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mkfs_sized $((64 * 1048576)) > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+#"$XFS_IO_PROG" -c "extsize $((blksz * bsz))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/252.out b/tests/generic/252.out
new file mode 100644
index 0000000..3bc78c2
--- /dev/null
+++ b/tests/generic/252.out
@@ -0,0 +1,10 @@
+QA output created by 252
+Format and mount
+Create the original files
+Compare files
+ec8bb3b24d5b0f1b5bdf8c8f0f541ee6  SCRATCH_MNT/test-252/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+3ed86318f4ff8da26c1c2a6e3041f9be  SCRATCH_MNT/test-252/file2
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 860ff4a..1767484 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -252,7 +252,9 @@
 247 auto quick rw
 248 auto quick rw
 249 auto quick rw
+250 auto quick
 251 ioctl trim
+252 auto quick
 255 auto quick prealloc
 256 auto quick
 257 dir auto quick

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

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

* [PATCH 07/23] reflink: test intersecting CoW and falloc/fpunch/fzero/fcollapse/finsert/ftrunc
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Ensure that we correctly handle a CoW operation immediately followed
by a truncate, falloc, fpunch, fzero, fcollapse, and finsert operation
in the middle of the CoW'd region before any flush can occur.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/253     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/253.out |   13 +++++++
 tests/generic/254     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/254.out |   13 +++++++
 tests/generic/259     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/259.out |   13 +++++++
 tests/generic/261     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/261.out |   13 +++++++
 tests/generic/262     |   96 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/262.out |   13 +++++++
 tests/generic/264     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/264.out |   13 +++++++
 tests/generic/group   |    6 +++
 13 files changed, 645 insertions(+)
 create mode 100755 tests/generic/253
 create mode 100644 tests/generic/253.out
 create mode 100755 tests/generic/254
 create mode 100644 tests/generic/254.out
 create mode 100755 tests/generic/259
 create mode 100644 tests/generic/259.out
 create mode 100755 tests/generic/261
 create mode 100644 tests/generic/261.out
 create mode 100755 tests/generic/262
 create mode 100644 tests/generic/262.out
 create mode 100755 tests/generic/264
 create mode 100644 tests/generic/264.out


diff --git a/tests/generic/253 b/tests/generic/253
new file mode 100755
index 0000000..d8e0840
--- /dev/null
+++ b/tests/generic/253
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 253
+#
+# Truncate a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "truncate"
+
+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=65536
+nr=4
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/253.out b/tests/generic/253.out
new file mode 100644
index 0000000..f7c07a0
--- /dev/null
+++ b/tests/generic/253.out
@@ -0,0 +1,13 @@
+QA output created by 253
+Format and mount
+Create the original files
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file1
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file2
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file2.chk
+CoW and unmount
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file1
+b5fc98f04b19fa7b2085ec1358c78760  SCRATCH_MNT/test-253/file2
+b5fc98f04b19fa7b2085ec1358c78760  SCRATCH_MNT/test-253/file2.chk
+Check for damage
diff --git a/tests/generic/254 b/tests/generic/254
new file mode 100755
index 0000000..c66b2f4
--- /dev/null
+++ b/tests/generic/254
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 254
+#
+# Punch a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fpunch"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fpunch $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "pwrite -S 0x00 $((blksz * 2)) $blksz" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/254.out b/tests/generic/254.out
new file mode 100644
index 0000000..00d2121
--- /dev/null
+++ b/tests/generic/254.out
@@ -0,0 +1,13 @@
+QA output created by 254
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-254/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-254/file2.chk
+Check for damage
diff --git a/tests/generic/259 b/tests/generic/259
new file mode 100755
index 0000000..3307144
--- /dev/null
+++ b/tests/generic/259
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 259
+#
+# fzero a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fzero"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fzero $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "pwrite -S 0x00 $((blksz * 2)) $blksz" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/259.out b/tests/generic/259.out
new file mode 100644
index 0000000..ebe1020
--- /dev/null
+++ b/tests/generic/259.out
@@ -0,0 +1,13 @@
+QA output created by 259
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-259/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-259/file2.chk
+Check for damage
diff --git a/tests/generic/261 b/tests/generic/261
new file mode 100755
index 0000000..3027a63
--- /dev/null
+++ b/tests/generic/261
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 261
+#
+# fcollapse a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fcollapse"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fcollapse $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * (nr - 1)))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/261.out b/tests/generic/261.out
new file mode 100644
index 0000000..7e0e562
--- /dev/null
+++ b/tests/generic/261.out
@@ -0,0 +1,13 @@
+QA output created by 261
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file1
+91b31bb8bffa8c3d3374445039287226  SCRATCH_MNT/test-261/file2
+91b31bb8bffa8c3d3374445039287226  SCRATCH_MNT/test-261/file2.chk
+Check for damage
diff --git a/tests/generic/262 b/tests/generic/262
new file mode 100755
index 0000000..4050f34
--- /dev/null
+++ b/tests/generic/262
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 262
+#
+# finsert a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "finsert"
+
+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=65536
+nr=4
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "finsert $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+_pwrite_byte 0x62 $blksz $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x00 $((blksz * 2)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x62 $((blksz * 3)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x61 $((blksz * 4)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/262.out b/tests/generic/262.out
new file mode 100644
index 0000000..cc582ba
--- /dev/null
+++ b/tests/generic/262.out
@@ -0,0 +1,13 @@
+QA output created by 262
+Format and mount
+Create the original files
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file1
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file2
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file2.chk
+CoW and unmount
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-262/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-262/file2.chk
+Check for damage
diff --git a/tests/generic/264 b/tests/generic/264
new file mode 100755
index 0000000..7a81fa7
--- /dev/null
+++ b/tests/generic/264
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 264
+#
+# fallocate a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "falloc"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "falloc $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/264.out b/tests/generic/264.out
new file mode 100644
index 0000000..de175f9
--- /dev/null
+++ b/tests/generic/264.out
@@ -0,0 +1,13 @@
+QA output created by 264
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file1
+3383b9c17e643acd1a9a249cf041e183  SCRATCH_MNT/test-264/file2
+3383b9c17e643acd1a9a249cf041e183  SCRATCH_MNT/test-264/file2.chk
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 1767484..0b584d9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -255,12 +255,18 @@
 250 auto quick
 251 ioctl trim
 252 auto quick
+253 auto quick clone
+254 auto quick clone
 255 auto quick prealloc
 256 auto quick
 257 dir auto quick
 258 auto quick
+259 auto quick clone
 260 auto quick trim
+261 auto quick clone
+262 auto quick clone
 263 rw auto quick
+264 auto quick clone
 269 auto rw prealloc ioctl enospc stress
 270 auto quota rw prealloc ioctl enospc stress
 273 auto rw


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

* [PATCH 07/23] reflink: test intersecting CoW and falloc/fpunch/fzero/fcollapse/finsert/ftrunc
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Ensure that we correctly handle a CoW operation immediately followed
by a truncate, falloc, fpunch, fzero, fcollapse, and finsert operation
in the middle of the CoW'd region before any flush can occur.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/253     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/253.out |   13 +++++++
 tests/generic/254     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/254.out |   13 +++++++
 tests/generic/259     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/259.out |   13 +++++++
 tests/generic/261     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/261.out |   13 +++++++
 tests/generic/262     |   96 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/262.out |   13 +++++++
 tests/generic/264     |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/264.out |   13 +++++++
 tests/generic/group   |    6 +++
 13 files changed, 645 insertions(+)
 create mode 100755 tests/generic/253
 create mode 100644 tests/generic/253.out
 create mode 100755 tests/generic/254
 create mode 100644 tests/generic/254.out
 create mode 100755 tests/generic/259
 create mode 100644 tests/generic/259.out
 create mode 100755 tests/generic/261
 create mode 100644 tests/generic/261.out
 create mode 100755 tests/generic/262
 create mode 100644 tests/generic/262.out
 create mode 100755 tests/generic/264
 create mode 100644 tests/generic/264.out


diff --git a/tests/generic/253 b/tests/generic/253
new file mode 100755
index 0000000..d8e0840
--- /dev/null
+++ b/tests/generic/253
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 253
+#
+# Truncate a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "truncate"
+
+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=65536
+nr=4
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * 2))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/253.out b/tests/generic/253.out
new file mode 100644
index 0000000..f7c07a0
--- /dev/null
+++ b/tests/generic/253.out
@@ -0,0 +1,13 @@
+QA output created by 253
+Format and mount
+Create the original files
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file1
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file2
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file2.chk
+CoW and unmount
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-253/file1
+b5fc98f04b19fa7b2085ec1358c78760  SCRATCH_MNT/test-253/file2
+b5fc98f04b19fa7b2085ec1358c78760  SCRATCH_MNT/test-253/file2.chk
+Check for damage
diff --git a/tests/generic/254 b/tests/generic/254
new file mode 100755
index 0000000..c66b2f4
--- /dev/null
+++ b/tests/generic/254
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 254
+#
+# Punch a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fpunch"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fpunch $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "pwrite -S 0x00 $((blksz * 2)) $blksz" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/254.out b/tests/generic/254.out
new file mode 100644
index 0000000..00d2121
--- /dev/null
+++ b/tests/generic/254.out
@@ -0,0 +1,13 @@
+QA output created by 254
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-254/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-254/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-254/file2.chk
+Check for damage
diff --git a/tests/generic/259 b/tests/generic/259
new file mode 100755
index 0000000..3307144
--- /dev/null
+++ b/tests/generic/259
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 259
+#
+# fzero a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fzero"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fzero $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "pwrite -S 0x00 $((blksz * 2)) $blksz" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/259.out b/tests/generic/259.out
new file mode 100644
index 0000000..ebe1020
--- /dev/null
+++ b/tests/generic/259.out
@@ -0,0 +1,13 @@
+QA output created by 259
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-259/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-259/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-259/file2.chk
+Check for damage
diff --git a/tests/generic/261 b/tests/generic/261
new file mode 100755
index 0000000..3027a63
--- /dev/null
+++ b/tests/generic/261
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 261
+#
+# fcollapse a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "fcollapse"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "fcollapse $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "truncate $((blksz * (nr - 1)))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/261.out b/tests/generic/261.out
new file mode 100644
index 0000000..7e0e562
--- /dev/null
+++ b/tests/generic/261.out
@@ -0,0 +1,13 @@
+QA output created by 261
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-261/file1
+91b31bb8bffa8c3d3374445039287226  SCRATCH_MNT/test-261/file2
+91b31bb8bffa8c3d3374445039287226  SCRATCH_MNT/test-261/file2.chk
+Check for damage
diff --git a/tests/generic/262 b/tests/generic/262
new file mode 100755
index 0000000..4050f34
--- /dev/null
+++ b/tests/generic/262
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 262
+#
+# finsert a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "finsert"
+
+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=65536
+nr=4
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 2)) $blksz $((blksz * 2))" -c "finsert $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+_pwrite_byte 0x62 $blksz $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x00 $((blksz * 2)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x62 $((blksz * 3)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_pwrite_byte 0x61 $((blksz * 4)) $blksz "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/262.out b/tests/generic/262.out
new file mode 100644
index 0000000..cc582ba
--- /dev/null
+++ b/tests/generic/262.out
@@ -0,0 +1,13 @@
+QA output created by 262
+Format and mount
+Create the original files
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file1
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file2
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file2.chk
+CoW and unmount
+Compare files
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-262/file1
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-262/file2
+b9f7a56c2ab90569cb19d8597583c6a6  SCRATCH_MNT/test-262/file2.chk
+Check for damage
diff --git a/tests/generic/264 b/tests/generic/264
new file mode 100755
index 0000000..7a81fa7
--- /dev/null
+++ b/tests/generic/264
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 264
+#
+# fallocate a file at midway through a CoW region.
+#
+# This test is dependent on the system page size, so we cannot use md5 in
+# the golden output; we can only compare to a check file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "falloc"
+
+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=65536
+nr=5
+
+echo "Create the original files"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "falloc $((blksz * 2)) $blksz" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+"$XFS_IO_PROG" -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/264.out b/tests/generic/264.out
new file mode 100644
index 0000000..de175f9
--- /dev/null
+++ b/tests/generic/264.out
@@ -0,0 +1,13 @@
+QA output created by 264
+Format and mount
+Create the original files
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file1
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file2
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file2.chk
+CoW and unmount
+Compare files
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-264/file1
+3383b9c17e643acd1a9a249cf041e183  SCRATCH_MNT/test-264/file2
+3383b9c17e643acd1a9a249cf041e183  SCRATCH_MNT/test-264/file2.chk
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 1767484..0b584d9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -255,12 +255,18 @@
 250 auto quick
 251 ioctl trim
 252 auto quick
+253 auto quick clone
+254 auto quick clone
 255 auto quick prealloc
 256 auto quick
 257 dir auto quick
 258 auto quick
+259 auto quick clone
 260 auto quick trim
+261 auto quick clone
+262 auto quick clone
 263 rw auto quick
+264 auto quick clone
 269 auto rw prealloc ioctl enospc stress
 270 auto quota rw prealloc ioctl enospc stress
 273 auto rw

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

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

* [PATCH 08/23] reflink: test CoW behavior with IO errors
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Test various scenarios (with dm-flakey) where we simulate write
failures during CoW, to see if the FS can get through it without
blowing up or corrupting data.  Plumb in a FS-generic method to
sort out repairing filesystems after they get hit by IO errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc             |   28 +++++++++++++
 tests/generic/265     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/265.out |   11 +++++
 tests/generic/266     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/266.out |   12 +++++
 tests/generic/267     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/267.out |   10 +++++
 tests/generic/268     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/268.out |   12 +++++
 tests/generic/271     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/271.out |   11 +++++
 tests/generic/272     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/272.out |   12 +++++
 tests/generic/276     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/276.out |   11 +++++
 tests/generic/278     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/278.out |   12 +++++
 tests/generic/279     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/279.out |   11 +++++
 tests/generic/281     |  104 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/281.out |   12 +++++
 tests/generic/282     |  104 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/282.out |   10 +++++
 tests/generic/283     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/283.out |   12 +++++
 tests/generic/group   |   12 +++++
 26 files changed, 1422 insertions(+)
 create mode 100755 tests/generic/265
 create mode 100644 tests/generic/265.out
 create mode 100755 tests/generic/266
 create mode 100644 tests/generic/266.out
 create mode 100755 tests/generic/267
 create mode 100644 tests/generic/267.out
 create mode 100755 tests/generic/268
 create mode 100644 tests/generic/268.out
 create mode 100755 tests/generic/271
 create mode 100644 tests/generic/271.out
 create mode 100755 tests/generic/272
 create mode 100644 tests/generic/272.out
 create mode 100755 tests/generic/276
 create mode 100644 tests/generic/276.out
 create mode 100755 tests/generic/278
 create mode 100644 tests/generic/278.out
 create mode 100755 tests/generic/279
 create mode 100644 tests/generic/279.out
 create mode 100755 tests/generic/281
 create mode 100644 tests/generic/281.out
 create mode 100755 tests/generic/282
 create mode 100644 tests/generic/282.out
 create mode 100755 tests/generic/283
 create mode 100644 tests/generic/283.out


diff --git a/common/rc b/common/rc
index 863d4b3..467c217 100644
--- a/common/rc
+++ b/common/rc
@@ -953,6 +953,34 @@ _scratch_xfs_repair()
     $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_repair_scratch_fs()
+{
+    case $FSTYP in
+    xfs)
+        _scratch_xfs_repair "$@"
+	res=$?
+	if [ "$res" -eq 2 ]; then
+		echo "xfs_repair returns $res; replay log?"
+		_scratch_mount
+		res=$?
+		if [ "$res" -gt 0 ]; then
+			echo "mount returns $res; zap log?"
+			_scratch_xfs_repair -L
+			echo "log zap returns $?"
+		else
+			umount "$SCRATCH_MNT"
+		fi
+		_scratch_xfs_repair "$@"
+	fi
+	echo "error $?"
+        ;;
+    *)
+        # Let's hope fsck -y suffices...
+        fsck -t $FSTYP -y $SCRATCH_DEV
+        ;;
+    esac
+}
+
 _get_pids_by_name()
 {
     if [ $# -ne 1 ]
diff --git a/tests/generic/265 b/tests/generic/265
new file mode 100755
index 0000000..e91b307
--- /dev/null
+++ b/tests/generic/265
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 265
+#
+# Test CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/265.out b/tests/generic/265.out
new file mode 100644
index 0000000..1b67114
--- /dev/null
+++ b/tests/generic/265.out
@@ -0,0 +1,11 @@
+QA output created by 265
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
+Check for damage
diff --git a/tests/generic/266 b/tests/generic/266
new file mode 100755
index 0000000..a100348
--- /dev/null
+++ b/tests/generic/266
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 266
+#
+# Test CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/266.out b/tests/generic/266.out
new file mode 100644
index 0000000..bcfa097
--- /dev/null
+++ b/tests/generic/266.out
@@ -0,0 +1,12 @@
+QA output created by 266
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file2
+CoW and unmount
+fdatasync: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
+Check for damage
diff --git a/tests/generic/267 b/tests/generic/267
new file mode 100755
index 0000000..25aaed7
--- /dev/null
+++ b/tests/generic/267
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 267
+#
+# Test CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/267.out b/tests/generic/267.out
new file mode 100644
index 0000000..3c58e67
--- /dev/null
+++ b/tests/generic/267.out
@@ -0,0 +1,10 @@
+QA output created by 267
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file1
+Check for damage
diff --git a/tests/generic/268 b/tests/generic/268
new file mode 100755
index 0000000..fa3d991
--- /dev/null
+++ b/tests/generic/268
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 268
+#
+# Test CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x64 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/268.out b/tests/generic/268.out
new file mode 100644
index 0000000..234e8be
--- /dev/null
+++ b/tests/generic/268.out
@@ -0,0 +1,12 @@
+QA output created by 268
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file2
+CoW and unmount
+fdatasync: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
+Check for damage
diff --git a/tests/generic/271 b/tests/generic/271
new file mode 100755
index 0000000..efdd377
--- /dev/null
+++ b/tests/generic/271
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 271
+#
+# Test DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/271.out b/tests/generic/271.out
new file mode 100644
index 0000000..f7ea004
--- /dev/null
+++ b/tests/generic/271.out
@@ -0,0 +1,11 @@
+QA output created by 271
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
+Check for damage
diff --git a/tests/generic/272 b/tests/generic/272
new file mode 100755
index 0000000..64c9834
--- /dev/null
+++ b/tests/generic/272
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 272
+#
+# Test DIO CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/272.out b/tests/generic/272.out
new file mode 100644
index 0000000..4794088
--- /dev/null
+++ b/tests/generic/272.out
@@ -0,0 +1,12 @@
+QA output created by 272
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file2
+CoW and unmount
+pwrite64: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
+Check for damage
diff --git a/tests/generic/276 b/tests/generic/276
new file mode 100755
index 0000000..3b51ffd
--- /dev/null
+++ b/tests/generic/276
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 276
+#
+# Test DIO CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/276.out b/tests/generic/276.out
new file mode 100644
index 0000000..e2aeacf
--- /dev/null
+++ b/tests/generic/276.out
@@ -0,0 +1,11 @@
+QA output created by 276
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
+Check for damage
diff --git a/tests/generic/278 b/tests/generic/278
new file mode 100755
index 0000000..892320e
--- /dev/null
+++ b/tests/generic/278
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 278
+#
+# Test CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x64 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/278.out b/tests/generic/278.out
new file mode 100644
index 0000000..6723b73
--- /dev/null
+++ b/tests/generic/278.out
@@ -0,0 +1,12 @@
+QA output created by 278
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file2
+CoW and unmount
+pwrite64: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
+Check for damage
diff --git a/tests/generic/279 b/tests/generic/279
new file mode 100755
index 0000000..66ea000
--- /dev/null
+++ b/tests/generic/279
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 279
+#
+# Test mmap CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/279.out b/tests/generic/279.out
new file mode 100644
index 0000000..f34c2b2
--- /dev/null
+++ b/tests/generic/279.out
@@ -0,0 +1,11 @@
+QA output created by 279
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file2
+CoW and unmount
+msync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
+Check for damage
diff --git a/tests/generic/281 b/tests/generic/281
new file mode 100755
index 0000000..09dc4be
--- /dev/null
+++ b/tests/generic/281
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 281
+#
+# Test mmap CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/281.out b/tests/generic/281.out
new file mode 100644
index 0000000..17a656b
--- /dev/null
+++ b/tests/generic/281.out
@@ -0,0 +1,12 @@
+QA output created by 281
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file2
+CoW and unmount
+msync: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
+Check for damage
diff --git a/tests/generic/282 b/tests/generic/282
new file mode 100755
index 0000000..29b7c13
--- /dev/null
+++ b/tests/generic/282
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 282
+#
+# Test mmap CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/282.out b/tests/generic/282.out
new file mode 100644
index 0000000..624dbfa
--- /dev/null
+++ b/tests/generic/282.out
@@ -0,0 +1,10 @@
+QA output created by 282
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file1
+Check for damage
diff --git a/tests/generic/283 b/tests/generic/283
new file mode 100755
index 0000000..3861954
--- /dev/null
+++ b/tests/generic/283
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 283
+#
+# Test mmap CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/283.out b/tests/generic/283.out
new file mode 100644
index 0000000..f9fd5c8
--- /dev/null
+++ b/tests/generic/283.out
@@ -0,0 +1,12 @@
+QA output created by 283
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file2
+CoW and unmount
+msync: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 0b584d9..c2624eb 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -267,13 +267,25 @@
 262 auto quick clone
 263 rw auto quick
 264 auto quick clone
+265 auto quick clone
+266 auto quick clone
+267 auto quick clone
+268 auto quick clone
 269 auto rw prealloc ioctl enospc stress
 270 auto quota rw prealloc ioctl enospc stress
+271 auto quick clone
+272 auto quick clone
 273 auto rw
 274 auto rw prealloc
 275 auto rw enospc
+276 auto quick clone
 277 auto ioctl quick metadata
+278 auto quick clone
+279 auto quick clone
 280 auto quota freeze dangerous
+281 auto quick clone
+282 auto quick clone
+283 auto quick clone
 285 auto rw
 286 auto quick other
 288 auto quick ioctl trim


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

* [PATCH 08/23] reflink: test CoW behavior with IO errors
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Test various scenarios (with dm-flakey) where we simulate write
failures during CoW, to see if the FS can get through it without
blowing up or corrupting data.  Plumb in a FS-generic method to
sort out repairing filesystems after they get hit by IO errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc             |   28 +++++++++++++
 tests/generic/265     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/265.out |   11 +++++
 tests/generic/266     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/266.out |   12 +++++
 tests/generic/267     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/267.out |   10 +++++
 tests/generic/268     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/268.out |   12 +++++
 tests/generic/271     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/271.out |   11 +++++
 tests/generic/272     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/272.out |   12 +++++
 tests/generic/276     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/276.out |   11 +++++
 tests/generic/278     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/278.out |   12 +++++
 tests/generic/279     |  103 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/279.out |   11 +++++
 tests/generic/281     |  104 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/281.out |   12 +++++
 tests/generic/282     |  104 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/282.out |   10 +++++
 tests/generic/283     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/283.out |   12 +++++
 tests/generic/group   |   12 +++++
 26 files changed, 1422 insertions(+)
 create mode 100755 tests/generic/265
 create mode 100644 tests/generic/265.out
 create mode 100755 tests/generic/266
 create mode 100644 tests/generic/266.out
 create mode 100755 tests/generic/267
 create mode 100644 tests/generic/267.out
 create mode 100755 tests/generic/268
 create mode 100644 tests/generic/268.out
 create mode 100755 tests/generic/271
 create mode 100644 tests/generic/271.out
 create mode 100755 tests/generic/272
 create mode 100644 tests/generic/272.out
 create mode 100755 tests/generic/276
 create mode 100644 tests/generic/276.out
 create mode 100755 tests/generic/278
 create mode 100644 tests/generic/278.out
 create mode 100755 tests/generic/279
 create mode 100644 tests/generic/279.out
 create mode 100755 tests/generic/281
 create mode 100644 tests/generic/281.out
 create mode 100755 tests/generic/282
 create mode 100644 tests/generic/282.out
 create mode 100755 tests/generic/283
 create mode 100644 tests/generic/283.out


diff --git a/common/rc b/common/rc
index 863d4b3..467c217 100644
--- a/common/rc
+++ b/common/rc
@@ -953,6 +953,34 @@ _scratch_xfs_repair()
     $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_repair_scratch_fs()
+{
+    case $FSTYP in
+    xfs)
+        _scratch_xfs_repair "$@"
+	res=$?
+	if [ "$res" -eq 2 ]; then
+		echo "xfs_repair returns $res; replay log?"
+		_scratch_mount
+		res=$?
+		if [ "$res" -gt 0 ]; then
+			echo "mount returns $res; zap log?"
+			_scratch_xfs_repair -L
+			echo "log zap returns $?"
+		else
+			umount "$SCRATCH_MNT"
+		fi
+		_scratch_xfs_repair "$@"
+	fi
+	echo "error $?"
+        ;;
+    *)
+        # Let's hope fsck -y suffices...
+        fsck -t $FSTYP -y $SCRATCH_DEV
+        ;;
+    esac
+}
+
 _get_pids_by_name()
 {
     if [ $# -ne 1 ]
diff --git a/tests/generic/265 b/tests/generic/265
new file mode 100755
index 0000000..e91b307
--- /dev/null
+++ b/tests/generic/265
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 265
+#
+# Test CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/265.out b/tests/generic/265.out
new file mode 100644
index 0000000..1b67114
--- /dev/null
+++ b/tests/generic/265.out
@@ -0,0 +1,11 @@
+QA output created by 265
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-265/file1
+Check for damage
diff --git a/tests/generic/266 b/tests/generic/266
new file mode 100755
index 0000000..a100348
--- /dev/null
+++ b/tests/generic/266
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 266
+#
+# Test CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/266.out b/tests/generic/266.out
new file mode 100644
index 0000000..bcfa097
--- /dev/null
+++ b/tests/generic/266.out
@@ -0,0 +1,12 @@
+QA output created by 266
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file2
+CoW and unmount
+fdatasync: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-266/file1
+Check for damage
diff --git a/tests/generic/267 b/tests/generic/267
new file mode 100755
index 0000000..25aaed7
--- /dev/null
+++ b/tests/generic/267
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 267
+#
+# Test CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/267.out b/tests/generic/267.out
new file mode 100644
index 0000000..3c58e67
--- /dev/null
+++ b/tests/generic/267.out
@@ -0,0 +1,10 @@
+QA output created by 267
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-267/file1
+Check for damage
diff --git a/tests/generic/268 b/tests/generic/268
new file mode 100755
index 0000000..fa3d991
--- /dev/null
+++ b/tests/generic/268
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 268
+#
+# Test CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x64 -b $((blksz * bsz)) 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/268.out b/tests/generic/268.out
new file mode 100644
index 0000000..234e8be
--- /dev/null
+++ b/tests/generic/268.out
@@ -0,0 +1,12 @@
+QA output created by 268
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file2
+CoW and unmount
+fdatasync: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-268/file1
+Check for damage
diff --git a/tests/generic/271 b/tests/generic/271
new file mode 100755
index 0000000..efdd377
--- /dev/null
+++ b/tests/generic/271
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 271
+#
+# Test DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/271.out b/tests/generic/271.out
new file mode 100644
index 0000000..f7ea004
--- /dev/null
+++ b/tests/generic/271.out
@@ -0,0 +1,11 @@
+QA output created by 271
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-271/file1
+Check for damage
diff --git a/tests/generic/272 b/tests/generic/272
new file mode 100755
index 0000000..64c9834
--- /dev/null
+++ b/tests/generic/272
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 272
+#
+# Test DIO CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/272.out b/tests/generic/272.out
new file mode 100644
index 0000000..4794088
--- /dev/null
+++ b/tests/generic/272.out
@@ -0,0 +1,12 @@
+QA output created by 272
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file2
+CoW and unmount
+pwrite64: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-272/file1
+Check for damage
diff --git a/tests/generic/276 b/tests/generic/276
new file mode 100755
index 0000000..3b51ffd
--- /dev/null
+++ b/tests/generic/276
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 276
+#
+# Test DIO CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/276.out b/tests/generic/276.out
new file mode 100644
index 0000000..e2aeacf
--- /dev/null
+++ b/tests/generic/276.out
@@ -0,0 +1,11 @@
+QA output created by 276
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file2
+CoW and unmount
+pwrite64: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-276/file1
+Check for damage
diff --git a/tests/generic/278 b/tests/generic/278
new file mode 100755
index 0000000..892320e
--- /dev/null
+++ b/tests/generic/278
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 278
+#
+# Test CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x64 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/278.out b/tests/generic/278.out
new file mode 100644
index 0000000..6723b73
--- /dev/null
+++ b/tests/generic/278.out
@@ -0,0 +1,12 @@
+QA output created by 278
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file2
+CoW and unmount
+pwrite64: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-278/file1
+Check for damage
diff --git a/tests/generic/279 b/tests/generic/279
new file mode 100755
index 0000000..66ea000
--- /dev/null
+++ b/tests/generic/279
@@ -0,0 +1,103 @@
+#! /bin/bash
+# FS QA Test No. 279
+#
+# Test mmap CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/279.out b/tests/generic/279.out
new file mode 100644
index 0000000..f34c2b2
--- /dev/null
+++ b/tests/generic/279.out
@@ -0,0 +1,11 @@
+QA output created by 279
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file2
+CoW and unmount
+msync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-279/file1
+Check for damage
diff --git a/tests/generic/281 b/tests/generic/281
new file mode 100755
index 0000000..09dc4be
--- /dev/null
+++ b/tests/generic/281
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 281
+#
+# Test mmap CoW behavior when the write permanently fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+
+echo "Clean up the mess"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/281.out b/tests/generic/281.out
new file mode 100644
index 0000000..17a656b
--- /dev/null
+++ b/tests/generic/281.out
@@ -0,0 +1,12 @@
+QA output created by 281
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file2
+CoW and unmount
+msync: Input/output error
+Clean up the mess
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-281/file1
+Check for damage
diff --git a/tests/generic/282 b/tests/generic/282
new file mode 100755
index 0000000..29b7c13
--- /dev/null
+++ b/tests/generic/282
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 282
+#
+# Test mmap CoW behavior when the write temporarily fails and we unmount.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+rm -rf "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/282.out b/tests/generic/282.out
new file mode 100644
index 0000000..624dbfa
--- /dev/null
+++ b/tests/generic/282.out
@@ -0,0 +1,10 @@
+QA output created by 282
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-282/file1
+Check for damage
diff --git a/tests/generic/283 b/tests/generic/283
new file mode 100755
index 0000000..3861954
--- /dev/null
+++ b/tests/generic/283
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 283
+#
+# Test mmap CoW behavior when the write temporarily fails but the userspace
+# program writes again.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/mwrite.out"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_need_to_be_root
+_require_dm_target error
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+sync
+_dmerror_load_error_table
+urk=$("$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync -s 0 $((blksz * nr))" "$testdir/file2" > "$TEST_DIR/mwrite.out" 2>&1)
+cat "$TEST_DIR/mwrite.out" | tee -a "$seqres.full"
+_dmerror_load_working_table
+
+echo "Rewrite"
+"$XFS_IO_PROG" -f -c "mmap -rw 0 $((blksz * nr))" -c "mwrite -S 0x63 0 $((blksz * nr))" -c "msync 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full" 2>&1
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/283.out b/tests/generic/283.out
new file mode 100644
index 0000000..f9fd5c8
--- /dev/null
+++ b/tests/generic/283.out
@@ -0,0 +1,12 @@
+QA output created by 283
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file2
+CoW and unmount
+msync: Input/output error
+Rewrite
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-283/file1
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 0b584d9..c2624eb 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -267,13 +267,25 @@
 262 auto quick clone
 263 rw auto quick
 264 auto quick clone
+265 auto quick clone
+266 auto quick clone
+267 auto quick clone
+268 auto quick clone
 269 auto rw prealloc ioctl enospc stress
 270 auto quota rw prealloc ioctl enospc stress
+271 auto quick clone
+272 auto quick clone
 273 auto rw
 274 auto rw prealloc
 275 auto rw enospc
+276 auto quick clone
 277 auto ioctl quick metadata
+278 auto quick clone
+279 auto quick clone
 280 auto quota freeze dangerous
+281 auto quick clone
+282 auto quick clone
+283 auto quick clone
 285 auto rw
 286 auto quick other
 288 auto quick ioctl trim

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

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

* [PATCH 09/23] reflink: test CoW operations against the source file
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Ensure that CoW operations against shared blocks in the source file
work correctly.

v2: remove filefrag dependencies

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/196     |    2 -
 tests/generic/197     |    2 -
 tests/generic/284     |   95 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/284.out |   13 ++++++
 tests/generic/287     |   95 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/287.out |   13 ++++++
 tests/generic/289     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/289.out |   13 ++++++
 tests/generic/290     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/290.out |   13 ++++++
 tests/generic/291     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/291.out |   13 ++++++
 tests/generic/292     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/292.out |   13 ++++++
 tests/generic/293     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/293.out |   13 ++++++
 tests/generic/295     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/295.out |   13 ++++++
 tests/generic/296     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/296.out |   13 ++++++
 tests/generic/group   |    9 ++++
 21 files changed, 1036 insertions(+), 2 deletions(-)
 create mode 100755 tests/generic/284
 create mode 100644 tests/generic/284.out
 create mode 100755 tests/generic/287
 create mode 100644 tests/generic/287.out
 create mode 100755 tests/generic/289
 create mode 100644 tests/generic/289.out
 create mode 100755 tests/generic/290
 create mode 100644 tests/generic/290.out
 create mode 100755 tests/generic/291
 create mode 100644 tests/generic/291.out
 create mode 100755 tests/generic/292
 create mode 100644 tests/generic/292.out
 create mode 100755 tests/generic/293
 create mode 100644 tests/generic/293.out
 create mode 100755 tests/generic/295
 create mode 100644 tests/generic/295.out
 create mode 100755 tests/generic/296
 create mode 100644 tests/generic/296.out


diff --git a/tests/generic/196 b/tests/generic/196
index 4da9c76..11ecebb 100755
--- a/tests/generic/196
+++ b/tests/generic/196
@@ -2,7 +2,7 @@
 # FS QA Test No. 196
 #
 # Ensuring that copy on write in direct-io mode works when the CoW
-# range originally covers multiple extents, some unwritten, some not.
+# range originally covers multiple extents, some regular, some not.
 #   - Create two files.
 #   - Reflink the odd blocks of the first file into the second file.
 #   - directio CoW across the halfway mark, starting with the unwritten extent.
diff --git a/tests/generic/197 b/tests/generic/197
index 54ee5ab..72c2cb3 100755
--- a/tests/generic/197
+++ b/tests/generic/197
@@ -2,7 +2,7 @@
 # FS QA Test No. 197
 #
 # Ensuring that copy on write in buffered mode works when the CoW
-# range originally covers multiple extents, some unwritten, some not.
+# range originally covers multiple extents, some regular, some not.
 #   - Create two files.
 #   - Reflink the odd blocks of the first file into the second file.
 #   - CoW across the halfway mark, starting with the unwritten extent.
diff --git a/tests/generic/284 b/tests/generic/284
new file mode 100755
index 0000000..2a94bd1
--- /dev/null
+++ b/tests/generic/284
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 284
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers regular unshared and regular shared blocks.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/284.out b/tests/generic/284.out
new file mode 100644
index 0000000..da24b6d
--- /dev/null
+++ b/tests/generic/284.out
@@ -0,0 +1,13 @@
+QA output created by 284
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-284/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-284/file3
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-284/file1.chk
+CoW across the transition
+Compare files
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-284/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-284/file3
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-284/file1.chk
+Check for damage
diff --git a/tests/generic/287 b/tests/generic/287
new file mode 100755
index 0000000..d3c740c
--- /dev/null
+++ b/tests/generic/287
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 287
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers regular unshared and regular shared blocks.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - dio CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/287.out b/tests/generic/287.out
new file mode 100644
index 0000000..fd1dcc0
--- /dev/null
+++ b/tests/generic/287.out
@@ -0,0 +1,13 @@
+QA output created by 287
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-287/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-287/file3
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-287/file1.chk
+CoW across the transition
+Compare files
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-287/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-287/file3
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-287/file1.chk
+Check for damage
diff --git a/tests/generic/289 b/tests/generic/289
new file mode 100755
index 0000000..253782d
--- /dev/null
+++ b/tests/generic/289
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 289
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers unwritten and regular shared blocks.
+#   - Create two files.
+#   - fallocate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/289.out b/tests/generic/289.out
new file mode 100644
index 0000000..424ac10
--- /dev/null
+++ b/tests/generic/289.out
@@ -0,0 +1,13 @@
+QA output created by 289
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-289/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-289/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-289/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-289/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-289/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-289/file1.chk
+Check for damage
diff --git a/tests/generic/290 b/tests/generic/290
new file mode 100755
index 0000000..76dae61
--- /dev/null
+++ b/tests/generic/290
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 290
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers unwritten and regular shared blocks.
+#   - Create two files.
+#   - fallocate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/290.out b/tests/generic/290.out
new file mode 100644
index 0000000..6af6c5b
--- /dev/null
+++ b/tests/generic/290.out
@@ -0,0 +1,13 @@
+QA output created by 290
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-290/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-290/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-290/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-290/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-290/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-290/file1.chk
+Check for damage
diff --git a/tests/generic/291 b/tests/generic/291
new file mode 100755
index 0000000..a7bdd8b
--- /dev/null
+++ b/tests/generic/291
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 291
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers holes and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/291.out b/tests/generic/291.out
new file mode 100644
index 0000000..93b813d
--- /dev/null
+++ b/tests/generic/291.out
@@ -0,0 +1,13 @@
+QA output created by 291
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-291/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-291/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-291/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-291/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-291/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-291/file1.chk
+Check for damage
diff --git a/tests/generic/292 b/tests/generic/292
new file mode 100755
index 0000000..23e1b92
--- /dev/null
+++ b/tests/generic/292
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 292
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers holes and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/292.out b/tests/generic/292.out
new file mode 100644
index 0000000..2337a46
--- /dev/null
+++ b/tests/generic/292.out
@@ -0,0 +1,13 @@
+QA output created by 292
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-292/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-292/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-292/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-292/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-292/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-292/file1.chk
+Check for damage
diff --git a/tests/generic/293 b/tests/generic/293
new file mode 100755
index 0000000..1d2d418
--- /dev/null
+++ b/tests/generic/293
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 293
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers delalloc blocks and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Write the even blocks of the first file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 0 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/293.out b/tests/generic/293.out
new file mode 100644
index 0000000..1f1aeb3
--- /dev/null
+++ b/tests/generic/293.out
@@ -0,0 +1,13 @@
+QA output created by 293
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-293/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-293/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-293/file1.chk
+CoW across the transition
+Compare files
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-293/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-293/file3
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-293/file1.chk
+Check for damage
diff --git a/tests/generic/295 b/tests/generic/295
new file mode 100755
index 0000000..e8b74f2
--- /dev/null
+++ b/tests/generic/295
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 295
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers delalloc blocks and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Write the even blocks of the first file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 0 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/295.out b/tests/generic/295.out
new file mode 100644
index 0000000..a1c9b1f
--- /dev/null
+++ b/tests/generic/295.out
@@ -0,0 +1,13 @@
+QA output created by 295
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-295/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-295/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-295/file1.chk
+CoW across the transition
+Compare files
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-295/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-295/file3
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-295/file1.chk
+Check for damage
diff --git a/tests/generic/296 b/tests/generic/296
new file mode 100755
index 0000000..f8edc1b
--- /dev/null
+++ b/tests/generic/296
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 296
+#
+# - Create two reflinked files a byte longer than a block.
+# - Rewrite the whole file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/296.out b/tests/generic/296.out
new file mode 100644
index 0000000..1b44cb4
--- /dev/null
+++ b/tests/generic/296.out
@@ -0,0 +1,13 @@
+QA output created by 296
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file2
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file2.chk
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-296/file2
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-296/file2.chk
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index c2624eb..98242e8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -286,10 +286,19 @@
 281 auto quick clone
 282 auto quick clone
 283 auto quick clone
+284 auto quick clone
 285 auto rw
 286 auto quick other
+287 auto quick clone
 288 auto quick ioctl trim
+289 auto quick clone
+290 auto quick clone
+291 auto quick clone
+292 auto quick clone
+293 auto quick clone
 294 auto quick
+295 auto quick clone
+296 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
 306 auto quick rw


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

* [PATCH 09/23] reflink: test CoW operations against the source file
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Ensure that CoW operations against shared blocks in the source file
work correctly.

v2: remove filefrag dependencies

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/196     |    2 -
 tests/generic/197     |    2 -
 tests/generic/284     |   95 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/284.out |   13 ++++++
 tests/generic/287     |   95 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/287.out |   13 ++++++
 tests/generic/289     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/289.out |   13 ++++++
 tests/generic/290     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/290.out |   13 ++++++
 tests/generic/291     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/291.out |   13 ++++++
 tests/generic/292     |  102 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/292.out |   13 ++++++
 tests/generic/293     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/293.out |   13 ++++++
 tests/generic/295     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/295.out |   13 ++++++
 tests/generic/296     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/296.out |   13 ++++++
 tests/generic/group   |    9 ++++
 21 files changed, 1036 insertions(+), 2 deletions(-)
 create mode 100755 tests/generic/284
 create mode 100644 tests/generic/284.out
 create mode 100755 tests/generic/287
 create mode 100644 tests/generic/287.out
 create mode 100755 tests/generic/289
 create mode 100644 tests/generic/289.out
 create mode 100755 tests/generic/290
 create mode 100644 tests/generic/290.out
 create mode 100755 tests/generic/291
 create mode 100644 tests/generic/291.out
 create mode 100755 tests/generic/292
 create mode 100644 tests/generic/292.out
 create mode 100755 tests/generic/293
 create mode 100644 tests/generic/293.out
 create mode 100755 tests/generic/295
 create mode 100644 tests/generic/295.out
 create mode 100755 tests/generic/296
 create mode 100644 tests/generic/296.out


diff --git a/tests/generic/196 b/tests/generic/196
index 4da9c76..11ecebb 100755
--- a/tests/generic/196
+++ b/tests/generic/196
@@ -2,7 +2,7 @@
 # FS QA Test No. 196
 #
 # Ensuring that copy on write in direct-io mode works when the CoW
-# range originally covers multiple extents, some unwritten, some not.
+# range originally covers multiple extents, some regular, some not.
 #   - Create two files.
 #   - Reflink the odd blocks of the first file into the second file.
 #   - directio CoW across the halfway mark, starting with the unwritten extent.
diff --git a/tests/generic/197 b/tests/generic/197
index 54ee5ab..72c2cb3 100755
--- a/tests/generic/197
+++ b/tests/generic/197
@@ -2,7 +2,7 @@
 # FS QA Test No. 197
 #
 # Ensuring that copy on write in buffered mode works when the CoW
-# range originally covers multiple extents, some unwritten, some not.
+# range originally covers multiple extents, some regular, some not.
 #   - Create two files.
 #   - Reflink the odd blocks of the first file into the second file.
 #   - CoW across the halfway mark, starting with the unwritten extent.
diff --git a/tests/generic/284 b/tests/generic/284
new file mode 100755
index 0000000..2a94bd1
--- /dev/null
+++ b/tests/generic/284
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 284
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers regular unshared and regular shared blocks.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/284.out b/tests/generic/284.out
new file mode 100644
index 0000000..da24b6d
--- /dev/null
+++ b/tests/generic/284.out
@@ -0,0 +1,13 @@
+QA output created by 284
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-284/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-284/file3
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-284/file1.chk
+CoW across the transition
+Compare files
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-284/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-284/file3
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-284/file1.chk
+Check for damage
diff --git a/tests/generic/287 b/tests/generic/287
new file mode 100755
index 0000000..d3c740c
--- /dev/null
+++ b/tests/generic/287
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 287
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers regular unshared and regular shared blocks.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - dio CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/287.out b/tests/generic/287.out
new file mode 100644
index 0000000..fd1dcc0
--- /dev/null
+++ b/tests/generic/287.out
@@ -0,0 +1,13 @@
+QA output created by 287
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-287/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-287/file3
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-287/file1.chk
+CoW across the transition
+Compare files
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-287/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-287/file3
+2dc2b131303b2f70ddb480778caac8b7  SCRATCH_MNT/test-287/file1.chk
+Check for damage
diff --git a/tests/generic/289 b/tests/generic/289
new file mode 100755
index 0000000..253782d
--- /dev/null
+++ b/tests/generic/289
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 289
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers unwritten and regular shared blocks.
+#   - Create two files.
+#   - fallocate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/289.out b/tests/generic/289.out
new file mode 100644
index 0000000..424ac10
--- /dev/null
+++ b/tests/generic/289.out
@@ -0,0 +1,13 @@
+QA output created by 289
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-289/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-289/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-289/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-289/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-289/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-289/file1.chk
+Check for damage
diff --git a/tests/generic/290 b/tests/generic/290
new file mode 100755
index 0000000..76dae61
--- /dev/null
+++ b/tests/generic/290
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 290
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers unwritten and regular shared blocks.
+#   - Create two files.
+#   - fallocate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/290.out b/tests/generic/290.out
new file mode 100644
index 0000000..6af6c5b
--- /dev/null
+++ b/tests/generic/290.out
@@ -0,0 +1,13 @@
+QA output created by 290
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-290/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-290/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-290/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-290/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-290/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-290/file1.chk
+Check for damage
diff --git a/tests/generic/291 b/tests/generic/291
new file mode 100755
index 0000000..a7bdd8b
--- /dev/null
+++ b/tests/generic/291
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 291
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers holes and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/291.out b/tests/generic/291.out
new file mode 100644
index 0000000..93b813d
--- /dev/null
+++ b/tests/generic/291.out
@@ -0,0 +1,13 @@
+QA output created by 291
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-291/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-291/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-291/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-291/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-291/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-291/file1.chk
+Check for damage
diff --git a/tests/generic/292 b/tests/generic/292
new file mode 100755
index 0000000..23e1b92
--- /dev/null
+++ b/tests/generic/292
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 292
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers holes and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/292.out b/tests/generic/292.out
new file mode 100644
index 0000000..2337a46
--- /dev/null
+++ b/tests/generic/292.out
@@ -0,0 +1,13 @@
+QA output created by 292
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-292/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-292/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-292/file1.chk
+CoW across the transition
+Compare files
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-292/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-292/file3
+e8cf59797f0b3758c8878c368bb4cf7e  SCRATCH_MNT/test-292/file1.chk
+Check for damage
diff --git a/tests/generic/293 b/tests/generic/293
new file mode 100755
index 0000000..1d2d418
--- /dev/null
+++ b/tests/generic/293
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 293
+#
+# Ensuring that copy on write in buffered mode to the source file when the
+# CoW range covers delalloc blocks and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Write the even blocks of the first file.
+#   - CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 0 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/293.out b/tests/generic/293.out
new file mode 100644
index 0000000..1f1aeb3
--- /dev/null
+++ b/tests/generic/293.out
@@ -0,0 +1,13 @@
+QA output created by 293
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-293/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-293/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-293/file1.chk
+CoW across the transition
+Compare files
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-293/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-293/file3
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-293/file1.chk
+Check for damage
diff --git a/tests/generic/295 b/tests/generic/295
new file mode 100755
index 0000000..e8b74f2
--- /dev/null
+++ b/tests/generic/295
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 295
+#
+# Ensuring that copy on write in directio mode to the source file when the
+# CoW range covers delalloc blocks and regular shared blocks.
+#   - Create two files.
+#   - Truncate the first file.
+#   - Write the odd blocks of the first file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Write the even blocks of the first file.
+#   - DIO CoW the first file across the halfway mark, starting with the
+#     regular extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+"$XFS_IO_PROG" -f -c "truncate $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file1.chk" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+sync
+seq 1 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 0 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x64 $((blksz * f)) $blksz "$testdir/file1.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file1.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file1.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/295.out b/tests/generic/295.out
new file mode 100644
index 0000000..a1c9b1f
--- /dev/null
+++ b/tests/generic/295.out
@@ -0,0 +1,13 @@
+QA output created by 295
+Format and mount
+Create the original files
+Compare files
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-295/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-295/file3
+b8a8a88d4c143f79900c4b4e79aa3e37  SCRATCH_MNT/test-295/file1.chk
+CoW across the transition
+Compare files
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-295/file1
+ce2023f765eba19677517c511886d5c9  SCRATCH_MNT/test-295/file3
+35e2170e14665b780c6dec328d6a263b  SCRATCH_MNT/test-295/file1.chk
+Check for damage
diff --git a/tests/generic/296 b/tests/generic/296
new file mode 100755
index 0000000..f8edc1b
--- /dev/null
+++ b/tests/generic/296
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 296
+#
+# - Create two reflinked files a byte longer than a block.
+# - Rewrite the whole file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/296.out b/tests/generic/296.out
new file mode 100644
index 0000000..1b44cb4
--- /dev/null
+++ b/tests/generic/296.out
@@ -0,0 +1,13 @@
+QA output created by 296
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file2
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file2.chk
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-296/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-296/file2
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-296/file2.chk
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index c2624eb..98242e8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -286,10 +286,19 @@
 281 auto quick clone
 282 auto quick clone
 283 auto quick clone
+284 auto quick clone
 285 auto rw
 286 auto quick other
+287 auto quick clone
 288 auto quick ioctl trim
+289 auto quick clone
+290 auto quick clone
+291 auto quick clone
+292 auto quick clone
+293 auto quick clone
 294 auto quick
+295 auto quick clone
+296 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
 306 auto quick rw

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

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

* [PATCH 10/23] xfs: more reflink tests
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Create a couple of XFS-specific tests -- one to check that growing
and shrinking the refcount btree works and a second one to check
what happens when we hit maximum refcount.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/169     |   90 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/169.out |    8 ++++
 tests/xfs/179     |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/179.out |   10 ++++
 tests/xfs/group   |    4 +-
 5 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100755 tests/xfs/169
 create mode 100644 tests/xfs/169.out
 create mode 100755 tests/xfs/179
 create mode 100644 tests/xfs/179.out


diff --git a/tests/xfs/169 b/tests/xfs/169
new file mode 100755
index 0000000..e0fcc44
--- /dev/null
+++ b/tests/xfs/169
@@ -0,0 +1,90 @@
+#! /bin/bash
+# FS QA Test No. 169
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree.  Delete and recreate a few times to
+# exercise the refcount btree grow/shrink functions.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f "$seqres.full"
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original file blocks"
+blksz="$(stat -f "$testdir" -c '%S')"
+nr_blks=$((8 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+
+	echo "$i: Reflink every other block"
+	seq 1 2 $((nr_blks - 1)) | while read nr; do
+		_reflink_range  "$testdir/file1" $((nr * blksz)) \
+				"$testdir/file2" $((nr * blksz)) $blksz >> "$seqres.full"
+	done
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+
+	test "$i" = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf "$testdir/file1" "$testdir/file2"
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/169.out b/tests/xfs/169.out
new file mode 100644
index 0000000..263f696
--- /dev/null
+++ b/tests/xfs/169.out
@@ -0,0 +1,8 @@
+QA output created by 169
+Create the original file blocks
+1: Reflink every other block
+1: Delete both files
+2: Reflink every other block
+2: Delete both files
+x: Reflink every other block
+Check for damage
diff --git a/tests/xfs/179 b/tests/xfs/179
new file mode 100755
index 0000000..4cdf862
--- /dev/null
+++ b/tests/xfs/179
@@ -0,0 +1,119 @@
+#! /bin/bash
+# FS QA Test No. 179
+#
+# See how well reflink handles overflowing reflink counts.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+
+test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs -d agcount=1 > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+blksz=65536
+
+echo "Create original files"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+echo "Change reference count"
+umount "$SCRATCH_MNT"
+echo "set refcount to -4" >> "$seqres.full"
+"$XFS_DB_PROG" -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' "$SCRATCH_DEV" >> "$seqres.full"
+echo "check refcount after setting to -4" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "Reflink the overlinked file"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file4" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file5" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file6" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file7" >> "$seqres.full"
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after reflinking 5 more times" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "CoW a couple files"
+_pwrite_byte 0x62 0 $blksz "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $blksz "$testdir/file5" >> "$seqres.full"
+_pwrite_byte 0x62 0 $blksz "$testdir/file7" >> "$seqres.full"
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after cowing 3 files" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "Remove reflinked files"
+rm -rf "$testdir"/file*
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after removing all files" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
+res=$?
+if [ $res -eq 0 ]; then
+	# If repair succeeds then format the device so that the post-test
+	# check doesn't fail due to the single AG.
+	_scratch_mkfs >> "$seqres.full" 2>&1
+else
+	_fail "xfs_repair fails"
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/179.out b/tests/xfs/179.out
new file mode 100644
index 0000000..4d3e605
--- /dev/null
+++ b/tests/xfs/179.out
@@ -0,0 +1,10 @@
+QA output created by 179
+Format and mount
+Create original files
+Change reference count
+Reflink the overlinked file
+Check scratch fs
+CoW a couple files
+Check scratch fs
+Remove reflinked files
+Check scratch fs
diff --git a/tests/xfs/group b/tests/xfs/group
index 2db3520..f0c1c2b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -127,7 +127,7 @@
 127 auto quick clone
 128 auto quick clone
 129 auto quick clone
-130 fuzzers
+130 fuzzers clone
 131 auto quick clone
 132 auto quick clone
 133 auto quick quota
@@ -166,6 +166,7 @@
 166 rw metadata auto quick
 167 rw metadata auto stress
 168 dmapi
+169 auto quick clone
 170 rw filestreams auto quick
 171 rw filestreams
 172 rw filestreams
@@ -175,6 +176,7 @@
 176 dmapi
 177 dmapi
 178 mkfs other auto
+179 auto quick clone
 181 log auto quick
 183 rw other auto quick
 185 dmapi


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

* [PATCH 10/23] xfs: more reflink tests
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Create a couple of XFS-specific tests -- one to check that growing
and shrinking the refcount btree works and a second one to check
what happens when we hit maximum refcount.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/169     |   90 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/169.out |    8 ++++
 tests/xfs/179     |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/179.out |   10 ++++
 tests/xfs/group   |    4 +-
 5 files changed, 230 insertions(+), 1 deletion(-)
 create mode 100755 tests/xfs/169
 create mode 100644 tests/xfs/169.out
 create mode 100755 tests/xfs/179
 create mode 100644 tests/xfs/179.out


diff --git a/tests/xfs/169 b/tests/xfs/169
new file mode 100755
index 0000000..e0fcc44
--- /dev/null
+++ b/tests/xfs/169
@@ -0,0 +1,90 @@
+#! /bin/bash
+# FS QA Test No. 169
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree.  Delete and recreate a few times to
+# exercise the refcount btree grow/shrink functions.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f "$seqres.full"
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original file blocks"
+blksz="$(stat -f "$testdir" -c '%S')"
+nr_blks=$((8 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+
+	echo "$i: Reflink every other block"
+	seq 1 2 $((nr_blks - 1)) | while read nr; do
+		_reflink_range  "$testdir/file1" $((nr * blksz)) \
+				"$testdir/file2" $((nr * blksz)) $blksz >> "$seqres.full"
+	done
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+
+	test "$i" = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf "$testdir/file1" "$testdir/file2"
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/169.out b/tests/xfs/169.out
new file mode 100644
index 0000000..263f696
--- /dev/null
+++ b/tests/xfs/169.out
@@ -0,0 +1,8 @@
+QA output created by 169
+Create the original file blocks
+1: Reflink every other block
+1: Delete both files
+2: Reflink every other block
+2: Delete both files
+x: Reflink every other block
+Check for damage
diff --git a/tests/xfs/179 b/tests/xfs/179
new file mode 100755
index 0000000..4cdf862
--- /dev/null
+++ b/tests/xfs/179
@@ -0,0 +1,119 @@
+#! /bin/bash
+# FS QA Test No. 179
+#
+# See how well reflink handles overflowing reflink counts.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+
+test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs -d agcount=1 > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+blksz=65536
+
+echo "Create original files"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+echo "Change reference count"
+umount "$SCRATCH_MNT"
+echo "set refcount to -4" >> "$seqres.full"
+"$XFS_DB_PROG" -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' "$SCRATCH_DEV" >> "$seqres.full"
+echo "check refcount after setting to -4" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "Reflink the overlinked file"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file4" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file5" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file6" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file7" >> "$seqres.full"
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after reflinking 5 more times" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "CoW a couple files"
+_pwrite_byte 0x62 0 $blksz "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $blksz "$testdir/file5" >> "$seqres.full"
+_pwrite_byte 0x62 0 $blksz "$testdir/file7" >> "$seqres.full"
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after cowing 3 files" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+_scratch_mount >> "$seqres.full"
+
+echo "Remove reflinked files"
+rm -rf "$testdir"/file*
+
+echo "Check scratch fs"
+umount "$SCRATCH_MNT"
+echo "check refcount after removing all files" >> "$seqres.full"
+"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
+"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
+res=$?
+if [ $res -eq 0 ]; then
+	# If repair succeeds then format the device so that the post-test
+	# check doesn't fail due to the single AG.
+	_scratch_mkfs >> "$seqres.full" 2>&1
+else
+	_fail "xfs_repair fails"
+fi
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/179.out b/tests/xfs/179.out
new file mode 100644
index 0000000..4d3e605
--- /dev/null
+++ b/tests/xfs/179.out
@@ -0,0 +1,10 @@
+QA output created by 179
+Format and mount
+Create original files
+Change reference count
+Reflink the overlinked file
+Check scratch fs
+CoW a couple files
+Check scratch fs
+Remove reflinked files
+Check scratch fs
diff --git a/tests/xfs/group b/tests/xfs/group
index 2db3520..f0c1c2b 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -127,7 +127,7 @@
 127 auto quick clone
 128 auto quick clone
 129 auto quick clone
-130 fuzzers
+130 fuzzers clone
 131 auto quick clone
 132 auto quick clone
 133 auto quick quota
@@ -166,6 +166,7 @@
 166 rw metadata auto quick
 167 rw metadata auto stress
 168 dmapi
+169 auto quick clone
 170 rw filestreams auto quick
 171 rw filestreams
 172 rw filestreams
@@ -175,6 +176,7 @@
 176 dmapi
 177 dmapi
 178 mkfs other auto
+179 auto quick clone
 181 log auto quick
 183 rw other auto quick
 185 dmapi

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

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

* [PATCH 11/23] reflink: ensure that we can handle reflinking a lot of extents
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:12   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Update the existing stress tests to ensure that we can handle
reflinking the same block a million times, and that we can handle
reflinking million different extents.  Add a couple of tests to ensure
that we can ^C and SIGKILL our way out of long-running reflinks.

v2: Don't run the signal tests on NFS, as we cannot interrupt NFS
clone operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: don't run on NFS]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 .gitignore              |    1 
 src/Makefile            |    2 -
 src/punch-alternating.c |   59 +++++++++++++++++++++++++++
 tests/generic/175       |   42 +++++++-------------
 tests/generic/175.out   |    6 +++
 tests/generic/176       |   50 +++++++++++++++--------
 tests/generic/176.out   |    4 +-
 tests/generic/297       |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/297.out   |    6 +++
 tests/generic/298       |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/298.out   |    6 +++
 tests/generic/group     |    6 ++-
 12 files changed, 334 insertions(+), 50 deletions(-)
 create mode 100644 src/punch-alternating.c
 create mode 100755 tests/generic/297
 create mode 100644 tests/generic/297.out
 create mode 100755 tests/generic/298
 create mode 100644 tests/generic/298.out


diff --git a/.gitignore b/.gitignore
index bbe7c1a..c98c7bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,6 +115,7 @@
 /src/aio-dio-regress/aiocp
 /src/aio-dio-regress/aiodio_sparse2
 /src/aio-dio-regress/aio-dio-eof-race
+/src/punch-alternating
 /src/cloner
 /src/renameat2
 /src/t_rename_overwrite
diff --git a/src/Makefile b/src/Makefile
index 48e6765..3110208 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -19,7 +19,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
-	renameat2 t_getcwd e4compact test-nextquota
+	renameat2 t_getcwd e4compact test-nextquota punch-alternating
 
 SUBDIRS =
 
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
new file mode 100644
index 0000000..9566310
--- /dev/null
+++ b/src/punch-alternating.c
@@ -0,0 +1,59 @@
+/*
+ * Punch out every other block in a file.
+ * Copyright (C) 2016 Oracle.
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include "global.h"
+
+int main(int argc, char *argv[])
+{
+	struct stat	s;
+	off_t		offset;
+	int		fd;
+	blksize_t	blksz;
+	off_t		sz;
+	int		mode;
+	int		error;
+
+	if (argc != 2) {
+		printf("Usage: %s file\n", argv[0]);
+		printf("Punches every other block in the file.\n");
+		return 1;
+	}
+
+	fd = open(argv[1], O_WRONLY);
+	if (fd < 0)
+		goto err;
+
+	error = fstat(fd, &s);
+	if (error)
+		goto err;
+
+	sz = s.st_size;
+	blksz = s.st_blksize;
+
+	mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
+	for (offset = 0; offset < sz; offset += blksz * 2) {
+		error = fallocate(fd, mode, offset, blksz);
+		if (error)
+			goto err;
+	}
+
+	error = fsync(fd);
+	if (error)
+		goto err;
+
+	error = close(fd);
+	if (error)
+		goto err;
+	return 0;
+err:
+	perror(argv[1]);
+	return 2;
+}
diff --git a/tests/generic/175 b/tests/generic/175
index ac2f54f..0a6d5b8 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -1,12 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 175
 #
-# Try to hit the maximum reference count (eek!)
-#
-# This test runs extremely slowly, so it's not automatically run anywhere.
+# See how well reflink handles reflinking the same block a million times.
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
+# Copyright (c) 2016, 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
@@ -34,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
     cd /
-    rm -rf "$tmp".* "$testdir1"
+    rm -rf "$tmp".*
 }
 
 # get standard environment, filters and checks
@@ -58,40 +56,28 @@ 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')"
 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
-_pwrite_byte 0x62 0 $blksz "$testdir/file2" >> "$seqres.full"
-_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
 
-nr=32
-fnr=32
+fnr=19
+echo "Create extents"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do
-	echo " ++ Reflink size $i, $(( (2 ** i) * blksz)) bytes" | tee -a "$seqres.full"
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
 	n=$(( (2 ** i) * blksz))
-	_reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full" || break
+	_reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full"
 done
+_scratch_remount
 
-nrf=$((nr - fnr))
-echo "Clone $((2 ** nrf)) files"
-seq 0 $((2 ** nrf)) | while read i; do
-	_cp-reflink "$testdir/file1" "$testdir/file1-$i"
-done
+echo "Reflink the big file"
+blks=$((2 ** (fnr + 1) ))
+bytes=$((blks * blksz))
+echo "reflinking $blks blocks, $bytes bytes" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
-
-echo "Remove big file and recheck"
-_scratch_mount >> "$seqres.full" 2>&1
-umount "$SCRATCH_MNT"
-_check_scratch_fs
-
-echo "Remove all files and recheck"
-_scratch_mount >> "$seqres.full" 2>&1
-umount "$SCRATCH_MNT"
 
 # success, all done
 status=0
diff --git a/tests/generic/175.out b/tests/generic/175.out
index e69de29..8fa5726 100644
--- a/tests/generic/175.out
+++ b/tests/generic/175.out
@@ -0,0 +1,6 @@
+QA output created by 175
+Format and mount
+Create a one block file
+Create extents
+Reflink the big file
+Check scratch fs
diff --git a/tests/generic/176 b/tests/generic/176
index e32f94f..b1ebb83 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -1,10 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 176
 #
-# Try to run out of space while cloning?
+# See how well reflink handles reflinking a file with a million extents.
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
+# Copyright (c) 2016, 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
@@ -32,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
     cd /
-    rm -rf "$tmp".* "$testdir1"
+    rm -rf "$tmp".*
 }
 
 # get standard environment, filters and checks
@@ -44,6 +44,9 @@ _cleanup()
 # real QA test starts here
 _supported_os Linux
 _require_scratch_reflink
+_require_cp_reflink
+
+test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
 
 rm -f "$seqres.full"
 
@@ -55,22 +58,35 @@ 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"
-_pwrite_byte 0x61 0 $((blksz * nr_free)) "$testdir/bigfile" >> "$seqres.full" 2>&1
+# Setup for one million blocks, but we'll accept stress testing down to
+# 2^17 blocks... that should be plenty for anyone.
+fnr=20
+free_blocks=$(stat -f -c '%a' "$testdir")
+blksz=$(stat -f -c '%S' "$testdir")
+space_avail=$((free_blocks * blksz))
+calc_space() {
+	blocks_needed=$(( 2 ** (fnr + 1) ))
+	space_needed=$((blocks_needed * blksz * 5 / 4))
+}
+calc_space
+while test $space_needed -gt $space_avail; do
+	fnr=$((fnr - 1))
+	calc_space
+done
+test $fnr -lt 17 && _notrun "Insufficient space for stress test; would only create $blocks_needed extents."
+
+echo "Create a many-block file"
+echo "creating $blocks_needed blocks..." >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x61 -b 4194304 0 $((2 ** (fnr + 1) * blksz))" "$testdir/file1" >> "$seqres.full"
+echo "punching..." >> "$seqres.full"
+"$here/src/punch-alternating" "$testdir/file1" >> "$seqres.full"
+echo "...done" >> "$seqres.full"
 _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="$(_reflink_range "$testdir/bigfile" $((lblk * blksz)) "$fname" $((lblk * blksz)) $blksz 2>&1)"
-	echo "$fname: $out" >> "$seqres.full"
-	echo "$out" | grep -q "No space left on device" && break
-done
+echo "Reflink the big file"
+bytes=$((blocks_needed * blksz))
+echo "reflinking $((blocks_needed / 2)) blocks, $((bytes / 2)) bytes" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
diff --git a/tests/generic/176.out b/tests/generic/176.out
index eec98eb..90819a0 100644
--- a/tests/generic/176.out
+++ b/tests/generic/176.out
@@ -1,5 +1,5 @@
 QA output created by 176
 Format and mount
-Create a big file
-Try to reflink
+Create a many-block file
+Reflink the big file
 Check scratch fs
diff --git a/tests/generic/297 b/tests/generic/297
new file mode 100755
index 0000000..067ade8
--- /dev/null
+++ b/tests/generic/297
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 297
+#
+# See how well reflink handles ^C in the middle of a slow reflink.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/before" "$TEST_DIR/after"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_command "$(which timeout)" "timeout"
+
+test "$FSTYP" == "nfs"  && _notrun "NFS can't interrupt clone operations"
+
+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 "Create a one block file"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+
+fnr=26		# 2^26 reflink extents should be enough to find a slow op?
+timeout=8	# guarantee a good long run...
+echo "Find a reflink size that takes a long time"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
+	n=$(( (2 ** i) * blksz))
+	touch "$TEST_DIR/before"
+	"$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+	touch "$TEST_DIR/after"
+	before=$(stat -c '%Y' "$TEST_DIR/before")
+	after=$(stat -c '%Y' "$TEST_DIR/after")
+	delta=$((after - before))
+	test $delta -gt $timeout && break
+done
+
+echo "Try to kill reflink after a shorter period of time"
+kill_after=2	# give us a shorter time to die
+n=$(stat -c '%s' "$testdir/file1")
+echo "performing kill test on $n bytes..." >> "$seqres.full"
+touch "$TEST_DIR/before"
+timeout -s INT "${kill_after}s" "$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+touch "$TEST_DIR/after"
+before=$(stat -c '%Y' "$TEST_DIR/before")
+after=$(stat -c '%Y' "$TEST_DIR/after")
+delta=$((after - before))
+echo "reflink of $n bytes took $delta seconds" >> "$seqres.full"
+test $delta -gt $timeout && _fail "reflink didn't stop in time, n=$n t=$delta"
+
+echo "Check scratch fs"
+sleep 2		# give it a few seconds to actually die...
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/297.out b/tests/generic/297.out
new file mode 100644
index 0000000..cfe5b96
--- /dev/null
+++ b/tests/generic/297.out
@@ -0,0 +1,6 @@
+QA output created by 297
+Format and mount
+Create a one block file
+Find a reflink size that takes a long time
+Try to kill reflink after a shorter period of time
+Check scratch fs
diff --git a/tests/generic/298 b/tests/generic/298
new file mode 100755
index 0000000..10bd040
--- /dev/null
+++ b/tests/generic/298
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 298
+#
+# See how well reflink handles SIGKILL in the middle of a slow reflink.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/before" "$TEST_DIR/after"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_command "$(which timeout)" "timeout"
+
+test "$FSTYP" == "nfs"  && _notrun "NFS can't interrupt clone operations"
+
+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 "Create a one block file"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+
+fnr=26		# 2^26 reflink extents should be enough to find a slow op?
+timeout=8	# guarantee a good long run...
+echo "Find a reflink size that takes a long time"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
+	n=$(( (2 ** i) * blksz))
+	touch "$TEST_DIR/before"
+	"$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+	touch "$TEST_DIR/after"
+	before=$(stat -c '%Y' "$TEST_DIR/before")
+	after=$(stat -c '%Y' "$TEST_DIR/after")
+	delta=$((after - before))
+	test $delta -gt $timeout && break
+done
+
+echo "Try to kill reflink after a shorter period of time"
+kill_after=2	# give us a shorter time to die
+n=$(stat -c '%s' "$testdir/file1")
+echo "performing kill test on $n bytes..." >> "$seqres.full"
+touch "$TEST_DIR/before"
+urk=$(timeout -s KILL "${kill_after}s" "$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1)
+touch "$TEST_DIR/after"
+before=$(stat -c '%Y' "$TEST_DIR/before")
+after=$(stat -c '%Y' "$TEST_DIR/after")
+delta=$((after - before))
+echo "reflink of $n bytes took $delta seconds" >> "$seqres.full"
+test $delta -gt $timeout && _fail "reflink didn't stop in time, n=$n t=$delta"
+
+echo "Check scratch fs"
+sleep 2		# give it a few seconds to actually die...
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/298.out b/tests/generic/298.out
new file mode 100644
index 0000000..c1cdc7d
--- /dev/null
+++ b/tests/generic/298.out
@@ -0,0 +1,6 @@
+QA output created by 298
+Format and mount
+Create a one block file
+Find a reflink size that takes a long time
+Try to kill reflink after a shorter period of time
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index 98242e8..3798f3b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -177,8 +177,8 @@
 172 auto quick clone
 173 auto quick clone
 174 auto quick clone
-175 clone_stress
-176 clone_stress
+175 auto quick clone
+176 auto quick clone
 177 auto quick prealloc metadata
 178 auto quick clone
 179 auto quick clone
@@ -299,6 +299,8 @@
 294 auto quick
 295 auto quick clone
 296 auto quick clone
+297 auto quick clone
+298 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
 306 auto quick rw


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

* [PATCH 11/23] reflink: ensure that we can handle reflinking a lot of extents
@ 2016-02-09  1:12   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:12 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Update the existing stress tests to ensure that we can handle
reflinking the same block a million times, and that we can handle
reflinking million different extents.  Add a couple of tests to ensure
that we can ^C and SIGKILL our way out of long-running reflinks.

v2: Don't run the signal tests on NFS, as we cannot interrupt NFS
clone operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: don't run on NFS]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 .gitignore              |    1 
 src/Makefile            |    2 -
 src/punch-alternating.c |   59 +++++++++++++++++++++++++++
 tests/generic/175       |   42 +++++++-------------
 tests/generic/175.out   |    6 +++
 tests/generic/176       |   50 +++++++++++++++--------
 tests/generic/176.out   |    4 +-
 tests/generic/297       |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/297.out   |    6 +++
 tests/generic/298       |  101 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/298.out   |    6 +++
 tests/generic/group     |    6 ++-
 12 files changed, 334 insertions(+), 50 deletions(-)
 create mode 100644 src/punch-alternating.c
 create mode 100755 tests/generic/297
 create mode 100644 tests/generic/297.out
 create mode 100755 tests/generic/298
 create mode 100644 tests/generic/298.out


diff --git a/.gitignore b/.gitignore
index bbe7c1a..c98c7bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,6 +115,7 @@
 /src/aio-dio-regress/aiocp
 /src/aio-dio-regress/aiodio_sparse2
 /src/aio-dio-regress/aio-dio-eof-race
+/src/punch-alternating
 /src/cloner
 /src/renameat2
 /src/t_rename_overwrite
diff --git a/src/Makefile b/src/Makefile
index 48e6765..3110208 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -19,7 +19,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
-	renameat2 t_getcwd e4compact test-nextquota
+	renameat2 t_getcwd e4compact test-nextquota punch-alternating
 
 SUBDIRS =
 
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
new file mode 100644
index 0000000..9566310
--- /dev/null
+++ b/src/punch-alternating.c
@@ -0,0 +1,59 @@
+/*
+ * Punch out every other block in a file.
+ * Copyright (C) 2016 Oracle.
+ */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include "global.h"
+
+int main(int argc, char *argv[])
+{
+	struct stat	s;
+	off_t		offset;
+	int		fd;
+	blksize_t	blksz;
+	off_t		sz;
+	int		mode;
+	int		error;
+
+	if (argc != 2) {
+		printf("Usage: %s file\n", argv[0]);
+		printf("Punches every other block in the file.\n");
+		return 1;
+	}
+
+	fd = open(argv[1], O_WRONLY);
+	if (fd < 0)
+		goto err;
+
+	error = fstat(fd, &s);
+	if (error)
+		goto err;
+
+	sz = s.st_size;
+	blksz = s.st_blksize;
+
+	mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
+	for (offset = 0; offset < sz; offset += blksz * 2) {
+		error = fallocate(fd, mode, offset, blksz);
+		if (error)
+			goto err;
+	}
+
+	error = fsync(fd);
+	if (error)
+		goto err;
+
+	error = close(fd);
+	if (error)
+		goto err;
+	return 0;
+err:
+	perror(argv[1]);
+	return 2;
+}
diff --git a/tests/generic/175 b/tests/generic/175
index ac2f54f..0a6d5b8 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -1,12 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 175
 #
-# Try to hit the maximum reference count (eek!)
-#
-# This test runs extremely slowly, so it's not automatically run anywhere.
+# See how well reflink handles reflinking the same block a million times.
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
+# Copyright (c) 2016, 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
@@ -34,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
     cd /
-    rm -rf "$tmp".* "$testdir1"
+    rm -rf "$tmp".*
 }
 
 # get standard environment, filters and checks
@@ -58,40 +56,28 @@ 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')"
 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
-_pwrite_byte 0x62 0 $blksz "$testdir/file2" >> "$seqres.full"
-_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
 
-nr=32
-fnr=32
+fnr=19
+echo "Create extents"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do
-	echo " ++ Reflink size $i, $(( (2 ** i) * blksz)) bytes" | tee -a "$seqres.full"
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
 	n=$(( (2 ** i) * blksz))
-	_reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full" || break
+	_reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full"
 done
+_scratch_remount
 
-nrf=$((nr - fnr))
-echo "Clone $((2 ** nrf)) files"
-seq 0 $((2 ** nrf)) | while read i; do
-	_cp-reflink "$testdir/file1" "$testdir/file1-$i"
-done
+echo "Reflink the big file"
+blks=$((2 ** (fnr + 1) ))
+bytes=$((blks * blksz))
+echo "reflinking $blks blocks, $bytes bytes" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
-_check_scratch_fs
-
-echo "Remove big file and recheck"
-_scratch_mount >> "$seqres.full" 2>&1
-umount "$SCRATCH_MNT"
-_check_scratch_fs
-
-echo "Remove all files and recheck"
-_scratch_mount >> "$seqres.full" 2>&1
-umount "$SCRATCH_MNT"
 
 # success, all done
 status=0
diff --git a/tests/generic/175.out b/tests/generic/175.out
index e69de29..8fa5726 100644
--- a/tests/generic/175.out
+++ b/tests/generic/175.out
@@ -0,0 +1,6 @@
+QA output created by 175
+Format and mount
+Create a one block file
+Create extents
+Reflink the big file
+Check scratch fs
diff --git a/tests/generic/176 b/tests/generic/176
index e32f94f..b1ebb83 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -1,10 +1,10 @@
 #! /bin/bash
 # FS QA Test No. 176
 #
-# Try to run out of space while cloning?
+# See how well reflink handles reflinking a file with a million extents.
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
+# Copyright (c) 2016, 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
@@ -32,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
     cd /
-    rm -rf "$tmp".* "$testdir1"
+    rm -rf "$tmp".*
 }
 
 # get standard environment, filters and checks
@@ -44,6 +44,9 @@ _cleanup()
 # real QA test starts here
 _supported_os Linux
 _require_scratch_reflink
+_require_cp_reflink
+
+test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
 
 rm -f "$seqres.full"
 
@@ -55,22 +58,35 @@ 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"
-_pwrite_byte 0x61 0 $((blksz * nr_free)) "$testdir/bigfile" >> "$seqres.full" 2>&1
+# Setup for one million blocks, but we'll accept stress testing down to
+# 2^17 blocks... that should be plenty for anyone.
+fnr=20
+free_blocks=$(stat -f -c '%a' "$testdir")
+blksz=$(stat -f -c '%S' "$testdir")
+space_avail=$((free_blocks * blksz))
+calc_space() {
+	blocks_needed=$(( 2 ** (fnr + 1) ))
+	space_needed=$((blocks_needed * blksz * 5 / 4))
+}
+calc_space
+while test $space_needed -gt $space_avail; do
+	fnr=$((fnr - 1))
+	calc_space
+done
+test $fnr -lt 17 && _notrun "Insufficient space for stress test; would only create $blocks_needed extents."
+
+echo "Create a many-block file"
+echo "creating $blocks_needed blocks..." >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x61 -b 4194304 0 $((2 ** (fnr + 1) * blksz))" "$testdir/file1" >> "$seqres.full"
+echo "punching..." >> "$seqres.full"
+"$here/src/punch-alternating" "$testdir/file1" >> "$seqres.full"
+echo "...done" >> "$seqres.full"
 _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="$(_reflink_range "$testdir/bigfile" $((lblk * blksz)) "$fname" $((lblk * blksz)) $blksz 2>&1)"
-	echo "$fname: $out" >> "$seqres.full"
-	echo "$out" | grep -q "No space left on device" && break
-done
+echo "Reflink the big file"
+bytes=$((blocks_needed * blksz))
+echo "reflinking $((blocks_needed / 2)) blocks, $((bytes / 2)) bytes" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
 
 echo "Check scratch fs"
 umount "$SCRATCH_MNT"
diff --git a/tests/generic/176.out b/tests/generic/176.out
index eec98eb..90819a0 100644
--- a/tests/generic/176.out
+++ b/tests/generic/176.out
@@ -1,5 +1,5 @@
 QA output created by 176
 Format and mount
-Create a big file
-Try to reflink
+Create a many-block file
+Reflink the big file
 Check scratch fs
diff --git a/tests/generic/297 b/tests/generic/297
new file mode 100755
index 0000000..067ade8
--- /dev/null
+++ b/tests/generic/297
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 297
+#
+# See how well reflink handles ^C in the middle of a slow reflink.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/before" "$TEST_DIR/after"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_command "$(which timeout)" "timeout"
+
+test "$FSTYP" == "nfs"  && _notrun "NFS can't interrupt clone operations"
+
+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 "Create a one block file"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+
+fnr=26		# 2^26 reflink extents should be enough to find a slow op?
+timeout=8	# guarantee a good long run...
+echo "Find a reflink size that takes a long time"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
+	n=$(( (2 ** i) * blksz))
+	touch "$TEST_DIR/before"
+	"$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+	touch "$TEST_DIR/after"
+	before=$(stat -c '%Y' "$TEST_DIR/before")
+	after=$(stat -c '%Y' "$TEST_DIR/after")
+	delta=$((after - before))
+	test $delta -gt $timeout && break
+done
+
+echo "Try to kill reflink after a shorter period of time"
+kill_after=2	# give us a shorter time to die
+n=$(stat -c '%s' "$testdir/file1")
+echo "performing kill test on $n bytes..." >> "$seqres.full"
+touch "$TEST_DIR/before"
+timeout -s INT "${kill_after}s" "$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+touch "$TEST_DIR/after"
+before=$(stat -c '%Y' "$TEST_DIR/before")
+after=$(stat -c '%Y' "$TEST_DIR/after")
+delta=$((after - before))
+echo "reflink of $n bytes took $delta seconds" >> "$seqres.full"
+test $delta -gt $timeout && _fail "reflink didn't stop in time, n=$n t=$delta"
+
+echo "Check scratch fs"
+sleep 2		# give it a few seconds to actually die...
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/297.out b/tests/generic/297.out
new file mode 100644
index 0000000..cfe5b96
--- /dev/null
+++ b/tests/generic/297.out
@@ -0,0 +1,6 @@
+QA output created by 297
+Format and mount
+Create a one block file
+Find a reflink size that takes a long time
+Try to kill reflink after a shorter period of time
+Check scratch fs
diff --git a/tests/generic/298 b/tests/generic/298
new file mode 100755
index 0000000..10bd040
--- /dev/null
+++ b/tests/generic/298
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 298
+#
+# See how well reflink handles SIGKILL in the middle of a slow reflink.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/before" "$TEST_DIR/after"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_command "$(which timeout)" "timeout"
+
+test "$FSTYP" == "nfs"  && _notrun "NFS can't interrupt clone operations"
+
+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 "Create a one block file"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
+
+fnr=26		# 2^26 reflink extents should be enough to find a slow op?
+timeout=8	# guarantee a good long run...
+echo "Find a reflink size that takes a long time"
+truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+for i in $(seq 0 $fnr); do
+	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
+	n=$(( (2 ** i) * blksz))
+	touch "$TEST_DIR/before"
+	"$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1
+	touch "$TEST_DIR/after"
+	before=$(stat -c '%Y' "$TEST_DIR/before")
+	after=$(stat -c '%Y' "$TEST_DIR/after")
+	delta=$((after - before))
+	test $delta -gt $timeout && break
+done
+
+echo "Try to kill reflink after a shorter period of time"
+kill_after=2	# give us a shorter time to die
+n=$(stat -c '%s' "$testdir/file1")
+echo "performing kill test on $n bytes..." >> "$seqres.full"
+touch "$TEST_DIR/before"
+urk=$(timeout -s KILL "${kill_after}s" "$XFS_IO_PROG" -f -c "reflink $testdir/file1 0 $n $n" "$testdir/file1" >> "$seqres.full" 2>&1)
+touch "$TEST_DIR/after"
+before=$(stat -c '%Y' "$TEST_DIR/before")
+after=$(stat -c '%Y' "$TEST_DIR/after")
+delta=$((after - before))
+echo "reflink of $n bytes took $delta seconds" >> "$seqres.full"
+test $delta -gt $timeout && _fail "reflink didn't stop in time, n=$n t=$delta"
+
+echo "Check scratch fs"
+sleep 2		# give it a few seconds to actually die...
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/298.out b/tests/generic/298.out
new file mode 100644
index 0000000..c1cdc7d
--- /dev/null
+++ b/tests/generic/298.out
@@ -0,0 +1,6 @@
+QA output created by 298
+Format and mount
+Create a one block file
+Find a reflink size that takes a long time
+Try to kill reflink after a shorter period of time
+Check scratch fs
diff --git a/tests/generic/group b/tests/generic/group
index 98242e8..3798f3b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -177,8 +177,8 @@
 172 auto quick clone
 173 auto quick clone
 174 auto quick clone
-175 clone_stress
-176 clone_stress
+175 auto quick clone
+176 auto quick clone
 177 auto quick prealloc metadata
 178 auto quick clone
 179 auto quick clone
@@ -299,6 +299,8 @@
 294 auto quick
 295 auto quick clone
 296 auto quick clone
+297 auto quick clone
+298 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
 306 auto quick rw

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

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

* [PATCH 12/23] xfs/122: support refcount/rmap data structures
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Include the refcount and rmap structures in the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/122     |    3 +++
 tests/xfs/122.out |    4 ++++
 tests/xfs/group   |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)


diff --git a/tests/xfs/122 b/tests/xfs/122
index e6697a2..758cb50 100755
--- a/tests/xfs/122
+++ b/tests/xfs/122
@@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
 xfs_dir3_icfree_hdr
 xfs_dir3_icleaf_hdr
 xfs_name
+xfs_owner_info
+xfs_refcount_irec
+xfs_rmap_irec
 xfs_alloctype_t
 xfs_buf_cancel_t
 xfs_bmbt_rec_32_t
diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 8ba121e..c590166 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -75,6 +75,10 @@ sizeof(struct xfs_extent_data) = 24
 sizeof(struct xfs_extent_data_info) = 32
 sizeof(struct xfs_fs_eofblocks) = 128
 sizeof(struct xfs_icreate_log) = 28
+sizeof(struct xfs_refcount_key) = 4
+sizeof(struct xfs_refcount_rec) = 12
+sizeof(struct xfs_rmap_key) = 20
+sizeof(struct xfs_rmap_rec) = 24
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336
diff --git a/tests/xfs/group b/tests/xfs/group
index f0c1c2b..abf1d33 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -119,7 +119,7 @@
 119 log v2log auto freeze dangerous
 120 fuzzers
 121 log auto quick
-122 other auto quick
+122 other auto quick clone
 123 fuzzers
 124 fuzzers
 125 fuzzers


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

* [PATCH 12/23] xfs/122: support refcount/rmap data structures
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Include the refcount and rmap structures in the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/122     |    3 +++
 tests/xfs/122.out |    4 ++++
 tests/xfs/group   |    2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)


diff --git a/tests/xfs/122 b/tests/xfs/122
index e6697a2..758cb50 100755
--- a/tests/xfs/122
+++ b/tests/xfs/122
@@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
 xfs_dir3_icfree_hdr
 xfs_dir3_icleaf_hdr
 xfs_name
+xfs_owner_info
+xfs_refcount_irec
+xfs_rmap_irec
 xfs_alloctype_t
 xfs_buf_cancel_t
 xfs_bmbt_rec_32_t
diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 8ba121e..c590166 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -75,6 +75,10 @@ sizeof(struct xfs_extent_data) = 24
 sizeof(struct xfs_extent_data_info) = 32
 sizeof(struct xfs_fs_eofblocks) = 128
 sizeof(struct xfs_icreate_log) = 28
+sizeof(struct xfs_refcount_key) = 4
+sizeof(struct xfs_refcount_rec) = 12
+sizeof(struct xfs_rmap_key) = 20
+sizeof(struct xfs_rmap_rec) = 24
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336
diff --git a/tests/xfs/group b/tests/xfs/group
index f0c1c2b..abf1d33 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -119,7 +119,7 @@
 119 log v2log auto freeze dangerous
 120 fuzzers
 121 log auto quick
-122 other auto quick
+122 other auto quick clone
 123 fuzzers
 124 fuzzers
 125 fuzzers

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

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

* [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Perform copy-on-writes at random offsets to stress the CoW allocation
system.  Assess the effectiveness of the extent size hint at
combatting fragmentation via unshare, a rewrite, and no-op after the
random writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/301     |  105 +++++++++++++++++++++++++++++++++
 tests/generic/301.out |   11 ++++
 tests/generic/302     |  105 +++++++++++++++++++++++++++++++++
 tests/generic/302.out |   11 ++++
 tests/generic/group   |    2 +
 tests/xfs/180         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/180.out     |   12 ++++
 tests/xfs/182         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/182.out     |   13 ++++
 tests/xfs/184         |  110 +++++++++++++++++++++++++++++++++++
 tests/xfs/184.out     |   11 ++++
 tests/xfs/192         |  110 +++++++++++++++++++++++++++++++++++
 tests/xfs/192.out     |   11 ++++
 tests/xfs/193         |  107 ++++++++++++++++++++++++++++++++++
 tests/xfs/193.out     |   11 ++++
 tests/xfs/198         |  107 ++++++++++++++++++++++++++++++++++
 tests/xfs/198.out     |   11 ++++
 tests/xfs/200         |  114 ++++++++++++++++++++++++++++++++++++
 tests/xfs/200.out     |   11 ++++
 tests/xfs/204         |  114 ++++++++++++++++++++++++++++++++++++
 tests/xfs/204.out     |   11 ++++
 tests/xfs/207         |  104 +++++++++++++++++++++++++++++++++
 tests/xfs/207.out     |   10 +++
 tests/xfs/208         |  154 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/208.out     |   15 +++++
 tests/xfs/209         |   88 ++++++++++++++++++++++++++++
 tests/xfs/209.out     |    6 ++
 tests/xfs/210         |  125 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/210.out     |   14 ++++
 tests/xfs/211         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/211.out     |   12 ++++
 tests/xfs/group       |   13 ++++
 32 files changed, 1861 insertions(+)
 create mode 100755 tests/generic/301
 create mode 100644 tests/generic/301.out
 create mode 100755 tests/generic/302
 create mode 100644 tests/generic/302.out
 create mode 100755 tests/xfs/180
 create mode 100644 tests/xfs/180.out
 create mode 100755 tests/xfs/182
 create mode 100644 tests/xfs/182.out
 create mode 100755 tests/xfs/184
 create mode 100644 tests/xfs/184.out
 create mode 100755 tests/xfs/192
 create mode 100644 tests/xfs/192.out
 create mode 100755 tests/xfs/193
 create mode 100644 tests/xfs/193.out
 create mode 100755 tests/xfs/198
 create mode 100644 tests/xfs/198.out
 create mode 100755 tests/xfs/200
 create mode 100644 tests/xfs/200.out
 create mode 100755 tests/xfs/204
 create mode 100644 tests/xfs/204.out
 create mode 100755 tests/xfs/207
 create mode 100644 tests/xfs/207.out
 create mode 100755 tests/xfs/208
 create mode 100644 tests/xfs/208.out
 create mode 100755 tests/xfs/209
 create mode 100644 tests/xfs/209.out
 create mode 100755 tests/xfs/210
 create mode 100644 tests/xfs/210.out
 create mode 100755 tests/xfs/211
 create mode 100644 tests/xfs/211.out


diff --git a/tests/generic/301 b/tests/generic/301
new file mode 100755
index 0000000..c4f70e1
--- /dev/null
+++ b/tests/generic/301
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 301
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+for i in `seq 1 8`; do
+	"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/301.out b/tests/generic/301.out
new file mode 100644
index 0000000..668b053
--- /dev/null
+++ b/tests/generic/301.out
@@ -0,0 +1,11 @@
+QA output created by 301
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file1
+Check extent counts
+Check for damage
diff --git a/tests/generic/302 b/tests/generic/302
new file mode 100755
index 0000000..e0aea69
--- /dev/null
+++ b/tests/generic/302
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 302
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+for i in `seq 1 8`; do
+	"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -le $internal_blks || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/302.out b/tests/generic/302.out
new file mode 100644
index 0000000..002e54d
--- /dev/null
+++ b/tests/generic/302.out
@@ -0,0 +1,11 @@
+QA output created by 302
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file1
+Check extent counts
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 3798f3b..7e1ea72 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -303,6 +303,8 @@
 298 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
+301 auto quick clone
+302 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick
diff --git a/tests/xfs/180 b/tests/xfs/180
new file mode 100755
index 0000000..0bbece0
--- /dev/null
+++ b/tests/xfs/180
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 180
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/180.out b/tests/xfs/180.out
new file mode 100644
index 0000000..b538430
--- /dev/null
+++ b/tests/xfs/180.out
@@ -0,0 +1,12 @@
+QA output created by 180
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-180/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/182 b/tests/xfs/182
new file mode 100755
index 0000000..8a32671
--- /dev/null
+++ b/tests/xfs/182
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 182
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/182.out b/tests/xfs/182.out
new file mode 100644
index 0000000..49a18e6
--- /dev/null
+++ b/tests/xfs/182.out
@@ -0,0 +1,13 @@
+QA output created by 182
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file2
+CoW and unmount
+pwrite64: Invalid argument
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file1
+c6ba35da9f73ced20d7781a448cc11d4  SCRATCH_MNT/test-182/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/184 b/tests/xfs/184
new file mode 100755
index 0000000..27bd00f
--- /dev/null
+++ b/tests/xfs/184
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 184
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - falloc the whole file to unshare blocks.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/184.out b/tests/xfs/184.out
new file mode 100644
index 0000000..8a329c2
--- /dev/null
+++ b/tests/xfs/184.out
@@ -0,0 +1,11 @@
+QA output created by 184
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/192 b/tests/xfs/192
new file mode 100755
index 0000000..7cdd707
--- /dev/null
+++ b/tests/xfs/192
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 192
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - falloc the whole file to unshare blocks.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/192.out b/tests/xfs/192.out
new file mode 100644
index 0000000..b65e107
--- /dev/null
+++ b/tests/xfs/192.out
@@ -0,0 +1,11 @@
+QA output created by 192
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/193 b/tests/xfs/193
new file mode 100755
index 0000000..d42c3da
--- /dev/null
+++ b/tests/xfs/193
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 193
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/193.out b/tests/xfs/193.out
new file mode 100644
index 0000000..9ba6ea5
--- /dev/null
+++ b/tests/xfs/193.out
@@ -0,0 +1,11 @@
+QA output created by 193
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/198 b/tests/xfs/198
new file mode 100755
index 0000000..aade7b8
--- /dev/null
+++ b/tests/xfs/198
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 198
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/198.out b/tests/xfs/198.out
new file mode 100644
index 0000000..9e05a17
--- /dev/null
+++ b/tests/xfs/198.out
@@ -0,0 +1,11 @@
+QA output created by 198
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/200 b/tests/xfs/200
new file mode 100755
index 0000000..1d0e415
--- /dev/null
+++ b/tests/xfs/200
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 200
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Read the whole file into memory.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - fadvise(dontneed) the whole file to evict the pages.
+# - falloc the whole fle to see if the extsz hints still apply.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+cat "$testdir/file2" > /dev/null
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "fadvise -d 0 $((blksz * nr))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/200.out b/tests/xfs/200.out
new file mode 100644
index 0000000..57a2726
--- /dev/null
+++ b/tests/xfs/200.out
@@ -0,0 +1,11 @@
+QA output created by 200
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/204 b/tests/xfs/204
new file mode 100755
index 0000000..507cfc3
--- /dev/null
+++ b/tests/xfs/204
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 204
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Read the whole file into memory.
+# - DIO write to random offsets to scatter CoW reservations.
+# - fadvise(dontneed) the whole file to evict the pages.
+# - falloc the whole fle to see if the extsz hints still apply.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+cat "$testdir/file2" > /dev/null
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "fadvise -d 0 $((blksz * nr))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/204.out b/tests/xfs/204.out
new file mode 100644
index 0000000..0b46503
--- /dev/null
+++ b/tests/xfs/204.out
@@ -0,0 +1,11 @@
+QA output created by 204
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/207 b/tests/xfs/207
new file mode 100755
index 0000000..d8d7e90
--- /dev/null
+++ b/tests/xfs/207
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 207
+#
+# Test setting the extsz and cowextsz hints:
+# - Ensure that we can set both on a zero-byte file.
+# - Ensure that we can set only cowextsz on a many-byte file.
+# - Ensure that whatever we set we get back later.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Set extsz and cowextsz on zero byte file"
+"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
+
+echo "Set extsz and cowextsz on 1Mbyte file"
+"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
+_scratch_remount
+
+fn() {
+	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
+}
+echo "Check extsz and cowextsz settings on zero byte file"
+test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
+test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 
+
+echo "Check extsz and cowextsz settings on 1Mbyte file"
+test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
+test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
+
+echo "Set cowextsize and check flag"
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
+_scratch_remount
+test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
+test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
+"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
+_scratch_remount
+test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
+test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/207.out b/tests/xfs/207.out
new file mode 100644
index 0000000..6fc0105
--- /dev/null
+++ b/tests/xfs/207.out
@@ -0,0 +1,10 @@
+QA output created by 207
+Format and mount
+Create the original files
+Set extsz and cowextsz on zero byte file
+Set extsz and cowextsz on 1Mbyte file
+xfs_io: XFS_IOC_FSSETXATTR SCRATCH_MNT/test-207/file2: Invalid argument
+Check extsz and cowextsz settings on zero byte file
+Check extsz and cowextsz settings on 1Mbyte file
+Set cowextsize and check flag
+Check for damage
diff --git a/tests/xfs/208 b/tests/xfs/208
new file mode 100755
index 0000000..6b470f4
--- /dev/null
+++ b/tests/xfs/208
@@ -0,0 +1,154 @@
+#! /bin/bash
+# FS QA Test No. 208
+#
+# Ensure that the effective cow extent allocation size hint is the maximum of
+# the cowextsize and extsize inode fields.
+# - Create two reflinked files.  Set extsz hint on second file to $blocksize
+#   and cowextsize hint to 1MB.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+# - Repeat, but with extsz = 1MB and cowextsz = $blocksize.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "extsize $real_blksz" "$testdir/file2"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "extsize $((blksz * bsz))" "$testdir/file3"
+"$XFS_IO_PROG" -f -c "cowextsize $real_blksz" "$testdir/file3"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_scratch_remount
+
+echo "Check extsize and cowextsize"
+expected="[$real_blksz] $testdir/file2"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "extsize" "$testdir/file2")" || echo "file2 extsize setting failed"
+expected="[$((blksz * bsz))] $testdir/file2"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2")" || echo "file2 cowextsize setting failed"
+
+expected="[$real_blksz] $testdir/file3"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file3")" || echo "file3 extsize setting failed"
+expected="[$((blksz * bsz))] $testdir/file3"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "extsize" "$testdir/file3")" || echo "file3 cowextsize setting failed"
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+
+echo "CoW and unmount"
+echo "extsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file2" >> "$seqres.full"
+echo "cowextsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+
+echo "extsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file3" >> "$seqres.full"
+echo "cowextsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file3" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file3" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file3" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| echo "file2 badly fragmented"
+
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| echo "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/208.out b/tests/xfs/208.out
new file mode 100644
index 0000000..0a31249
--- /dev/null
+++ b/tests/xfs/208.out
@@ -0,0 +1,15 @@
+QA output created by 208
+Format and mount
+Create the original files
+Check extsize and cowextsize
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file2
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file3
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-208/file2
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-208/file3
+Check extent counts
+Check for damage
diff --git a/tests/xfs/209 b/tests/xfs/209
new file mode 100755
index 0000000..ef47e74
--- /dev/null
+++ b/tests/xfs/209
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 209
+#
+# Make sure setting cowextsz on a directory propagates it to subfiles.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Set extsz and cowextsz on directory"
+"$XFS_IO_PROG" -c "cowextsize 1048576" "$testdir" >> "$seqres.full"
+
+echo "Create a fake tree structure"
+seq 1 32 | while read nr; do
+	mkdir "$testdir/dir-$nr"
+	seq 1 8 | while read nnr; do
+		touch "$testdir/dir-$nr/file-$nnr"
+	done
+done
+_scratch_remount
+
+echo "Check cowextsize settings"
+seq 1 32 | while read nr; do
+	seq 1 8 | while read nnr; do
+		file="$testdir/dir-$nr/file-$nnr"
+		expected="[1048576] $file"
+		actual="$("$XFS_IO_PROG" -c "cowextsize" "$file")"
+		test "$expected" = "$actual" || echo "cowextsize didn't propagate to $file"
+	done
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/209.out b/tests/xfs/209.out
new file mode 100644
index 0000000..ffb0609
--- /dev/null
+++ b/tests/xfs/209.out
@@ -0,0 +1,6 @@
+QA output created by 209
+Format and mount
+Set extsz and cowextsz on directory
+Create a fake tree structure
+Check cowextsize settings
+Check for damage
diff --git a/tests/xfs/210 b/tests/xfs/210
new file mode 100755
index 0000000..95e73b2
--- /dev/null
+++ b/tests/xfs/210
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 210
+#
+# During reflink, XFS should carry the cowextsz setting to the destination file
+# if the destination file size is less than the size of the source file, the
+# length is the size of the source file, both offsets are zero, and the
+# destination does not already have a cowextsz setting.  It should not do so
+# otherwise.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Create initial file"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 131072" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -c "cowextsize 1048576" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1" "$testdir/file4" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file7" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file9" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file10" >> "$seqres.full"
+
+echo "Reflink to an empty file"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 0 >> "$seqres.full"
+
+echo "Reflink to an empty file that already has cowextsz"
+"$XFS_IO_PROG" -f -c "cowextsize 524288" "$testdir/file3" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file3" 0 0 >> "$seqres.full"
+
+echo "Reflink to a small file"
+_reflink_range "$testdir/file1" 0 "$testdir/file4" 0 0 >> "$seqres.full"
+
+echo "Reflink to a nonzero offset"
+_reflink_range "$testdir/file1" 0 "$testdir/file5" 65536 0 >> "$seqres.full"
+
+echo "Reflink from a nonzero offset"
+_reflink_range "$testdir/file1" 65536 "$testdir/file6" 0 0 >> "$seqres.full"
+
+echo "Reflink to a large file"
+_reflink_range "$testdir/file1" 0 "$testdir/file7" 0 0 >> "$seqres.full"
+
+echo "Reflink less than the whole source file"
+_reflink_range "$testdir/file1" 0 "$testdir/file8" 0 65536 >> "$seqres.full"
+
+echo "cp reflink to a large file"
+_cp_reflink "$testdir/file1" "$testdir/file9" >> "$seqres.full"
+
+echo "cp reflink to a large file with cowextsize"
+"$XFS_IO_PROG" -f -c "cowextsize 524288" "$testdir/file10" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file10" >> "$seqres.full"
+
+fn() {
+	"$XFS_IO_PROG" -c "cowextsize" "$1" | sed -e 's/.\([0-9]*\).*$/\1/g'
+}
+echo "Check cowextsz"
+test "$(fn "$testdir/file1")" -eq 1048576 || echo "file1 cowextsize wrong"
+test "$(fn "$testdir/file2")" -eq 1048576 || echo "file2 cowextsize wrong"
+test "$(fn "$testdir/file3")" -eq 524288 || echo "file3 cowextsize wrong"
+test "$(fn "$testdir/file4")" -eq 1048576 || echo "file4 cowextsize wrong"
+test "$(fn "$testdir/file5")" -eq 0 || echo "file5 cowextsize wrong"
+test "$(fn "$testdir/file6")" -eq 0 || echo "file6 cowextsize wrong"
+test "$(fn "$testdir/file7")" -eq 0 || echo "file7 cowextsize wrong"
+test "$(fn "$testdir/file8")" -eq 0 || echo "file8 cowextsize wrong"
+test "$(fn "$testdir/file9")" -eq 1048576 || echo "file9 cowextsize wrong"
+test "$(fn "$testdir/file10")" -eq 524288 || echo "file10 cowextsize wrong"
+for i in $(seq 1 10); do
+	echo "$testdir/file$i $(fn "$testdir/file$i")" >> "$seqres.full"
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/210.out b/tests/xfs/210.out
new file mode 100644
index 0000000..ca5086b
--- /dev/null
+++ b/tests/xfs/210.out
@@ -0,0 +1,14 @@
+QA output created by 210
+Format and mount
+Create initial file
+Reflink to an empty file
+Reflink to an empty file that already has cowextsz
+Reflink to a small file
+Reflink to a nonzero offset
+Reflink from a nonzero offset
+Reflink to a large file
+Reflink less than the whole source file
+cp reflink to a large file
+cp reflink to a large file with cowextsize
+Check cowextsz
+Check for damage
diff --git a/tests/xfs/211 b/tests/xfs/211
new file mode 100755
index 0000000..abc9a07
--- /dev/null
+++ b/tests/xfs/211
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 211
+#
+# Test fragmentation in a big file after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=50000
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 2) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b 8388608 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/211.out b/tests/xfs/211.out
new file mode 100644
index 0000000..3d912a8
--- /dev/null
+++ b/tests/xfs/211.out
@@ -0,0 +1,12 @@
+QA output created by 211
+Format and mount
+Create the original files
+Compare files
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file1
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file2
+CoW and unmount
+Compare files
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file1
+7d8ab127adfc1f745a7d1cd5e44d10d8  SCRATCH_MNT/test-211/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index abf1d33..119e1fd 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -177,8 +177,11 @@
 177 dmapi
 178 mkfs other auto
 179 auto quick clone
+180 auto quick clone
 181 log auto quick
+182 auto quick clone
 183 rw other auto quick
+184 auto quick clone
 185 dmapi
 186 attr auto quick
 187 attr auto quick
@@ -186,16 +189,26 @@
 189 mount auto quick
 190 rw auto quick
 191 nfs4acl auto
+192 auto quick clone
+193 auto quick clone
 194 rw auto
 195 ioctl dump auto quick
 196 quota auto quick
 197 dir auto quick
+198 auto quick clone
 199 mount auto quick
+200 auto quick clone
 201 metadata auto quick
 202 repair auto quick
 203 ioctl auto
+204 auto quick clone
 205 metadata rw auto
 206 growfs auto quick
+207 auto quick clone
+208 auto quick clone
+209 auto quick clone
+210 auto quick clone
+211 clone_stress
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick


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

* [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Perform copy-on-writes at random offsets to stress the CoW allocation
system.  Assess the effectiveness of the extent size hint at
combatting fragmentation via unshare, a rewrite, and no-op after the
random writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/301     |  105 +++++++++++++++++++++++++++++++++
 tests/generic/301.out |   11 ++++
 tests/generic/302     |  105 +++++++++++++++++++++++++++++++++
 tests/generic/302.out |   11 ++++
 tests/generic/group   |    2 +
 tests/xfs/180         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/180.out     |   12 ++++
 tests/xfs/182         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/182.out     |   13 ++++
 tests/xfs/184         |  110 +++++++++++++++++++++++++++++++++++
 tests/xfs/184.out     |   11 ++++
 tests/xfs/192         |  110 +++++++++++++++++++++++++++++++++++
 tests/xfs/192.out     |   11 ++++
 tests/xfs/193         |  107 ++++++++++++++++++++++++++++++++++
 tests/xfs/193.out     |   11 ++++
 tests/xfs/198         |  107 ++++++++++++++++++++++++++++++++++
 tests/xfs/198.out     |   11 ++++
 tests/xfs/200         |  114 ++++++++++++++++++++++++++++++++++++
 tests/xfs/200.out     |   11 ++++
 tests/xfs/204         |  114 ++++++++++++++++++++++++++++++++++++
 tests/xfs/204.out     |   11 ++++
 tests/xfs/207         |  104 +++++++++++++++++++++++++++++++++
 tests/xfs/207.out     |   10 +++
 tests/xfs/208         |  154 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/208.out     |   15 +++++
 tests/xfs/209         |   88 ++++++++++++++++++++++++++++
 tests/xfs/209.out     |    6 ++
 tests/xfs/210         |  125 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/210.out     |   14 ++++
 tests/xfs/211         |  111 +++++++++++++++++++++++++++++++++++
 tests/xfs/211.out     |   12 ++++
 tests/xfs/group       |   13 ++++
 32 files changed, 1861 insertions(+)
 create mode 100755 tests/generic/301
 create mode 100644 tests/generic/301.out
 create mode 100755 tests/generic/302
 create mode 100644 tests/generic/302.out
 create mode 100755 tests/xfs/180
 create mode 100644 tests/xfs/180.out
 create mode 100755 tests/xfs/182
 create mode 100644 tests/xfs/182.out
 create mode 100755 tests/xfs/184
 create mode 100644 tests/xfs/184.out
 create mode 100755 tests/xfs/192
 create mode 100644 tests/xfs/192.out
 create mode 100755 tests/xfs/193
 create mode 100644 tests/xfs/193.out
 create mode 100755 tests/xfs/198
 create mode 100644 tests/xfs/198.out
 create mode 100755 tests/xfs/200
 create mode 100644 tests/xfs/200.out
 create mode 100755 tests/xfs/204
 create mode 100644 tests/xfs/204.out
 create mode 100755 tests/xfs/207
 create mode 100644 tests/xfs/207.out
 create mode 100755 tests/xfs/208
 create mode 100644 tests/xfs/208.out
 create mode 100755 tests/xfs/209
 create mode 100644 tests/xfs/209.out
 create mode 100755 tests/xfs/210
 create mode 100644 tests/xfs/210.out
 create mode 100755 tests/xfs/211
 create mode 100644 tests/xfs/211.out


diff --git a/tests/generic/301 b/tests/generic/301
new file mode 100755
index 0000000..c4f70e1
--- /dev/null
+++ b/tests/generic/301
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 301
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+for i in `seq 1 8`; do
+	"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/301.out b/tests/generic/301.out
new file mode 100644
index 0000000..668b053
--- /dev/null
+++ b/tests/generic/301.out
@@ -0,0 +1,11 @@
+QA output created by 301
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-301/file1
+Check extent counts
+Check for damage
diff --git a/tests/generic/302 b/tests/generic/302
new file mode 100755
index 0000000..e0aea69
--- /dev/null
+++ b/tests/generic/302
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 302
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+for i in `seq 1 8`; do
+	"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -le $internal_blks || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/302.out b/tests/generic/302.out
new file mode 100644
index 0000000..002e54d
--- /dev/null
+++ b/tests/generic/302.out
@@ -0,0 +1,11 @@
+QA output created by 302
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-302/file1
+Check extent counts
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 3798f3b..7e1ea72 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -303,6 +303,8 @@
 298 auto quick clone
 299 auto aio enospc rw stress
 300 auto aio enospc preallocrw stress
+301 auto quick clone
+302 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick
diff --git a/tests/xfs/180 b/tests/xfs/180
new file mode 100755
index 0000000..0bbece0
--- /dev/null
+++ b/tests/xfs/180
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 180
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/180.out b/tests/xfs/180.out
new file mode 100644
index 0000000..b538430
--- /dev/null
+++ b/tests/xfs/180.out
@@ -0,0 +1,12 @@
+QA output created by 180
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-180/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-180/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/182 b/tests/xfs/182
new file mode 100755
index 0000000..8a32671
--- /dev/null
+++ b/tests/xfs/182
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 182
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/182.out b/tests/xfs/182.out
new file mode 100644
index 0000000..49a18e6
--- /dev/null
+++ b/tests/xfs/182.out
@@ -0,0 +1,13 @@
+QA output created by 182
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file2
+CoW and unmount
+pwrite64: Invalid argument
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-182/file1
+c6ba35da9f73ced20d7781a448cc11d4  SCRATCH_MNT/test-182/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/184 b/tests/xfs/184
new file mode 100755
index 0000000..27bd00f
--- /dev/null
+++ b/tests/xfs/184
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 184
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - falloc the whole file to unshare blocks.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/184.out b/tests/xfs/184.out
new file mode 100644
index 0000000..8a329c2
--- /dev/null
+++ b/tests/xfs/184.out
@@ -0,0 +1,11 @@
+QA output created by 184
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-184/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/192 b/tests/xfs/192
new file mode 100755
index 0000000..7cdd707
--- /dev/null
+++ b/tests/xfs/192
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 192
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - falloc the whole file to unshare blocks.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/192.out b/tests/xfs/192.out
new file mode 100644
index 0000000..b65e107
--- /dev/null
+++ b/tests/xfs/192.out
@@ -0,0 +1,11 @@
+QA output created by 192
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-192/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/193 b/tests/xfs/193
new file mode 100755
index 0000000..d42c3da
--- /dev/null
+++ b/tests/xfs/193
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 193
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/193.out b/tests/xfs/193.out
new file mode 100644
index 0000000..9ba6ea5
--- /dev/null
+++ b/tests/xfs/193.out
@@ -0,0 +1,11 @@
+QA output created by 193
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-193/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/198 b/tests/xfs/198
new file mode 100755
index 0000000..aade7b8
--- /dev/null
+++ b/tests/xfs/198
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 198
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks * 2 / 3)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/198.out b/tests/xfs/198.out
new file mode 100644
index 0000000..9e05a17
--- /dev/null
+++ b/tests/xfs/198.out
@@ -0,0 +1,11 @@
+QA output created by 198
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-198/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/200 b/tests/xfs/200
new file mode 100755
index 0000000..1d0e415
--- /dev/null
+++ b/tests/xfs/200
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 200
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Read the whole file into memory.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - fadvise(dontneed) the whole file to evict the pages.
+# - falloc the whole fle to see if the extsz hints still apply.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+cat "$testdir/file2" > /dev/null
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "fadvise -d 0 $((blksz * nr))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/200.out b/tests/xfs/200.out
new file mode 100644
index 0000000..57a2726
--- /dev/null
+++ b/tests/xfs/200.out
@@ -0,0 +1,11 @@
+QA output created by 200
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-200/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/204 b/tests/xfs/204
new file mode 100755
index 0000000..507cfc3
--- /dev/null
+++ b/tests/xfs/204
@@ -0,0 +1,114 @@
+#! /bin/bash
+# FS QA Test No. 204
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Read the whole file into memory.
+# - DIO write to random offsets to scatter CoW reservations.
+# - fadvise(dontneed) the whole file to evict the pages.
+# - falloc the whole fle to see if the extsz hints still apply.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+cat "$testdir/file2" > /dev/null
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "fadvise -d 0 $((blksz * nr))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/204.out b/tests/xfs/204.out
new file mode 100644
index 0000000..0b46503
--- /dev/null
+++ b/tests/xfs/204.out
@@ -0,0 +1,11 @@
+QA output created by 204
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-204/file1
+Check extent counts
+Check for damage
diff --git a/tests/xfs/207 b/tests/xfs/207
new file mode 100755
index 0000000..d8d7e90
--- /dev/null
+++ b/tests/xfs/207
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 207
+#
+# Test setting the extsz and cowextsz hints:
+# - Ensure that we can set both on a zero-byte file.
+# - Ensure that we can set only cowextsz on a many-byte file.
+# - Ensure that whatever we set we get back later.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Set extsz and cowextsz on zero byte file"
+"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
+
+echo "Set extsz and cowextsz on 1Mbyte file"
+"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
+_scratch_remount
+
+fn() {
+	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
+}
+echo "Check extsz and cowextsz settings on zero byte file"
+test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
+test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 
+
+echo "Check extsz and cowextsz settings on 1Mbyte file"
+test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
+test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
+
+echo "Set cowextsize and check flag"
+"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
+_scratch_remount
+test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
+test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
+"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
+_scratch_remount
+test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
+test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/207.out b/tests/xfs/207.out
new file mode 100644
index 0000000..6fc0105
--- /dev/null
+++ b/tests/xfs/207.out
@@ -0,0 +1,10 @@
+QA output created by 207
+Format and mount
+Create the original files
+Set extsz and cowextsz on zero byte file
+Set extsz and cowextsz on 1Mbyte file
+xfs_io: XFS_IOC_FSSETXATTR SCRATCH_MNT/test-207/file2: Invalid argument
+Check extsz and cowextsz settings on zero byte file
+Check extsz and cowextsz settings on 1Mbyte file
+Set cowextsize and check flag
+Check for damage
diff --git a/tests/xfs/208 b/tests/xfs/208
new file mode 100755
index 0000000..6b470f4
--- /dev/null
+++ b/tests/xfs/208
@@ -0,0 +1,154 @@
+#! /bin/bash
+# FS QA Test No. 208
+#
+# Ensure that the effective cow extent allocation size hint is the maximum of
+# the cowextsize and extsize inode fields.
+# - Create two reflinked files.  Set extsz hint on second file to $blocksize
+#   and cowextsize hint to 1MB.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+# - Repeat, but with extsz = 1MB and cowextsz = $blocksize.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=128
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "extsize $real_blksz" "$testdir/file2"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "extsize $((blksz * bsz))" "$testdir/file3"
+"$XFS_IO_PROG" -f -c "cowextsize $real_blksz" "$testdir/file3"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_scratch_remount
+
+echo "Check extsize and cowextsize"
+expected="[$real_blksz] $testdir/file2"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "extsize" "$testdir/file2")" || echo "file2 extsize setting failed"
+expected="[$((blksz * bsz))] $testdir/file2"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2")" || echo "file2 cowextsize setting failed"
+
+expected="[$real_blksz] $testdir/file3"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file3")" || echo "file3 extsize setting failed"
+expected="[$((blksz * bsz))] $testdir/file3"
+test "$expected" = "$("$XFS_IO_PROG" -f -c "extsize" "$testdir/file3")" || echo "file3 cowextsize setting failed"
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+
+echo "CoW and unmount"
+echo "extsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file2" >> "$seqres.full"
+echo "cowextsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file2" >> "$seqres.full"
+
+echo "extsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file3" >> "$seqres.full"
+echo "cowextsize" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file3" >> "$seqres.full"
+
+"$XFS_IO_PROG" -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr))" -c "fdatasync" "$testdir/file3" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" -c "fdatasync" "$testdir/file3" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| echo "file2 badly fragmented"
+
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| echo "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/208.out b/tests/xfs/208.out
new file mode 100644
index 0000000..0a31249
--- /dev/null
+++ b/tests/xfs/208.out
@@ -0,0 +1,15 @@
+QA output created by 208
+Format and mount
+Create the original files
+Check extsize and cowextsize
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file2
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file3
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-208/file1
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-208/file2
+d41f6527bc8320364e12ea7076140b8b  SCRATCH_MNT/test-208/file3
+Check extent counts
+Check for damage
diff --git a/tests/xfs/209 b/tests/xfs/209
new file mode 100755
index 0000000..ef47e74
--- /dev/null
+++ b/tests/xfs/209
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 209
+#
+# Make sure setting cowextsz on a directory propagates it to subfiles.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Set extsz and cowextsz on directory"
+"$XFS_IO_PROG" -c "cowextsize 1048576" "$testdir" >> "$seqres.full"
+
+echo "Create a fake tree structure"
+seq 1 32 | while read nr; do
+	mkdir "$testdir/dir-$nr"
+	seq 1 8 | while read nnr; do
+		touch "$testdir/dir-$nr/file-$nnr"
+	done
+done
+_scratch_remount
+
+echo "Check cowextsize settings"
+seq 1 32 | while read nr; do
+	seq 1 8 | while read nnr; do
+		file="$testdir/dir-$nr/file-$nnr"
+		expected="[1048576] $file"
+		actual="$("$XFS_IO_PROG" -c "cowextsize" "$file")"
+		test "$expected" = "$actual" || echo "cowextsize didn't propagate to $file"
+	done
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/209.out b/tests/xfs/209.out
new file mode 100644
index 0000000..ffb0609
--- /dev/null
+++ b/tests/xfs/209.out
@@ -0,0 +1,6 @@
+QA output created by 209
+Format and mount
+Set extsz and cowextsz on directory
+Create a fake tree structure
+Check cowextsize settings
+Check for damage
diff --git a/tests/xfs/210 b/tests/xfs/210
new file mode 100755
index 0000000..95e73b2
--- /dev/null
+++ b/tests/xfs/210
@@ -0,0 +1,125 @@
+#! /bin/bash
+# FS QA Test No. 210
+#
+# During reflink, XFS should carry the cowextsz setting to the destination file
+# if the destination file size is less than the size of the source file, the
+# length is the size of the source file, both offsets are zero, and the
+# destination does not already have a cowextsz setting.  It should not do so
+# otherwise.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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 "Create initial file"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 131072" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -c "cowextsize 1048576" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1" "$testdir/file4" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file7" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file9" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 262144" "$testdir/file10" >> "$seqres.full"
+
+echo "Reflink to an empty file"
+_reflink_range "$testdir/file1" 0 "$testdir/file2" 0 0 >> "$seqres.full"
+
+echo "Reflink to an empty file that already has cowextsz"
+"$XFS_IO_PROG" -f -c "cowextsize 524288" "$testdir/file3" >> "$seqres.full"
+_reflink_range "$testdir/file1" 0 "$testdir/file3" 0 0 >> "$seqres.full"
+
+echo "Reflink to a small file"
+_reflink_range "$testdir/file1" 0 "$testdir/file4" 0 0 >> "$seqres.full"
+
+echo "Reflink to a nonzero offset"
+_reflink_range "$testdir/file1" 0 "$testdir/file5" 65536 0 >> "$seqres.full"
+
+echo "Reflink from a nonzero offset"
+_reflink_range "$testdir/file1" 65536 "$testdir/file6" 0 0 >> "$seqres.full"
+
+echo "Reflink to a large file"
+_reflink_range "$testdir/file1" 0 "$testdir/file7" 0 0 >> "$seqres.full"
+
+echo "Reflink less than the whole source file"
+_reflink_range "$testdir/file1" 0 "$testdir/file8" 0 65536 >> "$seqres.full"
+
+echo "cp reflink to a large file"
+_cp_reflink "$testdir/file1" "$testdir/file9" >> "$seqres.full"
+
+echo "cp reflink to a large file with cowextsize"
+"$XFS_IO_PROG" -f -c "cowextsize 524288" "$testdir/file10" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file10" >> "$seqres.full"
+
+fn() {
+	"$XFS_IO_PROG" -c "cowextsize" "$1" | sed -e 's/.\([0-9]*\).*$/\1/g'
+}
+echo "Check cowextsz"
+test "$(fn "$testdir/file1")" -eq 1048576 || echo "file1 cowextsize wrong"
+test "$(fn "$testdir/file2")" -eq 1048576 || echo "file2 cowextsize wrong"
+test "$(fn "$testdir/file3")" -eq 524288 || echo "file3 cowextsize wrong"
+test "$(fn "$testdir/file4")" -eq 1048576 || echo "file4 cowextsize wrong"
+test "$(fn "$testdir/file5")" -eq 0 || echo "file5 cowextsize wrong"
+test "$(fn "$testdir/file6")" -eq 0 || echo "file6 cowextsize wrong"
+test "$(fn "$testdir/file7")" -eq 0 || echo "file7 cowextsize wrong"
+test "$(fn "$testdir/file8")" -eq 0 || echo "file8 cowextsize wrong"
+test "$(fn "$testdir/file9")" -eq 1048576 || echo "file9 cowextsize wrong"
+test "$(fn "$testdir/file10")" -eq 524288 || echo "file10 cowextsize wrong"
+for i in $(seq 1 10); do
+	echo "$testdir/file$i $(fn "$testdir/file$i")" >> "$seqres.full"
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/210.out b/tests/xfs/210.out
new file mode 100644
index 0000000..ca5086b
--- /dev/null
+++ b/tests/xfs/210.out
@@ -0,0 +1,14 @@
+QA output created by 210
+Format and mount
+Create initial file
+Reflink to an empty file
+Reflink to an empty file that already has cowextsz
+Reflink to a small file
+Reflink to a nonzero offset
+Reflink from a nonzero offset
+Reflink to a large file
+Reflink less than the whole source file
+cp reflink to a large file
+cp reflink to a large file with cowextsize
+Check cowextsz
+Check for damage
diff --git a/tests/xfs/211 b/tests/xfs/211
new file mode 100755
index 0000000..abc9a07
--- /dev/null
+++ b/tests/xfs/211
@@ -0,0 +1,111 @@
+#! /bin/bash
+# FS QA Test No. 211
+#
+# Test fragmentation in a big file after a lot of random CoW:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Rewrite the whole file to use up reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+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=65536
+nr=50000
+bsz=16
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 2) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr + 1))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "cowextsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "cowextsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((blksz * nr + 1))" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b 8388608 0 $((blksz * nr))" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || test $new_extents -lt 15 \
+	|| _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/211.out b/tests/xfs/211.out
new file mode 100644
index 0000000..3d912a8
--- /dev/null
+++ b/tests/xfs/211.out
@@ -0,0 +1,12 @@
+QA output created by 211
+Format and mount
+Create the original files
+Compare files
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file1
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file2
+CoW and unmount
+Compare files
+07415406aea963ab8e005f1d3744fded  SCRATCH_MNT/test-211/file1
+7d8ab127adfc1f745a7d1cd5e44d10d8  SCRATCH_MNT/test-211/file2
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index abf1d33..119e1fd 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -177,8 +177,11 @@
 177 dmapi
 178 mkfs other auto
 179 auto quick clone
+180 auto quick clone
 181 log auto quick
+182 auto quick clone
 183 rw other auto quick
+184 auto quick clone
 185 dmapi
 186 attr auto quick
 187 attr auto quick
@@ -186,16 +189,26 @@
 189 mount auto quick
 190 rw auto quick
 191 nfs4acl auto
+192 auto quick clone
+193 auto quick clone
 194 rw auto
 195 ioctl dump auto quick
 196 quota auto quick
 197 dir auto quick
+198 auto quick clone
 199 mount auto quick
+200 auto quick clone
 201 metadata auto quick
 202 repair auto quick
 203 ioctl auto
+204 auto quick clone
 205 metadata rw auto
 206 growfs auto quick
+207 auto quick clone
+208 auto quick clone
+209 auto quick clone
+210 auto quick clone
+211 clone_stress
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick

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

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

* [PATCH 14/23] reflink: high offset reflink and dedupe tests
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Ensure that we can pass absurdly enormous offsets and lengths to
reflink/dedupe and it'll survive.

v2: Ask for dedupe in the dedupe test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: call _require_test_dedupe]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/303     |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/303.out |   21 ++++++++++
 tests/generic/304     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/304.out |   22 +++++++++++
 tests/generic/group   |    2 +
 5 files changed, 244 insertions(+)
 create mode 100755 tests/generic/303
 create mode 100644 tests/generic/303.out
 create mode 100755 tests/generic/304
 create mode 100644 tests/generic/304.out


diff --git a/tests/generic/303 b/tests/generic/303
new file mode 100755
index 0000000..c337483
--- /dev/null
+++ b/tests/generic/303
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 303
+#
+# Check that high-offset reflinks work.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_test_reflink
+_require_cp_reflink
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+testdir="$TEST_DIR/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original files"
+bigoff=9223372036854775806
+len=9223372036854775807
+bigoff_64k=9223372036854710272	# bigoff rounded down to 64k
+"$XFS_IO_PROG" -f -c "truncate $len" "$testdir/file0" >> "$seqres.full"
+test -s "$testdir/file0" || _notrun "High offset ftruncate failed"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x61 1048575 1 "$testdir/file2" >> "$seqres.full"
+
+echo "Reflink large single byte file"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+
+echo "Reflink large empty file"
+_cp_reflink "$testdir/file0" "$testdir/file4" >> "$seqres.full"
+
+echo "Reflink past maximum file size in dest file (should fail)"
+_reflink_range "$testdir/file1" 0 "$testdir/file5" 4611686018427322368 $len >> "$seqres.full"
+
+echo "Reflink high offset to low offset"
+_reflink_range "$testdir/file1" $bigoff_64k "$testdir/file6" 1048576 65535 >> "$seqres.full"
+
+echo "Reflink past source file EOF (should fail)"
+_reflink_range "$testdir/file2" 524288 "$testdir/file7" 0 1048576 >> "$seqres.full"
+
+echo "Reflink max size at nonzero offset (should fail)"
+_reflink_range "$testdir/file2" 524288 "$testdir/file8" 0 $len >> "$seqres.full"
+
+echo "Reflink with huge off/len (should fail)"
+_reflink_range "$testdir/file2" $bigoff_64k "$testdir/file9" 0 $bigoff_64k >> "$seqres.full"
+
+echo "Check file creation"
+_test_remount
+echo "file3"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file3"
+echo "file4"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file4"
+# file5 should fail above
+echo "file6"
+"$XFS_IO_PROG" -c "pread -v -q 1114110 1" "$testdir/file6"
+# file7 should fail above
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/303.out b/tests/generic/303.out
new file mode 100644
index 0000000..39a8803
--- /dev/null
+++ b/tests/generic/303.out
@@ -0,0 +1,21 @@
+QA output created by 303
+Format and mount
+Create the original files
+Reflink large single byte file
+Reflink large empty file
+Reflink past maximum file size in dest file (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink high offset to low offset
+Reflink past source file EOF (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink max size at nonzero offset (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink with huge off/len (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Check file creation
+file3
+7ffffffffffffffe:  61  a
+file4
+7ffffffffffffffe:  00  .
+file6
+0010fffe:  61  a
diff --git a/tests/generic/304 b/tests/generic/304
new file mode 100755
index 0000000..443ed21
--- /dev/null
+++ b/tests/generic/304
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 304
+#
+# Check that high-offset dedupes work.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_test_dedupe
+_require_cp_reflink
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+testdir="$TEST_DIR/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original files"
+bigoff=9223372036854775806
+len=9223372036854775807
+bigoff_64k=9223372036854710272	# bigoff rounded down to 64k
+"$XFS_IO_PROG" -f -c "truncate $len" "$testdir/file0" >> "$seqres.full"
+test -s "$testdir/file0" || _notrun "High offset ftruncate failed"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 1048575 1 "$testdir/file2" >> "$seqres.full"
+
+echo "Dedupe large single byte file"
+_dedupe_range "$testdir/file1" 0 "$testdir/file3" 0 $len >> "$seqres.full"
+
+echo "Dedupe large empty file"
+_dedupe_range "$testdir/file0" 0 "$testdir/file4" 0 $len >> "$seqres.full"
+
+echo "Dedupe past maximum file size in dest file (should fail)"
+_dedupe_range "$testdir/file1" 0 "$testdir/file5" 4611686018427322368 $len >> "$seqres.full"
+
+echo "Dedupe high offset to low offset"
+_dedupe_range "$testdir/file1" $bigoff_64k "$testdir/file6" 1048576 65535 >> "$seqres.full"
+
+echo "Dedupe past source file EOF (should fail)"
+_dedupe_range "$testdir/file2" 524288 "$testdir/file7" 0 1048576 >> "$seqres.full"
+
+echo "Dedupe max size at nonzero offset (should fail)"
+_dedupe_range "$testdir/file2" 524288 "$testdir/file8" 0 $len >> "$seqres.full"
+
+echo "Dedupe with huge off/len (should fail)"
+_dedupe_range "$testdir/file2" $bigoff_64k "$testdir/file9" 0 $bigoff_64k >> "$seqres.full"
+
+echo "Check file creation"
+_test_remount
+echo "file3"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file3"
+echo "file4"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file4"
+# file5 should fail above
+echo "file6"
+"$XFS_IO_PROG" -c "pread -v -q 1114110 1" "$testdir/file6"
+# file7 should fail above
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/304.out b/tests/generic/304.out
new file mode 100644
index 0000000..4af2a39
--- /dev/null
+++ b/tests/generic/304.out
@@ -0,0 +1,22 @@
+QA output created by 304
+Format and mount
+Create the original files
+Dedupe large single byte file
+dedupe: Invalid argument
+Dedupe large empty file
+dedupe: Invalid argument
+Dedupe past maximum file size in dest file (should fail)
+dedupe: Invalid argument
+Dedupe high offset to low offset
+dedupe: Extents did not match.
+Dedupe past source file EOF (should fail)
+dedupe: Invalid argument
+Dedupe max size at nonzero offset (should fail)
+dedupe: Invalid argument
+Dedupe with huge off/len (should fail)
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
+Check file creation
+file3
+7ffffffffffffffe:  61  a
+file4
+file6
diff --git a/tests/generic/group b/tests/generic/group
index 7e1ea72..3229dad 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -305,6 +305,8 @@
 300 auto aio enospc preallocrw stress
 301 auto quick clone
 302 auto quick clone
+303 auto quick clone
+304 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick


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

* [PATCH 14/23] reflink: high offset reflink and dedupe tests
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Ensure that we can pass absurdly enormous offsets and lengths to
reflink/dedupe and it'll survive.

v2: Ask for dedupe in the dedupe test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: call _require_test_dedupe]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/303     |   99 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/303.out |   21 ++++++++++
 tests/generic/304     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/304.out |   22 +++++++++++
 tests/generic/group   |    2 +
 5 files changed, 244 insertions(+)
 create mode 100755 tests/generic/303
 create mode 100644 tests/generic/303.out
 create mode 100755 tests/generic/304
 create mode 100644 tests/generic/304.out


diff --git a/tests/generic/303 b/tests/generic/303
new file mode 100755
index 0000000..c337483
--- /dev/null
+++ b/tests/generic/303
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 303
+#
+# Check that high-offset reflinks work.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_test_reflink
+_require_cp_reflink
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+testdir="$TEST_DIR/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original files"
+bigoff=9223372036854775806
+len=9223372036854775807
+bigoff_64k=9223372036854710272	# bigoff rounded down to 64k
+"$XFS_IO_PROG" -f -c "truncate $len" "$testdir/file0" >> "$seqres.full"
+test -s "$testdir/file0" || _notrun "High offset ftruncate failed"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x61 1048575 1 "$testdir/file2" >> "$seqres.full"
+
+echo "Reflink large single byte file"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+
+echo "Reflink large empty file"
+_cp_reflink "$testdir/file0" "$testdir/file4" >> "$seqres.full"
+
+echo "Reflink past maximum file size in dest file (should fail)"
+_reflink_range "$testdir/file1" 0 "$testdir/file5" 4611686018427322368 $len >> "$seqres.full"
+
+echo "Reflink high offset to low offset"
+_reflink_range "$testdir/file1" $bigoff_64k "$testdir/file6" 1048576 65535 >> "$seqres.full"
+
+echo "Reflink past source file EOF (should fail)"
+_reflink_range "$testdir/file2" 524288 "$testdir/file7" 0 1048576 >> "$seqres.full"
+
+echo "Reflink max size at nonzero offset (should fail)"
+_reflink_range "$testdir/file2" 524288 "$testdir/file8" 0 $len >> "$seqres.full"
+
+echo "Reflink with huge off/len (should fail)"
+_reflink_range "$testdir/file2" $bigoff_64k "$testdir/file9" 0 $bigoff_64k >> "$seqres.full"
+
+echo "Check file creation"
+_test_remount
+echo "file3"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file3"
+echo "file4"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file4"
+# file5 should fail above
+echo "file6"
+"$XFS_IO_PROG" -c "pread -v -q 1114110 1" "$testdir/file6"
+# file7 should fail above
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/303.out b/tests/generic/303.out
new file mode 100644
index 0000000..39a8803
--- /dev/null
+++ b/tests/generic/303.out
@@ -0,0 +1,21 @@
+QA output created by 303
+Format and mount
+Create the original files
+Reflink large single byte file
+Reflink large empty file
+Reflink past maximum file size in dest file (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink high offset to low offset
+Reflink past source file EOF (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink max size at nonzero offset (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Reflink with huge off/len (should fail)
+XFS_IOC_CLONE_RANGE: Invalid argument
+Check file creation
+file3
+7ffffffffffffffe:  61  a
+file4
+7ffffffffffffffe:  00  .
+file6
+0010fffe:  61  a
diff --git a/tests/generic/304 b/tests/generic/304
new file mode 100755
index 0000000..443ed21
--- /dev/null
+++ b/tests/generic/304
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 304
+#
+# Check that high-offset dedupes work.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_test_dedupe
+_require_cp_reflink
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+testdir="$TEST_DIR/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original files"
+bigoff=9223372036854775806
+len=9223372036854775807
+bigoff_64k=9223372036854710272	# bigoff rounded down to 64k
+"$XFS_IO_PROG" -f -c "truncate $len" "$testdir/file0" >> "$seqres.full"
+test -s "$testdir/file0" || _notrun "High offset ftruncate failed"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x61 $bigoff 1 "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x61 1048575 1 "$testdir/file2" >> "$seqres.full"
+
+echo "Dedupe large single byte file"
+_dedupe_range "$testdir/file1" 0 "$testdir/file3" 0 $len >> "$seqres.full"
+
+echo "Dedupe large empty file"
+_dedupe_range "$testdir/file0" 0 "$testdir/file4" 0 $len >> "$seqres.full"
+
+echo "Dedupe past maximum file size in dest file (should fail)"
+_dedupe_range "$testdir/file1" 0 "$testdir/file5" 4611686018427322368 $len >> "$seqres.full"
+
+echo "Dedupe high offset to low offset"
+_dedupe_range "$testdir/file1" $bigoff_64k "$testdir/file6" 1048576 65535 >> "$seqres.full"
+
+echo "Dedupe past source file EOF (should fail)"
+_dedupe_range "$testdir/file2" 524288 "$testdir/file7" 0 1048576 >> "$seqres.full"
+
+echo "Dedupe max size at nonzero offset (should fail)"
+_dedupe_range "$testdir/file2" 524288 "$testdir/file8" 0 $len >> "$seqres.full"
+
+echo "Dedupe with huge off/len (should fail)"
+_dedupe_range "$testdir/file2" $bigoff_64k "$testdir/file9" 0 $bigoff_64k >> "$seqres.full"
+
+echo "Check file creation"
+_test_remount
+echo "file3"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file3"
+echo "file4"
+"$XFS_IO_PROG" -c "pread -v -q $bigoff 1" "$testdir/file4"
+# file5 should fail above
+echo "file6"
+"$XFS_IO_PROG" -c "pread -v -q 1114110 1" "$testdir/file6"
+# file7 should fail above
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/304.out b/tests/generic/304.out
new file mode 100644
index 0000000..4af2a39
--- /dev/null
+++ b/tests/generic/304.out
@@ -0,0 +1,22 @@
+QA output created by 304
+Format and mount
+Create the original files
+Dedupe large single byte file
+dedupe: Invalid argument
+Dedupe large empty file
+dedupe: Invalid argument
+Dedupe past maximum file size in dest file (should fail)
+dedupe: Invalid argument
+Dedupe high offset to low offset
+dedupe: Extents did not match.
+Dedupe past source file EOF (should fail)
+dedupe: Invalid argument
+Dedupe max size at nonzero offset (should fail)
+dedupe: Invalid argument
+Dedupe with huge off/len (should fail)
+XFS_IOC_FILE_EXTENT_SAME: Invalid argument
+Check file creation
+file3
+7ffffffffffffffe:  61  a
+file4
+file6
diff --git a/tests/generic/group b/tests/generic/group
index 7e1ea72..3229dad 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -305,6 +305,8 @@
 300 auto aio enospc preallocrw stress
 301 auto quick clone
 302 auto quick clone
+303 auto quick clone
+304 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick

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

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

* [PATCH 15/23] reflink: test xfs cow behavior when the filesystem crashes
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Use the extent size hint to force leftover CoW reservations then
crash the filesystem to see how recovery works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/212     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/212.out |   14 +++++++
 tests/xfs/group   |    1 +
 3 files changed, 121 insertions(+)
 create mode 100755 tests/xfs/212
 create mode 100644 tests/xfs/212.out


diff --git a/tests/xfs/212 b/tests/xfs/212
new file mode 100755
index 0000000..ccddf05
--- /dev/null
+++ b/tests/xfs/212
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 212
+#
+# Test recovery of "lost" CoW blocks after a crash:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty one byte on the second file and fsync.
+# - Crash the FS to test recovery.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=16
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * nr - 1)) 1" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * nr - 1)) 1" -c "fsync" "$testdir/file2.chk" >> "$seqres.full"
+sync
+
+echo "Crash and recover"
+"$XFS_IO_PROG" -x -c "shutdown" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/212.out b/tests/xfs/212.out
new file mode 100644
index 0000000..24b35e2
--- /dev/null
+++ b/tests/xfs/212.out
@@ -0,0 +1,14 @@
+QA output created by 212
+Format and mount
+Create the original files
+Compare files
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file1
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file2
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file2.chk
+CoW and leave leftovers
+Crash and recover
+Compare files
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file1
+83feff041c88d5c746837552399dc27d  SCRATCH_MNT/test-212/file2
+83feff041c88d5c746837552399dc27d  SCRATCH_MNT/test-212/file2.chk
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index 119e1fd..d4a0d59 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -209,6 +209,7 @@
 209 auto quick clone
 210 auto quick clone
 211 clone_stress
+212 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick


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

* [PATCH 15/23] reflink: test xfs cow behavior when the filesystem crashes
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Use the extent size hint to force leftover CoW reservations then
crash the filesystem to see how recovery works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/212     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/212.out |   14 +++++++
 tests/xfs/group   |    1 +
 3 files changed, 121 insertions(+)
 create mode 100755 tests/xfs/212
 create mode 100644 tests/xfs/212.out


diff --git a/tests/xfs/212 b/tests/xfs/212
new file mode 100755
index 0000000..ccddf05
--- /dev/null
+++ b/tests/xfs/212
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 212
+#
+# Test recovery of "lost" CoW blocks after a crash:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty one byte on the second file and fsync.
+# - Crash the FS to test recovery.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+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=65536
+nr=16
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "extsize $((blksz * bsz))" "$testdir/file2"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+"$XFS_IO_PROG" -f -c "extsize" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * nr - 1)) 1" -c "fsync" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * nr - 1)) 1" -c "fsync" "$testdir/file2.chk" >> "$seqres.full"
+sync
+
+echo "Crash and recover"
+"$XFS_IO_PROG" -x -c "shutdown" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/212.out b/tests/xfs/212.out
new file mode 100644
index 0000000..24b35e2
--- /dev/null
+++ b/tests/xfs/212.out
@@ -0,0 +1,14 @@
+QA output created by 212
+Format and mount
+Create the original files
+Compare files
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file1
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file2
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file2.chk
+CoW and leave leftovers
+Crash and recover
+Compare files
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-212/file1
+83feff041c88d5c746837552399dc27d  SCRATCH_MNT/test-212/file2
+83feff041c88d5c746837552399dc27d  SCRATCH_MNT/test-212/file2.chk
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index 119e1fd..d4a0d59 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -209,6 +209,7 @@
 209 auto quick clone
 210 auto quick clone
 211 clone_stress
+212 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick

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

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

* [PATCH 16/23] reflink: test quota accounting
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink        |    2 -
 tests/generic/305     |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/305.out |   23 ++++++++++
 tests/generic/326     |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/326.out |   23 ++++++++++
 tests/generic/327     |   92 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/327.out |   13 ++++++
 tests/generic/328     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/328.out |   26 ++++++++++++
 tests/generic/group   |    4 ++
 tests/xfs/213         |  110 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/213.out     |   23 ++++++++++
 tests/xfs/214         |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/214.out     |   23 ++++++++++
 tests/xfs/group       |    2 +
 15 files changed, 768 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/305
 create mode 100644 tests/generic/305.out
 create mode 100755 tests/generic/326
 create mode 100644 tests/generic/326.out
 create mode 100755 tests/generic/327
 create mode 100644 tests/generic/327.out
 create mode 100755 tests/generic/328
 create mode 100644 tests/generic/328.out
 create mode 100755 tests/xfs/213
 create mode 100644 tests/xfs/213.out
 create mode 100755 tests/xfs/214
 create mode 100644 tests/xfs/214.out


diff --git a/common/reflink b/common/reflink
index 3d6a8c1..139e00e 100644
--- a/common/reflink
+++ b/common/reflink
@@ -153,7 +153,7 @@ _cp_reflink() {
 	file1="$1"
 	file2="$2"
 
-	cp --reflink=always "$file1" "$file2"
+	cp --reflink=always -p "$file1" "$file2"
 }
 
 # Reflink some file1 into file2
diff --git a/tests/generic/305 b/tests/generic/305
new file mode 100755
index 0000000..5721dd0
--- /dev/null
+++ b/tests/generic/305
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 305
+#
+# Ensure that quota charges us for reflinking a file and that we're not
+# charged for buffered copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/305.out b/tests/generic/305.out
new file mode 100644
index 0000000..2acfe04
--- /dev/null
+++ b/tests/generic/305.out
@@ -0,0 +1,23 @@
+QA output created by 305
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/generic/326 b/tests/generic/326
new file mode 100755
index 0000000..b71d4bb
--- /dev/null
+++ b/tests/generic/326
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 326
+#
+# Ensure that quota charges us for reflinking a file and that we're not
+# charged for directio copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/326.out b/tests/generic/326.out
new file mode 100644
index 0000000..950d8f8
--- /dev/null
+++ b/tests/generic/326.out
@@ -0,0 +1,23 @@
+QA output created by 326
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/generic/327 b/tests/generic/327
new file mode 100755
index 0000000..95fa223
--- /dev/null
+++ b/tests/generic/327
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test No. 327
+#
+# Ensure that we can't go over the hard block limit when reflinking.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+chown fsgqa "$testdir/file1"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_repquota
+_scratch_remount
+
+echo "Set hard quota to prevent third reflink"
+setquota -u fsgqa 0 1024 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to reflink again"
+touch "$testdir/file3"
+chown fsgqa "$testdir/file3"
+_cp_reflink "$testdir/file1" "$testdir/file3" 2>&1 | _filter_scratch
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/327.out b/tests/generic/327.out
new file mode 100644
index 0000000..32e5eab
--- /dev/null
+++ b/tests/generic/327.out
@@ -0,0 +1,13 @@
+QA output created by 327
+Format and mount
+Create the original files
+root      --       0       0       0              4     0     0       
+fsgqa     --    2048       0       0              2     0     0       
+Set hard quota to prevent third reflink
+root      --       0       0       0              4     0     0       
+fsgqa     +-    2048       0    1024              2     0     0       
+Try to reflink again
+cp: failed to clone 'SCRATCH_MNT/test-327/file3' from 'SCRATCH_MNT/test-327/file1': Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    2048       0    1024              3     0     0       
+Check for damage
diff --git a/tests/generic/328 b/tests/generic/328
new file mode 100755
index 0000000..506ca7f
--- /dev/null
+++ b/tests/generic/328
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 328
+#
+# Ensure that we can't go over the hard block limit when CoWing a file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+chown fsgqa "$testdir/file1"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_repquota
+_scratch_remount
+
+echo "Set hard quota to prevent rewrite"
+setquota -u fsgqa 0 1024 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to dio write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" -d >> "$seqres.full"
+_repquota
+
+echo "Try to write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" >> "$seqres.full"
+_repquota
+
+echo "Set hard quota to allow rewrite"
+setquota -u fsgqa 0 8192 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to dio write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" -d >> "$seqres.full"
+sync
+_repquota
+
+echo "Try to write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file3" >> "$seqres.full"
+sync
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/328.out b/tests/generic/328.out
new file mode 100644
index 0000000..e5dcb67
--- /dev/null
+++ b/tests/generic/328.out
@@ -0,0 +1,26 @@
+QA output created by 328
+Format and mount
+Create the original files
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0       0              3     0     0       
+Set hard quota to prevent rewrite
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Try to dio write the whole file
+pwrite64: Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Try to write the whole file
+pwrite64: Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Set hard quota to allow rewrite
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Try to dio write the whole file
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Try to write the whole file
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 3229dad..d4531f8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -307,6 +307,7 @@
 302 auto quick clone
 303 auto quick clone
 304 auto quick clone
+305 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick
@@ -327,3 +328,6 @@
 323 auto aio stress
 324 auto fsr quick
 325 auto quick data log
+326 auto quick clone
+327 auto quick clone
+328 auto quick clone
diff --git a/tests/xfs/213 b/tests/xfs/213
new file mode 100755
index 0000000..7441e78
--- /dev/null
+++ b/tests/xfs/213
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 213
+#
+# Ensure that quota charges us for reflnking a file and that we're not
+# charged for buffered copy on write.  Same test as 822, but we get to
+# play with cowextsz.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+_require_xfs_io_command "cowextsize"
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+blksz=65536
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((sz/2))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/213.out b/tests/xfs/213.out
new file mode 100644
index 0000000..0028bd1
--- /dev/null
+++ b/tests/xfs/213.out
@@ -0,0 +1,23 @@
+QA output created by 213
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3520       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/xfs/214 b/tests/xfs/214
new file mode 100755
index 0000000..0cfd69b
--- /dev/null
+++ b/tests/xfs/214
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 214
+#
+# Ensure that quota charges us for reflnking a file and that we're not
+# charged for directio copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+_require_xfs_io_command "cowextsize"
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+blksz=65536
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((sz/2))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/214.out b/tests/xfs/214.out
new file mode 100644
index 0000000..8f6bb0f
--- /dev/null
+++ b/tests/xfs/214.out
@@ -0,0 +1,23 @@
+QA output created by 214
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3520       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index d4a0d59..afd960f 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -210,6 +210,8 @@
 210 auto quick clone
 211 clone_stress
 212 auto quick clone
+213 auto quick clone
+214 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick


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

* [PATCH 16/23] reflink: test quota accounting
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink        |    2 -
 tests/generic/305     |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/305.out |   23 ++++++++++
 tests/generic/326     |  105 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/326.out |   23 ++++++++++
 tests/generic/327     |   92 +++++++++++++++++++++++++++++++++++++++++
 tests/generic/327.out |   13 ++++++
 tests/generic/328     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/328.out |   26 ++++++++++++
 tests/generic/group   |    4 ++
 tests/xfs/213         |  110 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/213.out     |   23 ++++++++++
 tests/xfs/214         |  109 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/214.out     |   23 ++++++++++
 tests/xfs/group       |    2 +
 15 files changed, 768 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/305
 create mode 100644 tests/generic/305.out
 create mode 100755 tests/generic/326
 create mode 100644 tests/generic/326.out
 create mode 100755 tests/generic/327
 create mode 100644 tests/generic/327.out
 create mode 100755 tests/generic/328
 create mode 100644 tests/generic/328.out
 create mode 100755 tests/xfs/213
 create mode 100644 tests/xfs/213.out
 create mode 100755 tests/xfs/214
 create mode 100644 tests/xfs/214.out


diff --git a/common/reflink b/common/reflink
index 3d6a8c1..139e00e 100644
--- a/common/reflink
+++ b/common/reflink
@@ -153,7 +153,7 @@ _cp_reflink() {
 	file1="$1"
 	file2="$2"
 
-	cp --reflink=always "$file1" "$file2"
+	cp --reflink=always -p "$file1" "$file2"
 }
 
 # Reflink some file1 into file2
diff --git a/tests/generic/305 b/tests/generic/305
new file mode 100755
index 0000000..5721dd0
--- /dev/null
+++ b/tests/generic/305
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 305
+#
+# Ensure that quota charges us for reflinking a file and that we're not
+# charged for buffered copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/305.out b/tests/generic/305.out
new file mode 100644
index 0000000..2acfe04
--- /dev/null
+++ b/tests/generic/305.out
@@ -0,0 +1,23 @@
+QA output created by 305
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/generic/326 b/tests/generic/326
new file mode 100755
index 0000000..b71d4bb
--- /dev/null
+++ b/tests/generic/326
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 326
+#
+# Ensure that quota charges us for reflinking a file and that we're not
+# charged for directio copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/326.out b/tests/generic/326.out
new file mode 100644
index 0000000..950d8f8
--- /dev/null
+++ b/tests/generic/326.out
@@ -0,0 +1,23 @@
+QA output created by 326
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/generic/327 b/tests/generic/327
new file mode 100755
index 0000000..95fa223
--- /dev/null
+++ b/tests/generic/327
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test No. 327
+#
+# Ensure that we can't go over the hard block limit when reflinking.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+chown fsgqa "$testdir/file1"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_repquota
+_scratch_remount
+
+echo "Set hard quota to prevent third reflink"
+setquota -u fsgqa 0 1024 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to reflink again"
+touch "$testdir/file3"
+chown fsgqa "$testdir/file3"
+_cp_reflink "$testdir/file1" "$testdir/file3" 2>&1 | _filter_scratch
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/327.out b/tests/generic/327.out
new file mode 100644
index 0000000..32e5eab
--- /dev/null
+++ b/tests/generic/327.out
@@ -0,0 +1,13 @@
+QA output created by 327
+Format and mount
+Create the original files
+root      --       0       0       0              4     0     0       
+fsgqa     --    2048       0       0              2     0     0       
+Set hard quota to prevent third reflink
+root      --       0       0       0              4     0     0       
+fsgqa     +-    2048       0    1024              2     0     0       
+Try to reflink again
+cp: failed to clone 'SCRATCH_MNT/test-327/file3' from 'SCRATCH_MNT/test-327/file1': Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    2048       0    1024              3     0     0       
+Check for damage
diff --git a/tests/generic/328 b/tests/generic/328
new file mode 100755
index 0000000..506ca7f
--- /dev/null
+++ b/tests/generic/328
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 328
+#
+# Ensure that we can't go over the hard block limit when CoWing a file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+chown fsgqa "$testdir/file1"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+_repquota
+_scratch_remount
+
+echo "Set hard quota to prevent rewrite"
+setquota -u fsgqa 0 1024 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to dio write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" -d >> "$seqres.full"
+_repquota
+
+echo "Try to write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" >> "$seqres.full"
+_repquota
+
+echo "Set hard quota to allow rewrite"
+setquota -u fsgqa 0 8192 0 0 "$SCRATCH_MNT"
+_repquota
+
+echo "Try to dio write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file1" -d >> "$seqres.full"
+sync
+_repquota
+
+echo "Try to write the whole file"
+_pwrite_byte 0x62 0 $sz "$testdir/file3" >> "$seqres.full"
+sync
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/328.out b/tests/generic/328.out
new file mode 100644
index 0000000..e5dcb67
--- /dev/null
+++ b/tests/generic/328.out
@@ -0,0 +1,26 @@
+QA output created by 328
+Format and mount
+Create the original files
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0       0              3     0     0       
+Set hard quota to prevent rewrite
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Try to dio write the whole file
+pwrite64: Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Try to write the whole file
+pwrite64: Disk quota exceeded
+root      --       0       0       0              4     0     0       
+fsgqa     +-    3072       0    1024              3     0     0       
+Set hard quota to allow rewrite
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Try to dio write the whole file
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Try to write the whole file
+root      --       0       0       0              4     0     0       
+fsgqa     --    3072       0    8192              3     0     0       
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index 3229dad..d4531f8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -307,6 +307,7 @@
 302 auto quick clone
 303 auto quick clone
 304 auto quick clone
+305 auto quick clone
 306 auto quick rw
 307 auto quick
 308 auto quick
@@ -327,3 +328,6 @@
 323 auto aio stress
 324 auto fsr quick
 325 auto quick data log
+326 auto quick clone
+327 auto quick clone
+328 auto quick clone
diff --git a/tests/xfs/213 b/tests/xfs/213
new file mode 100755
index 0000000..7441e78
--- /dev/null
+++ b/tests/xfs/213
@@ -0,0 +1,110 @@
+#! /bin/bash
+# FS QA Test No. 213
+#
+# Ensure that quota charges us for reflnking a file and that we're not
+# charged for buffered copy on write.  Same test as 822, but we get to
+# play with cowextsz.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+_require_xfs_io_command "cowextsize"
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+blksz=65536
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((sz/2))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/213.out b/tests/xfs/213.out
new file mode 100644
index 0000000..0028bd1
--- /dev/null
+++ b/tests/xfs/213.out
@@ -0,0 +1,23 @@
+QA output created by 213
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3520       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/xfs/214 b/tests/xfs/214
new file mode 100755
index 0000000..0cfd69b
--- /dev/null
+++ b/tests/xfs/214
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 214
+#
+# Ensure that quota charges us for reflnking a file and that we're not
+# charged for directio copy on write.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/quota
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_quota
+_need_to_be_root
+_require_nobody
+_require_xfs_io_command "cowextsize"
+
+_repquota() {
+	repquota "$SCRATCH_MNT" | egrep '^(fsgqa|root|nobody)'
+}
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
+_scratch_mount >> "$seqres.full" 2>&1
+quotacheck -u -g "$SCRATCH_MNT" 2> /dev/null
+quotaon "$SCRATCH_MNT" 2> /dev/null
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+sz=1048576
+blksz=65536
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((sz/2))" "$testdir" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $sz 0 $sz" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file3" >> "$seqres.full"
+touch "$testdir/urk"
+chown nobody "$testdir/urk"
+touch "$testdir/erk"
+chown fsgqa "$testdir/erk"
+_repquota
+_scratch_remount
+
+echo "Change file ownership"
+chown fsgqa "$testdir/file1"
+chown fsgqa "$testdir/file2"
+chown fsgqa "$testdir/file3"
+_repquota
+
+echo "CoW one of the files"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $blksz $((sz - blksz)) $blksz" -c "fsync" "$testdir/file2" >> "$seqres.full"
+_repquota
+
+echo "Remount the FS to see if accounting changes"
+_scratch_remount
+_repquota
+
+echo "Chown one of the files"
+chown nobody "$testdir/file3"
+_repquota
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/214.out b/tests/xfs/214.out
new file mode 100644
index 0000000..8f6bb0f
--- /dev/null
+++ b/tests/xfs/214.out
@@ -0,0 +1,23 @@
+QA output created by 214
+Format and mount
+Create the original files
+root      --    3072       0       0              7     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --       0       0       0              1     0     0       
+Change file ownership
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+CoW one of the files
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3520       0       0              4     0     0       
+Remount the FS to see if accounting changes
+root      --       0       0       0              4     0     0       
+nobody    --       0       0       0              1     0     0       
+fsgqa     --    3072       0       0              4     0     0       
+Chown one of the files
+root      --       0       0       0              4     0     0       
+nobody    --    1024       0       0              2     0     0       
+fsgqa     --    2048       0       0              3     0     0       
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index d4a0d59..afd960f 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -210,6 +210,8 @@
 210 auto quick clone
 211 clone_stress
 212 auto quick clone
+213 auto quick clone
+214 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
 220 auto quota quick

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

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

* [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/215.out |   14 +++++
 tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/218.out |   14 +++++
 tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/219.out |   14 +++++
 tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/221.out |   14 +++++
 tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/223.out |   14 +++++
 tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/224.out |   14 +++++
 tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/225.out |   14 +++++
 tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/226.out |   14 +++++
 tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/228.out |   14 +++++
 tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/230.out |   14 +++++
 tests/xfs/group   |   10 ++++
 21 files changed, 1298 insertions(+)
 create mode 100755 tests/xfs/215
 create mode 100644 tests/xfs/215.out
 create mode 100755 tests/xfs/218
 create mode 100644 tests/xfs/218.out
 create mode 100755 tests/xfs/219
 create mode 100644 tests/xfs/219.out
 create mode 100755 tests/xfs/221
 create mode 100644 tests/xfs/221.out
 create mode 100755 tests/xfs/223
 create mode 100644 tests/xfs/223.out
 create mode 100755 tests/xfs/224
 create mode 100644 tests/xfs/224.out
 create mode 100755 tests/xfs/225
 create mode 100644 tests/xfs/225.out
 create mode 100755 tests/xfs/226
 create mode 100644 tests/xfs/226.out
 create mode 100755 tests/xfs/228
 create mode 100644 tests/xfs/228.out
 create mode 100755 tests/xfs/230
 create mode 100644 tests/xfs/230.out


diff --git a/tests/xfs/215 b/tests/xfs/215
new file mode 100755
index 0000000..8dd5cb5
--- /dev/null
+++ b/tests/xfs/215
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 215
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file and fallocate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/215.out b/tests/xfs/215.out
new file mode 100644
index 0000000..5412722
--- /dev/null
+++ b/tests/xfs/215.out
@@ -0,0 +1,14 @@
+QA output created by 215
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-215/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-215/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-215/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-215/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-215/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-215/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/218 b/tests/xfs/218
new file mode 100755
index 0000000..fb61652
--- /dev/null
+++ b/tests/xfs/218
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 218
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file and fallocate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/218.out b/tests/xfs/218.out
new file mode 100644
index 0000000..4b70fb9
--- /dev/null
+++ b/tests/xfs/218.out
@@ -0,0 +1,14 @@
+QA output created by 218
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-218/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-218/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-218/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-218/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-218/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-218/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/219 b/tests/xfs/219
new file mode 100755
index 0000000..df3a3b4
--- /dev/null
+++ b/tests/xfs/219
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 219
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some holes, some not.
+#   - Set cowextsize hint.
+#   - Create a file and truncate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/219.out b/tests/xfs/219.out
new file mode 100644
index 0000000..b6fc64b
--- /dev/null
+++ b/tests/xfs/219.out
@@ -0,0 +1,14 @@
+QA output created by 219
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-219/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-219/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-219/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-219/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-219/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-219/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/221 b/tests/xfs/221
new file mode 100755
index 0000000..298ecdf
--- /dev/null
+++ b/tests/xfs/221
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 221
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some holes, some not.
+#   - Set cowextsize hint.
+#   - Create a file and truncate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/221.out b/tests/xfs/221.out
new file mode 100644
index 0000000..09ece61
--- /dev/null
+++ b/tests/xfs/221.out
@@ -0,0 +1,14 @@
+QA output created by 221
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-221/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-221/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-221/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-221/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-221/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-221/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/223 b/tests/xfs/223
new file mode 100755
index 0000000..c9903c6
--- /dev/null
+++ b/tests/xfs/223
@@ -0,0 +1,113 @@
+#! /bin/bash
+# FS QA Test No. 223
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some delalloc, some not.
+#   - Set cowextsize hint.
+#   - Create a file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Buffered write the even blocks of the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/223.out b/tests/xfs/223.out
new file mode 100644
index 0000000..4454fd8
--- /dev/null
+++ b/tests/xfs/223.out
@@ -0,0 +1,14 @@
+QA output created by 223
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-223/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-223/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-223/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-223/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-223/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-223/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/224 b/tests/xfs/224
new file mode 100755
index 0000000..cff8f5b
--- /dev/null
+++ b/tests/xfs/224
@@ -0,0 +1,113 @@
+#! /bin/bash
+# FS QA Test No. 224
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some delalloc, some not.
+#   - Set cowextsize hint.
+#   - Create a file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Buffered write the even blocks of the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/224.out b/tests/xfs/224.out
new file mode 100644
index 0000000..aa7d8a5
--- /dev/null
+++ b/tests/xfs/224.out
@@ -0,0 +1,14 @@
+QA output created by 224
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-224/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-224/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-224/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-224/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-224/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-224/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/225 b/tests/xfs/225
new file mode 100755
index 0000000..2474df7
--- /dev/null
+++ b/tests/xfs/225
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 225
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some regular, some not.
+#   - Set cowextsize hint.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/225.out b/tests/xfs/225.out
new file mode 100644
index 0000000..1355465
--- /dev/null
+++ b/tests/xfs/225.out
@@ -0,0 +1,14 @@
+QA output created by 225
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-225/file1
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-225/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-225/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-225/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-225/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-225/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/226 b/tests/xfs/226
new file mode 100755
index 0000000..3cff26b
--- /dev/null
+++ b/tests/xfs/226
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 226
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some regular, some not.
+#   - Set cowextsize hint.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/226.out b/tests/xfs/226.out
new file mode 100644
index 0000000..120b62f
--- /dev/null
+++ b/tests/xfs/226.out
@@ -0,0 +1,14 @@
+QA output created by 226
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-226/file1
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-226/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-226/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-226/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-226/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-226/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/228 b/tests/xfs/228
new file mode 100755
index 0000000..f0d79ef
--- /dev/null
+++ b/tests/xfs/228
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 228
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# now cow
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/228.out b/tests/xfs/228.out
new file mode 100644
index 0000000..8fa4267
--- /dev/null
+++ b/tests/xfs/228.out
@@ -0,0 +1,14 @@
+QA output created by 228
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-228/file1
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-228/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-228/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-228/file1
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-228/file3
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-228/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/230 b/tests/xfs/230
new file mode 100755
index 0000000..89cbc54
--- /dev/null
+++ b/tests/xfs/230
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 230
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# now cow
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/230.out b/tests/xfs/230.out
new file mode 100644
index 0000000..32c8fd2
--- /dev/null
+++ b/tests/xfs/230.out
@@ -0,0 +1,14 @@
+QA output created by 230
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-230/file1
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-230/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-230/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-230/file1
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-230/file3
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-230/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index afd960f..da83274 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -212,12 +212,22 @@
 212 auto quick clone
 213 auto quick clone
 214 auto quick clone
+215 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
+218 auto quick clone
+219 auto quick clone
 220 auto quota quick
+221 auto quick clone
 222 auto fsr ioctl quick
+223 auto quick clone
+224 auto quick clone
+225 auto quick clone
+226 auto quick clone
 227 auto fsr
+228 auto quick clone
 229 auto rw
+230 auto quick clone
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick


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

* [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/215.out |   14 +++++
 tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/218.out |   14 +++++
 tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/219.out |   14 +++++
 tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/221.out |   14 +++++
 tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/223.out |   14 +++++
 tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/224.out |   14 +++++
 tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/225.out |   14 +++++
 tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/226.out |   14 +++++
 tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/228.out |   14 +++++
 tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/230.out |   14 +++++
 tests/xfs/group   |   10 ++++
 21 files changed, 1298 insertions(+)
 create mode 100755 tests/xfs/215
 create mode 100644 tests/xfs/215.out
 create mode 100755 tests/xfs/218
 create mode 100644 tests/xfs/218.out
 create mode 100755 tests/xfs/219
 create mode 100644 tests/xfs/219.out
 create mode 100755 tests/xfs/221
 create mode 100644 tests/xfs/221.out
 create mode 100755 tests/xfs/223
 create mode 100644 tests/xfs/223.out
 create mode 100755 tests/xfs/224
 create mode 100644 tests/xfs/224.out
 create mode 100755 tests/xfs/225
 create mode 100644 tests/xfs/225.out
 create mode 100755 tests/xfs/226
 create mode 100644 tests/xfs/226.out
 create mode 100755 tests/xfs/228
 create mode 100644 tests/xfs/228.out
 create mode 100755 tests/xfs/230
 create mode 100644 tests/xfs/230.out


diff --git a/tests/xfs/215 b/tests/xfs/215
new file mode 100755
index 0000000..8dd5cb5
--- /dev/null
+++ b/tests/xfs/215
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 215
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file and fallocate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/215.out b/tests/xfs/215.out
new file mode 100644
index 0000000..5412722
--- /dev/null
+++ b/tests/xfs/215.out
@@ -0,0 +1,14 @@
+QA output created by 215
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-215/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-215/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-215/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-215/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-215/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-215/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/218 b/tests/xfs/218
new file mode 100755
index 0000000..fb61652
--- /dev/null
+++ b/tests/xfs/218
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 218
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file and fallocate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/218.out b/tests/xfs/218.out
new file mode 100644
index 0000000..4b70fb9
--- /dev/null
+++ b/tests/xfs/218.out
@@ -0,0 +1,14 @@
+QA output created by 218
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-218/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-218/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-218/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-218/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-218/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-218/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/219 b/tests/xfs/219
new file mode 100755
index 0000000..df3a3b4
--- /dev/null
+++ b/tests/xfs/219
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 219
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some holes, some not.
+#   - Set cowextsize hint.
+#   - Create a file and truncate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/219.out b/tests/xfs/219.out
new file mode 100644
index 0000000..b6fc64b
--- /dev/null
+++ b/tests/xfs/219.out
@@ -0,0 +1,14 @@
+QA output created by 219
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-219/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-219/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-219/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-219/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-219/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-219/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/221 b/tests/xfs/221
new file mode 100755
index 0000000..298ecdf
--- /dev/null
+++ b/tests/xfs/221
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 221
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some holes, some not.
+#   - Set cowextsize hint.
+#   - Create a file and truncate a second file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/221.out b/tests/xfs/221.out
new file mode 100644
index 0000000..09ece61
--- /dev/null
+++ b/tests/xfs/221.out
@@ -0,0 +1,14 @@
+QA output created by 221
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-221/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-221/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-221/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-221/file1
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-221/file3
+09101629908f9bdd5d178e7ce20bb1bb  SCRATCH_MNT/test-221/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/223 b/tests/xfs/223
new file mode 100755
index 0000000..c9903c6
--- /dev/null
+++ b/tests/xfs/223
@@ -0,0 +1,113 @@
+#! /bin/bash
+# FS QA Test No. 223
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some delalloc, some not.
+#   - Set cowextsize hint.
+#   - Create a file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Buffered write the even blocks of the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/223.out b/tests/xfs/223.out
new file mode 100644
index 0000000..4454fd8
--- /dev/null
+++ b/tests/xfs/223.out
@@ -0,0 +1,14 @@
+QA output created by 223
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-223/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-223/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-223/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-223/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-223/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-223/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/224 b/tests/xfs/224
new file mode 100755
index 0000000..cff8f5b
--- /dev/null
+++ b/tests/xfs/224
@@ -0,0 +1,113 @@
+#! /bin/bash
+# FS QA Test No. 224
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some delalloc, some not.
+#   - Set cowextsize hint.
+#   - Create a file.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - Buffered write the even blocks of the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+seq 1 2 $((nr-1)) | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/224.out b/tests/xfs/224.out
new file mode 100644
index 0000000..aa7d8a5
--- /dev/null
+++ b/tests/xfs/224.out
@@ -0,0 +1,14 @@
+QA output created by 224
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-224/file1
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-224/file3
+fa50dba51826899c372464a153cb2117  SCRATCH_MNT/test-224/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-224/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-224/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-224/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/225 b/tests/xfs/225
new file mode 100755
index 0000000..2474df7
--- /dev/null
+++ b/tests/xfs/225
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 225
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some regular, some not.
+#   - Set cowextsize hint.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/225.out b/tests/xfs/225.out
new file mode 100644
index 0000000..1355465
--- /dev/null
+++ b/tests/xfs/225.out
@@ -0,0 +1,14 @@
+QA output created by 225
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-225/file1
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-225/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-225/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-225/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-225/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-225/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/226 b/tests/xfs/226
new file mode 100755
index 0000000..3cff26b
--- /dev/null
+++ b/tests/xfs/226
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 226
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some regular, some not.
+#   - Set cowextsize hint.
+#   - Create two files.
+#   - Reflink the odd blocks of the first file into the second file.
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+
+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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
+seq 0 2 $((nr-1)) | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "CoW across the transition"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/226.out b/tests/xfs/226.out
new file mode 100644
index 0000000..120b62f
--- /dev/null
+++ b/tests/xfs/226.out
@@ -0,0 +1,14 @@
+QA output created by 226
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-226/file1
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-226/file3
+d3959a68638c50af07f0258e032cb554  SCRATCH_MNT/test-226/file3.chk
+CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-226/file1
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-226/file3
+55968a95dfc0120df4e8485576514320  SCRATCH_MNT/test-226/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/228 b/tests/xfs/228
new file mode 100755
index 0000000..f0d79ef
--- /dev/null
+++ b/tests/xfs/228
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 228
+#
+# Ensuring that copy on write in direct-io mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - directio CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# now cow
+"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/228.out b/tests/xfs/228.out
new file mode 100644
index 0000000..8fa4267
--- /dev/null
+++ b/tests/xfs/228.out
@@ -0,0 +1,14 @@
+QA output created by 228
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-228/file1
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-228/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-228/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-228/file1
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-228/file3
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-228/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/230 b/tests/xfs/230
new file mode 100755
index 0000000..89cbc54
--- /dev/null
+++ b/tests/xfs/230
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 230
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "directio CoW across the transition"
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# now cow
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
+_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file3")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 20)) || _fail "file3 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/230.out b/tests/xfs/230.out
new file mode 100644
index 0000000..32c8fd2
--- /dev/null
+++ b/tests/xfs/230.out
@@ -0,0 +1,14 @@
+QA output created by 230
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-230/file1
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-230/file3
+6366fd359371414186688a0ef6988893  SCRATCH_MNT/test-230/file3.chk
+directio CoW across the transition
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-230/file1
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-230/file3
+36f6b5317a9a921fc91175390ccf7f69  SCRATCH_MNT/test-230/file3.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index afd960f..da83274 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -212,12 +212,22 @@
 212 auto quick clone
 213 auto quick clone
 214 auto quick clone
+215 auto quick clone
 216 log metadata auto quick
 217 log metadata auto
+218 auto quick clone
+219 auto quick clone
 220 auto quota quick
+221 auto quick clone
 222 auto fsr ioctl quick
+223 auto quick clone
+224 auto quick clone
+225 auto quick clone
+226 auto quick clone
 227 auto fsr
+228 auto quick clone
 229 auto rw
+230 auto quick clone
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick

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

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

* [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/231     |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/231.out |   17 +++++++
 tests/xfs/232     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/232.out |   17 +++++++
 tests/xfs/group   |    2 +
 5 files changed, 308 insertions(+)
 create mode 100755 tests/xfs/231
 create mode 100644 tests/xfs/231.out
 create mode 100755 tests/xfs/232
 create mode 100644 tests/xfs/232.out


diff --git a/tests/xfs/231 b/tests/xfs/231
new file mode 100755
index 0000000..d9ae102
--- /dev/null
+++ b/tests/xfs/231
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 231
+#
+# Test recovery of unused CoW reservations:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty a single byte on a number of CoW reservations in the second file.
+# - Fsync to flush out the dirty pages.
+# - Wait for the reclaim to run.
+# - Write more and see how bad fragmentation is.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+old_cow_lifetime=$(cat /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime)
+
+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=65536
+nr=64
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+echo 2 > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Wait for CoW expiration"
+sleep 3
+
+echo "Allocate free space"
+for i in $(seq 1 32); do
+	"$XFS_IO_PROG" -f -c "falloc 0 1" "$testdir/junk.$i" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/junk" >> "$seqres.full"
+
+echo "CoW and leave leftovers"
+echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/231.out b/tests/xfs/231.out
new file mode 100644
index 0000000..872ce7b
--- /dev/null
+++ b/tests/xfs/231.out
@@ -0,0 +1,17 @@
+QA output created by 231
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file2
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file2.chk
+CoW and leave leftovers
+Wait for CoW expiration
+Allocate free space
+CoW and leave leftovers
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file1
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-231/file2
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-231/file2.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/232 b/tests/xfs/232
new file mode 100755
index 0000000..1cbc791
--- /dev/null
+++ b/tests/xfs/232
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 232
+#
+# Test non-recovery of unused CoW reservations for dirty files:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty a single byte on a number of CoW reservations in the second file.
+# - Fsync to flush out the dirty pages.
+# - Dirty a single byte anywhere in the second file.
+# - Wait for the reclaim to run.
+# - Write more and see how bad fragmentation is.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+old_cow_lifetime=$(cat /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime)
+
+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=65536
+nr=64
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+echo 2 > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Wait for CoW expiration"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * 2)) 1" "$testdir/file2" >> "$seqres.full"
+sleep 3
+
+echo "Allocate free space"
+for i in $(seq 1 32); do
+	"$XFS_IO_PROG" -f -c "falloc 0 1" "$testdir/junk.$i" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/junk" >> "$seqres.full"
+
+echo "CoW and leave leftovers"
+echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 12)) || _fail "file2 not sufficiently fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/232.out b/tests/xfs/232.out
new file mode 100644
index 0000000..ccabdaa
--- /dev/null
+++ b/tests/xfs/232.out
@@ -0,0 +1,17 @@
+QA output created by 232
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file2
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file2.chk
+CoW and leave leftovers
+Wait for CoW expiration
+Allocate free space
+CoW and leave leftovers
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file1
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-232/file2
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-232/file2.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index da83274..de3c7d6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -228,6 +228,8 @@
 228 auto quick clone
 229 auto rw
 230 auto quick clone
+231 auto quick clone
+232 auto quick clone
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick


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

* [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/231     |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/231.out |   17 +++++++
 tests/xfs/232     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/232.out |   17 +++++++
 tests/xfs/group   |    2 +
 5 files changed, 308 insertions(+)
 create mode 100755 tests/xfs/231
 create mode 100644 tests/xfs/231.out
 create mode 100755 tests/xfs/232
 create mode 100644 tests/xfs/232.out


diff --git a/tests/xfs/231 b/tests/xfs/231
new file mode 100755
index 0000000..d9ae102
--- /dev/null
+++ b/tests/xfs/231
@@ -0,0 +1,135 @@
+#! /bin/bash
+# FS QA Test No. 231
+#
+# Test recovery of unused CoW reservations:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty a single byte on a number of CoW reservations in the second file.
+# - Fsync to flush out the dirty pages.
+# - Wait for the reclaim to run.
+# - Write more and see how bad fragmentation is.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+old_cow_lifetime=$(cat /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime)
+
+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=65536
+nr=64
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+echo 2 > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Wait for CoW expiration"
+sleep 3
+
+echo "Allocate free space"
+for i in $(seq 1 32); do
+	"$XFS_IO_PROG" -f -c "falloc 0 1" "$testdir/junk.$i" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/junk" >> "$seqres.full"
+
+echo "CoW and leave leftovers"
+echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/231.out b/tests/xfs/231.out
new file mode 100644
index 0000000..872ce7b
--- /dev/null
+++ b/tests/xfs/231.out
@@ -0,0 +1,17 @@
+QA output created by 231
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file2
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file2.chk
+CoW and leave leftovers
+Wait for CoW expiration
+Allocate free space
+CoW and leave leftovers
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-231/file1
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-231/file2
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-231/file2.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/232 b/tests/xfs/232
new file mode 100755
index 0000000..1cbc791
--- /dev/null
+++ b/tests/xfs/232
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 232
+#
+# Test non-recovery of unused CoW reservations for dirty files:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Dirty a single byte on a number of CoW reservations in the second file.
+# - Fsync to flush out the dirty pages.
+# - Dirty a single byte anywhere in the second file.
+# - Wait for the reclaim to run.
+# - Write more and see how bad fragmentation is.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+    #rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+
+old_cow_lifetime=$(cat /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime)
+
+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=65536
+nr=64
+bsz=2
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+internal_blks=$((blksz * nr / real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file2.chk" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "CoW and leave leftovers"
+echo 2 > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f - 1)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Wait for CoW expiration"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * 2)) 1" "$testdir/file2" >> "$seqres.full"
+sleep 3
+
+echo "Allocate free space"
+for i in $(seq 1 32); do
+	"$XFS_IO_PROG" -f -c "falloc 0 1" "$testdir/junk.$i" >> "$seqres.full"
+done
+"$XFS_IO_PROG" -f -c "falloc 0 $((blksz * nr))" "$testdir/junk" >> "$seqres.full"
+
+echo "CoW and leave leftovers"
+echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
+seq 2 2 $((nr - 1)) | while read f; do
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
+	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
+done
+sync
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+md5sum "$testdir/file2.chk" | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents "$testdir/file1")
+new_extents=$(_count_extents "$testdir/file2")
+
+echo "old extents: $old_extents" >> "$seqres.full"
+echo "new extents: $new_extents" >> "$seqres.full"
+echo "maximum extents: $internal_blks" >> "$seqres.full"
+test $new_extents -lt $((internal_blks / 12)) || _fail "file2 not sufficiently fragmented"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/232.out b/tests/xfs/232.out
new file mode 100644
index 0000000..ccabdaa
--- /dev/null
+++ b/tests/xfs/232.out
@@ -0,0 +1,17 @@
+QA output created by 232
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file1
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file2
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file2.chk
+CoW and leave leftovers
+Wait for CoW expiration
+Allocate free space
+CoW and leave leftovers
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-232/file1
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-232/file2
+211b0f725e67149d75104a747365eb70  SCRATCH_MNT/test-232/file2.chk
+Check extent counts
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index da83274..de3c7d6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -228,6 +228,8 @@
 228 auto quick clone
 229 auto rw
 230 auto quick clone
+231 auto quick clone
+232 auto quick clone
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick

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

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

* [PATCH 19/23] xfs: test rmapbt functionality
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs        |   44 ++++++++++++++++++++++
 tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
 tests/xfs/233.out |    6 +++
 tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/234.out |    6 +++
 tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/235.out |   14 +++++++
 tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/236.out |    8 ++++
 tests/xfs/group   |    4 ++
 10 files changed, 450 insertions(+)
 create mode 100644 common/xfs
 create mode 100755 tests/xfs/233
 create mode 100644 tests/xfs/233.out
 create mode 100755 tests/xfs/234
 create mode 100644 tests/xfs/234.out
 create mode 100755 tests/xfs/235
 create mode 100644 tests/xfs/235.out
 create mode 100755 tests/xfs/236
 create mode 100644 tests/xfs/236.out


diff --git a/common/xfs b/common/xfs
new file mode 100644
index 0000000..2d1a76f
--- /dev/null
+++ b/common/xfs
@@ -0,0 +1,44 @@
+##/bin/bash
+# Routines for handling XFS
+#-----------------------------------------------------------------------
+#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will 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 to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+#  USA
+#
+#  Contact information: Oracle Corporation, 500 Oracle Parkway,
+#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
+#-----------------------------------------------------------------------
+
+_require_xfs_test_rmapbt()
+{
+	_require_test
+
+	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
+		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
+	fi
+}
+
+_require_xfs_scratch_rmapbt()
+{
+	_require_scratch
+
+	_scratch_mkfs > /dev/null
+	_scratch_mount
+	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
+		_scratch_unmount
+		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
+	fi
+	_scratch_unmount
+}
diff --git a/tests/xfs/233 b/tests/xfs/233
new file mode 100755
index 0000000..2e61275
--- /dev/null
+++ b/tests/xfs/233
@@ -0,0 +1,78 @@
+#! /bin/bash
+# FS QA Test No. 233
+#
+# Tests xfs_growfs on a rmapbt filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+
+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 files"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $((blksz * 14 + 71)) "$testdir/original" >> "$seqres.full"
+cp -p "$testdir/original" "$testdir/copy1"
+cp -p "$testdir/copy1" "$testdir/copy2"
+
+echo "Grow fs"
+"$XFS_GROWFS_PROG" "$SCRATCH_MNT" 2>&1 |  _filter_growfs >> "$seqres.full"
+_scratch_remount
+
+echo "Create more copies"
+cp -p "$testdir/original" "$testdir/copy3"
+
+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/233.out b/tests/xfs/233.out
new file mode 100644
index 0000000..7a7b991
--- /dev/null
+++ b/tests/xfs/233.out
@@ -0,0 +1,6 @@
+QA output created by 233
+Format and mount
+Create the original files
+Grow fs
+Create more copies
+Check scratch fs
diff --git a/tests/xfs/234 b/tests/xfs/234
new file mode 100755
index 0000000..1bdf8b2
--- /dev/null
+++ b/tests/xfs/234
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 234
+#
+# Ensure that we can create enough distinct rmap entries to force creation
+# of a multi-level rmap btree, and that metadump will successfully copy
+# said block.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".* "$testdir" "$metadump_file" "$TEST_DIR/image"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_loop
+_require_xfs_scratch_rmapbt
+_require_xfs_io_command "fpunch"
+
+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))
+_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+sync
+
+echo "Punch every other block"
+seq 1 2 $((nr_blks - 1)) | while read nr; do
+	"$XFS_IO_PROG" -c "fpunch $((nr * blksz)) $blksz" "$testdir/file1" >> "$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" "$TEST_DIR/image"
+_mount -t $FSTYP "$TEST_DIR/image" "$SCRATCH_MNT"
+umount "$SCRATCH_MNT"
+
+echo "Check restored fs"
+_check_generic_filesystem "$metadump_file"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/234.out b/tests/xfs/234.out
new file mode 100644
index 0000000..463d466
--- /dev/null
+++ b/tests/xfs/234.out
@@ -0,0 +1,6 @@
+QA output created by 234
+Create the original file blocks
+Punch every other block
+Create metadump file
+Restore metadump
+Check restored fs
diff --git a/tests/xfs/235 b/tests/xfs/235
new file mode 100755
index 0000000..4e34d3c
--- /dev/null
+++ b/tests/xfs/235
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 235
+#
+# Create and populate an XFS filesystem, corrupt the rmap btree,
+# then see how the kernel and xfs_repair deal with it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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-7031  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
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
+
+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"
+_pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * 64)) "${SCRATCH_MNT}/file1" >> "$seqres.full"
+cp -p "${SCRATCH_MNT}/file0" "${SCRATCH_MNT}/file2"
+cp -p "${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"
+seq 0 $((agcount - 1)) | while read ag; do
+	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr rmaproot" \
+		-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 "+ copy more"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 0 $((blksz * 64))" -c "fsync" "${SCRATCH_MNT}/file4" >> "$seqres.full"
+test -s "${SCRATCH_MNT}/file4" || _fail "should not be able to copy with busted rmap 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 "+ copy more (2)"
+cp -p "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file5" || \
+	_fail "modified rmap 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/235.out b/tests/xfs/235.out
new file mode 100644
index 0000000..89a11d6
--- /dev/null
+++ b/tests/xfs/235.out
@@ -0,0 +1,14 @@
+QA output created by 235
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ copy more
+fsync: Structure needs cleaning
++ repair fs
++ mount image (2)
++ chattr -R -i
++ copy more (2)
++ check fs (2)
diff --git a/tests/xfs/236 b/tests/xfs/236
new file mode 100755
index 0000000..d3a9edc
--- /dev/null
+++ b/tests/xfs/236
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 236
+#
+# Ensure that we can create enough distinct rmapbt entries to force creation
+# of a multi-level rmap btree.  Delete and recreate a few times to
+# exercise the rmap btree grow/shrink functions.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+_require_xfs_io_command "fpunch"
+
+rm -f "$seqres.full"
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original file blocks"
+blksz="$(stat -f "$testdir" -c '%S')"
+nr_blks=$((8 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x62 0 $((blksz * nr_blks)) "$testdir/file2" >> "$seqres.full"
+	sync
+
+	echo "$i: Reflink every other block"
+	seq 1 2 $((nr_blks - 1)) | while read nr; do
+		"$XFS_IO_PROG" -c "fpunch $((nr * blksz)) $blksz" "$testdir/file2" >> "$seqres.full"
+	done
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+
+	test "$i" = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf "$testdir/file1" "$testdir/file2"
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/236.out b/tests/xfs/236.out
new file mode 100644
index 0000000..237a7e1
--- /dev/null
+++ b/tests/xfs/236.out
@@ -0,0 +1,8 @@
+QA output created by 236
+Create the original file blocks
+1: Reflink every other block
+1: Delete both files
+2: Reflink every other block
+2: Delete both files
+x: Reflink every other block
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index de3c7d6..1d08065 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -230,6 +230,10 @@
 230 auto quick clone
 231 auto quick clone
 232 auto quick clone
+233 auto quick rmap
+234 auto quick rmap
+235 fuzzers rmap
+236 auto quick rmap
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick


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

* [PATCH 19/23] xfs: test rmapbt functionality
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs        |   44 ++++++++++++++++++++++
 tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
 tests/xfs/233.out |    6 +++
 tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/234.out |    6 +++
 tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/235.out |   14 +++++++
 tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/236.out |    8 ++++
 tests/xfs/group   |    4 ++
 10 files changed, 450 insertions(+)
 create mode 100644 common/xfs
 create mode 100755 tests/xfs/233
 create mode 100644 tests/xfs/233.out
 create mode 100755 tests/xfs/234
 create mode 100644 tests/xfs/234.out
 create mode 100755 tests/xfs/235
 create mode 100644 tests/xfs/235.out
 create mode 100755 tests/xfs/236
 create mode 100644 tests/xfs/236.out


diff --git a/common/xfs b/common/xfs
new file mode 100644
index 0000000..2d1a76f
--- /dev/null
+++ b/common/xfs
@@ -0,0 +1,44 @@
+##/bin/bash
+# Routines for handling XFS
+#-----------------------------------------------------------------------
+#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will 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 to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+#  USA
+#
+#  Contact information: Oracle Corporation, 500 Oracle Parkway,
+#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
+#-----------------------------------------------------------------------
+
+_require_xfs_test_rmapbt()
+{
+	_require_test
+
+	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
+		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
+	fi
+}
+
+_require_xfs_scratch_rmapbt()
+{
+	_require_scratch
+
+	_scratch_mkfs > /dev/null
+	_scratch_mount
+	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
+		_scratch_unmount
+		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
+	fi
+	_scratch_unmount
+}
diff --git a/tests/xfs/233 b/tests/xfs/233
new file mode 100755
index 0000000..2e61275
--- /dev/null
+++ b/tests/xfs/233
@@ -0,0 +1,78 @@
+#! /bin/bash
+# FS QA Test No. 233
+#
+# Tests xfs_growfs on a rmapbt filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+
+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 files"
+blksz="$(stat -f "$testdir" -c '%S')"
+_pwrite_byte 0x61 0 $((blksz * 14 + 71)) "$testdir/original" >> "$seqres.full"
+cp -p "$testdir/original" "$testdir/copy1"
+cp -p "$testdir/copy1" "$testdir/copy2"
+
+echo "Grow fs"
+"$XFS_GROWFS_PROG" "$SCRATCH_MNT" 2>&1 |  _filter_growfs >> "$seqres.full"
+_scratch_remount
+
+echo "Create more copies"
+cp -p "$testdir/original" "$testdir/copy3"
+
+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/233.out b/tests/xfs/233.out
new file mode 100644
index 0000000..7a7b991
--- /dev/null
+++ b/tests/xfs/233.out
@@ -0,0 +1,6 @@
+QA output created by 233
+Format and mount
+Create the original files
+Grow fs
+Create more copies
+Check scratch fs
diff --git a/tests/xfs/234 b/tests/xfs/234
new file mode 100755
index 0000000..1bdf8b2
--- /dev/null
+++ b/tests/xfs/234
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 234
+#
+# Ensure that we can create enough distinct rmap entries to force creation
+# of a multi-level rmap btree, and that metadump will successfully copy
+# said block.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".* "$testdir" "$metadump_file" "$TEST_DIR/image"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_loop
+_require_xfs_scratch_rmapbt
+_require_xfs_io_command "fpunch"
+
+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))
+_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+sync
+
+echo "Punch every other block"
+seq 1 2 $((nr_blks - 1)) | while read nr; do
+	"$XFS_IO_PROG" -c "fpunch $((nr * blksz)) $blksz" "$testdir/file1" >> "$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" "$TEST_DIR/image"
+_mount -t $FSTYP "$TEST_DIR/image" "$SCRATCH_MNT"
+umount "$SCRATCH_MNT"
+
+echo "Check restored fs"
+_check_generic_filesystem "$metadump_file"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/234.out b/tests/xfs/234.out
new file mode 100644
index 0000000..463d466
--- /dev/null
+++ b/tests/xfs/234.out
@@ -0,0 +1,6 @@
+QA output created by 234
+Create the original file blocks
+Punch every other block
+Create metadump file
+Restore metadump
+Check restored fs
diff --git a/tests/xfs/235 b/tests/xfs/235
new file mode 100755
index 0000000..4e34d3c
--- /dev/null
+++ b/tests/xfs/235
@@ -0,0 +1,108 @@
+#! /bin/bash
+# FS QA Test No. 235
+#
+# Create and populate an XFS filesystem, corrupt the rmap btree,
+# then see how the kernel and xfs_repair deal with it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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-7031  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
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+test -n "${FORCE_FUZZ}" || _require_scratch_xfs_crc
+
+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"
+_pwrite_byte 0x62 0 $((blksz * 64)) "${SCRATCH_MNT}/file0" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * 64)) "${SCRATCH_MNT}/file1" >> "$seqres.full"
+cp -p "${SCRATCH_MNT}/file0" "${SCRATCH_MNT}/file2"
+cp -p "${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"
+seq 0 $((agcount - 1)) | while read ag; do
+	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr rmaproot" \
+		-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 "+ copy more"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 0 $((blksz * 64))" -c "fsync" "${SCRATCH_MNT}/file4" >> "$seqres.full"
+test -s "${SCRATCH_MNT}/file4" || _fail "should not be able to copy with busted rmap 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 "+ copy more (2)"
+cp -p "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file5" || \
+	_fail "modified rmap 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/235.out b/tests/xfs/235.out
new file mode 100644
index 0000000..89a11d6
--- /dev/null
+++ b/tests/xfs/235.out
@@ -0,0 +1,14 @@
+QA output created by 235
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ copy more
+fsync: Structure needs cleaning
++ repair fs
++ mount image (2)
++ chattr -R -i
++ copy more (2)
++ check fs (2)
diff --git a/tests/xfs/236 b/tests/xfs/236
new file mode 100755
index 0000000..d3a9edc
--- /dev/null
+++ b/tests/xfs/236
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 236
+#
+# Ensure that we can create enough distinct rmapbt entries to force creation
+# of a multi-level rmap btree.  Delete and recreate a few times to
+# exercise the rmap btree grow/shrink functions.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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 /
+    umount "$SCRATCH_MNT" > /dev/null 2>&1
+    rm -rf "$tmp".* "$testdir"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+_require_xfs_io_command "fpunch"
+
+rm -f "$seqres.full"
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+echo "Create the original file blocks"
+blksz="$(stat -f "$testdir" -c '%S')"
+nr_blks=$((8 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) "$testdir/file1" >> "$seqres.full"
+	_pwrite_byte 0x62 0 $((blksz * nr_blks)) "$testdir/file2" >> "$seqres.full"
+	sync
+
+	echo "$i: Reflink every other block"
+	seq 1 2 $((nr_blks - 1)) | while read nr; do
+		"$XFS_IO_PROG" -c "fpunch $((nr * blksz)) $blksz" "$testdir/file2" >> "$seqres.full"
+	done
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+
+	test "$i" = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf "$testdir/file1" "$testdir/file2"
+	umount "$SCRATCH_MNT"
+	_check_scratch_fs
+	_scratch_mount
+done
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/236.out b/tests/xfs/236.out
new file mode 100644
index 0000000..237a7e1
--- /dev/null
+++ b/tests/xfs/236.out
@@ -0,0 +1,8 @@
+QA output created by 236
+Create the original file blocks
+1: Reflink every other block
+1: Delete both files
+2: Reflink every other block
+2: Delete both files
+x: Reflink every other block
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index de3c7d6..1d08065 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -230,6 +230,10 @@
 230 auto quick clone
 231 auto quick clone
 232 auto quick clone
+233 auto quick rmap
+234 auto quick rmap
+235 fuzzers rmap
+236 auto quick rmap
 238 auto quick metadata ioctl
 242 auto quick prealloc
 244 auto quota quick

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

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

* [PATCH 20/23] reflink: test aio copy on write
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:13   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Make sure that copy on write works with the AIO path.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/329     |  105 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/329.out |   12 +++++
 tests/generic/330     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/330.out |   11 +++++
 tests/generic/331     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/331.out |   12 +++++
 tests/generic/332     |   97 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/332.out |   11 +++++
 tests/generic/group   |    4 ++
 9 files changed, 455 insertions(+)
 create mode 100755 tests/generic/329
 create mode 100644 tests/generic/329.out
 create mode 100755 tests/generic/330
 create mode 100644 tests/generic/330.out
 create mode 100755 tests/generic/331
 create mode 100644 tests/generic/331.out
 create mode 100755 tests/generic/332
 create mode 100644 tests/generic/332.out


diff --git a/tests/generic/329 b/tests/generic/329
new file mode 100755
index 0000000..cf6dab0
--- /dev/null
+++ b/tests/generic/329
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 329
+#
+# Test AIO DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_aiodio "aiocp"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/329.out b/tests/generic/329.out
new file mode 100644
index 0000000..f14726c
--- /dev/null
+++ b/tests/generic/329.out
@@ -0,0 +1,12 @@
+QA output created by 329
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-329/file2
+Check for damage
diff --git a/tests/generic/330 b/tests/generic/330
new file mode 100755
index 0000000..d720f58
--- /dev/null
+++ b/tests/generic/330
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 330
+#
+# Test AIO DIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_aiodio "aiocp"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/330.out b/tests/generic/330.out
new file mode 100644
index 0000000..9a33a22
--- /dev/null
+++ b/tests/generic/330.out
@@ -0,0 +1,11 @@
+QA output created by 330
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-330/file2
+Check for damage
diff --git a/tests/generic/331 b/tests/generic/331
new file mode 100755
index 0000000..589150b
--- /dev/null
+++ b/tests/generic/331
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 331
+#
+# Test AIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -c "fdatasync" "$testdir/file2"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/331.out b/tests/generic/331.out
new file mode 100644
index 0000000..adbf841
--- /dev/null
+++ b/tests/generic/331.out
@@ -0,0 +1,12 @@
+QA output created by 331
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-331/file2
+Check for damage
diff --git a/tests/generic/332 b/tests/generic/332
new file mode 100755
index 0000000..7c24a61
--- /dev/null
+++ b/tests/generic/332
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 332
+#
+# Test AIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/332.out b/tests/generic/332.out
new file mode 100644
index 0000000..b584b1e
--- /dev/null
+++ b/tests/generic/332.out
@@ -0,0 +1,11 @@
+QA output created by 332
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-332/file2
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index d4531f8..b5ae5ad 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -331,3 +331,7 @@
 326 auto quick clone
 327 auto quick clone
 328 auto quick clone
+329 auto quick clone
+330 auto quick clone
+331 auto quick clone
+332 auto quick clone


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

* [PATCH 20/23] reflink: test aio copy on write
@ 2016-02-09  1:13   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:13 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Make sure that copy on write works with the AIO path.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/329     |  105 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/329.out |   12 +++++
 tests/generic/330     |   96 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/330.out |   11 +++++
 tests/generic/331     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/331.out |   12 +++++
 tests/generic/332     |   97 ++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/332.out |   11 +++++
 tests/generic/group   |    4 ++
 9 files changed, 455 insertions(+)
 create mode 100755 tests/generic/329
 create mode 100644 tests/generic/329.out
 create mode 100755 tests/generic/330
 create mode 100644 tests/generic/330.out
 create mode 100755 tests/generic/331
 create mode 100644 tests/generic/331.out
 create mode 100755 tests/generic/332
 create mode 100644 tests/generic/332.out


diff --git a/tests/generic/329 b/tests/generic/329
new file mode 100755
index 0000000..cf6dab0
--- /dev/null
+++ b/tests/generic/329
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 329
+#
+# Test AIO DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_aiodio "aiocp"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/329.out b/tests/generic/329.out
new file mode 100644
index 0000000..f14726c
--- /dev/null
+++ b/tests/generic/329.out
@@ -0,0 +1,12 @@
+QA output created by 329
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-329/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-329/file2
+Check for damage
diff --git a/tests/generic/330 b/tests/generic/330
new file mode 100755
index 0000000..d720f58
--- /dev/null
+++ b/tests/generic/330
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 330
+#
+# Test AIO DIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_aiodio "aiocp"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/330.out b/tests/generic/330.out
new file mode 100644
index 0000000..9a33a22
--- /dev/null
+++ b/tests/generic/330.out
@@ -0,0 +1,11 @@
+QA output created by 330
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-330/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-330/file2
+Check for damage
diff --git a/tests/generic/331 b/tests/generic/331
new file mode 100755
index 0000000..589150b
--- /dev/null
+++ b/tests/generic/331
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 331
+#
+# Test AIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -c "fdatasync" "$testdir/file2"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/331.out b/tests/generic/331.out
new file mode 100644
index 0000000..adbf841
--- /dev/null
+++ b/tests/generic/331.out
@@ -0,0 +1,12 @@
+QA output created by 331
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-331/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-331/file2
+Check for damage
diff --git a/tests/generic/332 b/tests/generic/332
new file mode 100755
index 0000000..7c24a61
--- /dev/null
+++ b/tests/generic/332
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 332
+#
+# Test AIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".* "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/332.out b/tests/generic/332.out
new file mode 100644
index 0000000..b584b1e
--- /dev/null
+++ b/tests/generic/332.out
@@ -0,0 +1,11 @@
+QA output created by 332
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-332/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-332/file2
+Check for damage
diff --git a/tests/generic/group b/tests/generic/group
index d4531f8..b5ae5ad 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -331,3 +331,7 @@
 326 auto quick clone
 327 auto quick clone
 328 auto quick clone
+329 auto quick clone
+330 auto quick clone
+331 auto quick clone
+332 auto quick clone

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

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

* [PATCH 21/23] xfs: aio cow tests
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/237     |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/237.out |   12 ++++++
 tests/xfs/239     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/239.out |   11 +++++
 tests/xfs/240     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/240.out |   12 ++++++
 tests/xfs/241     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/241.out |   11 +++++
 tests/xfs/group   |    4 ++
 9 files changed, 463 insertions(+)
 create mode 100755 tests/xfs/237
 create mode 100644 tests/xfs/237.out
 create mode 100755 tests/xfs/239
 create mode 100644 tests/xfs/239.out
 create mode 100755 tests/xfs/240
 create mode 100644 tests/xfs/240.out
 create mode 100755 tests/xfs/241
 create mode 100644 tests/xfs/241.out


diff --git a/tests/xfs/237 b/tests/xfs/237
new file mode 100755
index 0000000..8288724
--- /dev/null
+++ b/tests/xfs/237
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 237
+#
+# Test AIO DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_xfs_io_command "cowextsize"
+_require_aiodio "aiocp"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/237.out b/tests/xfs/237.out
new file mode 100644
index 0000000..c83dd8b
--- /dev/null
+++ b/tests/xfs/237.out
@@ -0,0 +1,12 @@
+QA output created by 237
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-237/file2
+Check for damage
diff --git a/tests/xfs/239 b/tests/xfs/239
new file mode 100755
index 0000000..dfb1107
--- /dev/null
+++ b/tests/xfs/239
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 239
+#
+# Test AIO DIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "cowextsize"
+_require_aiodio "aiocp"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/239.out b/tests/xfs/239.out
new file mode 100644
index 0000000..a123da9
--- /dev/null
+++ b/tests/xfs/239.out
@@ -0,0 +1,11 @@
+QA output created by 239
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-239/file2
+Check for damage
diff --git a/tests/xfs/240 b/tests/xfs/240
new file mode 100755
index 0000000..100beba
--- /dev/null
+++ b/tests/xfs/240
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 240
+#
+# Test AIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_xfs_io_command "cowextsize"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -c "fdatasync" "$testdir/file2"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/240.out b/tests/xfs/240.out
new file mode 100644
index 0000000..1a22e8a
--- /dev/null
+++ b/tests/xfs/240.out
@@ -0,0 +1,12 @@
+QA output created by 240
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-240/file2
+Check for damage
diff --git a/tests/xfs/241 b/tests/xfs/241
new file mode 100755
index 0000000..3fdb9c3
--- /dev/null
+++ b/tests/xfs/241
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 241
+#
+# Test AIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "cowextsize"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/241.out b/tests/xfs/241.out
new file mode 100644
index 0000000..a7e7df2
--- /dev/null
+++ b/tests/xfs/241.out
@@ -0,0 +1,11 @@
+QA output created by 241
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-241/file2
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index 1d08065..c0ce1f4 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -234,7 +234,11 @@
 234 auto quick rmap
 235 fuzzers rmap
 236 auto quick rmap
+237 auto quick clone
 238 auto quick metadata ioctl
+239 auto quick clone
+240 auto quick clone
+241 auto quick clone
 242 auto quick prealloc
 244 auto quota quick
 250 auto quick rw prealloc metadata


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

* [PATCH 21/23] xfs: aio cow tests
@ 2016-02-09  1:14   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/237     |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/237.out |   12 ++++++
 tests/xfs/239     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/239.out |   11 +++++
 tests/xfs/240     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/240.out |   12 ++++++
 tests/xfs/241     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/241.out |   11 +++++
 tests/xfs/group   |    4 ++
 9 files changed, 463 insertions(+)
 create mode 100755 tests/xfs/237
 create mode 100644 tests/xfs/237.out
 create mode 100755 tests/xfs/239
 create mode 100644 tests/xfs/239.out
 create mode 100755 tests/xfs/240
 create mode 100644 tests/xfs/240.out
 create mode 100755 tests/xfs/241
 create mode 100644 tests/xfs/241.out


diff --git a/tests/xfs/237 b/tests/xfs/237
new file mode 100755
index 0000000..8288724
--- /dev/null
+++ b/tests/xfs/237
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 237
+#
+# Test AIO DIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_xfs_io_command "cowextsize"
+_require_aiodio "aiocp"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/237.out b/tests/xfs/237.out
new file mode 100644
index 0000000..c83dd8b
--- /dev/null
+++ b/tests/xfs/237.out
@@ -0,0 +1,12 @@
+QA output created by 237
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file2
+CoW and unmount
+write missed bytes expect 8388608 got 0
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-237/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-237/file2
+Check for damage
diff --git a/tests/xfs/239 b/tests/xfs/239
new file mode 100755
index 0000000..dfb1107
--- /dev/null
+++ b/tests/xfs/239
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 239
+#
+# Test AIO DIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "cowextsize"
+_require_aiodio "aiocp"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+sync
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+"$AIO_TEST" -f DIRECT -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/239.out b/tests/xfs/239.out
new file mode 100644
index 0000000..a123da9
--- /dev/null
+++ b/tests/xfs/239.out
@@ -0,0 +1,11 @@
+QA output created by 239
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-239/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-239/file2
+Check for damage
diff --git a/tests/xfs/240 b/tests/xfs/240
new file mode 100755
index 0000000..100beba
--- /dev/null
+++ b/tests/xfs/240
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 240
+#
+# Test AIO CoW behavior when the write temporarily fails.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+    _dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_dm_target error
+_require_xfs_io_command "cowextsize"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+rm -f "$seqres.full"
+
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_dmerror_init
+_dmerror_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf $testdir
+mkdir $testdir
+
+blksz=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+_dmerror_load_error_table
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -c "fdatasync" "$testdir/file2"
+_dmerror_load_working_table
+_dmerror_unmount
+_dmerror_mount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+_dmerror_unmount
+_dmerror_cleanup
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/240.out b/tests/xfs/240.out
new file mode 100644
index 0000000..1a22e8a
--- /dev/null
+++ b/tests/xfs/240.out
@@ -0,0 +1,12 @@
+QA output created by 240
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file2
+CoW and unmount
+fdatasync: Input/output error
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-240/file1
+d94b0ab13385aba594411c174b1cc13c  SCRATCH_MNT/test-240/file2
+Check for damage
diff --git a/tests/xfs/241 b/tests/xfs/241
new file mode 100755
index 0000000..3fdb9c3
--- /dev/null
+++ b/tests/xfs/241
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 241
+#
+# Test AIO CoW behavior.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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" "$TEST_DIR/moo"
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+_require_xfs_io_command "cowextsize"
+AIO_TEST="src/aio-dio-regress/aiocp"
+test -x "$AIO_TEST" || _notrun "aiocp not built"
+
+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=65536
+nr=640
+bsz=128
+
+free_blocks=$(stat -f -c '%a' "$testdir")
+real_blksz=$(stat -f -c '%S' "$testdir")
+space_needed=$(((blksz * nr * 3) * 5 / 4))
+space_avail=$((free_blocks * real_blksz))
+test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
+
+echo "Create the original files"
+"$XFS_IO_PROG" -c "cowextsize $((blksz * bsz * 2))" "$testdir"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b $((blksz * bsz)) 0 $((blksz * nr))" "$testdir/file1" >> "$seqres.full"
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "CoW and unmount"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
+"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
+sync
+"$AIO_TEST" -b $((blksz * bsz)) "$TEST_DIR/moo" "$testdir/file2" >> "$seqres.full"
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_repair_scratch_fs >> "$seqres.full" 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/241.out b/tests/xfs/241.out
new file mode 100644
index 0000000..a7e7df2
--- /dev/null
+++ b/tests/xfs/241.out
@@ -0,0 +1,11 @@
+QA output created by 241
+Format and mount
+Create the original files
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file1
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file2
+CoW and unmount
+Compare files
+1886e67cf8783e89ce6ddc5bb09a3944  SCRATCH_MNT/test-241/file1
+7a4d22297e80ff3c92cb1b3e4566d234  SCRATCH_MNT/test-241/file2
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index 1d08065..c0ce1f4 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -234,7 +234,11 @@
 234 auto quick rmap
 235 fuzzers rmap
 236 auto quick rmap
+237 auto quick clone
 238 auto quick metadata ioctl
+239 auto quick clone
+240 auto quick clone
+241 auto quick clone
 242 auto quick prealloc
 244 auto quota quick
 250 auto quick rw prealloc metadata

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

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

* [PATCH 22/23] xfs: test xfs_getbmapx behavior with shared extents
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Make sure that xfs_getbmapx behaves properly w.r.t. shared extents
and CoW fork reporting.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs        |   19 ++++++
 tests/xfs/243     |  169 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/243.out |   27 ++++++++
 tests/xfs/245     |   99 +++++++++++++++++++++++++++++++
 tests/xfs/245.out |   13 ++++
 tests/xfs/group   |    2 +
 6 files changed, 329 insertions(+)
 create mode 100755 tests/xfs/243
 create mode 100644 tests/xfs/243.out
 create mode 100755 tests/xfs/245
 create mode 100644 tests/xfs/245.out


diff --git a/common/xfs b/common/xfs
index 2d1a76f..91b7916 100644
--- a/common/xfs
+++ b/common/xfs
@@ -42,3 +42,22 @@ _require_xfs_scratch_rmapbt()
 	fi
 	_scratch_unmount
 }
+
+_xfs_bmapx_find() {
+	case "$1" in
+	"attr")
+		param="a"
+		;;
+	"cow")
+		param="c"
+		;;
+	*)
+		param="e"
+		;;
+	esac
+	shift
+	file="$1"
+	shift
+
+	"$XFS_IO_PROG" -c "bmap -${param}lpv" "$file" | grep -c "$@"
+}
diff --git a/tests/xfs/243 b/tests/xfs/243
new file mode 100755
index 0000000..a97e87e
--- /dev/null
+++ b/tests/xfs/243
@@ -0,0 +1,169 @@
+#! /bin/bash
+# FS QA Test No. 243
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+
+# 10 blocks are cow'd
+seq 0 10 $((nr/2)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) 1 "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) 1 "$testdir/file3.chk" >> "$seqres.full"
+done
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Dump extents"
+"$XFS_IO_PROG" -c "cowextsize" "$testdir/file3" | _filter_scratch
+echo "Delayed allocation CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" delalloc) -gt 0 || \
+	echo "Expected to find a delalloc CoW extent"
+echo "Shared data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+echo "Unwritten data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten data extent"
+echo "Hole data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" hole) -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Regular data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '000000$') -gt 0 || \
+	echo "Expected to find a regular data extent"
+
+sync
+
+echo "Dump extents after sync"
+"$XFS_IO_PROG" -c "cowextsize" "$testdir/file3" | _filter_scratch
+echo "Delayed allocation CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" -v hole ) -gt 0 || \
+	echo "Expected to find a regular CoW extent"
+echo "Real CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" delalloc ) -eq 0 || \
+	echo "Expected to find zero delalloc CoW extent"
+echo "Shared data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+echo "Unwritten data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten data extent"
+echo "Hole data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" hole) -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Regular data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '000000$') -gt 0 || \
+	echo "Expected to find a regular data extent"
+
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/243.out b/tests/xfs/243.out
new file mode 100644
index 0000000..0390be7
--- /dev/null
+++ b/tests/xfs/243.out
@@ -0,0 +1,27 @@
+QA output created by 243
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-243/file1
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3.chk
+Dump extents
+[1048576] SCRATCH_MNT/test-243/file3
+Delayed allocation CoW extents:
+Shared data extents:
+Unwritten data extents:
+Hole data extents:
+Regular data extents:
+Dump extents after sync
+[1048576] SCRATCH_MNT/test-243/file3
+Delayed allocation CoW extents:
+Real CoW extents:
+Shared data extents:
+Unwritten data extents:
+Hole data extents:
+Regular data extents:
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-243/file1
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3.chk
+Check for damage
diff --git a/tests/xfs/245 b/tests/xfs/245
new file mode 100755
index 0000000..8da1abe
--- /dev/null
+++ b/tests/xfs/245
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 245
+#
+# Make sure that reflink deals with extents going beyond EOF.
+# - fallocate 256k in file1
+# - pwrite 252-257k to cause it to speculatively prealloc file1
+# - reflink file1 to file2
+# - compare file[12]
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_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 "Create the original files"
+"$XFS_IO_PROG" -f -c "falloc 0 256k" -c "pwrite 252k 6k" "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Unwritten data extents"
+test $(_xfs_bmapx_find data "$testdir/file1" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten file1 extent"
+echo "Shared data extents"
+test $(_xfs_bmapx_find data "$testdir/file1" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+
+echo "Hole data extents"
+test $(_xfs_bmapx_find data "$testdir/file2" 'hole') -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Shared data extents"
+test $(_xfs_bmapx_find data "$testdir/file2" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+
+echo "Hole cow extents"
+test $(_xfs_bmapx_find cow "$testdir/file1" 'hole') -gt 0 || \
+	echo "Expected to find a hole cow extent"
+echo "Hole cow extents"
+test $(_xfs_bmapx_find cow "$testdir/file2" 'hole') -gt 0 || \
+	echo "Expected to find a hole cow extent"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/245.out b/tests/xfs/245.out
new file mode 100644
index 0000000..92a2cbe
--- /dev/null
+++ b/tests/xfs/245.out
@@ -0,0 +1,13 @@
+QA output created by 245
+Format and mount
+Create the original files
+Compare files
+b0b91e1a18165fcd6549f2f5f3ef4823  SCRATCH_MNT/test-245/file1
+b0b91e1a18165fcd6549f2f5f3ef4823  SCRATCH_MNT/test-245/file2
+Unwritten data extents
+Shared data extents
+Hole data extents
+Shared data extents
+Hole cow extents
+Hole cow extents
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index c0ce1f4..23fc180 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -240,7 +240,9 @@
 240 auto quick clone
 241 auto quick clone
 242 auto quick prealloc
+243 auto quick clone
 244 auto quota quick
+245 auto quick clone
 250 auto quick rw prealloc metadata
 252 auto quick prealloc
 253 auto quick


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

* [PATCH 22/23] xfs: test xfs_getbmapx behavior with shared extents
@ 2016-02-09  1:14   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Make sure that xfs_getbmapx behaves properly w.r.t. shared extents
and CoW fork reporting.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/xfs        |   19 ++++++
 tests/xfs/243     |  169 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/243.out |   27 ++++++++
 tests/xfs/245     |   99 +++++++++++++++++++++++++++++++
 tests/xfs/245.out |   13 ++++
 tests/xfs/group   |    2 +
 6 files changed, 329 insertions(+)
 create mode 100755 tests/xfs/243
 create mode 100644 tests/xfs/243.out
 create mode 100755 tests/xfs/245
 create mode 100644 tests/xfs/245.out


diff --git a/common/xfs b/common/xfs
index 2d1a76f..91b7916 100644
--- a/common/xfs
+++ b/common/xfs
@@ -42,3 +42,22 @@ _require_xfs_scratch_rmapbt()
 	fi
 	_scratch_unmount
 }
+
+_xfs_bmapx_find() {
+	case "$1" in
+	"attr")
+		param="a"
+		;;
+	"cow")
+		param="c"
+		;;
+	*)
+		param="e"
+		;;
+	esac
+	shift
+	file="$1"
+	shift
+
+	"$XFS_IO_PROG" -c "bmap -${param}lpv" "$file" | grep -c "$@"
+}
diff --git a/tests/xfs/243 b/tests/xfs/243
new file mode 100755
index 0000000..a97e87e
--- /dev/null
+++ b/tests/xfs/243
@@ -0,0 +1,169 @@
+#! /bin/bash
+# FS QA Test No. 243
+#
+# Ensuring that copy on write in buffered mode works when the CoW
+# range originally covers multiple extents, some unwritten, some not.
+#   - Set cowextsize hint.
+#   - Create a file with the following repeating sequence of blocks:
+#     1. reflinked
+#     2. unwritten
+#     3. hole
+#     4. regular block
+#     5. delalloc
+#   - CoW across the halfway mark, starting with the unwritten extent.
+#   - Check that the files are now different where we say they're different.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_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 "Create the original files"
+blksz=65536
+nr=64
+real_blksz=$(stat -f -c '%S' "$testdir")
+internal_blks=$((blksz * nr / real_blksz))
+"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
+$XFS_IO_PROG -f -c "truncate $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
+# 0 blocks are reflinked
+seq 0 5 $nr | while read f; do
+	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 1 blocks are unwritten
+seq 1 5 $nr | while read f; do
+	$XFS_IO_PROG -f -c "falloc $((blksz * f)) $blksz" "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 2 blocks are holes
+seq 2 5 $nr | while read f; do
+	_pwrite_byte 0x00 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+# 3 blocks are regular
+seq 3 5 $nr | while read f; do
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x71 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+sync
+# 4 blocks are delalloc (do later)
+seq 4 5 $nr | while read f; do
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x62 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
+done
+
+# 10 blocks are cow'd
+seq 0 10 $((nr/2)) | while read f; do
+	_pwrite_byte 0x61 $((blksz * f)) 1 "$testdir/file3" >> "$seqres.full"
+	_pwrite_byte 0x61 $((blksz * f)) 1 "$testdir/file3.chk" >> "$seqres.full"
+done
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Dump extents"
+"$XFS_IO_PROG" -c "cowextsize" "$testdir/file3" | _filter_scratch
+echo "Delayed allocation CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" delalloc) -gt 0 || \
+	echo "Expected to find a delalloc CoW extent"
+echo "Shared data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+echo "Unwritten data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten data extent"
+echo "Hole data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" hole) -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Regular data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '000000$') -gt 0 || \
+	echo "Expected to find a regular data extent"
+
+sync
+
+echo "Dump extents after sync"
+"$XFS_IO_PROG" -c "cowextsize" "$testdir/file3" | _filter_scratch
+echo "Delayed allocation CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" -v hole ) -gt 0 || \
+	echo "Expected to find a regular CoW extent"
+echo "Real CoW extents:"
+test $(_xfs_bmapx_find cow "$testdir/file3" delalloc ) -eq 0 || \
+	echo "Expected to find zero delalloc CoW extent"
+echo "Shared data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+echo "Unwritten data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten data extent"
+echo "Hole data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" hole) -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Regular data extents:"
+test $(_xfs_bmapx_find data "$testdir/file3" '000000$') -gt 0 || \
+	echo "Expected to find a regular data extent"
+
+_scratch_remount
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file3" | _filter_scratch
+md5sum "$testdir/file3.chk" | _filter_scratch
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/243.out b/tests/xfs/243.out
new file mode 100644
index 0000000..0390be7
--- /dev/null
+++ b/tests/xfs/243.out
@@ -0,0 +1,27 @@
+QA output created by 243
+Format and mount
+Create the original files
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-243/file1
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3.chk
+Dump extents
+[1048576] SCRATCH_MNT/test-243/file3
+Delayed allocation CoW extents:
+Shared data extents:
+Unwritten data extents:
+Hole data extents:
+Regular data extents:
+Dump extents after sync
+[1048576] SCRATCH_MNT/test-243/file3
+Delayed allocation CoW extents:
+Real CoW extents:
+Shared data extents:
+Unwritten data extents:
+Hole data extents:
+Regular data extents:
+Compare files
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-243/file1
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3
+d0fda5bf5d4fd70904ef1c1c56db28d0  SCRATCH_MNT/test-243/file3.chk
+Check for damage
diff --git a/tests/xfs/245 b/tests/xfs/245
new file mode 100755
index 0000000..8da1abe
--- /dev/null
+++ b/tests/xfs/245
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 245
+#
+# Make sure that reflink deals with extents going beyond EOF.
+# - fallocate 256k in file1
+# - pwrite 252-257k to cause it to speculatively prealloc file1
+# - reflink file1 to file2
+# - compare file[12]
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, 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".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/xfs
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_xfs_io_command "falloc"
+_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 "Create the original files"
+"$XFS_IO_PROG" -f -c "falloc 0 256k" -c "pwrite 252k 6k" "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+_cp_reflink "$testdir/file1" "$testdir/file2" >> "$seqres.full"
+
+echo "Compare files"
+md5sum "$testdir/file1" | _filter_scratch
+md5sum "$testdir/file2" | _filter_scratch
+
+echo "Unwritten data extents"
+test $(_xfs_bmapx_find data "$testdir/file1" '10000$') -gt 0 || \
+	echo "Expected to find an unwritten file1 extent"
+echo "Shared data extents"
+test $(_xfs_bmapx_find data "$testdir/file1" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+
+echo "Hole data extents"
+test $(_xfs_bmapx_find data "$testdir/file2" 'hole') -gt 0 || \
+	echo "Expected to find a hole data extent"
+echo "Shared data extents"
+test $(_xfs_bmapx_find data "$testdir/file2" '100000$') -gt 0 || \
+	echo "Expected to find a shared data extent"
+
+echo "Hole cow extents"
+test $(_xfs_bmapx_find cow "$testdir/file1" 'hole') -gt 0 || \
+	echo "Expected to find a hole cow extent"
+echo "Hole cow extents"
+test $(_xfs_bmapx_find cow "$testdir/file2" 'hole') -gt 0 || \
+	echo "Expected to find a hole cow extent"
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/245.out b/tests/xfs/245.out
new file mode 100644
index 0000000..92a2cbe
--- /dev/null
+++ b/tests/xfs/245.out
@@ -0,0 +1,13 @@
+QA output created by 245
+Format and mount
+Create the original files
+Compare files
+b0b91e1a18165fcd6549f2f5f3ef4823  SCRATCH_MNT/test-245/file1
+b0b91e1a18165fcd6549f2f5f3ef4823  SCRATCH_MNT/test-245/file2
+Unwritten data extents
+Shared data extents
+Hole data extents
+Shared data extents
+Hole cow extents
+Hole cow extents
+Check for damage
diff --git a/tests/xfs/group b/tests/xfs/group
index c0ce1f4..23fc180 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -240,7 +240,9 @@
 240 auto quick clone
 241 auto quick clone
 242 auto quick prealloc
+243 auto quick clone
 244 auto quota quick
+245 auto quick clone
 250 auto quick rw prealloc metadata
 252 auto quick prealloc
 253 auto quick

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

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

* [PATCH 23/23] reflink: test reflink+cow+enospc all at the same time
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  1:14   ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Set up an impossibly small filesystem and try to reflink and rewrite a
file on it to see what happens when we ENOSPC.  Basically
generic/16[67] but with a constrained fs size.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/166     |    6 ++-
 tests/generic/167     |    6 ++-
 tests/generic/333     |  104 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/333.out |    6 +++
 tests/generic/334     |  104 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/334.out |    6 +++
 tests/generic/group   |    2 +
 7 files changed, 232 insertions(+), 2 deletions(-)
 create mode 100755 tests/generic/333
 create mode 100644 tests/generic/333.out
 create mode 100755 tests/generic/334
 create mode 100644 tests/generic/334.out


diff --git a/tests/generic/166 b/tests/generic/166
index 2c2ff4e..30d76a0 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -69,7 +69,11 @@ _scratch_remount
 snappy() {
 	n=0
 	while [ ! -e "$testdir/finished" ]; do
-		_cp_reflink "$testdir/file1" "$testdir/snap_$n" || break
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
 		n=$((n + 1))
 	done
 }
diff --git a/tests/generic/167 b/tests/generic/167
index b80b481..5198a81 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -69,7 +69,11 @@ _scratch_remount
 snappy() {
 	n=0
 	while [ ! -e "$testdir/finished" ]; do
-		_cp_reflink "$testdir/file1" "$testdir/snap_$n" || break
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
 		n=$((n + 1))
 	done
 }
diff --git a/tests/generic/333 b/tests/generic/333
new file mode 100755
index 0000000..4ca7803
--- /dev/null
+++ b/tests/generic/333
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 333
+#
+# Test for races or FS corruption when trying to hit ENOSPC while DIO writing
+# to a file that's also the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs_sized $((400 * 1048576)) > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+loops=1024
+nr_loops=$((loops - 1))
+blksz=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * blksz)) "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e "$testdir/finished" ]; do
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
+		n=$((n + 1))
+	done
+	touch "$testdir/abort"
+}
+
+echo "Snapshot a file undergoing directio rewrite"
+snappy &
+seq 1 1000 | while read i; do
+	seq $nr_loops -1 0 | while read i; do
+		out="$(_pwrite_byte 0x63 $((i * blksz)) $blksz -d "$testdir/file1" 2>&1)"
+		echo "$out" >> "$seqres.full"
+		echo "$out" | grep -q "No space left" && touch "$testdir/abort"
+		echo "$out" | grep -qi "error" && touch "$testdir/abort"
+		test -e "$testdir/abort" && break
+	done
+	test -e "$testdir/abort" && break
+done
+touch "$testdir/finished"
+wait
+
+echo "Check for damage"
+_scratch_unmount
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/333.out b/tests/generic/333.out
new file mode 100644
index 0000000..501f2d6
--- /dev/null
+++ b/tests/generic/333.out
@@ -0,0 +1,6 @@
+QA output created by 333
+Format and mount
+Initialize file
+Snapshot a file undergoing directio rewrite
+Check for damage
+Done
diff --git a/tests/generic/334 b/tests/generic/334
new file mode 100755
index 0000000..a246711
--- /dev/null
+++ b/tests/generic/334
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 334
+#
+# Test for races or FS corruption when trying to hit ENOSPC while DIO writing
+# to a file that's also the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs_sized $((400 * 1048576)) > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+loops=1024
+nr_loops=$((loops - 1))
+blksz=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * blksz)) "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e "$testdir/finished" ]; do
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
+		n=$((n + 1))
+	done
+	touch "$testdir/abort"
+}
+
+echo "Snapshot a file undergoing buffered rewrite"
+snappy &
+seq 1 1000 | while read i; do
+	seq $nr_loops -1 0 | while read i; do
+		out="$(_pwrite_byte 0x63 $((i * blksz)) $blksz "$testdir/file1" 2>&1)"
+		echo "$out" >> "$seqres.full"
+		echo "$out" | grep -q "No space left" && touch "$testdir/abort"
+		echo "$out" | grep -qi "error" && touch "$testdir/abort"
+		test -e "$testdir/abort" && break
+	done
+	test -e "$testdir/abort" && break
+done
+touch "$testdir/finished"
+wait
+
+echo "Check for damage"
+_scratch_unmount
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/334.out b/tests/generic/334.out
new file mode 100644
index 0000000..c196ff1
--- /dev/null
+++ b/tests/generic/334.out
@@ -0,0 +1,6 @@
+QA output created by 334
+Format and mount
+Initialize file
+Snapshot a file undergoing buffered rewrite
+Check for damage
+Done
diff --git a/tests/generic/group b/tests/generic/group
index b5ae5ad..a23ffc9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -335,3 +335,5 @@
 330 auto quick clone
 331 auto quick clone
 332 auto quick clone
+333 auto quick clone
+334 auto quick clone


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

* [PATCH 23/23] reflink: test reflink+cow+enospc all at the same time
@ 2016-02-09  1:14   ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  1:14 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Set up an impossibly small filesystem and try to reflink and rewrite a
file on it to see what happens when we ENOSPC.  Basically
generic/16[67] but with a constrained fs size.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/166     |    6 ++-
 tests/generic/167     |    6 ++-
 tests/generic/333     |  104 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/333.out |    6 +++
 tests/generic/334     |  104 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/334.out |    6 +++
 tests/generic/group   |    2 +
 7 files changed, 232 insertions(+), 2 deletions(-)
 create mode 100755 tests/generic/333
 create mode 100644 tests/generic/333.out
 create mode 100755 tests/generic/334
 create mode 100644 tests/generic/334.out


diff --git a/tests/generic/166 b/tests/generic/166
index 2c2ff4e..30d76a0 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -69,7 +69,11 @@ _scratch_remount
 snappy() {
 	n=0
 	while [ ! -e "$testdir/finished" ]; do
-		_cp_reflink "$testdir/file1" "$testdir/snap_$n" || break
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
 		n=$((n + 1))
 	done
 }
diff --git a/tests/generic/167 b/tests/generic/167
index b80b481..5198a81 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -69,7 +69,11 @@ _scratch_remount
 snappy() {
 	n=0
 	while [ ! -e "$testdir/finished" ]; do
-		_cp_reflink "$testdir/file1" "$testdir/snap_$n" || break
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
 		n=$((n + 1))
 	done
 }
diff --git a/tests/generic/333 b/tests/generic/333
new file mode 100755
index 0000000..4ca7803
--- /dev/null
+++ b/tests/generic/333
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 333
+#
+# Test for races or FS corruption when trying to hit ENOSPC while DIO writing
+# to a file that's also the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs_sized $((400 * 1048576)) > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+loops=1024
+nr_loops=$((loops - 1))
+blksz=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * blksz)) "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e "$testdir/finished" ]; do
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
+		n=$((n + 1))
+	done
+	touch "$testdir/abort"
+}
+
+echo "Snapshot a file undergoing directio rewrite"
+snappy &
+seq 1 1000 | while read i; do
+	seq $nr_loops -1 0 | while read i; do
+		out="$(_pwrite_byte 0x63 $((i * blksz)) $blksz -d "$testdir/file1" 2>&1)"
+		echo "$out" >> "$seqres.full"
+		echo "$out" | grep -q "No space left" && touch "$testdir/abort"
+		echo "$out" | grep -qi "error" && touch "$testdir/abort"
+		test -e "$testdir/abort" && break
+	done
+	test -e "$testdir/abort" && break
+done
+touch "$testdir/finished"
+wait
+
+echo "Check for damage"
+_scratch_unmount
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/333.out b/tests/generic/333.out
new file mode 100644
index 0000000..501f2d6
--- /dev/null
+++ b/tests/generic/333.out
@@ -0,0 +1,6 @@
+QA output created by 333
+Format and mount
+Initialize file
+Snapshot a file undergoing directio rewrite
+Check for damage
+Done
diff --git a/tests/generic/334 b/tests/generic/334
new file mode 100755
index 0000000..a246711
--- /dev/null
+++ b/tests/generic/334
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 334
+#
+# Test for races or FS corruption when trying to hit ENOSPC while DIO writing
+# to a file that's also the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 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
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_reflink
+_require_cp_reflink
+
+echo "Format and mount"
+_scratch_mkfs_sized $((400 * 1048576)) > "$seqres.full" 2>&1
+_scratch_mount >> "$seqres.full" 2>&1
+
+testdir="$SCRATCH_MNT/test-$seq"
+rm -rf "$testdir"
+mkdir "$testdir"
+
+loops=1024
+nr_loops=$((loops - 1))
+blksz=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * blksz)) "$testdir/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+	n=0
+	while [ ! -e "$testdir/finished" ]; do
+		out="$(_cp_reflink "$testdir/file1" "$testdir/snap_$n" 2>&1)"
+		res=$?
+		echo "$out" | grep -q "No space left" && break
+		test -n "$out" && echo "$out"
+		test $res -ne 0 && break
+		n=$((n + 1))
+	done
+	touch "$testdir/abort"
+}
+
+echo "Snapshot a file undergoing buffered rewrite"
+snappy &
+seq 1 1000 | while read i; do
+	seq $nr_loops -1 0 | while read i; do
+		out="$(_pwrite_byte 0x63 $((i * blksz)) $blksz "$testdir/file1" 2>&1)"
+		echo "$out" >> "$seqres.full"
+		echo "$out" | grep -q "No space left" && touch "$testdir/abort"
+		echo "$out" | grep -qi "error" && touch "$testdir/abort"
+		test -e "$testdir/abort" && break
+	done
+	test -e "$testdir/abort" && break
+done
+touch "$testdir/finished"
+wait
+
+echo "Check for damage"
+_scratch_unmount
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/334.out b/tests/generic/334.out
new file mode 100644
index 0000000..c196ff1
--- /dev/null
+++ b/tests/generic/334.out
@@ -0,0 +1,6 @@
+QA output created by 334
+Format and mount
+Initialize file
+Snapshot a file undergoing buffered rewrite
+Check for damage
+Done
diff --git a/tests/generic/group b/tests/generic/group
index b5ae5ad..a23ffc9 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -335,3 +335,5 @@
 330 auto quick clone
 331 auto quick clone
 332 auto quick clone
+333 auto quick clone
+334 auto quick clone

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

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

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
  2016-02-09  1:11 ` Darrick J. Wong
@ 2016-02-09  7:21   ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:21 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:11:45PM -0800, Darrick J. Wong wrote:
> Happy New Year!
> 
> Dave Chinner: I've renumbered the new tests and pushed to github[3] if
> you'd like to pull.

Can you include the commit ID I should see at the head of the
tree so I can confirm I'm pulling the right branch?

BTW, git doesn't like this:

https://github.com/djwong/xfstests/tree/for-dave

What git really wants is the tree url with a separate branch name
like so:

https://github.com/djwong/xfstests.git for-dave

(i.e. the typical output from a git request-pull command)

> This is a (no longer) small patch set against the reflink/dedupe test
> cases in xfstests.  The first four patches fix errors in the existing
> reflink tests, some of which are from Christoph Hellwig.
> 
> Patches 5-6 refactor the dmerror code so that we can use it to
> simulate transient IO errors, then use this code to test that
> unwritten extent conversion does NOT happen after a directio write to
> an unwritten extent hits a disk error.   Due to a bug in the VFS
> directio code, ext4 can disclose stale disk contents if an aio dio
> write fails; XFS suffers this problem for any failing dio write to an
> unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
> directio updates to ease COW handling V2" (and a separate ext4 warning
> cleanup) is needed to fix this.
> 
> Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
> of the copy on write behavior that are necessary to support shared
> blocks.  The earlier patches focus on correct CoW behavior in the
> presence of IO errors during the copy-write, and the later patches
> focus on XFS' new cow-extent-size hint that greatly reduces
> fragmentation due to copy on write behavior by encouraging the
> allocator to allocate larger extents of replacement blocks.
> 
> Patches 10-12 and 14 perform stress testing on reflink and CoW to
> check the behaviors when we get close to maximum refcount, when we
> specify obnxiously large offsets and lengths, and when we try to
> reflink millions of extents at a time.
> 
> Patch 16 tests quota accounting behavior when reflink is enabled.
> 
> Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
> that things like metadump and growfs work correctly.
> 
> Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
> extents as having shared blocks.  XFS now follows btrfs and ocfs2
> FIEMAP behavior such that if any blocks of a file's extent are shared,
> the whole extent is marked shared.  This is in contrast to earlier
> XFS-only behavior that reported shared and non-shared regions as
> separate extents.

This may change - xfs_bmap doesn't combine extents in it's output
even if they are adjacent. For debugging purposes (which is what
xfs_bmap/fiemap is for), it's much better to be able to see the
exact extent layout and block sharing.

I suspect the solution of least surprise is to make fiemap behave
like the other filesystems, and make xfs_bmap behave in a manner
that is useful to us.... :P

> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
> xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
> tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
> 278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
> to run the cp_reflink tests) seemed to have a quota bug and crashes
> hard in 284 (but was otherwise fine).

Fun fun fun. I'll look through the patchs, and if there's nothing
major I'll pull it in once I get a commit ID from you.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
@ 2016-02-09  7:21   ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:21 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:11:45PM -0800, Darrick J. Wong wrote:
> Happy New Year!
> 
> Dave Chinner: I've renumbered the new tests and pushed to github[3] if
> you'd like to pull.

Can you include the commit ID I should see at the head of the
tree so I can confirm I'm pulling the right branch?

BTW, git doesn't like this:

https://github.com/djwong/xfstests/tree/for-dave

What git really wants is the tree url with a separate branch name
like so:

https://github.com/djwong/xfstests.git for-dave

(i.e. the typical output from a git request-pull command)

> This is a (no longer) small patch set against the reflink/dedupe test
> cases in xfstests.  The first four patches fix errors in the existing
> reflink tests, some of which are from Christoph Hellwig.
> 
> Patches 5-6 refactor the dmerror code so that we can use it to
> simulate transient IO errors, then use this code to test that
> unwritten extent conversion does NOT happen after a directio write to
> an unwritten extent hits a disk error.   Due to a bug in the VFS
> directio code, ext4 can disclose stale disk contents if an aio dio
> write fails; XFS suffers this problem for any failing dio write to an
> unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
> directio updates to ease COW handling V2" (and a separate ext4 warning
> cleanup) is needed to fix this.
> 
> Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
> of the copy on write behavior that are necessary to support shared
> blocks.  The earlier patches focus on correct CoW behavior in the
> presence of IO errors during the copy-write, and the later patches
> focus on XFS' new cow-extent-size hint that greatly reduces
> fragmentation due to copy on write behavior by encouraging the
> allocator to allocate larger extents of replacement blocks.
> 
> Patches 10-12 and 14 perform stress testing on reflink and CoW to
> check the behaviors when we get close to maximum refcount, when we
> specify obnxiously large offsets and lengths, and when we try to
> reflink millions of extents at a time.
> 
> Patch 16 tests quota accounting behavior when reflink is enabled.
> 
> Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
> that things like metadump and growfs work correctly.
> 
> Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
> extents as having shared blocks.  XFS now follows btrfs and ocfs2
> FIEMAP behavior such that if any blocks of a file's extent are shared,
> the whole extent is marked shared.  This is in contrast to earlier
> XFS-only behavior that reported shared and non-shared regions as
> separate extents.

This may change - xfs_bmap doesn't combine extents in it's output
even if they are adjacent. For debugging purposes (which is what
xfs_bmap/fiemap is for), it's much better to be able to see the
exact extent layout and block sharing.

I suspect the solution of least surprise is to make fiemap behave
like the other filesystems, and make xfs_bmap behave in a manner
that is useful to us.... :P

> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
> xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
> tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
> 278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
> to run the cp_reflink tests) seemed to have a quota bug and crashes
> hard in 284 (but was otherwise fine).

Fun fun fun. I'll look through the patchs, and if there's nothing
major I'll pull it in once I get a commit ID from you.

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] 88+ messages in thread

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
  2016-02-09  7:21   ` Dave Chinner
@ 2016-02-09  7:25     ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:25 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 06:21:06PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:11:45PM -0800, Darrick J. Wong wrote:
> > Happy New Year!
> > 
> > Dave Chinner: I've renumbered the new tests and pushed to github[3] if
> > you'd like to pull.
> 
> Can you include the commit ID I should see at the head of the
> tree so I can confirm I'm pulling the right branch?

Heh, surprisingly, I've never ever sent a pull request to anyone, anywhere. :)

HEAD is 9799e5c5397b7aa14dbc660645ef4ccaf5418c78

> BTW, git doesn't like this:
> 
> https://github.com/djwong/xfstests/tree/for-dave
> 
> What git really wants is the tree url with a separate branch name
> like so:
> 
> https://github.com/djwong/xfstests.git for-dave
> 
> (i.e. the typical output from a git request-pull command)
> 
> > This is a (no longer) small patch set against the reflink/dedupe test
> > cases in xfstests.  The first four patches fix errors in the existing
> > reflink tests, some of which are from Christoph Hellwig.
> > 
> > Patches 5-6 refactor the dmerror code so that we can use it to
> > simulate transient IO errors, then use this code to test that
> > unwritten extent conversion does NOT happen after a directio write to
> > an unwritten extent hits a disk error.   Due to a bug in the VFS
> > directio code, ext4 can disclose stale disk contents if an aio dio
> > write fails; XFS suffers this problem for any failing dio write to an
> > unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
> > directio updates to ease COW handling V2" (and a separate ext4 warning
> > cleanup) is needed to fix this.
> > 
> > Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
> > of the copy on write behavior that are necessary to support shared
> > blocks.  The earlier patches focus on correct CoW behavior in the
> > presence of IO errors during the copy-write, and the later patches
> > focus on XFS' new cow-extent-size hint that greatly reduces
> > fragmentation due to copy on write behavior by encouraging the
> > allocator to allocate larger extents of replacement blocks.
> > 
> > Patches 10-12 and 14 perform stress testing on reflink and CoW to
> > check the behaviors when we get close to maximum refcount, when we
> > specify obnxiously large offsets and lengths, and when we try to
> > reflink millions of extents at a time.
> > 
> > Patch 16 tests quota accounting behavior when reflink is enabled.
> > 
> > Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
> > that things like metadump and growfs work correctly.
> > 
> > Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
> > extents as having shared blocks.  XFS now follows btrfs and ocfs2
> > FIEMAP behavior such that if any blocks of a file's extent are shared,
> > the whole extent is marked shared.  This is in contrast to earlier
> > XFS-only behavior that reported shared and non-shared regions as
> > separate extents.
> 
> This may change - xfs_bmap doesn't combine extents in it's output
> even if they are adjacent. For debugging purposes (which is what
> xfs_bmap/fiemap is for), it's much better to be able to see the
> exact extent layout and block sharing.
> 
> I suspect the solution of least surprise is to make fiemap behave
> like the other filesystems, and make xfs_bmap behave in a manner
> that is useful to us.... :P

Hehe.  Well... FIEMAP now /does/ act like the other filesystems.

But perhaps we can do better with getbmapx and show the exact
shared regions.  I thought about adding a flag for that, but...

> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
> > xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
> > tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
> > 278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
> > to run the cp_reflink tests) seemed to have a quota bug and crashes
> > hard in 284 (but was otherwise fine).
> 
> Fun fun fun. I'll look through the patchs, and if there's nothing
> major I'll pull it in once I get a commit ID from you.

:)

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com

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

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
@ 2016-02-09  7:25     ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:25 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 06:21:06PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:11:45PM -0800, Darrick J. Wong wrote:
> > Happy New Year!
> > 
> > Dave Chinner: I've renumbered the new tests and pushed to github[3] if
> > you'd like to pull.
> 
> Can you include the commit ID I should see at the head of the
> tree so I can confirm I'm pulling the right branch?

Heh, surprisingly, I've never ever sent a pull request to anyone, anywhere. :)

HEAD is 9799e5c5397b7aa14dbc660645ef4ccaf5418c78

> BTW, git doesn't like this:
> 
> https://github.com/djwong/xfstests/tree/for-dave
> 
> What git really wants is the tree url with a separate branch name
> like so:
> 
> https://github.com/djwong/xfstests.git for-dave
> 
> (i.e. the typical output from a git request-pull command)
> 
> > This is a (no longer) small patch set against the reflink/dedupe test
> > cases in xfstests.  The first four patches fix errors in the existing
> > reflink tests, some of which are from Christoph Hellwig.
> > 
> > Patches 5-6 refactor the dmerror code so that we can use it to
> > simulate transient IO errors, then use this code to test that
> > unwritten extent conversion does NOT happen after a directio write to
> > an unwritten extent hits a disk error.   Due to a bug in the VFS
> > directio code, ext4 can disclose stale disk contents if an aio dio
> > write fails; XFS suffers this problem for any failing dio write to an
> > unwritten extent.  Christoph's kernel patchset titled "vfs/xfs:
> > directio updates to ease COW handling V2" (and a separate ext4 warning
> > cleanup) is needed to fix this.
> > 
> > Patches 7-9, 13, 15, 17, 18, 20, 21, and 23 exercise various parts
> > of the copy on write behavior that are necessary to support shared
> > blocks.  The earlier patches focus on correct CoW behavior in the
> > presence of IO errors during the copy-write, and the later patches
> > focus on XFS' new cow-extent-size hint that greatly reduces
> > fragmentation due to copy on write behavior by encouraging the
> > allocator to allocate larger extents of replacement blocks.
> > 
> > Patches 10-12 and 14 perform stress testing on reflink and CoW to
> > check the behaviors when we get close to maximum refcount, when we
> > specify obnxiously large offsets and lengths, and when we try to
> > reflink millions of extents at a time.
> > 
> > Patch 16 tests quota accounting behavior when reflink is enabled.
> > 
> > Patch 19 adds a few tests for the XFS reverse mapping btree to ensure
> > that things like metadump and growfs work correctly.
> > 
> > Patch 22 checks that get_bmapx and fiemap (on XFS) correctly flag
> > extents as having shared blocks.  XFS now follows btrfs and ocfs2
> > FIEMAP behavior such that if any blocks of a file's extent are shared,
> > the whole extent is marked shared.  This is in contrast to earlier
> > XFS-only behavior that reported shared and non-shared regions as
> > separate extents.
> 
> This may change - xfs_bmap doesn't combine extents in it's output
> even if they are adjacent. For debugging purposes (which is what
> xfs_bmap/fiemap is for), it's much better to be able to see the
> exact extent layout and block sharing.
> 
> I suspect the solution of least surprise is to make fiemap behave
> like the other filesystems, and make xfs_bmap behave in a manner
> that is useful to us.... :P

Hehe.  Well... FIEMAP now /does/ act like the other filesystems.

But perhaps we can do better with getbmapx and show the exact
shared regions.  I thought about adding a flag for that, but...

> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], xfstests[3],
> > xfs-docs[4], and man-pages[5].  All tests should pass on XFS.   I
> > tried btrfs this weekend and it failed 166, 175, 182, 266, 271, 272,
> > 278, 281, 297, 298, 304, 333, and 334.  ocfs2 (when I jury-rigged it
> > to run the cp_reflink tests) seemed to have a quota bug and crashes
> > hard in 284 (but was otherwise fine).
> 
> Fun fun fun. I'll look through the patchs, and if there's nothing
> major I'll pull it in once I get a commit ID from you.

:)

--D

> 
> 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] 88+ messages in thread

* Re: [PATCH 10/23] xfs: more reflink tests
  2016-02-09  1:12   ` Darrick J. Wong
@ 2016-02-09  7:36     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:36 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:12:50PM -0800, Darrick J. Wong wrote:
> Create a couple of XFS-specific tests -- one to check that growing
> and shrinking the refcount btree works and a second one to check
> what happens when we hit maximum refcount.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
.....
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_reflink
> +_require_cp_reflink
....
> +
> +test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"

I suspect we need a _require rule for checking that something in
the test src directory has been built.

> +echo "Check scratch fs"
> +umount "$SCRATCH_MNT"
> +echo "check refcount after removing all files" >> "$seqres.full"
> +"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
> +"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
> +res=$?
> +if [ $res -eq 0 ]; then
> +	# If repair succeeds then format the device so that the post-test
> +	# check doesn't fail due to the single AG.
> +	_scratch_mkfs >> "$seqres.full" 2>&1
> +else
> +	_fail "xfs_repair fails"
> +fi
> +
> +# success, all done
> +status=0
> +exit

This is what _require_scratch_nocheck avoids.

i.e. do this instead:

_require_scratch_nocheck
.....

"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1 
status=$?
exit

Also, we really don't need the quotes around these global
variables.  They are just noise and lots of stuff will break if
those variables are set to something that requires them to be
quoted.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 10/23] xfs: more reflink tests
@ 2016-02-09  7:36     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:36 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:12:50PM -0800, Darrick J. Wong wrote:
> Create a couple of XFS-specific tests -- one to check that growing
> and shrinking the refcount btree works and a second one to check
> what happens when we hit maximum refcount.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
.....
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_scratch_reflink
> +_require_cp_reflink
....
> +
> +test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"

I suspect we need a _require rule for checking that something in
the test src directory has been built.

> +echo "Check scratch fs"
> +umount "$SCRATCH_MNT"
> +echo "check refcount after removing all files" >> "$seqres.full"
> +"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
> +"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
> +res=$?
> +if [ $res -eq 0 ]; then
> +	# If repair succeeds then format the device so that the post-test
> +	# check doesn't fail due to the single AG.
> +	_scratch_mkfs >> "$seqres.full" 2>&1
> +else
> +	_fail "xfs_repair fails"
> +fi
> +
> +# success, all done
> +status=0
> +exit

This is what _require_scratch_nocheck avoids.

i.e. do this instead:

_require_scratch_nocheck
.....

"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1 
status=$?
exit

Also, we really don't need the quotes around these global
variables.  They are just noise and lots of stuff will break if
those variables are set to something that requires them to be
quoted.

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] 88+ messages in thread

* Re: [PATCH 06/23] dio unwritten conversion bug tests
  2016-02-09  1:12   ` Darrick J. Wong
@ 2016-02-09  7:37     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:37 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:12:23PM -0800, Darrick J. Wong wrote:
> Check that we don't expose old disk contents when a directio write to
> an unwritten extent fails due to IO errors.  This primarily affects
> XFS and ext4.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
.....
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -252,7 +252,9 @@
>  247 auto quick rw
>  248 auto quick rw
>  249 auto quick rw
> +250 auto quick
>  251 ioctl trim
> +252 auto quick

Also should be in the prealloc group if we are testing unwritten
extent behaviour and the rw group because it's testing IO.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 06/23] dio unwritten conversion bug tests
@ 2016-02-09  7:37     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:37 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:12:23PM -0800, Darrick J. Wong wrote:
> Check that we don't expose old disk contents when a directio write to
> an unwritten extent fails due to IO errors.  This primarily affects
> XFS and ext4.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
.....
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -252,7 +252,9 @@
>  247 auto quick rw
>  248 auto quick rw
>  249 auto quick rw
> +250 auto quick
>  251 ioctl trim
> +252 auto quick

Also should be in the prealloc group if we are testing unwritten
extent behaviour and the rw group because it's testing IO.

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] 88+ messages in thread

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
  2016-02-09  1:13   ` Darrick J. Wong
@ 2016-02-09  7:43     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:43 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> Include the refcount and rmap structures in the golden output.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/xfs/122     |    3 +++
>  tests/xfs/122.out |    4 ++++
>  tests/xfs/group   |    2 +-
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/tests/xfs/122 b/tests/xfs/122
> index e6697a2..758cb50 100755
> --- a/tests/xfs/122
> +++ b/tests/xfs/122
> @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
>  xfs_dir3_icfree_hdr
>  xfs_dir3_icleaf_hdr
>  xfs_name
> +xfs_owner_info
> +xfs_refcount_irec
> +xfs_rmap_irec
>  xfs_alloctype_t
>  xfs_buf_cancel_t
>  xfs_bmbt_rec_32_t

So this is going to cause failures on any userspace that doesn't
know about these new types, right?

Should these be conditional in some way?

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
@ 2016-02-09  7:43     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  7:43 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> Include the refcount and rmap structures in the golden output.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/xfs/122     |    3 +++
>  tests/xfs/122.out |    4 ++++
>  tests/xfs/group   |    2 +-
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/tests/xfs/122 b/tests/xfs/122
> index e6697a2..758cb50 100755
> --- a/tests/xfs/122
> +++ b/tests/xfs/122
> @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
>  xfs_dir3_icfree_hdr
>  xfs_dir3_icleaf_hdr
>  xfs_name
> +xfs_owner_info
> +xfs_refcount_irec
> +xfs_rmap_irec
>  xfs_alloctype_t
>  xfs_buf_cancel_t
>  xfs_bmbt_rec_32_t

So this is going to cause failures on any userspace that doesn't
know about these new types, right?

Should these be conditional in some way?

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] 88+ messages in thread

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
  2016-02-09  7:25     ` Darrick J. Wong
@ 2016-02-09  7:50       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:50 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

Aha, /me finds git request-pull.  Sorry for the noise.

--D

The following changes since commit d98149c205559950c03d6b1d539e45fd35b5630e:

  Fix prerequisite packages to build fstests on Ubuntu (2016-02-08 09:27:15 +1100)

are available in the git repository at:

  https://github.com/djwong/xfstests for-dave

for you to fetch changes up to 9799e5c5397b7aa14dbc660645ef4ccaf5418c78:

  reflink: test reflink+cow+enospc all at the same time (2016-02-08 17:07:36 -0800)

----------------------------------------------------------------
Darrick J. Wong (23):
      generic/182: this is a dedupe test, check for dedupe
      xfstests: filter whitespace in 128 and 132
      xfstests: make _scratch_mkfs_blocksized usable
      reflink: remove redundant filesystem checks from the end of the tests
      common/dmerror: add some more dmerror routines
      dio unwritten conversion bug tests
      reflink: test intersecting CoW and falloc/fpunch/fzero/fcollapse/finsert/ftrunc
      reflink: test CoW behavior with IO errors
      reflink: test CoW operations against the source file
      xfs: more reflink tests
      reflink: ensure that we can handle reflinking a lot of extents
      xfs/122: support refcount/rmap data structures
      xfs: test fragmentation characteristics of copy-on-write
      reflink: high offset reflink and dedupe tests
      reflink: test xfs cow behavior when the filesystem crashes
      reflink: test quota accounting
      reflink: test CoW across a mixed range of block types with cowextsize set
      xfs: test the automatic cowextsize extent garbage collector
      xfs: test rmapbt functionality
      reflink: test aio copy on write
      xfs: aio cow tests
      xfs: test xfs_getbmapx behavior with shared extents
      reflink: test reflink+cow+enospc all at the same time

 .gitignore                  |   2 +
 common/dmerror              |  27 ++-
 common/rc                   |  52 +++++
 common/reflink              |  32 +--
 common/xfs                  |  63 ++++++
 src/Makefile                |   2 +-
 src/aio-dio-regress/aiocp.c | 489 ++++++++++++++++++++++++++++++++++++++++++++
 src/punch-alternating.c     |  59 ++++++
 tests/btrfs/100             |   2 +-
 tests/btrfs/101             |   2 +-
 tests/generic/157           |   1 -
 tests/generic/158           |   1 -
 tests/generic/161           |   1 -
 tests/generic/162           |   1 -
 tests/generic/163           |   1 -
 tests/generic/164           |   1 -
 tests/generic/165           |   1 -
 tests/generic/166           |   7 +-
 tests/generic/167           |   7 +-
 tests/generic/168           |   1 -
 tests/generic/170           |   1 -
 tests/generic/171           |   1 -
 tests/generic/172           |   1 -
 tests/generic/173           |   1 -
 tests/generic/174           |   1 -
 tests/generic/175           |  43 ++--
 tests/generic/175.out       |   6 +
 tests/generic/176           |  51 +++--
 tests/generic/176.out       |   4 +-
 tests/generic/182           |   9 +-
 tests/generic/183           |   1 -
 tests/generic/185           |   1 -
 tests/generic/186           |   1 -
 tests/generic/187           |   1 -
 tests/generic/188           |   1 -
 tests/generic/189           |   1 -
 tests/generic/190           |   1 -
 tests/generic/191           |   1 -
 tests/generic/194           |   1 -
 tests/generic/195           |   1 -
 tests/generic/196           |   3 +-
 tests/generic/197           |   3 +-
 tests/generic/199           |   1 -
 tests/generic/200           |   1 -
 tests/generic/201           |   1 -
 tests/generic/202           |   1 -
 tests/generic/203           |   1 -
 tests/generic/205           |   1 -
 tests/generic/206           |   1 -
 tests/generic/216           |   1 -
 tests/generic/217           |   1 -
 tests/generic/218           |   1 -
 tests/generic/220           |   1 -
 tests/generic/222           |   1 -
 tests/generic/227           |   1 -
 tests/generic/229           |   1 -
 tests/generic/238           |   1 -
 tests/generic/242           |   1 -
 tests/generic/243           |   1 -
 tests/generic/250           | 104 ++++++++++
 tests/generic/250.out       |  10 +
 tests/generic/252           | 107 ++++++++++
 tests/generic/252.out       |  10 +
 tests/generic/253           |  93 +++++++++
 tests/generic/253.out       |  13 ++
 tests/generic/254           |  93 +++++++++
 tests/generic/254.out       |  13 ++
 tests/generic/259           |  93 +++++++++
 tests/generic/259.out       |  13 ++
 tests/generic/261           |  93 +++++++++
 tests/generic/261.out       |  13 ++
 tests/generic/262           |  96 +++++++++
 tests/generic/262.out       |  13 ++
 tests/generic/264           |  93 +++++++++
 tests/generic/264.out       |  13 ++
 tests/generic/265           | 102 +++++++++
 tests/generic/265.out       |  11 +
 tests/generic/266           | 103 ++++++++++
 tests/generic/266.out       |  12 ++
 tests/generic/267           | 103 ++++++++++
 tests/generic/267.out       |  10 +
 tests/generic/268           | 106 ++++++++++
 tests/generic/268.out       |  12 ++
 tests/generic/271           | 102 +++++++++
 tests/generic/271.out       |  11 +
 tests/generic/272           | 103 ++++++++++
 tests/generic/272.out       |  12 ++
 tests/generic/276           | 103 ++++++++++
 tests/generic/276.out       |  11 +
 tests/generic/278           | 106 ++++++++++
 tests/generic/278.out       |  12 ++
 tests/generic/279           | 103 ++++++++++
 tests/generic/279.out       |  11 +
 tests/generic/281           | 104 ++++++++++
 tests/generic/281.out       |  12 ++
 tests/generic/282           | 104 ++++++++++
 tests/generic/282.out       |  10 +
 tests/generic/283           | 107 ++++++++++
 tests/generic/283.out       |  12 ++
 tests/generic/284           |  95 +++++++++
 tests/generic/284.out       |  13 ++
 tests/generic/287           |  95 +++++++++
 tests/generic/287.out       |  13 ++
 tests/generic/289           | 102 +++++++++
 tests/generic/289.out       |  13 ++
 tests/generic/290           | 102 +++++++++
 tests/generic/290.out       |  13 ++
 tests/generic/291           | 102 +++++++++
 tests/generic/291.out       |  13 ++
 tests/generic/292           | 102 +++++++++
 tests/generic/292.out       |  13 ++
 tests/generic/293           | 107 ++++++++++
 tests/generic/293.out       |  13 ++
 tests/generic/295           | 107 ++++++++++
 tests/generic/295.out       |  13 ++
 tests/generic/296           |  96 +++++++++
 tests/generic/296.out       |  13 ++
 tests/generic/297           | 101 +++++++++
 tests/generic/297.out       |   6 +
 tests/generic/298           | 101 +++++++++
 tests/generic/298.out       |   6 +
 tests/generic/301           | 105 ++++++++++
 tests/generic/301.out       |  11 +
 tests/generic/302           | 105 ++++++++++
 tests/generic/302.out       |  11 +
 tests/generic/303           |  99 +++++++++
 tests/generic/303.out       |  21 ++
 tests/generic/304           | 100 +++++++++
 tests/generic/304.out       |  22 ++
 tests/generic/305           | 105 ++++++++++
 tests/generic/305.out       |  23 +++
 tests/generic/326           | 105 ++++++++++
 tests/generic/326.out       |  23 +++
 tests/generic/327           |  92 +++++++++
 tests/generic/327.out       |  13 ++
 tests/generic/328           | 109 ++++++++++
 tests/generic/328.out       |  26 +++
 tests/generic/329           | 105 ++++++++++
 tests/generic/329.out       |  12 ++
 tests/generic/330           |  96 +++++++++
 tests/generic/330.out       |  11 +
 tests/generic/331           | 107 ++++++++++
 tests/generic/331.out       |  12 ++
 tests/generic/332           |  97 +++++++++
 tests/generic/332.out       |  11 +
 tests/generic/333           | 104 ++++++++++
 tests/generic/333.out       |   6 +
 tests/generic/334           | 104 ++++++++++
 tests/generic/334.out       |   6 +
 tests/generic/group         |  49 ++++-
 tests/xfs/122               |   3 +
 tests/xfs/122.out           |   4 +
 tests/xfs/127               |   1 -
 tests/xfs/128               |   3 +-
 tests/xfs/128.out           |   8 +-
 tests/xfs/131               |   1 -
 tests/xfs/132               |  10 +-
 tests/xfs/132.out           |  40 ++--
 tests/xfs/139               |   1 -
 tests/xfs/140               |   1 -
 tests/xfs/169               |  90 ++++++++
 tests/xfs/169.out           |   8 +
 tests/xfs/179               | 119 +++++++++++
 tests/xfs/179.out           |  10 +
 tests/xfs/180               | 111 ++++++++++
 tests/xfs/180.out           |  12 ++
 tests/xfs/182               | 111 ++++++++++
 tests/xfs/182.out           |  13 ++
 tests/xfs/184               | 110 ++++++++++
 tests/xfs/184.out           |  11 +
 tests/xfs/192               | 110 ++++++++++
 tests/xfs/192.out           |  11 +
 tests/xfs/193               | 107 ++++++++++
 tests/xfs/193.out           |  11 +
 tests/xfs/198               | 107 ++++++++++
 tests/xfs/198.out           |  11 +
 tests/xfs/200               | 114 +++++++++++
 tests/xfs/200.out           |  11 +
 tests/xfs/204               | 114 +++++++++++
 tests/xfs/204.out           |  11 +
 tests/xfs/207               | 104 ++++++++++
 tests/xfs/207.out           |  10 +
 tests/xfs/208               | 154 ++++++++++++++
 tests/xfs/208.out           |  15 ++
 tests/xfs/209               |  88 ++++++++
 tests/xfs/209.out           |   6 +
 tests/xfs/210               | 125 +++++++++++
 tests/xfs/210.out           |  14 ++
 tests/xfs/211               | 111 ++++++++++
 tests/xfs/211.out           |  12 ++
 tests/xfs/212               | 106 ++++++++++
 tests/xfs/212.out           |  14 ++
 tests/xfs/213               | 110 ++++++++++
 tests/xfs/213.out           |  23 +++
 tests/xfs/214               | 109 ++++++++++
 tests/xfs/214.out           |  23 +++
 tests/xfs/215               | 108 ++++++++++
 tests/xfs/215.out           |  14 ++
 tests/xfs/218               | 108 ++++++++++
 tests/xfs/218.out           |  14 ++
 tests/xfs/219               | 108 ++++++++++
 tests/xfs/219.out           |  14 ++
 tests/xfs/221               | 108 ++++++++++
 tests/xfs/221.out           |  14 ++
 tests/xfs/223               | 113 ++++++++++
 tests/xfs/223.out           |  14 ++
 tests/xfs/224               | 113 ++++++++++
 tests/xfs/224.out           |  14 ++
 tests/xfs/225               | 108 ++++++++++
 tests/xfs/225.out           |  14 ++
 tests/xfs/226               | 108 ++++++++++
 tests/xfs/226.out           |  14 ++
 tests/xfs/228               | 137 +++++++++++++
 tests/xfs/228.out           |  14 ++
 tests/xfs/230               | 137 +++++++++++++
 tests/xfs/230.out           |  14 ++
 tests/xfs/231               | 135 ++++++++++++
 tests/xfs/231.out           |  17 ++
 tests/xfs/232               | 137 +++++++++++++
 tests/xfs/232.out           |  17 ++
 tests/xfs/233               |  78 +++++++
 tests/xfs/233.out           |   6 +
 tests/xfs/234               |  89 ++++++++
 tests/xfs/234.out           |   6 +
 tests/xfs/235               | 108 ++++++++++
 tests/xfs/235.out           |  14 ++
 tests/xfs/236               |  93 +++++++++
 tests/xfs/236.out           |   8 +
 tests/xfs/237               | 107 ++++++++++
 tests/xfs/237.out           |  12 ++
 tests/xfs/239               |  98 +++++++++
 tests/xfs/239.out           |  11 +
 tests/xfs/240               | 109 ++++++++++
 tests/xfs/240.out           |  12 ++
 tests/xfs/241               |  99 +++++++++
 tests/xfs/241.out           |  11 +
 tests/xfs/243               | 169 +++++++++++++++
 tests/xfs/243.out           |  27 +++
 tests/xfs/245               |  99 +++++++++
 tests/xfs/245.out           |  13 ++
 tests/xfs/group             |  44 +++-
 241 files changed, 11012 insertions(+), 177 deletions(-)
 create mode 100644 common/xfs
 create mode 100644 src/aio-dio-regress/aiocp.c
 create mode 100644 src/punch-alternating.c
 create mode 100755 tests/generic/250
 create mode 100644 tests/generic/250.out
 create mode 100755 tests/generic/252
 create mode 100644 tests/generic/252.out
 create mode 100755 tests/generic/253
 create mode 100644 tests/generic/253.out
 create mode 100755 tests/generic/254
 create mode 100644 tests/generic/254.out
 create mode 100755 tests/generic/259
 create mode 100644 tests/generic/259.out
 create mode 100755 tests/generic/261
 create mode 100644 tests/generic/261.out
 create mode 100755 tests/generic/262
 create mode 100644 tests/generic/262.out
 create mode 100755 tests/generic/264
 create mode 100644 tests/generic/264.out
 create mode 100755 tests/generic/265
 create mode 100644 tests/generic/265.out
 create mode 100755 tests/generic/266
 create mode 100644 tests/generic/266.out
 create mode 100755 tests/generic/267
 create mode 100644 tests/generic/267.out
 create mode 100755 tests/generic/268
 create mode 100644 tests/generic/268.out
 create mode 100755 tests/generic/271
 create mode 100644 tests/generic/271.out
 create mode 100755 tests/generic/272
 create mode 100644 tests/generic/272.out
 create mode 100755 tests/generic/276
 create mode 100644 tests/generic/276.out
 create mode 100755 tests/generic/278
 create mode 100644 tests/generic/278.out
 create mode 100755 tests/generic/279
 create mode 100644 tests/generic/279.out
 create mode 100755 tests/generic/281
 create mode 100644 tests/generic/281.out
 create mode 100755 tests/generic/282
 create mode 100644 tests/generic/282.out
 create mode 100755 tests/generic/283
 create mode 100644 tests/generic/283.out
 create mode 100755 tests/generic/284
 create mode 100644 tests/generic/284.out
 create mode 100755 tests/generic/287
 create mode 100644 tests/generic/287.out
 create mode 100755 tests/generic/289
 create mode 100644 tests/generic/289.out
 create mode 100755 tests/generic/290
 create mode 100644 tests/generic/290.out
 create mode 100755 tests/generic/291
 create mode 100644 tests/generic/291.out
 create mode 100755 tests/generic/292
 create mode 100644 tests/generic/292.out
 create mode 100755 tests/generic/293
 create mode 100644 tests/generic/293.out
 create mode 100755 tests/generic/295
 create mode 100644 tests/generic/295.out
 create mode 100755 tests/generic/296
 create mode 100644 tests/generic/296.out
 create mode 100755 tests/generic/297
 create mode 100644 tests/generic/297.out
 create mode 100755 tests/generic/298
 create mode 100644 tests/generic/298.out
 create mode 100755 tests/generic/301
 create mode 100644 tests/generic/301.out
 create mode 100755 tests/generic/302
 create mode 100644 tests/generic/302.out
 create mode 100755 tests/generic/303
 create mode 100644 tests/generic/303.out
 create mode 100755 tests/generic/304
 create mode 100644 tests/generic/304.out
 create mode 100755 tests/generic/305
 create mode 100644 tests/generic/305.out
 create mode 100755 tests/generic/326
 create mode 100644 tests/generic/326.out
 create mode 100755 tests/generic/327
 create mode 100644 tests/generic/327.out
 create mode 100755 tests/generic/328
 create mode 100644 tests/generic/328.out
 create mode 100755 tests/generic/329
 create mode 100644 tests/generic/329.out
 create mode 100755 tests/generic/330
 create mode 100644 tests/generic/330.out
 create mode 100755 tests/generic/331
 create mode 100644 tests/generic/331.out
 create mode 100755 tests/generic/332
 create mode 100644 tests/generic/332.out
 create mode 100755 tests/generic/333
 create mode 100644 tests/generic/333.out
 create mode 100755 tests/generic/334
 create mode 100644 tests/generic/334.out
 create mode 100755 tests/xfs/169
 create mode 100644 tests/xfs/169.out
 create mode 100755 tests/xfs/179
 create mode 100644 tests/xfs/179.out
 create mode 100755 tests/xfs/180
 create mode 100644 tests/xfs/180.out
 create mode 100755 tests/xfs/182
 create mode 100644 tests/xfs/182.out
 create mode 100755 tests/xfs/184
 create mode 100644 tests/xfs/184.out
 create mode 100755 tests/xfs/192
 create mode 100644 tests/xfs/192.out
 create mode 100755 tests/xfs/193
 create mode 100644 tests/xfs/193.out
 create mode 100755 tests/xfs/198
 create mode 100644 tests/xfs/198.out
 create mode 100755 tests/xfs/200
 create mode 100644 tests/xfs/200.out
 create mode 100755 tests/xfs/204
 create mode 100644 tests/xfs/204.out
 create mode 100755 tests/xfs/207
 create mode 100644 tests/xfs/207.out
 create mode 100755 tests/xfs/208
 create mode 100644 tests/xfs/208.out
 create mode 100755 tests/xfs/209
 create mode 100644 tests/xfs/209.out
 create mode 100755 tests/xfs/210
 create mode 100644 tests/xfs/210.out
 create mode 100755 tests/xfs/211
 create mode 100644 tests/xfs/211.out
 create mode 100755 tests/xfs/212
 create mode 100644 tests/xfs/212.out
 create mode 100755 tests/xfs/213
 create mode 100644 tests/xfs/213.out
 create mode 100755 tests/xfs/214
 create mode 100644 tests/xfs/214.out
 create mode 100755 tests/xfs/215
 create mode 100644 tests/xfs/215.out
 create mode 100755 tests/xfs/218
 create mode 100644 tests/xfs/218.out
 create mode 100755 tests/xfs/219
 create mode 100644 tests/xfs/219.out
 create mode 100755 tests/xfs/221
 create mode 100644 tests/xfs/221.out
 create mode 100755 tests/xfs/223
 create mode 100644 tests/xfs/223.out
 create mode 100755 tests/xfs/224
 create mode 100644 tests/xfs/224.out
 create mode 100755 tests/xfs/225
 create mode 100644 tests/xfs/225.out
 create mode 100755 tests/xfs/226
 create mode 100644 tests/xfs/226.out
 create mode 100755 tests/xfs/228
 create mode 100644 tests/xfs/228.out
 create mode 100755 tests/xfs/230
 create mode 100644 tests/xfs/230.out
 create mode 100755 tests/xfs/231
 create mode 100644 tests/xfs/231.out
 create mode 100755 tests/xfs/232
 create mode 100644 tests/xfs/232.out
 create mode 100755 tests/xfs/233
 create mode 100644 tests/xfs/233.out
 create mode 100755 tests/xfs/234
 create mode 100644 tests/xfs/234.out
 create mode 100755 tests/xfs/235
 create mode 100644 tests/xfs/235.out
 create mode 100755 tests/xfs/236
 create mode 100644 tests/xfs/236.out
 create mode 100755 tests/xfs/237
 create mode 100644 tests/xfs/237.out
 create mode 100755 tests/xfs/239
 create mode 100644 tests/xfs/239.out
 create mode 100755 tests/xfs/240
 create mode 100644 tests/xfs/240.out
 create mode 100755 tests/xfs/241
 create mode 100644 tests/xfs/241.out
 create mode 100755 tests/xfs/243
 create mode 100644 tests/xfs/243.out
 create mode 100755 tests/xfs/245
 create mode 100644 tests/xfs/245.out

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

* Re: [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls
@ 2016-02-09  7:50       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:50 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

Aha, /me finds git request-pull.  Sorry for the noise.

--D

The following changes since commit d98149c205559950c03d6b1d539e45fd35b5630e:

  Fix prerequisite packages to build fstests on Ubuntu (2016-02-08 09:27:15 +1100)

are available in the git repository at:

  https://github.com/djwong/xfstests for-dave

for you to fetch changes up to 9799e5c5397b7aa14dbc660645ef4ccaf5418c78:

  reflink: test reflink+cow+enospc all at the same time (2016-02-08 17:07:36 -0800)

----------------------------------------------------------------
Darrick J. Wong (23):
      generic/182: this is a dedupe test, check for dedupe
      xfstests: filter whitespace in 128 and 132
      xfstests: make _scratch_mkfs_blocksized usable
      reflink: remove redundant filesystem checks from the end of the tests
      common/dmerror: add some more dmerror routines
      dio unwritten conversion bug tests
      reflink: test intersecting CoW and falloc/fpunch/fzero/fcollapse/finsert/ftrunc
      reflink: test CoW behavior with IO errors
      reflink: test CoW operations against the source file
      xfs: more reflink tests
      reflink: ensure that we can handle reflinking a lot of extents
      xfs/122: support refcount/rmap data structures
      xfs: test fragmentation characteristics of copy-on-write
      reflink: high offset reflink and dedupe tests
      reflink: test xfs cow behavior when the filesystem crashes
      reflink: test quota accounting
      reflink: test CoW across a mixed range of block types with cowextsize set
      xfs: test the automatic cowextsize extent garbage collector
      xfs: test rmapbt functionality
      reflink: test aio copy on write
      xfs: aio cow tests
      xfs: test xfs_getbmapx behavior with shared extents
      reflink: test reflink+cow+enospc all at the same time

 .gitignore                  |   2 +
 common/dmerror              |  27 ++-
 common/rc                   |  52 +++++
 common/reflink              |  32 +--
 common/xfs                  |  63 ++++++
 src/Makefile                |   2 +-
 src/aio-dio-regress/aiocp.c | 489 ++++++++++++++++++++++++++++++++++++++++++++
 src/punch-alternating.c     |  59 ++++++
 tests/btrfs/100             |   2 +-
 tests/btrfs/101             |   2 +-
 tests/generic/157           |   1 -
 tests/generic/158           |   1 -
 tests/generic/161           |   1 -
 tests/generic/162           |   1 -
 tests/generic/163           |   1 -
 tests/generic/164           |   1 -
 tests/generic/165           |   1 -
 tests/generic/166           |   7 +-
 tests/generic/167           |   7 +-
 tests/generic/168           |   1 -
 tests/generic/170           |   1 -
 tests/generic/171           |   1 -
 tests/generic/172           |   1 -
 tests/generic/173           |   1 -
 tests/generic/174           |   1 -
 tests/generic/175           |  43 ++--
 tests/generic/175.out       |   6 +
 tests/generic/176           |  51 +++--
 tests/generic/176.out       |   4 +-
 tests/generic/182           |   9 +-
 tests/generic/183           |   1 -
 tests/generic/185           |   1 -
 tests/generic/186           |   1 -
 tests/generic/187           |   1 -
 tests/generic/188           |   1 -
 tests/generic/189           |   1 -
 tests/generic/190           |   1 -
 tests/generic/191           |   1 -
 tests/generic/194           |   1 -
 tests/generic/195           |   1 -
 tests/generic/196           |   3 +-
 tests/generic/197           |   3 +-
 tests/generic/199           |   1 -
 tests/generic/200           |   1 -
 tests/generic/201           |   1 -
 tests/generic/202           |   1 -
 tests/generic/203           |   1 -
 tests/generic/205           |   1 -
 tests/generic/206           |   1 -
 tests/generic/216           |   1 -
 tests/generic/217           |   1 -
 tests/generic/218           |   1 -
 tests/generic/220           |   1 -
 tests/generic/222           |   1 -
 tests/generic/227           |   1 -
 tests/generic/229           |   1 -
 tests/generic/238           |   1 -
 tests/generic/242           |   1 -
 tests/generic/243           |   1 -
 tests/generic/250           | 104 ++++++++++
 tests/generic/250.out       |  10 +
 tests/generic/252           | 107 ++++++++++
 tests/generic/252.out       |  10 +
 tests/generic/253           |  93 +++++++++
 tests/generic/253.out       |  13 ++
 tests/generic/254           |  93 +++++++++
 tests/generic/254.out       |  13 ++
 tests/generic/259           |  93 +++++++++
 tests/generic/259.out       |  13 ++
 tests/generic/261           |  93 +++++++++
 tests/generic/261.out       |  13 ++
 tests/generic/262           |  96 +++++++++
 tests/generic/262.out       |  13 ++
 tests/generic/264           |  93 +++++++++
 tests/generic/264.out       |  13 ++
 tests/generic/265           | 102 +++++++++
 tests/generic/265.out       |  11 +
 tests/generic/266           | 103 ++++++++++
 tests/generic/266.out       |  12 ++
 tests/generic/267           | 103 ++++++++++
 tests/generic/267.out       |  10 +
 tests/generic/268           | 106 ++++++++++
 tests/generic/268.out       |  12 ++
 tests/generic/271           | 102 +++++++++
 tests/generic/271.out       |  11 +
 tests/generic/272           | 103 ++++++++++
 tests/generic/272.out       |  12 ++
 tests/generic/276           | 103 ++++++++++
 tests/generic/276.out       |  11 +
 tests/generic/278           | 106 ++++++++++
 tests/generic/278.out       |  12 ++
 tests/generic/279           | 103 ++++++++++
 tests/generic/279.out       |  11 +
 tests/generic/281           | 104 ++++++++++
 tests/generic/281.out       |  12 ++
 tests/generic/282           | 104 ++++++++++
 tests/generic/282.out       |  10 +
 tests/generic/283           | 107 ++++++++++
 tests/generic/283.out       |  12 ++
 tests/generic/284           |  95 +++++++++
 tests/generic/284.out       |  13 ++
 tests/generic/287           |  95 +++++++++
 tests/generic/287.out       |  13 ++
 tests/generic/289           | 102 +++++++++
 tests/generic/289.out       |  13 ++
 tests/generic/290           | 102 +++++++++
 tests/generic/290.out       |  13 ++
 tests/generic/291           | 102 +++++++++
 tests/generic/291.out       |  13 ++
 tests/generic/292           | 102 +++++++++
 tests/generic/292.out       |  13 ++
 tests/generic/293           | 107 ++++++++++
 tests/generic/293.out       |  13 ++
 tests/generic/295           | 107 ++++++++++
 tests/generic/295.out       |  13 ++
 tests/generic/296           |  96 +++++++++
 tests/generic/296.out       |  13 ++
 tests/generic/297           | 101 +++++++++
 tests/generic/297.out       |   6 +
 tests/generic/298           | 101 +++++++++
 tests/generic/298.out       |   6 +
 tests/generic/301           | 105 ++++++++++
 tests/generic/301.out       |  11 +
 tests/generic/302           | 105 ++++++++++
 tests/generic/302.out       |  11 +
 tests/generic/303           |  99 +++++++++
 tests/generic/303.out       |  21 ++
 tests/generic/304           | 100 +++++++++
 tests/generic/304.out       |  22 ++
 tests/generic/305           | 105 ++++++++++
 tests/generic/305.out       |  23 +++
 tests/generic/326           | 105 ++++++++++
 tests/generic/326.out       |  23 +++
 tests/generic/327           |  92 +++++++++
 tests/generic/327.out       |  13 ++
 tests/generic/328           | 109 ++++++++++
 tests/generic/328.out       |  26 +++
 tests/generic/329           | 105 ++++++++++
 tests/generic/329.out       |  12 ++
 tests/generic/330           |  96 +++++++++
 tests/generic/330.out       |  11 +
 tests/generic/331           | 107 ++++++++++
 tests/generic/331.out       |  12 ++
 tests/generic/332           |  97 +++++++++
 tests/generic/332.out       |  11 +
 tests/generic/333           | 104 ++++++++++
 tests/generic/333.out       |   6 +
 tests/generic/334           | 104 ++++++++++
 tests/generic/334.out       |   6 +
 tests/generic/group         |  49 ++++-
 tests/xfs/122               |   3 +
 tests/xfs/122.out           |   4 +
 tests/xfs/127               |   1 -
 tests/xfs/128               |   3 +-
 tests/xfs/128.out           |   8 +-
 tests/xfs/131               |   1 -
 tests/xfs/132               |  10 +-
 tests/xfs/132.out           |  40 ++--
 tests/xfs/139               |   1 -
 tests/xfs/140               |   1 -
 tests/xfs/169               |  90 ++++++++
 tests/xfs/169.out           |   8 +
 tests/xfs/179               | 119 +++++++++++
 tests/xfs/179.out           |  10 +
 tests/xfs/180               | 111 ++++++++++
 tests/xfs/180.out           |  12 ++
 tests/xfs/182               | 111 ++++++++++
 tests/xfs/182.out           |  13 ++
 tests/xfs/184               | 110 ++++++++++
 tests/xfs/184.out           |  11 +
 tests/xfs/192               | 110 ++++++++++
 tests/xfs/192.out           |  11 +
 tests/xfs/193               | 107 ++++++++++
 tests/xfs/193.out           |  11 +
 tests/xfs/198               | 107 ++++++++++
 tests/xfs/198.out           |  11 +
 tests/xfs/200               | 114 +++++++++++
 tests/xfs/200.out           |  11 +
 tests/xfs/204               | 114 +++++++++++
 tests/xfs/204.out           |  11 +
 tests/xfs/207               | 104 ++++++++++
 tests/xfs/207.out           |  10 +
 tests/xfs/208               | 154 ++++++++++++++
 tests/xfs/208.out           |  15 ++
 tests/xfs/209               |  88 ++++++++
 tests/xfs/209.out           |   6 +
 tests/xfs/210               | 125 +++++++++++
 tests/xfs/210.out           |  14 ++
 tests/xfs/211               | 111 ++++++++++
 tests/xfs/211.out           |  12 ++
 tests/xfs/212               | 106 ++++++++++
 tests/xfs/212.out           |  14 ++
 tests/xfs/213               | 110 ++++++++++
 tests/xfs/213.out           |  23 +++
 tests/xfs/214               | 109 ++++++++++
 tests/xfs/214.out           |  23 +++
 tests/xfs/215               | 108 ++++++++++
 tests/xfs/215.out           |  14 ++
 tests/xfs/218               | 108 ++++++++++
 tests/xfs/218.out           |  14 ++
 tests/xfs/219               | 108 ++++++++++
 tests/xfs/219.out           |  14 ++
 tests/xfs/221               | 108 ++++++++++
 tests/xfs/221.out           |  14 ++
 tests/xfs/223               | 113 ++++++++++
 tests/xfs/223.out           |  14 ++
 tests/xfs/224               | 113 ++++++++++
 tests/xfs/224.out           |  14 ++
 tests/xfs/225               | 108 ++++++++++
 tests/xfs/225.out           |  14 ++
 tests/xfs/226               | 108 ++++++++++
 tests/xfs/226.out           |  14 ++
 tests/xfs/228               | 137 +++++++++++++
 tests/xfs/228.out           |  14 ++
 tests/xfs/230               | 137 +++++++++++++
 tests/xfs/230.out           |  14 ++
 tests/xfs/231               | 135 ++++++++++++
 tests/xfs/231.out           |  17 ++
 tests/xfs/232               | 137 +++++++++++++
 tests/xfs/232.out           |  17 ++
 tests/xfs/233               |  78 +++++++
 tests/xfs/233.out           |   6 +
 tests/xfs/234               |  89 ++++++++
 tests/xfs/234.out           |   6 +
 tests/xfs/235               | 108 ++++++++++
 tests/xfs/235.out           |  14 ++
 tests/xfs/236               |  93 +++++++++
 tests/xfs/236.out           |   8 +
 tests/xfs/237               | 107 ++++++++++
 tests/xfs/237.out           |  12 ++
 tests/xfs/239               |  98 +++++++++
 tests/xfs/239.out           |  11 +
 tests/xfs/240               | 109 ++++++++++
 tests/xfs/240.out           |  12 ++
 tests/xfs/241               |  99 +++++++++
 tests/xfs/241.out           |  11 +
 tests/xfs/243               | 169 +++++++++++++++
 tests/xfs/243.out           |  27 +++
 tests/xfs/245               |  99 +++++++++
 tests/xfs/245.out           |  13 ++
 tests/xfs/group             |  44 +++-
 241 files changed, 11012 insertions(+), 177 deletions(-)
 create mode 100644 common/xfs
 create mode 100644 src/aio-dio-regress/aiocp.c
 create mode 100644 src/punch-alternating.c
 create mode 100755 tests/generic/250
 create mode 100644 tests/generic/250.out
 create mode 100755 tests/generic/252
 create mode 100644 tests/generic/252.out
 create mode 100755 tests/generic/253
 create mode 100644 tests/generic/253.out
 create mode 100755 tests/generic/254
 create mode 100644 tests/generic/254.out
 create mode 100755 tests/generic/259
 create mode 100644 tests/generic/259.out
 create mode 100755 tests/generic/261
 create mode 100644 tests/generic/261.out
 create mode 100755 tests/generic/262
 create mode 100644 tests/generic/262.out
 create mode 100755 tests/generic/264
 create mode 100644 tests/generic/264.out
 create mode 100755 tests/generic/265
 create mode 100644 tests/generic/265.out
 create mode 100755 tests/generic/266
 create mode 100644 tests/generic/266.out
 create mode 100755 tests/generic/267
 create mode 100644 tests/generic/267.out
 create mode 100755 tests/generic/268
 create mode 100644 tests/generic/268.out
 create mode 100755 tests/generic/271
 create mode 100644 tests/generic/271.out
 create mode 100755 tests/generic/272
 create mode 100644 tests/generic/272.out
 create mode 100755 tests/generic/276
 create mode 100644 tests/generic/276.out
 create mode 100755 tests/generic/278
 create mode 100644 tests/generic/278.out
 create mode 100755 tests/generic/279
 create mode 100644 tests/generic/279.out
 create mode 100755 tests/generic/281
 create mode 100644 tests/generic/281.out
 create mode 100755 tests/generic/282
 create mode 100644 tests/generic/282.out
 create mode 100755 tests/generic/283
 create mode 100644 tests/generic/283.out
 create mode 100755 tests/generic/284
 create mode 100644 tests/generic/284.out
 create mode 100755 tests/generic/287
 create mode 100644 tests/generic/287.out
 create mode 100755 tests/generic/289
 create mode 100644 tests/generic/289.out
 create mode 100755 tests/generic/290
 create mode 100644 tests/generic/290.out
 create mode 100755 tests/generic/291
 create mode 100644 tests/generic/291.out
 create mode 100755 tests/generic/292
 create mode 100644 tests/generic/292.out
 create mode 100755 tests/generic/293
 create mode 100644 tests/generic/293.out
 create mode 100755 tests/generic/295
 create mode 100644 tests/generic/295.out
 create mode 100755 tests/generic/296
 create mode 100644 tests/generic/296.out
 create mode 100755 tests/generic/297
 create mode 100644 tests/generic/297.out
 create mode 100755 tests/generic/298
 create mode 100644 tests/generic/298.out
 create mode 100755 tests/generic/301
 create mode 100644 tests/generic/301.out
 create mode 100755 tests/generic/302
 create mode 100644 tests/generic/302.out
 create mode 100755 tests/generic/303
 create mode 100644 tests/generic/303.out
 create mode 100755 tests/generic/304
 create mode 100644 tests/generic/304.out
 create mode 100755 tests/generic/305
 create mode 100644 tests/generic/305.out
 create mode 100755 tests/generic/326
 create mode 100644 tests/generic/326.out
 create mode 100755 tests/generic/327
 create mode 100644 tests/generic/327.out
 create mode 100755 tests/generic/328
 create mode 100644 tests/generic/328.out
 create mode 100755 tests/generic/329
 create mode 100644 tests/generic/329.out
 create mode 100755 tests/generic/330
 create mode 100644 tests/generic/330.out
 create mode 100755 tests/generic/331
 create mode 100644 tests/generic/331.out
 create mode 100755 tests/generic/332
 create mode 100644 tests/generic/332.out
 create mode 100755 tests/generic/333
 create mode 100644 tests/generic/333.out
 create mode 100755 tests/generic/334
 create mode 100644 tests/generic/334.out
 create mode 100755 tests/xfs/169
 create mode 100644 tests/xfs/169.out
 create mode 100755 tests/xfs/179
 create mode 100644 tests/xfs/179.out
 create mode 100755 tests/xfs/180
 create mode 100644 tests/xfs/180.out
 create mode 100755 tests/xfs/182
 create mode 100644 tests/xfs/182.out
 create mode 100755 tests/xfs/184
 create mode 100644 tests/xfs/184.out
 create mode 100755 tests/xfs/192
 create mode 100644 tests/xfs/192.out
 create mode 100755 tests/xfs/193
 create mode 100644 tests/xfs/193.out
 create mode 100755 tests/xfs/198
 create mode 100644 tests/xfs/198.out
 create mode 100755 tests/xfs/200
 create mode 100644 tests/xfs/200.out
 create mode 100755 tests/xfs/204
 create mode 100644 tests/xfs/204.out
 create mode 100755 tests/xfs/207
 create mode 100644 tests/xfs/207.out
 create mode 100755 tests/xfs/208
 create mode 100644 tests/xfs/208.out
 create mode 100755 tests/xfs/209
 create mode 100644 tests/xfs/209.out
 create mode 100755 tests/xfs/210
 create mode 100644 tests/xfs/210.out
 create mode 100755 tests/xfs/211
 create mode 100644 tests/xfs/211.out
 create mode 100755 tests/xfs/212
 create mode 100644 tests/xfs/212.out
 create mode 100755 tests/xfs/213
 create mode 100644 tests/xfs/213.out
 create mode 100755 tests/xfs/214
 create mode 100644 tests/xfs/214.out
 create mode 100755 tests/xfs/215
 create mode 100644 tests/xfs/215.out
 create mode 100755 tests/xfs/218
 create mode 100644 tests/xfs/218.out
 create mode 100755 tests/xfs/219
 create mode 100644 tests/xfs/219.out
 create mode 100755 tests/xfs/221
 create mode 100644 tests/xfs/221.out
 create mode 100755 tests/xfs/223
 create mode 100644 tests/xfs/223.out
 create mode 100755 tests/xfs/224
 create mode 100644 tests/xfs/224.out
 create mode 100755 tests/xfs/225
 create mode 100644 tests/xfs/225.out
 create mode 100755 tests/xfs/226
 create mode 100644 tests/xfs/226.out
 create mode 100755 tests/xfs/228
 create mode 100644 tests/xfs/228.out
 create mode 100755 tests/xfs/230
 create mode 100644 tests/xfs/230.out
 create mode 100755 tests/xfs/231
 create mode 100644 tests/xfs/231.out
 create mode 100755 tests/xfs/232
 create mode 100644 tests/xfs/232.out
 create mode 100755 tests/xfs/233
 create mode 100644 tests/xfs/233.out
 create mode 100755 tests/xfs/234
 create mode 100644 tests/xfs/234.out
 create mode 100755 tests/xfs/235
 create mode 100644 tests/xfs/235.out
 create mode 100755 tests/xfs/236
 create mode 100644 tests/xfs/236.out
 create mode 100755 tests/xfs/237
 create mode 100644 tests/xfs/237.out
 create mode 100755 tests/xfs/239
 create mode 100644 tests/xfs/239.out
 create mode 100755 tests/xfs/240
 create mode 100644 tests/xfs/240.out
 create mode 100755 tests/xfs/241
 create mode 100644 tests/xfs/241.out
 create mode 100755 tests/xfs/243
 create mode 100644 tests/xfs/243.out
 create mode 100755 tests/xfs/245
 create mode 100644 tests/xfs/245.out

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

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

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
  2016-02-09  7:43     ` Dave Chinner
@ 2016-02-09  7:55       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:55 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 06:43:30PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> > Include the refcount and rmap structures in the golden output.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  tests/xfs/122     |    3 +++
> >  tests/xfs/122.out |    4 ++++
> >  tests/xfs/group   |    2 +-
> >  3 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/tests/xfs/122 b/tests/xfs/122
> > index e6697a2..758cb50 100755
> > --- a/tests/xfs/122
> > +++ b/tests/xfs/122
> > @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
> >  xfs_dir3_icfree_hdr
> >  xfs_dir3_icleaf_hdr
> >  xfs_name
> > +xfs_owner_info
> > +xfs_refcount_irec
> > +xfs_rmap_irec
> >  xfs_alloctype_t
> >  xfs_buf_cancel_t
> >  xfs_bmbt_rec_32_t
> 
> So this is going to cause failures on any userspace that doesn't
> know about these new types, right?
> 
> Should these be conditional in some way?

I wasn't sure how to handle this -- I could just keep the patch at the head of
my stack (unreleased) until xfsprogs pulls in the appropriate libxfs pieces?
So long as we're not dead certain of the final format of the rmapbt and
refcountbt, there's probably not a lot of value in putting this in (yet).

--D

> 
> Cheers,
> 
> Dave.
> 
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> 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] 88+ messages in thread

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
@ 2016-02-09  7:55       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  7:55 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 06:43:30PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> > Include the refcount and rmap structures in the golden output.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  tests/xfs/122     |    3 +++
> >  tests/xfs/122.out |    4 ++++
> >  tests/xfs/group   |    2 +-
> >  3 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/tests/xfs/122 b/tests/xfs/122
> > index e6697a2..758cb50 100755
> > --- a/tests/xfs/122
> > +++ b/tests/xfs/122
> > @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
> >  xfs_dir3_icfree_hdr
> >  xfs_dir3_icleaf_hdr
> >  xfs_name
> > +xfs_owner_info
> > +xfs_refcount_irec
> > +xfs_rmap_irec
> >  xfs_alloctype_t
> >  xfs_buf_cancel_t
> >  xfs_bmbt_rec_32_t
> 
> So this is going to cause failures on any userspace that doesn't
> know about these new types, right?
> 
> Should these be conditional in some way?

I wasn't sure how to handle this -- I could just keep the patch at the head of
my stack (unreleased) until xfsprogs pulls in the appropriate libxfs pieces?
So long as we're not dead certain of the final format of the rmapbt and
refcountbt, there's probably not a lot of value in putting this in (yet).

--D

> 
> Cheers,
> 
> Dave.
> 
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> 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] 88+ messages in thread

* Re: [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
  2016-02-09  1:13   ` Darrick J. Wong
@ 2016-02-09  8:01     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:01 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:13:09PM -0800, Darrick J. Wong wrote:
> Perform copy-on-writes at random offsets to stress the CoW allocation
> system.  Assess the effectiveness of the extent size hint at
> combatting fragmentation via unshare, a rewrite, and no-op after the
> random writes.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
....
> +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"

Now that I've noticed it, a few tests have this line commented out.
Probably should remove the tmp files, at least.

> +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

Again, somthing that is repeated - we just mkfs'd the scratch
device, so the $testdir is guaranteed not to exist...

> +echo "Check for damage"
> +umount "$SCRATCH_MNT"

I've also noticed this in a lot of tests - the scratch device will
be unmounted by the harness, so I don't think this is necessary....

> +free_blocks=$(stat -f -c '%a' "$testdir")
> +real_blksz=$(stat -f -c '%S' "$testdir")
> +space_needed=$(((blksz * nr * 3) * 5 / 4))
> +space_avail=$((free_blocks * real_blksz))
> +internal_blks=$((blksz * nr / real_blksz))
> +test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"

Why not:

_require_fs_space $space_needed

At minimum, it seems to be a repeated hunk of code, so it shoul dbe
factored.

> +testdir="$SCRATCH_MNT/test-$seq"
> +rm -rf $testdir
> +mkdir $testdir
> +
> +echo "Create the original files"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
> +_scratch_remount
> +
> +echo "Set extsz and cowextsz on zero byte file"
> +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
> +
> +echo "Set extsz and cowextsz on 1Mbyte file"
> +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
> +_scratch_remount
> +
> +fn() {
> +	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
> +}
> +echo "Check extsz and cowextsz settings on zero byte file"
> +test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
> +test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 

For this sort of thing, just dump the extent size value to the
golden output. i.e.

echo "Check extsz and cowextsz settings on zero byte file"
$XFS_IO_PROG -c extsize $testdir/file1
$XFS_IO_PROG -c cowextsize $testdir/file1

is all that is needed. that way if it fails, we see what value it
had instead of the expected 1MB. This also makes the test much less
verbose and easier to read

> +
> +echo "Check extsz and cowextsz settings on 1Mbyte file"
> +test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
> +test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
> +
> +echo "Set cowextsize and check flag"
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
> +_scratch_remount
> +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
> +test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
> +"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
> +_scratch_remount
> +test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
> +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"

Same with all these - just grep the output for the line you want,
and the golden output matching does everything else. e.g. the flag
check simply becomes:

$XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags'

Again, this tells us what the wrong flags are if it fails...

There are quite a few bits of these tests where the same thing
applies....

-Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
@ 2016-02-09  8:01     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:01 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:13:09PM -0800, Darrick J. Wong wrote:
> Perform copy-on-writes at random offsets to stress the CoW allocation
> system.  Assess the effectiveness of the extent size hint at
> combatting fragmentation via unshare, a rewrite, and no-op after the
> random writes.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
....
> +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"

Now that I've noticed it, a few tests have this line commented out.
Probably should remove the tmp files, at least.

> +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

Again, somthing that is repeated - we just mkfs'd the scratch
device, so the $testdir is guaranteed not to exist...

> +echo "Check for damage"
> +umount "$SCRATCH_MNT"

I've also noticed this in a lot of tests - the scratch device will
be unmounted by the harness, so I don't think this is necessary....

> +free_blocks=$(stat -f -c '%a' "$testdir")
> +real_blksz=$(stat -f -c '%S' "$testdir")
> +space_needed=$(((blksz * nr * 3) * 5 / 4))
> +space_avail=$((free_blocks * real_blksz))
> +internal_blks=$((blksz * nr / real_blksz))
> +test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"

Why not:

_require_fs_space $space_needed

At minimum, it seems to be a repeated hunk of code, so it shoul dbe
factored.

> +testdir="$SCRATCH_MNT/test-$seq"
> +rm -rf $testdir
> +mkdir $testdir
> +
> +echo "Create the original files"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
> +_scratch_remount
> +
> +echo "Set extsz and cowextsz on zero byte file"
> +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
> +
> +echo "Set extsz and cowextsz on 1Mbyte file"
> +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
> +_scratch_remount
> +
> +fn() {
> +	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
> +}
> +echo "Check extsz and cowextsz settings on zero byte file"
> +test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
> +test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 

For this sort of thing, just dump the extent size value to the
golden output. i.e.

echo "Check extsz and cowextsz settings on zero byte file"
$XFS_IO_PROG -c extsize $testdir/file1
$XFS_IO_PROG -c cowextsize $testdir/file1

is all that is needed. that way if it fails, we see what value it
had instead of the expected 1MB. This also makes the test much less
verbose and easier to read

> +
> +echo "Check extsz and cowextsz settings on 1Mbyte file"
> +test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
> +test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
> +
> +echo "Set cowextsize and check flag"
> +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
> +_scratch_remount
> +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
> +test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
> +"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
> +_scratch_remount
> +test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
> +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"

Same with all these - just grep the output for the line you want,
and the golden output matching does everything else. e.g. the flag
check simply becomes:

$XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags'

Again, this tells us what the wrong flags are if it fails...

There are quite a few bits of these tests where the same thing
applies....

-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] 88+ messages in thread

* Re: [PATCH 06/23] dio unwritten conversion bug tests
  2016-02-09  7:37     ` Dave Chinner
@ 2016-02-09  8:08       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  8:08 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 06:37:32PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:12:23PM -0800, Darrick J. Wong wrote:
> > Check that we don't expose old disk contents when a directio write to
> > an unwritten extent fails due to IO errors.  This primarily affects
> > XFS and ext4.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> .....
> > --- a/tests/generic/group
> > +++ b/tests/generic/group
> > @@ -252,7 +252,9 @@
> >  247 auto quick rw
> >  248 auto quick rw
> >  249 auto quick rw
> > +250 auto quick
> >  251 ioctl trim
> > +252 auto quick
> 
> Also should be in the prealloc group if we are testing unwritten
> extent behaviour and the rw group because it's testing IO.

Done.

Should the CoW tests be in 'rw' too?  They're testing IO, but otoh they
(most probably) require shared blocks to have much of a point.

--D

> 
> 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] 88+ messages in thread

* Re: [PATCH 06/23] dio unwritten conversion bug tests
@ 2016-02-09  8:08       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  8:08 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 06:37:32PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:12:23PM -0800, Darrick J. Wong wrote:
> > Check that we don't expose old disk contents when a directio write to
> > an unwritten extent fails due to IO errors.  This primarily affects
> > XFS and ext4.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> .....
> > --- a/tests/generic/group
> > +++ b/tests/generic/group
> > @@ -252,7 +252,9 @@
> >  247 auto quick rw
> >  248 auto quick rw
> >  249 auto quick rw
> > +250 auto quick
> >  251 ioctl trim
> > +252 auto quick
> 
> Also should be in the prealloc group if we are testing unwritten
> extent behaviour and the rw group because it's testing IO.

Done.

Should the CoW tests be in 'rw' too?  They're testing IO, but otoh they
(most probably) require shared blocks to have much of a point.

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
  2016-02-09  1:13   ` Darrick J. Wong
@ 2016-02-09  8:09     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:09 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:13:35PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/215.out |   14 +++++
>  tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/218.out |   14 +++++
>  tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/219.out |   14 +++++
>  tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/221.out |   14 +++++
>  tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/223.out |   14 +++++
>  tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/224.out |   14 +++++
>  tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/225.out |   14 +++++
>  tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/226.out |   14 +++++
>  tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/228.out |   14 +++++
>  tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/230.out |   14 +++++
>  tests/xfs/group   |   10 ++++
>  21 files changed, 1298 insertions(+)
>  create mode 100755 tests/xfs/215
>  create mode 100644 tests/xfs/215.out
>  create mode 100755 tests/xfs/218
>  create mode 100644 tests/xfs/218.out
>  create mode 100755 tests/xfs/219
>  create mode 100644 tests/xfs/219.out
>  create mode 100755 tests/xfs/221
>  create mode 100644 tests/xfs/221.out
>  create mode 100755 tests/xfs/223
>  create mode 100644 tests/xfs/223.out
>  create mode 100755 tests/xfs/224
>  create mode 100644 tests/xfs/224.out
>  create mode 100755 tests/xfs/225
>  create mode 100644 tests/xfs/225.out
>  create mode 100755 tests/xfs/226
>  create mode 100644 tests/xfs/226.out
>  create mode 100755 tests/xfs/228
>  create mode 100644 tests/xfs/228.out
>  create mode 100755 tests/xfs/230
>  create mode 100644 tests/xfs/230.out
> 
> 
> diff --git a/tests/xfs/215 b/tests/xfs/215
> new file mode 100755
> index 0000000..8dd5cb5
> --- /dev/null
> +++ b/tests/xfs/215
> @@ -0,0 +1,108 @@
> +#! /bin/bash
> +# FS QA Test No. 215
> +#
> +# Ensuring that copy on write in direct-io mode works when the CoW
> +# range originally covers multiple extents, some unwritten, some not.
> +#   - Set cowextsize hint.
> +#   - Create a file and fallocate a second file.
> +#   - Reflink the odd blocks of the first file into the second file.
> +#   - directio CoW across the halfway mark, starting with the unwritten extent.
> +#   - Check that the files are now different where we say they're different.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016, 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".*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_supported_os Linux
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +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 "Create the original files"
> +blksz=65536
> +nr=64
> +real_blksz=$(stat -f -c '%S' "$testdir")
> +internal_blks=$((blksz * nr / real_blksz))
> +"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
> +_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
> +$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
> +_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
> +seq 0 2 $((nr-1)) | while read f; do
> +	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
> +	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
> +done

This looks like several tests use this setup. Factor?

> +_scratch_remount
> +
> +echo "Compare files"
> +md5sum "$testdir/file1" | _filter_scratch
> +md5sum "$testdir/file3" | _filter_scratch
> +md5sum "$testdir/file3.chk" | _filter_scratch
> +
> +echo "directio CoW across the transition"
> +"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
> +_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
> +_scratch_remount

These could really do with local variables to keep the verbosity
down and make it easy to change in future.

off=$((blksz * nr / 4))
iosz=$((blksz * nr / 2))

$XFS_IO_PROG -d -c "pwrite -S 0x63 -b $iosz $off $iosz" $testdir/file3
_pwrite_byte 0x63 $off $iosz $testdir/file3.chk

-Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
@ 2016-02-09  8:09     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:09 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:13:35PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/215.out |   14 +++++
>  tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/218.out |   14 +++++
>  tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/219.out |   14 +++++
>  tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/221.out |   14 +++++
>  tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/223.out |   14 +++++
>  tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/224.out |   14 +++++
>  tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/225.out |   14 +++++
>  tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/226.out |   14 +++++
>  tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/228.out |   14 +++++
>  tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/230.out |   14 +++++
>  tests/xfs/group   |   10 ++++
>  21 files changed, 1298 insertions(+)
>  create mode 100755 tests/xfs/215
>  create mode 100644 tests/xfs/215.out
>  create mode 100755 tests/xfs/218
>  create mode 100644 tests/xfs/218.out
>  create mode 100755 tests/xfs/219
>  create mode 100644 tests/xfs/219.out
>  create mode 100755 tests/xfs/221
>  create mode 100644 tests/xfs/221.out
>  create mode 100755 tests/xfs/223
>  create mode 100644 tests/xfs/223.out
>  create mode 100755 tests/xfs/224
>  create mode 100644 tests/xfs/224.out
>  create mode 100755 tests/xfs/225
>  create mode 100644 tests/xfs/225.out
>  create mode 100755 tests/xfs/226
>  create mode 100644 tests/xfs/226.out
>  create mode 100755 tests/xfs/228
>  create mode 100644 tests/xfs/228.out
>  create mode 100755 tests/xfs/230
>  create mode 100644 tests/xfs/230.out
> 
> 
> diff --git a/tests/xfs/215 b/tests/xfs/215
> new file mode 100755
> index 0000000..8dd5cb5
> --- /dev/null
> +++ b/tests/xfs/215
> @@ -0,0 +1,108 @@
> +#! /bin/bash
> +# FS QA Test No. 215
> +#
> +# Ensuring that copy on write in direct-io mode works when the CoW
> +# range originally covers multiple extents, some unwritten, some not.
> +#   - Set cowextsize hint.
> +#   - Create a file and fallocate a second file.
> +#   - Reflink the odd blocks of the first file into the second file.
> +#   - directio CoW across the halfway mark, starting with the unwritten extent.
> +#   - Check that the files are now different where we say they're different.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016, 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".*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/reflink
> +
> +# real QA test starts here
> +_supported_os Linux
> +_require_scratch_reflink
> +_require_xfs_io_command "falloc"
> +
> +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 "Create the original files"
> +blksz=65536
> +nr=64
> +real_blksz=$(stat -f -c '%S' "$testdir")
> +internal_blks=$((blksz * nr / real_blksz))
> +"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
> +_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
> +$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
> +_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
> +seq 0 2 $((nr-1)) | while read f; do
> +	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
> +	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
> +done

This looks like several tests use this setup. Factor?

> +_scratch_remount
> +
> +echo "Compare files"
> +md5sum "$testdir/file1" | _filter_scratch
> +md5sum "$testdir/file3" | _filter_scratch
> +md5sum "$testdir/file3.chk" | _filter_scratch
> +
> +echo "directio CoW across the transition"
> +"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
> +_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
> +_scratch_remount

These could really do with local variables to keep the verbosity
down and make it easy to change in future.

off=$((blksz * nr / 4))
iosz=$((blksz * nr / 2))

$XFS_IO_PROG -d -c "pwrite -S 0x63 -b $iosz $off $iosz" $testdir/file3
_pwrite_byte 0x63 $off $iosz $testdir/file3.chk

-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] 88+ messages in thread

* Re: [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
  2016-02-09  1:13   ` Darrick J. Wong
@ 2016-02-09  8:15     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:13:42PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> +
> +_cleanup()
> +{
> +    cd /
> +    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> +    #rm -rf "$tmp".* "$testdir"

uncomment.

> +echo "CoW and leave leftovers"
> +echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> +seq 2 2 $((nr - 1)) | while read f; do
> +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
> +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
> +done

Ok, I just realised what was bugging me about these loops: "f" is
not a typical loop iterator for a count. Normally we'd use "i" for
these....

> +echo "old extents: $old_extents" >> "$seqres.full"
> +echo "new extents: $new_extents" >> "$seqres.full"
> +echo "maximum extents: $internal_blks" >> "$seqres.full"
> +test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"

I wouldn't use _fail like this, echo is sufficient to cause the test
to fail.

> +echo "Check for damage"
> +umount "$SCRATCH_MNT"
> +
> +# success, all done
> +status=0
> +exit

As would getting rid of the unmount and just setting status
appropriately...

/repeat

-Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
@ 2016-02-09  8:15     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:15 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:13:42PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> +
> +_cleanup()
> +{
> +    cd /
> +    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> +    #rm -rf "$tmp".* "$testdir"

uncomment.

> +echo "CoW and leave leftovers"
> +echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> +seq 2 2 $((nr - 1)) | while read f; do
> +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
> +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
> +done

Ok, I just realised what was bugging me about these loops: "f" is
not a typical loop iterator for a count. Normally we'd use "i" for
these....

> +echo "old extents: $old_extents" >> "$seqres.full"
> +echo "new extents: $new_extents" >> "$seqres.full"
> +echo "maximum extents: $internal_blks" >> "$seqres.full"
> +test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"

I wouldn't use _fail like this, echo is sufficient to cause the test
to fail.

> +echo "Check for damage"
> +umount "$SCRATCH_MNT"
> +
> +# success, all done
> +status=0
> +exit

As would getting rid of the unmount and just setting status
appropriately...

/repeat

-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] 88+ messages in thread

* Re: [PATCH 10/23] xfs: more reflink tests
  2016-02-09  7:36     ` Dave Chinner
@ 2016-02-09  8:16       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  8:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 06:36:22PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:12:50PM -0800, Darrick J. Wong wrote:
> > Create a couple of XFS-specific tests -- one to check that growing
> > and shrinking the refcount btree works and a second one to check
> > what happens when we hit maximum refcount.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> .....
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_scratch_reflink
> > +_require_cp_reflink
> ....
> > +
> > +test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
> 
> I suspect we need a _require rule for checking that something in
> the test src directory has been built.

Crapola, we also need punch-alternating, which doesn't appear until the next
patch.  Guess I'll go move it out of the next patch (or swap the order of
these two I guess.)

I added _require_test_program() which complains if src/$1 isn't built.

> > +echo "Check scratch fs"
> > +umount "$SCRATCH_MNT"
> > +echo "check refcount after removing all files" >> "$seqres.full"
> > +"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
> > +"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
> > +res=$?
> > +if [ $res -eq 0 ]; then
> > +	# If repair succeeds then format the device so that the post-test
> > +	# check doesn't fail due to the single AG.
> > +	_scratch_mkfs >> "$seqres.full" 2>&1
> > +else
> > +	_fail "xfs_repair fails"
> > +fi
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> This is what _require_scratch_nocheck avoids.
> 
> i.e. do this instead:
> 
> _require_scratch_nocheck
> .....
> 
> "$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1 
> status=$?
> exit

Ok.

> Also, we really don't need the quotes around these global
> variables.  They are just noise and lots of stuff will break if
> those variables are set to something that requires them to be
> quoted.

<nod>

--D

> 
> 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] 88+ messages in thread

* Re: [PATCH 10/23] xfs: more reflink tests
@ 2016-02-09  8:16       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09  8:16 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 06:36:22PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:12:50PM -0800, Darrick J. Wong wrote:
> > Create a couple of XFS-specific tests -- one to check that growing
> > and shrinking the refcount btree works and a second one to check
> > what happens when we hit maximum refcount.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> .....
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_scratch_reflink
> > +_require_cp_reflink
> ....
> > +
> > +test -x "$here/src/punch-alternating" || _notrun "punch-alternating not built"
> 
> I suspect we need a _require rule for checking that something in
> the test src directory has been built.

Crapola, we also need punch-alternating, which doesn't appear until the next
patch.  Guess I'll go move it out of the next patch (or swap the order of
these two I guess.)

I added _require_test_program() which complains if src/$1 isn't built.

> > +echo "Check scratch fs"
> > +umount "$SCRATCH_MNT"
> > +echo "check refcount after removing all files" >> "$seqres.full"
> > +"$XFS_DB_PROG" -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' "$SCRATCH_DEV" >> "$seqres.full"
> > +"$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1
> > +res=$?
> > +if [ $res -eq 0 ]; then
> > +	# If repair succeeds then format the device so that the post-test
> > +	# check doesn't fail due to the single AG.
> > +	_scratch_mkfs >> "$seqres.full" 2>&1
> > +else
> > +	_fail "xfs_repair fails"
> > +fi
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> This is what _require_scratch_nocheck avoids.
> 
> i.e. do this instead:
> 
> _require_scratch_nocheck
> .....
> 
> "$XFS_REPAIR_PROG" -o force_geometry -n "$SCRATCH_DEV" >> "$seqres.full" 2>&1 
> status=$?
> exit

Ok.

> Also, we really don't need the quotes around these global
> variables.  They are just noise and lots of stuff will break if
> those variables are set to something that requires them to be
> quoted.

<nod>

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 19/23] xfs: test rmapbt functionality
  2016-02-09  1:13   ` Darrick J. Wong
@ 2016-02-09  8:26     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:13:48PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/xfs        |   44 ++++++++++++++++++++++
>  tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
>  tests/xfs/233.out |    6 +++
>  tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/234.out |    6 +++
>  tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/235.out |   14 +++++++
>  tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/236.out |    8 ++++
>  tests/xfs/group   |    4 ++
>  10 files changed, 450 insertions(+)
>  create mode 100644 common/xfs
>  create mode 100755 tests/xfs/233
>  create mode 100644 tests/xfs/233.out
>  create mode 100755 tests/xfs/234
>  create mode 100644 tests/xfs/234.out
>  create mode 100755 tests/xfs/235
>  create mode 100644 tests/xfs/235.out
>  create mode 100755 tests/xfs/236
>  create mode 100644 tests/xfs/236.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> new file mode 100644
> index 0000000..2d1a76f
> --- /dev/null
> +++ b/common/xfs
> @@ -0,0 +1,44 @@
> +##/bin/bash
> +# Routines for handling XFS
> +#-----------------------------------------------------------------------
> +#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will 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 to the Free Software
> +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> +#  USA
> +#
> +#  Contact information: Oracle Corporation, 500 Oracle Parkway,
> +#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
> +#-----------------------------------------------------------------------
> +
> +_require_xfs_test_rmapbt()
> +{
> +	_require_test
> +
> +	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
> +		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
> +	fi
> +}
> +
> +_require_xfs_scratch_rmapbt()
> +{
> +	_require_scratch
> +
> +	_scratch_mkfs > /dev/null
> +	_scratch_mount
> +	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
> +		_scratch_unmount
> +		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
> +	fi
> +	_scratch_unmount
> +}

No, not yet. :)

Wait until I get my "split common/rc" patchset out there, because it
does not require:

> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/xfs

This.

And i don't want to have to undo a bunch of stuff in tests yet. Just
lump it all in common/rc for the moment.

> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_xfs_scratch_rmapbt
> +
> +echo "Format and mount"
> +_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > "$seqres.full" 2>&1
> +_scratch_mount >> "$seqres.full" 2>&1

_scratch_mkfs_sized ?

> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +    cd /
> +    #rm -f $tmp.*

More random uncommenting needed.

> +
> +echo "Check for damage"
> +umount "$SCRATCH_MNT"
> +_check_scratch_fs
> +
> +# success, all done
> +status=0
> +exit

Cull.

-Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 19/23] xfs: test rmapbt functionality
@ 2016-02-09  8:26     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:26 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:13:48PM -0800, Darrick J. Wong wrote:
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/xfs        |   44 ++++++++++++++++++++++
>  tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
>  tests/xfs/233.out |    6 +++
>  tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/234.out |    6 +++
>  tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/235.out |   14 +++++++
>  tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/236.out |    8 ++++
>  tests/xfs/group   |    4 ++
>  10 files changed, 450 insertions(+)
>  create mode 100644 common/xfs
>  create mode 100755 tests/xfs/233
>  create mode 100644 tests/xfs/233.out
>  create mode 100755 tests/xfs/234
>  create mode 100644 tests/xfs/234.out
>  create mode 100755 tests/xfs/235
>  create mode 100644 tests/xfs/235.out
>  create mode 100755 tests/xfs/236
>  create mode 100644 tests/xfs/236.out
> 
> 
> diff --git a/common/xfs b/common/xfs
> new file mode 100644
> index 0000000..2d1a76f
> --- /dev/null
> +++ b/common/xfs
> @@ -0,0 +1,44 @@
> +##/bin/bash
> +# Routines for handling XFS
> +#-----------------------------------------------------------------------
> +#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
> +#  (at your option) any later version.
> +#
> +#  This program is distributed in the hope that it will 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 to the Free Software
> +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> +#  USA
> +#
> +#  Contact information: Oracle Corporation, 500 Oracle Parkway,
> +#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
> +#-----------------------------------------------------------------------
> +
> +_require_xfs_test_rmapbt()
> +{
> +	_require_test
> +
> +	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
> +		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
> +	fi
> +}
> +
> +_require_xfs_scratch_rmapbt()
> +{
> +	_require_scratch
> +
> +	_scratch_mkfs > /dev/null
> +	_scratch_mount
> +	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
> +		_scratch_unmount
> +		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
> +	fi
> +	_scratch_unmount
> +}

No, not yet. :)

Wait until I get my "split common/rc" patchset out there, because it
does not require:

> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/xfs

This.

And i don't want to have to undo a bunch of stuff in tests yet. Just
lump it all in common/rc for the moment.

> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_xfs_scratch_rmapbt
> +
> +echo "Format and mount"
> +_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > "$seqres.full" 2>&1
> +_scratch_mount >> "$seqres.full" 2>&1

_scratch_mkfs_sized ?

> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +    cd /
> +    #rm -f $tmp.*

More random uncommenting needed.

> +
> +echo "Check for damage"
> +umount "$SCRATCH_MNT"
> +_check_scratch_fs
> +
> +# success, all done
> +status=0
> +exit

Cull.

-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] 88+ messages in thread

* Re: [PATCH 21/23] xfs: aio cow tests
  2016-02-09  1:14   ` Darrick J. Wong
@ 2016-02-09  8:32     ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:32 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 05:14:01PM -0800, Darrick J. Wong wrote:
.,,,
> +
> +echo "Check for damage"
> +_dmerror_unmount
> +_dmerror_cleanup
> +_repair_scratch_fs >> "$seqres.full" 2>&1

Are you testing repair here? If so, why doesn't failure matter.
If not, why do it? Or is _require_scratch_nocheck all that is needed
here?

> +echo "CoW and unmount"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"

offset = block size times block size?

I think some better names might be needed...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 21/23] xfs: aio cow tests
@ 2016-02-09  8:32     ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:32 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 05:14:01PM -0800, Darrick J. Wong wrote:
.,,,
> +
> +echo "Check for damage"
> +_dmerror_unmount
> +_dmerror_cleanup
> +_repair_scratch_fs >> "$seqres.full" 2>&1

Are you testing repair here? If so, why doesn't failure matter.
If not, why do it? Or is _require_scratch_nocheck all that is needed
here?

> +echo "CoW and unmount"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
> +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"

offset = block size times block size?

I think some better names might be needed...

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] 88+ messages in thread

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
  2016-02-09  7:55       ` Darrick J. Wong
@ 2016-02-09  8:53         ` Dave Chinner
  -1 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:53 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-btrfs, fstests, xfs

On Mon, Feb 08, 2016 at 11:55:06PM -0800, Darrick J. Wong wrote:
> On Tue, Feb 09, 2016 at 06:43:30PM +1100, Dave Chinner wrote:
> > On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> > > Include the refcount and rmap structures in the golden output.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  tests/xfs/122     |    3 +++
> > >  tests/xfs/122.out |    4 ++++
> > >  tests/xfs/group   |    2 +-
> > >  3 files changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > 
> > > diff --git a/tests/xfs/122 b/tests/xfs/122
> > > index e6697a2..758cb50 100755
> > > --- a/tests/xfs/122
> > > +++ b/tests/xfs/122
> > > @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
> > >  xfs_dir3_icfree_hdr
> > >  xfs_dir3_icleaf_hdr
> > >  xfs_name
> > > +xfs_owner_info
> > > +xfs_refcount_irec
> > > +xfs_rmap_irec
> > >  xfs_alloctype_t
> > >  xfs_buf_cancel_t
> > >  xfs_bmbt_rec_32_t
> > 
> > So this is going to cause failures on any userspace that doesn't
> > know about these new types, right?
> > 
> > Should these be conditional in some way?
> 
> I wasn't sure how to handle this -- I could just keep the patch at the head of
> my stack (unreleased) until xfsprogs pulls in the appropriate libxfs pieces?
> So long as we're not dead certain of the final format of the rmapbt and
> refcountbt, there's probably not a lot of value in putting this in (yet).

Well, I'm more concerned about running on older/current distros that
don't have support for them in userspace. My brain is mush right
now, so I don't have any brilliant ideas (hence the question, rather
than also presenting a posible solution). I'll have a think; maybe
we can make use of the configurable .out file code we have now?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 12/23] xfs/122: support refcount/rmap data structures
@ 2016-02-09  8:53         ` Dave Chinner
  0 siblings, 0 replies; 88+ messages in thread
From: Dave Chinner @ 2016-02-09  8:53 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Mon, Feb 08, 2016 at 11:55:06PM -0800, Darrick J. Wong wrote:
> On Tue, Feb 09, 2016 at 06:43:30PM +1100, Dave Chinner wrote:
> > On Mon, Feb 08, 2016 at 05:13:03PM -0800, Darrick J. Wong wrote:
> > > Include the refcount and rmap structures in the golden output.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  tests/xfs/122     |    3 +++
> > >  tests/xfs/122.out |    4 ++++
> > >  tests/xfs/group   |    2 +-
> > >  3 files changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > 
> > > diff --git a/tests/xfs/122 b/tests/xfs/122
> > > index e6697a2..758cb50 100755
> > > --- a/tests/xfs/122
> > > +++ b/tests/xfs/122
> > > @@ -90,6 +90,9 @@ xfs_da3_icnode_hdr
> > >  xfs_dir3_icfree_hdr
> > >  xfs_dir3_icleaf_hdr
> > >  xfs_name
> > > +xfs_owner_info
> > > +xfs_refcount_irec
> > > +xfs_rmap_irec
> > >  xfs_alloctype_t
> > >  xfs_buf_cancel_t
> > >  xfs_bmbt_rec_32_t
> > 
> > So this is going to cause failures on any userspace that doesn't
> > know about these new types, right?
> > 
> > Should these be conditional in some way?
> 
> I wasn't sure how to handle this -- I could just keep the patch at the head of
> my stack (unreleased) until xfsprogs pulls in the appropriate libxfs pieces?
> So long as we're not dead certain of the final format of the rmapbt and
> refcountbt, there's probably not a lot of value in putting this in (yet).

Well, I'm more concerned about running on older/current distros that
don't have support for them in userspace. My brain is mush right
now, so I don't have any brilliant ideas (hence the question, rather
than also presenting a posible solution). I'll have a think; maybe
we can make use of the configurable .out file code we have now?

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] 88+ messages in thread

* Re: [PATCH 21/23] xfs: aio cow tests
  2016-02-09  8:32     ` Dave Chinner
@ 2016-02-09 21:51       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09 21:51 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 07:32:15PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:14:01PM -0800, Darrick J. Wong wrote:
> .,,,
> > +
> > +echo "Check for damage"
> > +_dmerror_unmount
> > +_dmerror_cleanup
> > +_repair_scratch_fs >> "$seqres.full" 2>&1
> 
> Are you testing repair here? If so, why doesn't failure matter.
> If not, why do it? Or is _require_scratch_nocheck all that is needed
> here?

Uggghhh.... so xfs_repair dumps its regular output to stderr, so the "2>&1"
pushes the output to $seqres.full.

The return codes from xfs_repair seem to be:
0: fs is ok now
1: fs is probably broken
2: log needs to be replayed

The return codes from fsck seem to be:
0: no errors found
1: errors fixed
2: errors fixed, reboot required
(etc)

So I guess the way out is to provide a better wrapper to the repair tools
so that _repair_scratch_fs always returns 0 for "fs should be ok now" and
nonzero otherwise:

_repair_scratch_fs()
{
    case $FSTYP in
    xfs)
        _scratch_xfs_repair "$@" 2>&1
	res=$?
	if [ "$res" -eq 2 ]; then
		echo "xfs_repair returns $res; replay log?"
		_scratch_mount
		res=$?
		if [ "$res" -gt 0 ]; then
			echo "mount returns $res; zap log?"
			_scratch_xfs_repair -L 2>&1
			echo "log zap returns $?"
		else
			umount "$SCRATCH_MNT"
		fi
		_scratch_xfs_repair "$@" 2>&1
		res=$?
	fi
	test $res -ne 0 && >&2 echo "xfs_repair failed, err=$res"
	return $res
        ;;
    *)
        # Let's hope fsck -y suffices...
        fsck -t $FSTYP -y $SCRATCH_DEV 2>&1
	res=$?
	case $res in
	0|1|2)
		res=0
		;;
	*)
		>&2 echo "fsck.$FSTYP failed, err=$res"
		;;
	esac
	return $res
        ;;
    esac
}

> > +echo "CoW and unmount"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
> 
> offset = block size times block size?
> 
> I think some better names might be needed...

Yes.  Is now "bufnr" and bufsize=$((blksz * bufnr)).

--D

> 
> 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] 88+ messages in thread

* Re: [PATCH 21/23] xfs: aio cow tests
@ 2016-02-09 21:51       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-09 21:51 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 07:32:15PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:14:01PM -0800, Darrick J. Wong wrote:
> .,,,
> > +
> > +echo "Check for damage"
> > +_dmerror_unmount
> > +_dmerror_cleanup
> > +_repair_scratch_fs >> "$seqres.full" 2>&1
> 
> Are you testing repair here? If so, why doesn't failure matter.
> If not, why do it? Or is _require_scratch_nocheck all that is needed
> here?

Uggghhh.... so xfs_repair dumps its regular output to stderr, so the "2>&1"
pushes the output to $seqres.full.

The return codes from xfs_repair seem to be:
0: fs is ok now
1: fs is probably broken
2: log needs to be replayed

The return codes from fsck seem to be:
0: no errors found
1: errors fixed
2: errors fixed, reboot required
(etc)

So I guess the way out is to provide a better wrapper to the repair tools
so that _repair_scratch_fs always returns 0 for "fs should be ok now" and
nonzero otherwise:

_repair_scratch_fs()
{
    case $FSTYP in
    xfs)
        _scratch_xfs_repair "$@" 2>&1
	res=$?
	if [ "$res" -eq 2 ]; then
		echo "xfs_repair returns $res; replay log?"
		_scratch_mount
		res=$?
		if [ "$res" -gt 0 ]; then
			echo "mount returns $res; zap log?"
			_scratch_xfs_repair -L 2>&1
			echo "log zap returns $?"
		else
			umount "$SCRATCH_MNT"
		fi
		_scratch_xfs_repair "$@" 2>&1
		res=$?
	fi
	test $res -ne 0 && >&2 echo "xfs_repair failed, err=$res"
	return $res
        ;;
    *)
        # Let's hope fsck -y suffices...
        fsck -t $FSTYP -y $SCRATCH_DEV 2>&1
	res=$?
	case $res in
	0|1|2)
		res=0
		;;
	*)
		>&2 echo "fsck.$FSTYP failed, err=$res"
		;;
	esac
	return $res
        ;;
    esac
}

> > +echo "CoW and unmount"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * bsz)) 1" "$testdir/file2" >> "$seqres.full"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x63 -b $((blksz * bsz)) 0 $((blksz * nr))" "$TEST_DIR/moo" >> "$seqres.full"
> 
> offset = block size times block size?
> 
> I think some better names might be needed...

Yes.  Is now "bufnr" and bufsize=$((blksz * bufnr)).

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
  2016-02-09  8:01     ` Dave Chinner
@ 2016-02-10  1:02       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:02 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 07:01:44PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:09PM -0800, Darrick J. Wong wrote:
> > Perform copy-on-writes at random offsets to stress the CoW allocation
> > system.  Assess the effectiveness of the extent size hint at
> > combatting fragmentation via unshare, a rewrite, and no-op after the
> > random writes.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ....
> > +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"
> 
> Now that I've noticed it, a few tests have this line commented out.
> Probably should remove the tmp files, at least.

Done.

> > +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
> 
> Again, somthing that is repeated - we just mkfs'd the scratch
> device, so the $testdir is guaranteed not to exist...

I've done that to the new tests, will do to the existing ones.

> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> 
> I've also noticed this in a lot of tests - the scratch device will
> be unmounted by the harness, so I don't think this is necessary....

Done.

> > +free_blocks=$(stat -f -c '%a' "$testdir")
> > +real_blksz=$(stat -f -c '%S' "$testdir")
> > +space_needed=$(((blksz * nr * 3) * 5 / 4))
> > +space_avail=$((free_blocks * real_blksz))
> > +internal_blks=$((blksz * nr / real_blksz))
> > +test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
> 
> Why not:
> 
> _require_fs_space $space_needed
> 
> At minimum, it seems to be a repeated hunk of code, so it shoul dbe
> factored.

Ok, done.

> > +testdir="$SCRATCH_MNT/test-$seq"
> > +rm -rf $testdir
> > +mkdir $testdir
> > +
> > +echo "Create the original files"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
> > +_scratch_remount
> > +
> > +echo "Set extsz and cowextsz on zero byte file"
> > +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
> > +
> > +echo "Set extsz and cowextsz on 1Mbyte file"
> > +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
> > +_scratch_remount
> > +
> > +fn() {
> > +	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
> > +}
> > +echo "Check extsz and cowextsz settings on zero byte file"
> > +test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
> > +test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 
> 
> For this sort of thing, just dump the extent size value to the
> golden output. i.e.
> 
> echo "Check extsz and cowextsz settings on zero byte file"
> $XFS_IO_PROG -c extsize $testdir/file1
> $XFS_IO_PROG -c cowextsize $testdir/file1
> 
> is all that is needed. that way if it fails, we see what value it
> had instead of the expected 1MB. This also makes the test much less
> verbose and easier to read

Done.

> > +
> > +echo "Check extsz and cowextsz settings on 1Mbyte file"
> > +test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
> > +test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
> > +
> > +echo "Set cowextsize and check flag"
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
> > +_scratch_remount
> > +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
> > +test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
> > +"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
> > +_scratch_remount
> > +test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
> > +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"
> 
> Same with all these - just grep the output for the line you want,
> and the golden output matching does everything else. e.g. the flag
> check simply becomes:
> 
> $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags'
> 
> Again, this tells us what the wrong flags are if it fails...

Done.  It'll probably break whenever we add new flags, but that can be fixed.

--D

> 
> There are quite a few bits of these tests where the same thing
> applies....
> 
> -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] 88+ messages in thread

* Re: [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write
@ 2016-02-10  1:02       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:02 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 07:01:44PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:09PM -0800, Darrick J. Wong wrote:
> > Perform copy-on-writes at random offsets to stress the CoW allocation
> > system.  Assess the effectiveness of the extent size hint at
> > combatting fragmentation via unshare, a rewrite, and no-op after the
> > random writes.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ....
> > +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"
> 
> Now that I've noticed it, a few tests have this line commented out.
> Probably should remove the tmp files, at least.

Done.

> > +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
> 
> Again, somthing that is repeated - we just mkfs'd the scratch
> device, so the $testdir is guaranteed not to exist...

I've done that to the new tests, will do to the existing ones.

> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> 
> I've also noticed this in a lot of tests - the scratch device will
> be unmounted by the harness, so I don't think this is necessary....

Done.

> > +free_blocks=$(stat -f -c '%a' "$testdir")
> > +real_blksz=$(stat -f -c '%S' "$testdir")
> > +space_needed=$(((blksz * nr * 3) * 5 / 4))
> > +space_avail=$((free_blocks * real_blksz))
> > +internal_blks=$((blksz * nr / real_blksz))
> > +test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
> 
> Why not:
> 
> _require_fs_space $space_needed
> 
> At minimum, it seems to be a repeated hunk of code, so it shoul dbe
> factored.

Ok, done.

> > +testdir="$SCRATCH_MNT/test-$seq"
> > +rm -rf $testdir
> > +mkdir $testdir
> > +
> > +echo "Create the original files"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 0" "$testdir/file1" >> "$seqres.full"
> > +"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 1048576" "$testdir/file2" >> "$seqres.full"
> > +_scratch_remount
> > +
> > +echo "Set extsz and cowextsz on zero byte file"
> > +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file1" | _filter_scratch
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file1" | _filter_scratch
> > +
> > +echo "Set extsz and cowextsz on 1Mbyte file"
> > +"$XFS_IO_PROG" -f -c "extsize 1048576" "$testdir/file2" | _filter_scratch
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file2" | _filter_scratch
> > +_scratch_remount
> > +
> > +fn() {
> > +	"$XFS_IO_PROG" -c "$1" "$2" | sed -e 's/.\([0-9]*\).*$/\1/g'
> > +}
> > +echo "Check extsz and cowextsz settings on zero byte file"
> > +test $(fn extsize "$testdir/file1") -eq 1048576 || echo "file1 extsize not set"
> > +test $(fn cowextsize "$testdir/file1") -eq 1048576 || echo "file1 cowextsize not set" 
> 
> For this sort of thing, just dump the extent size value to the
> golden output. i.e.
> 
> echo "Check extsz and cowextsz settings on zero byte file"
> $XFS_IO_PROG -c extsize $testdir/file1
> $XFS_IO_PROG -c cowextsize $testdir/file1
> 
> is all that is needed. that way if it fails, we see what value it
> had instead of the expected 1MB. This also makes the test much less
> verbose and easier to read

Done.

> > +
> > +echo "Check extsz and cowextsz settings on 1Mbyte file"
> > +test $(fn extsize "$testdir/file2") -eq 0 || echo "file2 extsize not set"
> > +test $(fn cowextsize "$testdir/file2") -eq 1048576 || echo "file2 cowextsize not set" 
> > +
> > +echo "Set cowextsize and check flag"
> > +"$XFS_IO_PROG" -f -c "cowextsize 1048576" "$testdir/file3" | _filter_scratch
> > +_scratch_remount
> > +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 1 || echo "file3 cowextsz flag not set"
> > +test $(fn cowextsize "$testdir/file3") -eq 1048576 || echo "file3 cowextsize not set"
> > +"$XFS_IO_PROG" -f -c "cowextsize 0" "$testdir/file3" | _filter_scratch
> > +_scratch_remount
> > +test $(fn cowextsize "$testdir/file3") -eq 0 || echo "file3 cowextsize not set"
> > +test $("$XFS_IO_PROG" -c "stat" "$testdir/file3" | grep 'fsxattr.xflags' | awk '{print $4}' | grep -c 'C') -eq 0 || echo "file3 cowextsz flag not set"
> 
> Same with all these - just grep the output for the line you want,
> and the golden output matching does everything else. e.g. the flag
> check simply becomes:
> 
> $XFS_IO_PROG -c "stat" $testdir/file3 | grep 'fsxattr.xflags'
> 
> Again, this tells us what the wrong flags are if it fails...

Done.  It'll probably break whenever we add new flags, but that can be fixed.

--D

> 
> There are quite a few bits of these tests where the same thing
> applies....
> 
> -Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
  2016-02-09  8:09     ` Dave Chinner
@ 2016-02-10  1:03       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:03 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 07:09:23PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:35PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/215.out |   14 +++++
> >  tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/218.out |   14 +++++
> >  tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/219.out |   14 +++++
> >  tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/221.out |   14 +++++
> >  tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/223.out |   14 +++++
> >  tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/224.out |   14 +++++
> >  tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/225.out |   14 +++++
> >  tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/226.out |   14 +++++
> >  tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/228.out |   14 +++++
> >  tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/230.out |   14 +++++
> >  tests/xfs/group   |   10 ++++
> >  21 files changed, 1298 insertions(+)
> >  create mode 100755 tests/xfs/215
> >  create mode 100644 tests/xfs/215.out
> >  create mode 100755 tests/xfs/218
> >  create mode 100644 tests/xfs/218.out
> >  create mode 100755 tests/xfs/219
> >  create mode 100644 tests/xfs/219.out
> >  create mode 100755 tests/xfs/221
> >  create mode 100644 tests/xfs/221.out
> >  create mode 100755 tests/xfs/223
> >  create mode 100644 tests/xfs/223.out
> >  create mode 100755 tests/xfs/224
> >  create mode 100644 tests/xfs/224.out
> >  create mode 100755 tests/xfs/225
> >  create mode 100644 tests/xfs/225.out
> >  create mode 100755 tests/xfs/226
> >  create mode 100644 tests/xfs/226.out
> >  create mode 100755 tests/xfs/228
> >  create mode 100644 tests/xfs/228.out
> >  create mode 100755 tests/xfs/230
> >  create mode 100644 tests/xfs/230.out
> > 
> > 
> > diff --git a/tests/xfs/215 b/tests/xfs/215
> > new file mode 100755
> > index 0000000..8dd5cb5
> > --- /dev/null
> > +++ b/tests/xfs/215
> > @@ -0,0 +1,108 @@
> > +#! /bin/bash
> > +# FS QA Test No. 215
> > +#
> > +# Ensuring that copy on write in direct-io mode works when the CoW
> > +# range originally covers multiple extents, some unwritten, some not.
> > +#   - Set cowextsize hint.
> > +#   - Create a file and fallocate a second file.
> > +#   - Reflink the odd blocks of the first file into the second file.
> > +#   - directio CoW across the halfway mark, starting with the unwritten extent.
> > +#   - Check that the files are now different where we say they're different.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2016, 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".*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/reflink
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_require_scratch_reflink
> > +_require_xfs_io_command "falloc"
> > +
> > +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 "Create the original files"
> > +blksz=65536
> > +nr=64
> > +real_blksz=$(stat -f -c '%S' "$testdir")
> > +internal_blks=$((blksz * nr / real_blksz))
> > +"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
> > +_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
> > +$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
> > +_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
> > +seq 0 2 $((nr-1)) | while read f; do
> > +	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
> > +	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
> > +done
> 
> This looks like several tests use this setup. Factor?

Will tackle before I resubmit.

> 
> > +_scratch_remount
> > +
> > +echo "Compare files"
> > +md5sum "$testdir/file1" | _filter_scratch
> > +md5sum "$testdir/file3" | _filter_scratch
> > +md5sum "$testdir/file3.chk" | _filter_scratch
> > +
> > +echo "directio CoW across the transition"
> > +"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
> > +_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
> > +_scratch_remount
> 
> These could really do with local variables to keep the verbosity
> down and make it easy to change in future.
> 
> off=$((blksz * nr / 4))
> iosz=$((blksz * nr / 2))
> 
> $XFS_IO_PROG -d -c "pwrite -S 0x63 -b $iosz $off $iosz" $testdir/file3
> _pwrite_byte 0x63 $off $iosz $testdir/file3.chk

Done.  I decided on cowoff and cowsz since that's what we're doing.

--D

> 
> -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] 88+ messages in thread

* Re: [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set
@ 2016-02-10  1:03       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:03 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 07:09:23PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:35PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  tests/xfs/215     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/215.out |   14 +++++
> >  tests/xfs/218     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/218.out |   14 +++++
> >  tests/xfs/219     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/219.out |   14 +++++
> >  tests/xfs/221     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/221.out |   14 +++++
> >  tests/xfs/223     |  113 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/223.out |   14 +++++
> >  tests/xfs/224     |  113 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/224.out |   14 +++++
> >  tests/xfs/225     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/225.out |   14 +++++
> >  tests/xfs/226     |  108 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/226.out |   14 +++++
> >  tests/xfs/228     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/228.out |   14 +++++
> >  tests/xfs/230     |  137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/230.out |   14 +++++
> >  tests/xfs/group   |   10 ++++
> >  21 files changed, 1298 insertions(+)
> >  create mode 100755 tests/xfs/215
> >  create mode 100644 tests/xfs/215.out
> >  create mode 100755 tests/xfs/218
> >  create mode 100644 tests/xfs/218.out
> >  create mode 100755 tests/xfs/219
> >  create mode 100644 tests/xfs/219.out
> >  create mode 100755 tests/xfs/221
> >  create mode 100644 tests/xfs/221.out
> >  create mode 100755 tests/xfs/223
> >  create mode 100644 tests/xfs/223.out
> >  create mode 100755 tests/xfs/224
> >  create mode 100644 tests/xfs/224.out
> >  create mode 100755 tests/xfs/225
> >  create mode 100644 tests/xfs/225.out
> >  create mode 100755 tests/xfs/226
> >  create mode 100644 tests/xfs/226.out
> >  create mode 100755 tests/xfs/228
> >  create mode 100644 tests/xfs/228.out
> >  create mode 100755 tests/xfs/230
> >  create mode 100644 tests/xfs/230.out
> > 
> > 
> > diff --git a/tests/xfs/215 b/tests/xfs/215
> > new file mode 100755
> > index 0000000..8dd5cb5
> > --- /dev/null
> > +++ b/tests/xfs/215
> > @@ -0,0 +1,108 @@
> > +#! /bin/bash
> > +# FS QA Test No. 215
> > +#
> > +# Ensuring that copy on write in direct-io mode works when the CoW
> > +# range originally covers multiple extents, some unwritten, some not.
> > +#   - Set cowextsize hint.
> > +#   - Create a file and fallocate a second file.
> > +#   - Reflink the odd blocks of the first file into the second file.
> > +#   - directio CoW across the halfway mark, starting with the unwritten extent.
> > +#   - Check that the files are now different where we say they're different.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2016, 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".*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/reflink
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_require_scratch_reflink
> > +_require_xfs_io_command "falloc"
> > +
> > +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 "Create the original files"
> > +blksz=65536
> > +nr=64
> > +real_blksz=$(stat -f -c '%S' "$testdir")
> > +internal_blks=$((blksz * nr / real_blksz))
> > +"$XFS_IO_PROG" -c "cowextsize $((blksz * 16))" "$testdir" >> "$seqres.full"
> > +_pwrite_byte 0x61 0 $((blksz * nr)) "$testdir/file1" >> "$seqres.full"
> > +$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" "$testdir/file3" >> "$seqres.full"
> > +_pwrite_byte 0x00 0 $((blksz * nr)) "$testdir/file3.chk" >> "$seqres.full"
> > +seq 0 2 $((nr-1)) | while read f; do
> > +	_reflink_range "$testdir/file1" $((blksz * f)) "$testdir/file3" $((blksz * f)) $blksz >> "$seqres.full"
> > +	_pwrite_byte 0x61 $((blksz * f)) $blksz "$testdir/file3.chk" >> "$seqres.full"
> > +done
> 
> This looks like several tests use this setup. Factor?

Will tackle before I resubmit.

> 
> > +_scratch_remount
> > +
> > +echo "Compare files"
> > +md5sum "$testdir/file1" | _filter_scratch
> > +md5sum "$testdir/file3" | _filter_scratch
> > +md5sum "$testdir/file3.chk" | _filter_scratch
> > +
> > +echo "directio CoW across the transition"
> > +"$XFS_IO_PROG" -d -f -c "pwrite -S 0x63 -b $((blksz * nr / 2)) $((blksz * nr / 4)) $((blksz * nr / 2))" "$testdir/file3" >> "$seqres.full"
> > +_pwrite_byte 0x63 $((blksz * nr / 4)) $((blksz * nr / 2)) "$testdir/file3.chk" >> "$seqres.full"
> > +_scratch_remount
> 
> These could really do with local variables to keep the verbosity
> down and make it easy to change in future.
> 
> off=$((blksz * nr / 4))
> iosz=$((blksz * nr / 2))
> 
> $XFS_IO_PROG -d -c "pwrite -S 0x63 -b $iosz $off $iosz" $testdir/file3
> _pwrite_byte 0x63 $off $iosz $testdir/file3.chk

Done.  I decided on cowoff and cowsz since that's what we're doing.

--D

> 
> -Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
  2016-02-09  8:15     ` Dave Chinner
@ 2016-02-10  1:06       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:06 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 07:15:47PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:42PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > +
> > +_cleanup()
> > +{
> > +    cd /
> > +    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> > +    #rm -rf "$tmp".* "$testdir"
> 
> uncomment.
> 
> > +echo "CoW and leave leftovers"
> > +echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> > +seq 2 2 $((nr - 1)) | while read f; do
> > +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
> > +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
> > +done
> 
> Ok, I just realised what was bugging me about these loops: "f" is
> not a typical loop iterator for a count. Normally we'd use "i" for
> these....
> 
> > +echo "old extents: $old_extents" >> "$seqres.full"
> > +echo "new extents: $new_extents" >> "$seqres.full"
> > +echo "maximum extents: $internal_blks" >> "$seqres.full"
> > +test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"
> 
> I wouldn't use _fail like this, echo is sufficient to cause the test
> to fail.

Ok, fixed.

--D

> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> As would getting rid of the unmount and just setting status
> appropriately...
> 
> /repeat
> 
> -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] 88+ messages in thread

* Re: [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector
@ 2016-02-10  1:06       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:06 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 07:15:47PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:42PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > +
> > +_cleanup()
> > +{
> > +    cd /
> > +    echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> > +    #rm -rf "$tmp".* "$testdir"
> 
> uncomment.
> 
> > +echo "CoW and leave leftovers"
> > +echo $old_cow_lifetime > /proc/sys/fs/xfs/speculative_cow_prealloc_lifetime
> > +seq 2 2 $((nr - 1)) | while read f; do
> > +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2" >> "$seqres.full"
> > +	"$XFS_IO_PROG" -f -c "pwrite -S 0x63 $((blksz * f)) 1" "$testdir/file2.chk" >> "$seqres.full"
> > +done
> 
> Ok, I just realised what was bugging me about these loops: "f" is
> not a typical loop iterator for a count. Normally we'd use "i" for
> these....
> 
> > +echo "old extents: $old_extents" >> "$seqres.full"
> > +echo "new extents: $new_extents" >> "$seqres.full"
> > +echo "maximum extents: $internal_blks" >> "$seqres.full"
> > +test $new_extents -lt $((internal_blks / 7)) || _fail "file2 badly fragmented"
> 
> I wouldn't use _fail like this, echo is sufficient to cause the test
> to fail.

Ok, fixed.

--D

> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> As would getting rid of the unmount and just setting status
> appropriately...
> 
> /repeat
> 
> -Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

* Re: [PATCH 19/23] xfs: test rmapbt functionality
  2016-02-09  8:26     ` Dave Chinner
@ 2016-02-10  1:07       ` Darrick J. Wong
  -1 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:07 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, linux-btrfs, xfs

On Tue, Feb 09, 2016 at 07:26:40PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:48PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/xfs        |   44 ++++++++++++++++++++++
> >  tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/233.out |    6 +++
> >  tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/234.out |    6 +++
> >  tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/235.out |   14 +++++++
> >  tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/236.out |    8 ++++
> >  tests/xfs/group   |    4 ++
> >  10 files changed, 450 insertions(+)
> >  create mode 100644 common/xfs
> >  create mode 100755 tests/xfs/233
> >  create mode 100644 tests/xfs/233.out
> >  create mode 100755 tests/xfs/234
> >  create mode 100644 tests/xfs/234.out
> >  create mode 100755 tests/xfs/235
> >  create mode 100644 tests/xfs/235.out
> >  create mode 100755 tests/xfs/236
> >  create mode 100644 tests/xfs/236.out
> > 
> > 
> > diff --git a/common/xfs b/common/xfs
> > new file mode 100644
> > index 0000000..2d1a76f
> > --- /dev/null
> > +++ b/common/xfs
> > @@ -0,0 +1,44 @@
> > +##/bin/bash
> > +# Routines for handling XFS
> > +#-----------------------------------------------------------------------
> > +#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
> > +#  (at your option) any later version.
> > +#
> > +#  This program is distributed in the hope that it will 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 to the Free Software
> > +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> > +#  USA
> > +#
> > +#  Contact information: Oracle Corporation, 500 Oracle Parkway,
> > +#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
> > +#-----------------------------------------------------------------------
> > +
> > +_require_xfs_test_rmapbt()
> > +{
> > +	_require_test
> > +
> > +	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
> > +		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
> > +	fi
> > +}
> > +
> > +_require_xfs_scratch_rmapbt()
> > +{
> > +	_require_scratch
> > +
> > +	_scratch_mkfs > /dev/null
> > +	_scratch_mount
> > +	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
> > +		_scratch_unmount
> > +		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
> > +	fi
> > +	_scratch_unmount
> > +}
> 
> No, not yet. :)
> 
> Wait until I get my "split common/rc" patchset out there, because it
> does not require:

Ok, I moved all the common/xfs stuff back to common/rc.

> 
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/xfs
> 
> This.
> 
> And i don't want to have to undo a bunch of stuff in tests yet. Just
> lump it all in common/rc for the moment.
> 
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_xfs_scratch_rmapbt
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > "$seqres.full" 2>&1
> > +_scratch_mount >> "$seqres.full" 2>&1
> 
> _scratch_mkfs_sized ?

Done.
> 
> > +here=`pwd`
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +    cd /
> > +    #rm -f $tmp.*
> 
> More random uncommenting needed.
> 
> > +
> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> > +_check_scratch_fs
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> Cull.

Done

--D

> 
> -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] 88+ messages in thread

* Re: [PATCH 19/23] xfs: test rmapbt functionality
@ 2016-02-10  1:07       ` Darrick J. Wong
  0 siblings, 0 replies; 88+ messages in thread
From: Darrick J. Wong @ 2016-02-10  1:07 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, fstests, xfs

On Tue, Feb 09, 2016 at 07:26:40PM +1100, Dave Chinner wrote:
> On Mon, Feb 08, 2016 at 05:13:48PM -0800, Darrick J. Wong wrote:
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/xfs        |   44 ++++++++++++++++++++++
> >  tests/xfs/233     |   78 ++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/233.out |    6 +++
> >  tests/xfs/234     |   89 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/234.out |    6 +++
> >  tests/xfs/235     |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/235.out |   14 +++++++
> >  tests/xfs/236     |   93 ++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/xfs/236.out |    8 ++++
> >  tests/xfs/group   |    4 ++
> >  10 files changed, 450 insertions(+)
> >  create mode 100644 common/xfs
> >  create mode 100755 tests/xfs/233
> >  create mode 100644 tests/xfs/233.out
> >  create mode 100755 tests/xfs/234
> >  create mode 100644 tests/xfs/234.out
> >  create mode 100755 tests/xfs/235
> >  create mode 100644 tests/xfs/235.out
> >  create mode 100755 tests/xfs/236
> >  create mode 100644 tests/xfs/236.out
> > 
> > 
> > diff --git a/common/xfs b/common/xfs
> > new file mode 100644
> > index 0000000..2d1a76f
> > --- /dev/null
> > +++ b/common/xfs
> > @@ -0,0 +1,44 @@
> > +##/bin/bash
> > +# Routines for handling XFS
> > +#-----------------------------------------------------------------------
> > +#  Copyright (c) 2015 Oracle.  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; either version 2 of the License, or
> > +#  (at your option) any later version.
> > +#
> > +#  This program is distributed in the hope that it will 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 to the Free Software
> > +#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> > +#  USA
> > +#
> > +#  Contact information: Oracle Corporation, 500 Oracle Parkway,
> > +#  Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
> > +#-----------------------------------------------------------------------
> > +
> > +_require_xfs_test_rmapbt()
> > +{
> > +	_require_test
> > +
> > +	if [ "$(xfs_info "$TEST_DIR" | grep -c "rmapbt=1")" -ne 1 ]; then
> > +		_notrun "rmapbt not supported by test filesystem type: $FSTYP"
> > +	fi
> > +}
> > +
> > +_require_xfs_scratch_rmapbt()
> > +{
> > +	_require_scratch
> > +
> > +	_scratch_mkfs > /dev/null
> > +	_scratch_mount
> > +	if [ "$(xfs_info "$SCRATCH_MNT" | grep -c "rmapbt=1")" -ne 1 ]; then
> > +		_scratch_unmount
> > +		_notrun "rmapbt not supported by scratch filesystem type: $FSTYP"
> > +	fi
> > +	_scratch_unmount
> > +}
> 
> No, not yet. :)
> 
> Wait until I get my "split common/rc" patchset out there, because it
> does not require:

Ok, I moved all the common/xfs stuff back to common/rc.

> 
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/xfs
> 
> This.
> 
> And i don't want to have to undo a bunch of stuff in tests yet. Just
> lump it all in common/rc for the moment.
> 
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_supported_fs xfs
> > +_require_xfs_scratch_rmapbt
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs -d size=$((2 * 4096 * 4096)) -l size=4194304 > "$seqres.full" 2>&1
> > +_scratch_mount >> "$seqres.full" 2>&1
> 
> _scratch_mkfs_sized ?

Done.
> 
> > +here=`pwd`
> > +tmp=/tmp/$$
> > +status=1	# failure is the default!
> > +trap "_cleanup; exit \$status" 0 1 2 3 15
> > +
> > +_cleanup()
> > +{
> > +    cd /
> > +    #rm -f $tmp.*
> 
> More random uncommenting needed.
> 
> > +
> > +echo "Check for damage"
> > +umount "$SCRATCH_MNT"
> > +_check_scratch_fs
> > +
> > +# success, all done
> > +status=0
> > +exit
> 
> Cull.

Done

--D

> 
> -Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 
> _______________________________________________
> 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] 88+ messages in thread

end of thread, other threads:[~2016-02-10  1:07 UTC | newest]

Thread overview: 88+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09  1:11 [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls Darrick J. Wong
2016-02-09  1:11 ` Darrick J. Wong
2016-02-09  1:11 ` [PATCH 01/23] generic/182: this is a dedupe test, check for dedupe Darrick J. Wong
2016-02-09  1:11   ` Darrick J. Wong
2016-02-09  1:11 ` [PATCH 02/23] xfstests: filter whitespace in 128 and 132 Darrick J. Wong
2016-02-09  1:11   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 03/23] xfstests: make _scratch_mkfs_blocksized usable Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 04/23] reflink: remove redundant filesystem checks from the end of the tests Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 05/23] common/dmerror: add some more dmerror routines Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 06/23] dio unwritten conversion bug tests Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  7:37   ` Dave Chinner
2016-02-09  7:37     ` Dave Chinner
2016-02-09  8:08     ` Darrick J. Wong
2016-02-09  8:08       ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 07/23] reflink: test intersecting CoW and falloc/fpunch/fzero/fcollapse/finsert/ftrunc Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 08/23] reflink: test CoW behavior with IO errors Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 09/23] reflink: test CoW operations against the source file Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 10/23] xfs: more reflink tests Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  7:36   ` Dave Chinner
2016-02-09  7:36     ` Dave Chinner
2016-02-09  8:16     ` Darrick J. Wong
2016-02-09  8:16       ` Darrick J. Wong
2016-02-09  1:12 ` [PATCH 11/23] reflink: ensure that we can handle reflinking a lot of extents Darrick J. Wong
2016-02-09  1:12   ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 12/23] xfs/122: support refcount/rmap data structures Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  7:43   ` Dave Chinner
2016-02-09  7:43     ` Dave Chinner
2016-02-09  7:55     ` Darrick J. Wong
2016-02-09  7:55       ` Darrick J. Wong
2016-02-09  8:53       ` Dave Chinner
2016-02-09  8:53         ` Dave Chinner
2016-02-09  1:13 ` [PATCH 13/23] xfs: test fragmentation characteristics of copy-on-write Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  8:01   ` Dave Chinner
2016-02-09  8:01     ` Dave Chinner
2016-02-10  1:02     ` Darrick J. Wong
2016-02-10  1:02       ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 14/23] reflink: high offset reflink and dedupe tests Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 15/23] reflink: test xfs cow behavior when the filesystem crashes Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 16/23] reflink: test quota accounting Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 17/23] reflink: test CoW across a mixed range of block types with cowextsize set Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  8:09   ` Dave Chinner
2016-02-09  8:09     ` Dave Chinner
2016-02-10  1:03     ` Darrick J. Wong
2016-02-10  1:03       ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 18/23] xfs: test the automatic cowextsize extent garbage collector Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  8:15   ` Dave Chinner
2016-02-09  8:15     ` Dave Chinner
2016-02-10  1:06     ` Darrick J. Wong
2016-02-10  1:06       ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 19/23] xfs: test rmapbt functionality Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  8:26   ` Dave Chinner
2016-02-09  8:26     ` Dave Chinner
2016-02-10  1:07     ` Darrick J. Wong
2016-02-10  1:07       ` Darrick J. Wong
2016-02-09  1:13 ` [PATCH 20/23] reflink: test aio copy on write Darrick J. Wong
2016-02-09  1:13   ` Darrick J. Wong
2016-02-09  1:14 ` [PATCH 21/23] xfs: aio cow tests Darrick J. Wong
2016-02-09  1:14   ` Darrick J. Wong
2016-02-09  8:32   ` Dave Chinner
2016-02-09  8:32     ` Dave Chinner
2016-02-09 21:51     ` Darrick J. Wong
2016-02-09 21:51       ` Darrick J. Wong
2016-02-09  1:14 ` [PATCH 22/23] xfs: test xfs_getbmapx behavior with shared extents Darrick J. Wong
2016-02-09  1:14   ` Darrick J. Wong
2016-02-09  1:14 ` [PATCH 23/23] reflink: test reflink+cow+enospc all at the same time Darrick J. Wong
2016-02-09  1:14   ` Darrick J. Wong
2016-02-09  7:21 ` [PATCH v4.1 00/23] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls Dave Chinner
2016-02-09  7:21   ` Dave Chinner
2016-02-09  7:25   ` Darrick J. Wong
2016-02-09  7:25     ` Darrick J. Wong
2016-02-09  7:50     ` Darrick J. Wong
2016-02-09  7:50       ` Darrick J. Wong

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.