All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
@ 2016-06-17  1:46 ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Hi all,

This is the sixth revision of a patchset that adds to xfstests
support for testing reverse-mappings of physical blocks to file and
metadata (rmap); support for testing multiple file logical blocks to
the same physical block (reflink); and implements the beginnings of
online metadata scrubbing.

The first eight patches are in Eryu Guan's pull request on 2016-06-15.
Those patches haven't changed, but they're not yet in the upstream
repo.

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
There are also updates for xfs-docs[4].  The kernel patches should
apply to dchinner's for-next; xfsprogs patches to for-next; and
xfstest to master.  The kernel git tree already has for-next included.

The patches have been xfstested with x64, i386, and armv7l--arm64,
ppc64, and ppc64le no longer boot in qemu.  All three architectures
pass all 'clone' group tests except xfs/128 (which is the swapext
test), and AFAICT don't cause any new failures for the 'auto' group.

This is an extraordinary way to eat your data.  Enjoy! 
Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/djwong-devel
[2] https://github.com/djwong/xfsprogs/tree/djwong-devel
[3] https://github.com/djwong/xfstests/tree/djwong-devel
[4] https://github.com/djwong/xfs-documentation/tree/djwong-devel

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

* [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
@ 2016-06-17  1:46 ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Hi all,

This is the sixth revision of a patchset that adds to xfstests
support for testing reverse-mappings of physical blocks to file and
metadata (rmap); support for testing multiple file logical blocks to
the same physical block (reflink); and implements the beginnings of
online metadata scrubbing.

The first eight patches are in Eryu Guan's pull request on 2016-06-15.
Those patches haven't changed, but they're not yet in the upstream
repo.

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
There are also updates for xfs-docs[4].  The kernel patches should
apply to dchinner's for-next; xfsprogs patches to for-next; and
xfstest to master.  The kernel git tree already has for-next included.

The patches have been xfstested with x64, i386, and armv7l--arm64,
ppc64, and ppc64le no longer boot in qemu.  All three architectures
pass all 'clone' group tests except xfs/128 (which is the swapext
test), and AFAICT don't cause any new failures for the 'auto' group.

This is an extraordinary way to eat your data.  Enjoy! 
Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/djwong-devel
[2] https://github.com/djwong/xfsprogs/tree/djwong-devel
[3] https://github.com/djwong/xfstests/tree/djwong-devel
[4] https://github.com/djwong/xfs-documentation/tree/djwong-devel

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

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

* [PATCH 01/20] xfs/104: don't enospc when ag metadata overhead grows
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Adapt to different metadata overhead sizes by trying to reserve
decreasing amounts of disk space until we actually succeed at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/104 |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


diff --git a/tests/xfs/104 b/tests/xfs/104
index 17f9b62..785027e 100755
--- a/tests/xfs/104
+++ b/tests/xfs/104
@@ -88,9 +88,14 @@ sizeb=`expr $size / $dbsize`	# in data blocks
 echo "*** creating scratch filesystem"
 _create_scratch -lsize=10m -dsize=${size} -dagcount=${nags}
 
-fillsize=`expr 110 \* 1048576`	# 110 megabytes of filling
 echo "*** using some initial space on scratch filesystem"
-_fill_scratch $fillsize
+for i in `seq 125 -1 90`; do
+	fillsize=`expr $i \* 1048576`
+	out="$(_fill_scratch $fillsize 2>&1)"
+	echo "$out" | grep -q 'No space left on device' && continue
+	test -n "${out}" && echo "$out"
+	break
+done
 
 #
 # Grow the filesystem while actively stressing it...


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

* [PATCH 01/20] xfs/104: don't enospc when ag metadata overhead grows
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Adapt to different metadata overhead sizes by trying to reserve
decreasing amounts of disk space until we actually succeed at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/104 |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)


diff --git a/tests/xfs/104 b/tests/xfs/104
index 17f9b62..785027e 100755
--- a/tests/xfs/104
+++ b/tests/xfs/104
@@ -88,9 +88,14 @@ sizeb=`expr $size / $dbsize`	# in data blocks
 echo "*** creating scratch filesystem"
 _create_scratch -lsize=10m -dsize=${size} -dagcount=${nags}
 
-fillsize=`expr 110 \* 1048576`	# 110 megabytes of filling
 echo "*** using some initial space on scratch filesystem"
-_fill_scratch $fillsize
+for i in `seq 125 -1 90`; do
+	fillsize=`expr $i \* 1048576`
+	out="$(_fill_scratch $fillsize 2>&1)"
+	echo "$out" | grep -q 'No space left on device' && continue
+	test -n "${out}" && echo "$out"
+	break
+done
 
 #
 # Grow the filesystem while actively stressing it...

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

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

* [PATCH 02/20] tests: don't put loop control files on the scratch mount
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

If we're doing write/overwrite/snapshot/resource exhaustion tests on
the scratch device, use the test directory to hold the loop
termination signal files.  This way we don't run infinitely because we
can't create the flag due to ENOSPC.

v2: put the control files in /tmp, not $TEST_DIR

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/162 |    8 +++++---
 tests/generic/163 |    8 +++++---
 tests/generic/164 |    8 +++++---
 tests/generic/165 |    8 +++++---
 tests/generic/166 |    8 +++++---
 tests/generic/167 |    8 +++++---
 tests/generic/168 |    8 +++++---
 tests/generic/170 |    8 +++++---
 tests/generic/333 |   20 ++++++++++++--------
 tests/generic/334 |   20 ++++++++++++--------
 10 files changed, 64 insertions(+), 40 deletions(-)


diff --git a/tests/generic/162 b/tests/generic/162
index 5ff2ee2..61cf463 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -33,7 +33,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -51,6 +51,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -64,7 +66,7 @@ _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file2 >> $seqres.full
 		done
@@ -81,7 +83,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished dedupeing"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/163 b/tests/generic/163
index fcba677..e2c6042 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -33,7 +33,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -51,6 +51,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -64,7 +66,7 @@ _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file1 >> $seqres.full
 		done
@@ -81,7 +83,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished dedupeing"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/164 b/tests/generic/164
index acacb7f..78ea787 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -71,7 +73,7 @@ fbytes() {
 }
 
 reader() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		_read_range $testdir/file3 0 $((loops * blksz)) | fbytes
 	done
 }
@@ -91,7 +93,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished reflinking"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/165 b/tests/generic/165
index b742d19..ca11e1e 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -54,6 +54,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -72,7 +74,7 @@ fbytes() {
 }
 
 reader() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		_read_range $testdir/file3 0 $((loops * blksz)) -d | fbytes
 	done
 }
@@ -92,7 +94,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished reflinking"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/166 b/tests/generic/166
index 0e31f2e..8600a13 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -54,6 +54,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -68,7 +70,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo "$out" | grep -q "No space left" && break
@@ -83,7 +85,7 @@ snappy &
 seq $nr_loops -1 0 | while read i; do
 	_pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file1 >> $seqres.full
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/167 b/tests/generic/167
index b2d6c87..261506b 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +69,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo "$out" | grep -q "No space left" && break
@@ -82,7 +84,7 @@ snappy &
 seq $nr_loops -1 0 | while read i; do
 	_pwrite_byte 0x63 $((i * blksz)) $blksz $testdir/file1 >> $seqres.full
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/168 b/tests/generic/168
index 7047d10..ceee264 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -52,6 +52,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -66,7 +68,7 @@ _scratch_cycle_mount
 
 # Direct I/O overwriter...
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x63 $((i * blksz)) $blksz $testdir/file2 >> $seqres.full
 		done
@@ -82,7 +84,7 @@ seq 1 10 | while read j; do
 		[ $? -ne 0 ] && exit
 	done
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/170 b/tests/generic/170
index 4861052..6559243 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +69,7 @@ _scratch_cycle_mount
 
 # Direct I/O overwriter...
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file2 >> $seqres.full
 		done
@@ -83,7 +85,7 @@ seq 1 10 | while read j; do
 		[ $? -ne 0 ] && exit
 	done
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/333 b/tests/generic/333
index 8db86e3..3d874d7 100755
--- a/tests/generic/333
+++ b/tests/generic/333
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file $abort_file
     wait
 }
 
@@ -54,6 +54,10 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
+abort_file=/tmp/abort
+rm -rf $abort_file
 mkdir $testdir
 
 loops=1024
@@ -68,7 +72,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo $out | grep -q "No space left" && break
@@ -76,7 +80,7 @@ snappy() {
 		test $res -ne 0 && break
 		n=$((n + 1))
 	done
-	touch $testdir/abort
+	touch $abort_file
 }
 
 echo "Snapshot a file undergoing directio rewrite"
@@ -85,13 +89,13 @@ seq 1 1000 | while read j; 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
+		echo $out | grep -q "No space left" && touch $abort_file
+		echo $out | grep -qi "error" && touch $abort_file
+		test -e $abort_file && break
 	done
-	test -e $testdir/abort && break
+	test -e $abort_file && break
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/334 b/tests/generic/334
index 5714125..fb21d4f 100755
--- a/tests/generic/334
+++ b/tests/generic/334
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file $abort_file
     wait
 }
 
@@ -53,6 +53,10 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
+abort_file=/tmp/abort
+rm -rf $abort_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +71,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo $out | grep -q "No space left" && break
@@ -75,7 +79,7 @@ snappy() {
 		test $res -ne 0 && break
 		n=$((n + 1))
 	done
-	touch $testdir/abort
+	touch $abort_file
 }
 
 echo "Snapshot a file undergoing buffered rewrite"
@@ -84,13 +88,13 @@ seq 1 1000 | while read j; 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
+		echo $out | grep -q "No space left" && touch $abort_file
+		echo $out | grep -qi "error" && touch $abort_file
+		test -e $abort_file && break
 	done
-	test -e $testdir/abort && break
+	test -e $abort_file && break
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done


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

* [PATCH 02/20] tests: don't put loop control files on the scratch mount
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

If we're doing write/overwrite/snapshot/resource exhaustion tests on
the scratch device, use the test directory to hold the loop
termination signal files.  This way we don't run infinitely because we
can't create the flag due to ENOSPC.

v2: put the control files in /tmp, not $TEST_DIR

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/162 |    8 +++++---
 tests/generic/163 |    8 +++++---
 tests/generic/164 |    8 +++++---
 tests/generic/165 |    8 +++++---
 tests/generic/166 |    8 +++++---
 tests/generic/167 |    8 +++++---
 tests/generic/168 |    8 +++++---
 tests/generic/170 |    8 +++++---
 tests/generic/333 |   20 ++++++++++++--------
 tests/generic/334 |   20 ++++++++++++--------
 10 files changed, 64 insertions(+), 40 deletions(-)


diff --git a/tests/generic/162 b/tests/generic/162
index 5ff2ee2..61cf463 100755
--- a/tests/generic/162
+++ b/tests/generic/162
@@ -33,7 +33,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -51,6 +51,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -64,7 +66,7 @@ _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file2 >> $seqres.full
 		done
@@ -81,7 +83,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished dedupeing"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/163 b/tests/generic/163
index fcba677..e2c6042 100755
--- a/tests/generic/163
+++ b/tests/generic/163
@@ -33,7 +33,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -51,6 +51,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -64,7 +66,7 @@ _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x61 $((i * blksz)) $blksz $testdir/file1 >> $seqres.full
 		done
@@ -81,7 +83,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished dedupeing"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/164 b/tests/generic/164
index acacb7f..78ea787 100755
--- a/tests/generic/164
+++ b/tests/generic/164
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -71,7 +73,7 @@ fbytes() {
 }
 
 reader() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		_read_range $testdir/file3 0 $((loops * blksz)) | fbytes
 	done
 }
@@ -91,7 +93,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished reflinking"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/165 b/tests/generic/165
index b742d19..ca11e1e 100755
--- a/tests/generic/165
+++ b/tests/generic/165
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -54,6 +54,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=512
@@ -72,7 +74,7 @@ fbytes() {
 }
 
 reader() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		_read_range $testdir/file3 0 $((loops * blksz)) -d | fbytes
 	done
 }
@@ -92,7 +94,7 @@ for i in `seq 1 2`; do
 	done
 done
 echo "Finished reflinking"
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/166 b/tests/generic/166
index 0e31f2e..8600a13 100755
--- a/tests/generic/166
+++ b/tests/generic/166
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -54,6 +54,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -68,7 +70,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo "$out" | grep -q "No space left" && break
@@ -83,7 +85,7 @@ snappy &
 seq $nr_loops -1 0 | while read i; do
 	_pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file1 >> $seqres.full
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/167 b/tests/generic/167
index b2d6c87..261506b 100755
--- a/tests/generic/167
+++ b/tests/generic/167
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +69,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo "$out" | grep -q "No space left" && break
@@ -82,7 +84,7 @@ snappy &
 seq $nr_loops -1 0 | while read i; do
 	_pwrite_byte 0x63 $((i * blksz)) $blksz $testdir/file1 >> $seqres.full
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/168 b/tests/generic/168
index 7047d10..ceee264 100755
--- a/tests/generic/168
+++ b/tests/generic/168
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -52,6 +52,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -66,7 +68,7 @@ _scratch_cycle_mount
 
 # Direct I/O overwriter...
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x63 $((i * blksz)) $blksz $testdir/file2 >> $seqres.full
 		done
@@ -82,7 +84,7 @@ seq 1 10 | while read j; do
 		[ $? -ne 0 ] && exit
 	done
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/170 b/tests/generic/170
index 4861052..6559243 100755
--- a/tests/generic/170
+++ b/tests/generic/170
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file
     wait
 }
 
@@ -53,6 +53,8 @@ _scratch_mkfs > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +69,7 @@ _scratch_cycle_mount
 
 # Direct I/O overwriter...
 overwrite() {
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		seq $nr_loops -1 0 | while read i; do
 			_pwrite_byte 0x63 $((i * blksz)) $blksz -d $testdir/file2 >> $seqres.full
 		done
@@ -83,7 +85,7 @@ seq 1 10 | while read j; do
 		[ $? -ne 0 ] && exit
 	done
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/333 b/tests/generic/333
index 8db86e3..3d874d7 100755
--- a/tests/generic/333
+++ b/tests/generic/333
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file $abort_file
     wait
 }
 
@@ -54,6 +54,10 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
+abort_file=/tmp/abort
+rm -rf $abort_file
 mkdir $testdir
 
 loops=1024
@@ -68,7 +72,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo $out | grep -q "No space left" && break
@@ -76,7 +80,7 @@ snappy() {
 		test $res -ne 0 && break
 		n=$((n + 1))
 	done
-	touch $testdir/abort
+	touch $abort_file
 }
 
 echo "Snapshot a file undergoing directio rewrite"
@@ -85,13 +89,13 @@ seq 1 1000 | while read j; 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
+		echo $out | grep -q "No space left" && touch $abort_file
+		echo $out | grep -qi "error" && touch $abort_file
+		test -e $abort_file && break
 	done
-	test -e $testdir/abort && break
+	test -e $abort_file && break
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done
diff --git a/tests/generic/334 b/tests/generic/334
index 5714125..fb21d4f 100755
--- a/tests/generic/334
+++ b/tests/generic/334
@@ -34,7 +34,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 7 15
 _cleanup()
 {
     cd /
-    rm -rf $tmp.*
+    rm -rf $tmp.* $finished_file $abort_file
     wait
 }
 
@@ -53,6 +53,10 @@ _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
+finished_file=/tmp/finished
+rm -rf $finished_file
+abort_file=/tmp/abort
+rm -rf $abort_file
 mkdir $testdir
 
 loops=1024
@@ -67,7 +71,7 @@ _scratch_cycle_mount
 # Snapshot creator...
 snappy() {
 	n=0
-	while [ ! -e $testdir/finished ]; do
+	while [ ! -e $finished_file ]; do
 		out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
 		res=$?
 		echo $out | grep -q "No space left" && break
@@ -75,7 +79,7 @@ snappy() {
 		test $res -ne 0 && break
 		n=$((n + 1))
 	done
-	touch $testdir/abort
+	touch $abort_file
 }
 
 echo "Snapshot a file undergoing buffered rewrite"
@@ -84,13 +88,13 @@ seq 1 1000 | while read j; 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
+		echo $out | grep -q "No space left" && touch $abort_file
+		echo $out | grep -qi "error" && touch $abort_file
+		test -e $abort_file && break
 	done
-	test -e $testdir/abort && break
+	test -e $abort_file && break
 done
-touch $testdir/finished
+touch $finished_file
 wait
 
 # success, all done

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

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

* [PATCH 03/20] xfs: test copy-on-write leftover recovery
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Test recovery of CoW leftovers in xfs_repair.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/853     |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/853.out |   13 ++++
 tests/xfs/854     |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/854.out |   13 ++++
 tests/xfs/group   |    2 +
 5 files changed, 387 insertions(+)
 create mode 100755 tests/xfs/853
 create mode 100644 tests/xfs/853.out
 create mode 100755 tests/xfs/854
 create mode 100644 tests/xfs/854.out


diff --git a/tests/xfs/853 b/tests/xfs/853
new file mode 100755
index 0000000..14a6940
--- /dev/null
+++ b/tests/xfs/853
@@ -0,0 +1,179 @@
+#! /bin/bash
+# FS QA Test No. 853
+#
+# Test recovery of "lost" CoW blocks:
+# - Use the debugger to fake a leftover CoW extent
+# - See if xfs_repair fixes it
+#
+#-----------------------------------------------------------------------
+# 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
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+echo "Format"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+umount $SCRATCH_MNT
+
+_get_agf_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'agf 1' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_agf_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_get_sb_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'sb 0' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_sb_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'sb 0' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_filter_leftover() {
+	grep "^leftover" | sed -e "s/[0-9]\+/NR/g"
+}
+
+_dump_status() {
+	echo "** " "$@"
+	xfs_db -c 'sb 0' -c p $SCRATCH_DEV
+	echo "** agf header"
+	xfs_db -c 'agf 1' -c p $SCRATCH_DEV
+	echo "** refcntbt"
+	xfs_db -c 'agf 1' -c 'addr refcntroot' -c p $SCRATCH_DEV
+	echo "** rmapbt"
+	test $is_rmap -gt 0 && xfs_db -c 'agf 1' -c 'addr rmaproot' -c p $SCRATCH_DEV
+	echo "** bnobt"
+	xfs_db -c 'agf 1' -c 'addr bnoroot' -c p $SCRATCH_DEV
+	echo "** cntbt"
+	xfs_db -c 'agf 1' -c 'addr cntroot' -c p $SCRATCH_DEV
+}
+
+echo "We need AG1 to have a single free extent"
+bno_lvl=$(_get_agf_data level -c 'addr bnoroot')
+bno_nr=$(_get_agf_data numrecs -c 'addr bnoroot')
+refc_lvl=$(_get_agf_data level -c 'addr refcntroot')
+refc_nr=$(_get_agf_data numrecs -c 'addr refcntroot')
+
+test $bno_lvl -eq 0 || echo "  AG 1 bnobt must only have one level"
+test $bno_nr -eq 1 || echo "  AG 1 bnobt must only have one record"
+test $refc_lvl -eq 0 || echo "  AG 1 refcountbt must only have one level"
+test $refc_nr -eq 0 || echo "  AG 1 refcountbt must only have one record"
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_lvl=$(_get_agf_data level -c 'addr rmaproot')
+	rmap_nr=$(_get_agf_data numrecs -c 'addr rmaproot')
+	test $rmap_lvl -eq 0 || echo "  AG 1 rmapbt must only have one level"
+fi
+
+echo "Find our extent and old counter values"
+bno=$(_get_agf_data "recs[1].startblock" -c 'addr bnoroot')
+len=$(_get_agf_data "recs[1].blockcount" -c 'addr bnoroot')
+agf_freeblks=$(_get_agf_data freeblks)
+sb_fdblocks=$(_get_sb_data fdblocks)
+
+test $len -ge 200 || echo "  AG 1 doesn't have enough free blocks"
+
+# Take the last 100 blocks of the free extent
+debris_len=100
+debris_bno=$((bno + len - debris_len))
+
+echo "Remove the extent from the freesp btrees"
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr bnoroot'
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr cntroot'
+_set_agf_data freeblks $((agf_freeblks - debris_len))
+_set_agf_data longest $((len - debris_len))
+_set_sb_data fdblocks $((sb_fdblocks - debris_len))
+
+echo "Add the extent to the refcount btree"
+_set_agf_data numrecs 1 -c 'addr refcntroot'
+_set_agf_data "recs[1].startblock" $debris_bno -c 'addr refcntroot'
+_set_agf_data "recs[1].blockcount" $debris_len -c 'addr refcntroot'
+_set_agf_data "recs[1].refcount" 1 -c 'addr refcntroot'
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_nr=$((rmap_nr + 1))
+	_set_agf_data numrecs $rmap_nr -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].startblock" $debris_bno -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].blockcount" $debris_len -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].owner" -9 -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].offset" 0 -c 'addr rmaproot'
+fi
+
+_dump_status "broken fs config" >> $seqres.full
+
+echo "Look for leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+echo "Fix filesystem"
+_scratch_xfs_repair >> $seqres.full 2>&1 || echo "xfs_repair failed?"
+
+_dump_status "supposedly fixed fs config" >> $seqres.full
+
+echo "Look for no more leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for no more leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/853.out b/tests/xfs/853.out
new file mode 100644
index 0000000..3224e8d
--- /dev/null
+++ b/tests/xfs/853.out
@@ -0,0 +1,13 @@
+QA output created by 853
+Format
+We need AG1 to have a single free extent
+Find our extent and old counter values
+Remove the extent from the freesp btrees
+Add the extent to the refcount btree
+Look for leftover warning in xfs_check
+leftover CoW extent (NR/NR) len NR
+Look for leftover warning in xfs_repair
+leftover CoW extent (NR/NR) len NR
+Fix filesystem
+Look for no more leftover warning in xfs_check
+Look for no more leftover warning in xfs_repair
diff --git a/tests/xfs/854 b/tests/xfs/854
new file mode 100755
index 0000000..5c6bec9
--- /dev/null
+++ b/tests/xfs/854
@@ -0,0 +1,180 @@
+#! /bin/bash
+# FS QA Test No. 854
+#
+# Test recovery of "lost" CoW blocks:
+# - Use the debugger to fake a leftover CoW extent
+# - See if mount/umount fixes it
+#
+#-----------------------------------------------------------------------
+# 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
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+echo "Format"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+umount $SCRATCH_MNT
+
+_get_agf_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'agf 1' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_agf_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_get_sb_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'sb 0' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_sb_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'sb 0' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_filter_leftover() {
+	grep "^leftover" | sed -e "s/[0-9]\+/NR/g"
+}
+
+_dump_status() {
+	echo "** " "$@"
+	xfs_db -c 'sb 0' -c p $SCRATCH_DEV
+	echo "** agf header"
+	xfs_db -c 'agf 1' -c p $SCRATCH_DEV
+	echo "** refcntbt"
+	xfs_db -c 'agf 1' -c 'addr refcntroot' -c p $SCRATCH_DEV
+	echo "** rmapbt"
+	test $is_rmap -gt 0 && xfs_db -c 'agf 1' -c 'addr rmaproot' -c p $SCRATCH_DEV
+	echo "** bnobt"
+	xfs_db -c 'agf 1' -c 'addr bnoroot' -c p $SCRATCH_DEV
+	echo "** cntbt"
+	xfs_db -c 'agf 1' -c 'addr cntroot' -c p $SCRATCH_DEV
+}
+
+echo "We need AG1 to have a single free extent"
+bno_lvl=$(_get_agf_data level -c 'addr bnoroot')
+bno_nr=$(_get_agf_data numrecs -c 'addr bnoroot')
+refc_lvl=$(_get_agf_data level -c 'addr refcntroot')
+refc_nr=$(_get_agf_data numrecs -c 'addr refcntroot')
+
+test $bno_lvl -eq 0 || echo "  AG 1 bnobt must only have one level"
+test $bno_nr -eq 1 || echo "  AG 1 bnobt must only have one record"
+test $refc_lvl -eq 0 || echo "  AG 1 refcountbt must only have one level"
+test $refc_nr -eq 0 || echo "  AG 1 refcountbt must only have one record"
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_lvl=$(_get_agf_data level -c 'addr rmaproot')
+	rmap_nr=$(_get_agf_data numrecs -c 'addr rmaproot')
+	test $rmap_lvl -eq 0 || echo "  AG 1 rmapbt must only have one level"
+fi
+
+echo "Find our extent and old counter values"
+bno=$(_get_agf_data "recs[1].startblock" -c 'addr bnoroot')
+len=$(_get_agf_data "recs[1].blockcount" -c 'addr bnoroot')
+agf_freeblks=$(_get_agf_data freeblks)
+sb_fdblocks=$(_get_sb_data fdblocks)
+
+test $len -ge 200 || echo "  AG 1 doesn't have enough free blocks"
+
+# Take the last 100 blocks of the free extent
+debris_len=100
+debris_bno=$((bno + len - debris_len))
+
+echo "Remove the extent from the freesp btrees"
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr bnoroot'
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr cntroot'
+_set_agf_data freeblks $((agf_freeblks - debris_len))
+_set_agf_data longest $((len - debris_len))
+_set_sb_data fdblocks $((sb_fdblocks - debris_len))
+
+echo "Add the extent to the refcount btree"
+_set_agf_data numrecs 1 -c 'addr refcntroot'
+_set_agf_data "recs[1].startblock" $debris_bno -c 'addr refcntroot'
+_set_agf_data "recs[1].blockcount" $debris_len -c 'addr refcntroot'
+_set_agf_data "recs[1].refcount" 1 -c 'addr refcntroot'
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_nr=$((rmap_nr + 1))
+	_set_agf_data numrecs $rmap_nr -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].startblock" $debris_bno -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].blockcount" $debris_len -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].owner" -9 -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].offset" 0 -c 'addr rmaproot'
+fi
+
+_dump_status "broken fs config" >> $seqres.full
+
+echo "Look for leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+echo "Mount filesystem"
+_scratch_mount
+umount $SCRATCH_MNT
+
+_dump_status "supposedly fixed fs config" >> $seqres.full
+
+echo "Look for no more leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for no more leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/854.out b/tests/xfs/854.out
new file mode 100644
index 0000000..aae2fd7
--- /dev/null
+++ b/tests/xfs/854.out
@@ -0,0 +1,13 @@
+QA output created by 854
+Format
+We need AG1 to have a single free extent
+Find our extent and old counter values
+Remove the extent from the freesp btrees
+Add the extent to the refcount btree
+Look for leftover warning in xfs_check
+leftover CoW extent (NR/NR) len NR
+Look for leftover warning in xfs_repair
+leftover CoW extent (NR/NR) len NR
+Mount filesystem
+Look for no more leftover warning in xfs_check
+Look for no more leftover warning in xfs_repair
diff --git a/tests/xfs/group b/tests/xfs/group
index f4c6816..4ac62c1 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -285,3 +285,5 @@
 303 auto quick quota
 304 auto quick quota
 305 auto quota
+853 auto quick clone
+854 auto quick clone


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

* [PATCH 03/20] xfs: test copy-on-write leftover recovery
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Test recovery of CoW leftovers in xfs_repair.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/853     |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/853.out |   13 ++++
 tests/xfs/854     |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/854.out |   13 ++++
 tests/xfs/group   |    2 +
 5 files changed, 387 insertions(+)
 create mode 100755 tests/xfs/853
 create mode 100644 tests/xfs/853.out
 create mode 100755 tests/xfs/854
 create mode 100644 tests/xfs/854.out


diff --git a/tests/xfs/853 b/tests/xfs/853
new file mode 100755
index 0000000..14a6940
--- /dev/null
+++ b/tests/xfs/853
@@ -0,0 +1,179 @@
+#! /bin/bash
+# FS QA Test No. 853
+#
+# Test recovery of "lost" CoW blocks:
+# - Use the debugger to fake a leftover CoW extent
+# - See if xfs_repair fixes it
+#
+#-----------------------------------------------------------------------
+# 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
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+echo "Format"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+umount $SCRATCH_MNT
+
+_get_agf_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'agf 1' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_agf_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_get_sb_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'sb 0' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_sb_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'sb 0' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_filter_leftover() {
+	grep "^leftover" | sed -e "s/[0-9]\+/NR/g"
+}
+
+_dump_status() {
+	echo "** " "$@"
+	xfs_db -c 'sb 0' -c p $SCRATCH_DEV
+	echo "** agf header"
+	xfs_db -c 'agf 1' -c p $SCRATCH_DEV
+	echo "** refcntbt"
+	xfs_db -c 'agf 1' -c 'addr refcntroot' -c p $SCRATCH_DEV
+	echo "** rmapbt"
+	test $is_rmap -gt 0 && xfs_db -c 'agf 1' -c 'addr rmaproot' -c p $SCRATCH_DEV
+	echo "** bnobt"
+	xfs_db -c 'agf 1' -c 'addr bnoroot' -c p $SCRATCH_DEV
+	echo "** cntbt"
+	xfs_db -c 'agf 1' -c 'addr cntroot' -c p $SCRATCH_DEV
+}
+
+echo "We need AG1 to have a single free extent"
+bno_lvl=$(_get_agf_data level -c 'addr bnoroot')
+bno_nr=$(_get_agf_data numrecs -c 'addr bnoroot')
+refc_lvl=$(_get_agf_data level -c 'addr refcntroot')
+refc_nr=$(_get_agf_data numrecs -c 'addr refcntroot')
+
+test $bno_lvl -eq 0 || echo "  AG 1 bnobt must only have one level"
+test $bno_nr -eq 1 || echo "  AG 1 bnobt must only have one record"
+test $refc_lvl -eq 0 || echo "  AG 1 refcountbt must only have one level"
+test $refc_nr -eq 0 || echo "  AG 1 refcountbt must only have one record"
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_lvl=$(_get_agf_data level -c 'addr rmaproot')
+	rmap_nr=$(_get_agf_data numrecs -c 'addr rmaproot')
+	test $rmap_lvl -eq 0 || echo "  AG 1 rmapbt must only have one level"
+fi
+
+echo "Find our extent and old counter values"
+bno=$(_get_agf_data "recs[1].startblock" -c 'addr bnoroot')
+len=$(_get_agf_data "recs[1].blockcount" -c 'addr bnoroot')
+agf_freeblks=$(_get_agf_data freeblks)
+sb_fdblocks=$(_get_sb_data fdblocks)
+
+test $len -ge 200 || echo "  AG 1 doesn't have enough free blocks"
+
+# Take the last 100 blocks of the free extent
+debris_len=100
+debris_bno=$((bno + len - debris_len))
+
+echo "Remove the extent from the freesp btrees"
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr bnoroot'
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr cntroot'
+_set_agf_data freeblks $((agf_freeblks - debris_len))
+_set_agf_data longest $((len - debris_len))
+_set_sb_data fdblocks $((sb_fdblocks - debris_len))
+
+echo "Add the extent to the refcount btree"
+_set_agf_data numrecs 1 -c 'addr refcntroot'
+_set_agf_data "recs[1].startblock" $debris_bno -c 'addr refcntroot'
+_set_agf_data "recs[1].blockcount" $debris_len -c 'addr refcntroot'
+_set_agf_data "recs[1].refcount" 1 -c 'addr refcntroot'
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_nr=$((rmap_nr + 1))
+	_set_agf_data numrecs $rmap_nr -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].startblock" $debris_bno -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].blockcount" $debris_len -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].owner" -9 -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].offset" 0 -c 'addr rmaproot'
+fi
+
+_dump_status "broken fs config" >> $seqres.full
+
+echo "Look for leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+echo "Fix filesystem"
+_scratch_xfs_repair >> $seqres.full 2>&1 || echo "xfs_repair failed?"
+
+_dump_status "supposedly fixed fs config" >> $seqres.full
+
+echo "Look for no more leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for no more leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/853.out b/tests/xfs/853.out
new file mode 100644
index 0000000..3224e8d
--- /dev/null
+++ b/tests/xfs/853.out
@@ -0,0 +1,13 @@
+QA output created by 853
+Format
+We need AG1 to have a single free extent
+Find our extent and old counter values
+Remove the extent from the freesp btrees
+Add the extent to the refcount btree
+Look for leftover warning in xfs_check
+leftover CoW extent (NR/NR) len NR
+Look for leftover warning in xfs_repair
+leftover CoW extent (NR/NR) len NR
+Fix filesystem
+Look for no more leftover warning in xfs_check
+Look for no more leftover warning in xfs_repair
diff --git a/tests/xfs/854 b/tests/xfs/854
new file mode 100755
index 0000000..5c6bec9
--- /dev/null
+++ b/tests/xfs/854
@@ -0,0 +1,180 @@
+#! /bin/bash
+# FS QA Test No. 854
+#
+# Test recovery of "lost" CoW blocks:
+# - Use the debugger to fake a leftover CoW extent
+# - See if mount/umount fixes it
+#
+#-----------------------------------------------------------------------
+# 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
+_supported_fs xfs
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+echo "Format"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+umount $SCRATCH_MNT
+
+_get_agf_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'agf 1' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_agf_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'agf 1' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_get_sb_data() {
+	field="$1"
+	shift
+
+	xfs_db -c 'sb 0' "$@" -c "p $field" $SCRATCH_DEV | awk '{print $3}'
+}
+
+_set_sb_data() {
+	field="$1"
+	value="$2"
+	shift; shift
+
+	xfs_db -x -c 'sb 0' "$@" -c "write $field -- $value" $SCRATCH_DEV >> $seqres.full
+}
+
+_filter_leftover() {
+	grep "^leftover" | sed -e "s/[0-9]\+/NR/g"
+}
+
+_dump_status() {
+	echo "** " "$@"
+	xfs_db -c 'sb 0' -c p $SCRATCH_DEV
+	echo "** agf header"
+	xfs_db -c 'agf 1' -c p $SCRATCH_DEV
+	echo "** refcntbt"
+	xfs_db -c 'agf 1' -c 'addr refcntroot' -c p $SCRATCH_DEV
+	echo "** rmapbt"
+	test $is_rmap -gt 0 && xfs_db -c 'agf 1' -c 'addr rmaproot' -c p $SCRATCH_DEV
+	echo "** bnobt"
+	xfs_db -c 'agf 1' -c 'addr bnoroot' -c p $SCRATCH_DEV
+	echo "** cntbt"
+	xfs_db -c 'agf 1' -c 'addr cntroot' -c p $SCRATCH_DEV
+}
+
+echo "We need AG1 to have a single free extent"
+bno_lvl=$(_get_agf_data level -c 'addr bnoroot')
+bno_nr=$(_get_agf_data numrecs -c 'addr bnoroot')
+refc_lvl=$(_get_agf_data level -c 'addr refcntroot')
+refc_nr=$(_get_agf_data numrecs -c 'addr refcntroot')
+
+test $bno_lvl -eq 0 || echo "  AG 1 bnobt must only have one level"
+test $bno_nr -eq 1 || echo "  AG 1 bnobt must only have one record"
+test $refc_lvl -eq 0 || echo "  AG 1 refcountbt must only have one level"
+test $refc_nr -eq 0 || echo "  AG 1 refcountbt must only have one record"
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_lvl=$(_get_agf_data level -c 'addr rmaproot')
+	rmap_nr=$(_get_agf_data numrecs -c 'addr rmaproot')
+	test $rmap_lvl -eq 0 || echo "  AG 1 rmapbt must only have one level"
+fi
+
+echo "Find our extent and old counter values"
+bno=$(_get_agf_data "recs[1].startblock" -c 'addr bnoroot')
+len=$(_get_agf_data "recs[1].blockcount" -c 'addr bnoroot')
+agf_freeblks=$(_get_agf_data freeblks)
+sb_fdblocks=$(_get_sb_data fdblocks)
+
+test $len -ge 200 || echo "  AG 1 doesn't have enough free blocks"
+
+# Take the last 100 blocks of the free extent
+debris_len=100
+debris_bno=$((bno + len - debris_len))
+
+echo "Remove the extent from the freesp btrees"
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr bnoroot'
+_set_agf_data "recs[1].blockcount" $((len - debris_len)) -c 'addr cntroot'
+_set_agf_data freeblks $((agf_freeblks - debris_len))
+_set_agf_data longest $((len - debris_len))
+_set_sb_data fdblocks $((sb_fdblocks - debris_len))
+
+echo "Add the extent to the refcount btree"
+_set_agf_data numrecs 1 -c 'addr refcntroot'
+_set_agf_data "recs[1].startblock" $debris_bno -c 'addr refcntroot'
+_set_agf_data "recs[1].blockcount" $debris_len -c 'addr refcntroot'
+_set_agf_data "recs[1].refcount" 1 -c 'addr refcntroot'
+
+if [ $is_rmap -gt 0 ]; then
+	rmap_nr=$((rmap_nr + 1))
+	_set_agf_data numrecs $rmap_nr -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].startblock" $debris_bno -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].blockcount" $debris_len -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].owner" -9 -c 'addr rmaproot'
+	_set_agf_data "recs[$rmap_nr].offset" 0 -c 'addr rmaproot'
+fi
+
+_dump_status "broken fs config" >> $seqres.full
+
+echo "Look for leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+echo "Mount filesystem"
+_scratch_mount
+umount $SCRATCH_MNT
+
+_dump_status "supposedly fixed fs config" >> $seqres.full
+
+echo "Look for no more leftover warning in xfs_check"
+_scratch_xfs_check | _filter_leftover
+
+echo "Look for no more leftover warning in xfs_repair"
+_scratch_xfs_repair -n 2>&1 | _filter_leftover
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/854.out b/tests/xfs/854.out
new file mode 100644
index 0000000..aae2fd7
--- /dev/null
+++ b/tests/xfs/854.out
@@ -0,0 +1,13 @@
+QA output created by 854
+Format
+We need AG1 to have a single free extent
+Find our extent and old counter values
+Remove the extent from the freesp btrees
+Add the extent to the refcount btree
+Look for leftover warning in xfs_check
+leftover CoW extent (NR/NR) len NR
+Look for leftover warning in xfs_repair
+leftover CoW extent (NR/NR) len NR
+Mount filesystem
+Look for no more leftover warning in xfs_check
+Look for no more leftover warning in xfs_repair
diff --git a/tests/xfs/group b/tests/xfs/group
index f4c6816..4ac62c1 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -285,3 +285,5 @@
 303 auto quick quota
 304 auto quick quota
 305 auto quota
+853 auto quick clone
+854 auto quick clone

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

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

* [PATCH 04/20] xfs: test per-ag allocation accounting during truncate-caused refcountbt expansion
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Ensure that refcountbt allocations during truncate operations come
from the per-AG reservation and are not charged to the transaction.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/855     |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/855.out |   10 ++++++
 tests/xfs/group   |    1 +
 3 files changed, 106 insertions(+)
 create mode 100755 tests/xfs/855
 create mode 100644 tests/xfs/855.out


diff --git a/tests/xfs/855 b/tests/xfs/855
new file mode 100755
index 0000000..93bd286
--- /dev/null
+++ b/tests/xfs/855
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 855
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree by reflinking a file a number of times and
+# truncating the copies at successively lower sizes.  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
+_require_cp_reflink
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original file blocks"
+blksz="$(stat -f $testdir -c '%S')"
+nr_blks=$((2 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
+
+	echo "$i: Reflink a bunch of times"
+	seq 1 $nr_blks | while read nr; do
+		_cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
+	done
+	sync
+
+	echo "$i: Truncate files"
+	seq 1 $nr_blks | while read nr; do
+		truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
+	done
+
+	umount $SCRATCH_MNT
+	_check_scratch_fs
+	_scratch_mount
+
+	test $i = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf $testdir
+	mkdir -p $testdir
+	umount $SCRATCH_MNT
+	_check_scratch_fs
+	_scratch_mount
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/855.out b/tests/xfs/855.out
new file mode 100644
index 0000000..d196352
--- /dev/null
+++ b/tests/xfs/855.out
@@ -0,0 +1,10 @@
+QA output created by 855
+Create the original file blocks
+1: Reflink a bunch of times
+1: Truncate files
+1: Delete both files
+2: Reflink a bunch of times
+2: Truncate files
+2: Delete both files
+x: Reflink a bunch of times
+x: Truncate files
diff --git a/tests/xfs/group b/tests/xfs/group
index 4ac62c1..f0ca410 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -287,3 +287,4 @@
 305 auto quota
 853 auto quick clone
 854 auto quick clone
+855 auto clone


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

* [PATCH 04/20] xfs: test per-ag allocation accounting during truncate-caused refcountbt expansion
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Ensure that refcountbt allocations during truncate operations come
from the per-AG reservation and are not charged to the transaction.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/855     |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/855.out |   10 ++++++
 tests/xfs/group   |    1 +
 3 files changed, 106 insertions(+)
 create mode 100755 tests/xfs/855
 create mode 100644 tests/xfs/855.out


diff --git a/tests/xfs/855 b/tests/xfs/855
new file mode 100755
index 0000000..93bd286
--- /dev/null
+++ b/tests/xfs/855
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 855
+#
+# Ensure that we can create enough distinct reflink entries to force creation
+# of a multi-level refcount btree by reflinking a file a number of times and
+# truncating the copies at successively lower sizes.  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
+_require_cp_reflink
+
+rm -f $seqres.full
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+echo "Create the original file blocks"
+blksz="$(stat -f $testdir -c '%S')"
+nr_blks=$((2 * blksz / 12))
+
+for i in 1 2 x; do
+	_pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
+
+	echo "$i: Reflink a bunch of times"
+	seq 1 $nr_blks | while read nr; do
+		_cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
+	done
+	sync
+
+	echo "$i: Truncate files"
+	seq 1 $nr_blks | while read nr; do
+		truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
+	done
+
+	umount $SCRATCH_MNT
+	_check_scratch_fs
+	_scratch_mount
+
+	test $i = "x" && break
+
+	echo "$i: Delete both files"
+	rm -rf $testdir
+	mkdir -p $testdir
+	umount $SCRATCH_MNT
+	_check_scratch_fs
+	_scratch_mount
+done
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/855.out b/tests/xfs/855.out
new file mode 100644
index 0000000..d196352
--- /dev/null
+++ b/tests/xfs/855.out
@@ -0,0 +1,10 @@
+QA output created by 855
+Create the original file blocks
+1: Reflink a bunch of times
+1: Truncate files
+1: Delete both files
+2: Reflink a bunch of times
+2: Truncate files
+2: Delete both files
+x: Reflink a bunch of times
+x: Truncate files
diff --git a/tests/xfs/group b/tests/xfs/group
index 4ac62c1..f0ca410 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -287,3 +287,4 @@
 305 auto quota
 853 auto quick clone
 854 auto quick clone
+855 auto clone

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

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

* [PATCH 05/20] reflink: test interaction with swap files
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

Since none of the current filesystems support reflinked swap files,
make sure that we prohibit reflinking of swapfiles and swapon of
reflinked files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
---
 tests/generic/923     |   74 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/923.out |    6 ++++
 tests/generic/924     |   73 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/924.out |    5 +++
 tests/generic/group   |    2 +
 5 files changed, 160 insertions(+)
 create mode 100755 tests/generic/923
 create mode 100644 tests/generic/923.out
 create mode 100755 tests/generic/924
 create mode 100644 tests/generic/924.out


diff --git a/tests/generic/923 b/tests/generic/923
new file mode 100755
index 0000000..73c1621
--- /dev/null
+++ b/tests/generic/923
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test No. 923
+#
+# Check that we can't reflink a swapfile.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=160
+blksz=65536
+
+echo "Initialize file"
+echo > $seqres.full
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full
+mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full
+swapon $testdir/file1
+
+echo "Try to reflink"
+_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
+
+echo "Tear it down"
+swapoff $testdir/file1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/923.out b/tests/generic/923.out
new file mode 100644
index 0000000..97c18cf
--- /dev/null
+++ b/tests/generic/923.out
@@ -0,0 +1,6 @@
+QA output created by 923
+Format and mount
+Initialize file
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/test-923/file2' from 'SCRATCH_MNT/test-923/file1': Text file busy
+Tear it down
diff --git a/tests/generic/924 b/tests/generic/924
new file mode 100755
index 0000000..86c2a39
--- /dev/null
+++ b/tests/generic/924
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test No. 924
+#
+# Check that we can't swapon a reflinked file.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=160
+blksz=65536
+
+echo "Initialize file"
+echo > $seqres.full
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full
+mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full
+_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
+
+echo "Try to swapon"
+swapon $testdir/file1 2>&1 | _filter_scratch
+
+swapoff $testdir/file1 >> $seqres.full 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/924.out b/tests/generic/924.out
new file mode 100644
index 0000000..b67e6fa
--- /dev/null
+++ b/tests/generic/924.out
@@ -0,0 +1,5 @@
+QA output created by 924
+Format and mount
+Initialize file
+Try to swapon
+swapon: SCRATCH_MNT/test-924/file1: swapon failed: Invalid argument
diff --git a/tests/generic/group b/tests/generic/group
index 36fb759..6fdf109 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -354,3 +354,5 @@
 349 blockdev quick rw
 350 blockdev quick rw
 351 blockdev quick rw
+923 auto quick clone
+924 auto quick clone


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

* [PATCH 05/20] reflink: test interaction with swap files
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

Since none of the current filesystems support reflinked swap files,
make sure that we prohibit reflinking of swapfiles and swapon of
reflinked files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
---
 tests/generic/923     |   74 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/923.out |    6 ++++
 tests/generic/924     |   73 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/924.out |    5 +++
 tests/generic/group   |    2 +
 5 files changed, 160 insertions(+)
 create mode 100755 tests/generic/923
 create mode 100644 tests/generic/923.out
 create mode 100755 tests/generic/924
 create mode 100644 tests/generic/924.out


diff --git a/tests/generic/923 b/tests/generic/923
new file mode 100755
index 0000000..73c1621
--- /dev/null
+++ b/tests/generic/923
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test No. 923
+#
+# Check that we can't reflink a swapfile.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=160
+blksz=65536
+
+echo "Initialize file"
+echo > $seqres.full
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full
+mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full
+swapon $testdir/file1
+
+echo "Try to reflink"
+_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
+
+echo "Tear it down"
+swapoff $testdir/file1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/923.out b/tests/generic/923.out
new file mode 100644
index 0000000..97c18cf
--- /dev/null
+++ b/tests/generic/923.out
@@ -0,0 +1,6 @@
+QA output created by 923
+Format and mount
+Initialize file
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/test-923/file2' from 'SCRATCH_MNT/test-923/file1': Text file busy
+Tear it down
diff --git a/tests/generic/924 b/tests/generic/924
new file mode 100755
index 0000000..86c2a39
--- /dev/null
+++ b/tests/generic/924
@@ -0,0 +1,73 @@
+#! /bin/bash
+# FS QA Test No. 924
+#
+# Check that we can't swapon a reflinked file.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=160
+blksz=65536
+
+echo "Initialize file"
+echo > $seqres.full
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full
+mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full
+_cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch
+
+echo "Try to swapon"
+swapon $testdir/file1 2>&1 | _filter_scratch
+
+swapoff $testdir/file1 >> $seqres.full 2>&1
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/924.out b/tests/generic/924.out
new file mode 100644
index 0000000..b67e6fa
--- /dev/null
+++ b/tests/generic/924.out
@@ -0,0 +1,5 @@
+QA output created by 924
+Format and mount
+Initialize file
+Try to swapon
+swapon: SCRATCH_MNT/test-924/file1: swapon failed: Invalid argument
diff --git a/tests/generic/group b/tests/generic/group
index 36fb759..6fdf109 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -354,3 +354,5 @@
 349 blockdev quick rw
 350 blockdev quick rw
 351 blockdev quick rw
+923 auto quick clone
+924 auto quick clone

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

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

* [PATCH 06/20] xfs: test rmap behavior when multiple bmbt records map to a single rmapbt record
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Make sure that we can handle multiple bmbt records mapping to a
single rmapbt record.  This can happen if you fallocate more than
2^21 contiguous blocks to a file.

(Also add some helpers that can create huge devices with some dm-zero
and dm-snapshot fakery.)

v2: remove irrelevant t_immutable changes, put test in correct group
v3: calculate the hugedisk size correctly so that there are 2^22 blocks/AG

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/dmhugedisk |   61 +++++++++++++++++++++++++++
 tests/xfs/856     |  121 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/856.out |   13 ++++++
 tests/xfs/group   |    1 
 4 files changed, 196 insertions(+)
 create mode 100644 common/dmhugedisk
 create mode 100755 tests/xfs/856
 create mode 100644 tests/xfs/856.out


diff --git a/common/dmhugedisk b/common/dmhugedisk
new file mode 100644
index 0000000..9c3c7d5
--- /dev/null
+++ b/common/dmhugedisk
@@ -0,0 +1,61 @@
+##/bin/bash
+# Routines for creating huge (fake) disks
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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_dmhugedisk()
+{
+	_require_dm_target zero
+	_require_dm_target snapshot
+}
+
+_dmhugedisk_init()
+{
+	test -z "$1" && _fatal "must specify sector count to _dmhugedisk_init"
+	local dm_backing_dev=$SCRATCH_DEV
+
+	$DMSETUP_PROG remove huge-test > /dev/null 2>&1
+	$DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+
+	local blk_dev_size=$1
+
+	DMHUGEDISK_ZERO='/dev/mapper/huge-test-zero'
+	DMHUGEDISK_DEV='/dev/mapper/huge-test'
+
+	DMHUGEDISK_ZERO_TABLE="0 $blk_dev_size zero"
+	DMHUGEDISK_DEV_TABLE="0 $blk_dev_size snapshot $DMHUGEDISK_ZERO $SCRATCH_DEV N 512"
+
+	$DMSETUP_PROG create huge-test-zero --table "$DMHUGEDISK_ZERO_TABLE" || \
+		_fatal "failed to create dm huge zero device"
+	$DMSETUP_PROG create huge-test --table "$DMHUGEDISK_DEV_TABLE" || \
+		_fatal "failed to create dm huge device"
+}
+
+_dmhugedisk_cleanup()
+{
+	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+	# wait for device to be fully settled so that 'dmsetup remove' doesn't
+	# fail due to EBUSY
+	$UDEV_SETTLE_PROG >/dev/null 2>&1
+	$DMSETUP_PROG remove huge-test > /dev/null 2>&1
+	$DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+}
+
diff --git a/tests/xfs/856 b/tests/xfs/856
new file mode 100755
index 0000000..1bfb581
--- /dev/null
+++ b/tests/xfs/856
@@ -0,0 +1,121 @@
+#! /bin/bash
+# FS QA Test No. 856
+#
+# Create a file with more than 2^21 extents (the max length of a bmbt record).
+#
+#-----------------------------------------------------------------------
+# 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
+    _dmhugedisk_cleanup
+    rm -rf $tmp.*
+    _scratch_mkfs >/dev/null 2>&1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmhugedisk
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+# Figure out block size
+echo "Figure out block size"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+testdir=$SCRATCH_MNT/test-$seq
+blksz="$(stat -f $SCRATCH_MNT -c '%S')"
+
+umount $SCRATCH_MNT
+
+echo "Format huge device"
+_dmhugedisk_init $((blksz * 4 * 4400))	# more than 2^22 blocks per AG, 2 AGs
+_mkfs_dev -d agcount=2 $DMHUGEDISK_DEV
+_mount $DMHUGEDISK_DEV $SCRATCH_MNT 
+xfs_info $SCRATCH_MNT >> $seqres.full
+
+echo "Create the original file blocks"
+mkdir $testdir
+blksz="$(stat -f $testdir -c '%S')"
+nr_blks=2100000	# 2^21 plus a little more
+echo $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
+
+echo "Check extent count"
+xfs_bmap -l -p -v $testdir/file1 >> $seqres.full
+xfs_bmap -l -p -v $testdir/file1 | grep '^[[:space:]]*1:' -q && xfs_bmap -l -p -v $testdir/file1
+inum=$(stat -c '%i' $testdir/file1)
+umount $SCRATCH_MNT
+
+echo "Check bmap count"
+nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
+test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+#xfs_db -c "agf 0" -c p -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+
+echo "Check rmap count"
+nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
+test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
+
+echo "Check and fake-repair huge filesystem" | tee -a $seqres.full
+$XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
+$XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1
+test $? -eq 0 || echo "xfs_repair -n failed, see $seqres.full"
+
+echo "Real repair huge filesystem" | tee -a $seqres.full
+$XFS_REPAIR_PROG $DMHUGEDISK_DEV >> $seqres.full 2>&1
+test $? -eq 0 || echo "xfs_repair failed, see $seqres.full"
+
+echo "Check bmap count again"
+nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
+test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+
+echo "Check rmap count again"
+nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
+test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
+
+echo "Check and fake-repair huge filesystem again" | tee -a $seqres.full
+$XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
+$XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1
+_dmhugedisk_cleanup
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/856.out b/tests/xfs/856.out
new file mode 100644
index 0000000..b24ebf2
--- /dev/null
+++ b/tests/xfs/856.out
@@ -0,0 +1,13 @@
+QA output created by 856
+Figure out block size
+Format huge device
+Create the original file blocks
+Check extent count
+Check bmap count
+Check rmap count
+Check and fake-repair huge filesystem
+Real repair huge filesystem
+Check bmap count again
+Check rmap count again
+Check and fake-repair huge filesystem again
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index f0ca410..1ad37ff 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -288,3 +288,4 @@
 853 auto quick clone
 854 auto quick clone
 855 auto clone
+856 auto quick clone rmap


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

* [PATCH 06/20] xfs: test rmap behavior when multiple bmbt records map to a single rmapbt record
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Make sure that we can handle multiple bmbt records mapping to a
single rmapbt record.  This can happen if you fallocate more than
2^21 contiguous blocks to a file.

(Also add some helpers that can create huge devices with some dm-zero
and dm-snapshot fakery.)

v2: remove irrelevant t_immutable changes, put test in correct group
v3: calculate the hugedisk size correctly so that there are 2^22 blocks/AG

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/dmhugedisk |   61 +++++++++++++++++++++++++++
 tests/xfs/856     |  121 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/856.out |   13 ++++++
 tests/xfs/group   |    1 
 4 files changed, 196 insertions(+)
 create mode 100644 common/dmhugedisk
 create mode 100755 tests/xfs/856
 create mode 100644 tests/xfs/856.out


diff --git a/common/dmhugedisk b/common/dmhugedisk
new file mode 100644
index 0000000..9c3c7d5
--- /dev/null
+++ b/common/dmhugedisk
@@ -0,0 +1,61 @@
+##/bin/bash
+# Routines for creating huge (fake) disks
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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_dmhugedisk()
+{
+	_require_dm_target zero
+	_require_dm_target snapshot
+}
+
+_dmhugedisk_init()
+{
+	test -z "$1" && _fatal "must specify sector count to _dmhugedisk_init"
+	local dm_backing_dev=$SCRATCH_DEV
+
+	$DMSETUP_PROG remove huge-test > /dev/null 2>&1
+	$DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+
+	local blk_dev_size=$1
+
+	DMHUGEDISK_ZERO='/dev/mapper/huge-test-zero'
+	DMHUGEDISK_DEV='/dev/mapper/huge-test'
+
+	DMHUGEDISK_ZERO_TABLE="0 $blk_dev_size zero"
+	DMHUGEDISK_DEV_TABLE="0 $blk_dev_size snapshot $DMHUGEDISK_ZERO $SCRATCH_DEV N 512"
+
+	$DMSETUP_PROG create huge-test-zero --table "$DMHUGEDISK_ZERO_TABLE" || \
+		_fatal "failed to create dm huge zero device"
+	$DMSETUP_PROG create huge-test --table "$DMHUGEDISK_DEV_TABLE" || \
+		_fatal "failed to create dm huge device"
+}
+
+_dmhugedisk_cleanup()
+{
+	$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
+	# wait for device to be fully settled so that 'dmsetup remove' doesn't
+	# fail due to EBUSY
+	$UDEV_SETTLE_PROG >/dev/null 2>&1
+	$DMSETUP_PROG remove huge-test > /dev/null 2>&1
+	$DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+}
+
diff --git a/tests/xfs/856 b/tests/xfs/856
new file mode 100755
index 0000000..1bfb581
--- /dev/null
+++ b/tests/xfs/856
@@ -0,0 +1,121 @@
+#! /bin/bash
+# FS QA Test No. 856
+#
+# Create a file with more than 2^21 extents (the max length of a bmbt record).
+#
+#-----------------------------------------------------------------------
+# 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
+    _dmhugedisk_cleanup
+    rm -rf $tmp.*
+    _scratch_mkfs >/dev/null 2>&1
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmhugedisk
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_xfs_io_command "falloc"
+
+rm -f $seqres.full
+
+# Figure out block size
+echo "Figure out block size"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+testdir=$SCRATCH_MNT/test-$seq
+blksz="$(stat -f $SCRATCH_MNT -c '%S')"
+
+umount $SCRATCH_MNT
+
+echo "Format huge device"
+_dmhugedisk_init $((blksz * 4 * 4400))	# more than 2^22 blocks per AG, 2 AGs
+_mkfs_dev -d agcount=2 $DMHUGEDISK_DEV
+_mount $DMHUGEDISK_DEV $SCRATCH_MNT 
+xfs_info $SCRATCH_MNT >> $seqres.full
+
+echo "Create the original file blocks"
+mkdir $testdir
+blksz="$(stat -f $testdir -c '%S')"
+nr_blks=2100000	# 2^21 plus a little more
+echo $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
+
+echo "Check extent count"
+xfs_bmap -l -p -v $testdir/file1 >> $seqres.full
+xfs_bmap -l -p -v $testdir/file1 | grep '^[[:space:]]*1:' -q && xfs_bmap -l -p -v $testdir/file1
+inum=$(stat -c '%i' $testdir/file1)
+umount $SCRATCH_MNT
+
+echo "Check bmap count"
+nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
+test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+#xfs_db -c "agf 0" -c p -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+
+echo "Check rmap count"
+nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
+test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
+
+echo "Check and fake-repair huge filesystem" | tee -a $seqres.full
+$XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
+$XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1
+test $? -eq 0 || echo "xfs_repair -n failed, see $seqres.full"
+
+echo "Real repair huge filesystem" | tee -a $seqres.full
+$XFS_REPAIR_PROG $DMHUGEDISK_DEV >> $seqres.full 2>&1
+test $? -eq 0 || echo "xfs_repair failed, see $seqres.full"
+
+echo "Check bmap count again"
+nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
+test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
+
+echo "Check rmap count again"
+nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
+test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
+
+echo "Check and fake-repair huge filesystem again" | tee -a $seqres.full
+$XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
+$XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1
+_dmhugedisk_cleanup
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/856.out b/tests/xfs/856.out
new file mode 100644
index 0000000..b24ebf2
--- /dev/null
+++ b/tests/xfs/856.out
@@ -0,0 +1,13 @@
+QA output created by 856
+Figure out block size
+Format huge device
+Create the original file blocks
+Check extent count
+Check bmap count
+Check rmap count
+Check and fake-repair huge filesystem
+Real repair huge filesystem
+Check bmap count again
+Check rmap count again
+Check and fake-repair huge filesystem again
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index f0ca410..1ad37ff 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -288,3 +288,4 @@
 853 auto quick clone
 854 auto quick clone
 855 auto clone
+856 auto quick clone rmap

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

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

* [PATCH 07/20] reflink: test changing sharers of a block while keeping refcount the same
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Ensure that we can handle the case where the refcount stays the same
even though the actual sharers changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/925     |   80 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/925.out |   69 ++++++++++++++++++++++++++++++++++++
 tests/generic/926     |   94 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/926.out |   20 ++++++++++
 tests/generic/group   |    2 +
 5 files changed, 265 insertions(+)
 create mode 100755 tests/generic/925
 create mode 100644 tests/generic/925.out
 create mode 100755 tests/generic/926
 create mode 100644 tests/generic/926.out


diff --git a/tests/generic/925 b/tests/generic/925
new file mode 100755
index 0000000..9fa4ba9
--- /dev/null
+++ b/tests/generic/925
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test No. 925
+#
+# Share an extent amongst a bunch of files such that the refcount
+# stays the same while the rate of change of the set of owners is
+# steadily increasing.  For example, an extent of 32 blocks is owned
+# by 32 files.  At block 1, change one of the owners.  At block 2,
+# change 2 of the owners, and so on.
+#
+#-----------------------------------------------------------------------
+# 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
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=64
+blksz=65536
+
+echo "Initialize file"
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
+
+echo "Share the file n-ways"
+seq 1 $((blocks - 1)) | while read nr; do
+	_reflink_range $testdir/file 0 $testdir/file$nr.0 0 $((nr * blksz)) >> $seqres.full
+	seq $nr $((blocks - 1)) | while read nnr; do
+		_reflink_range $testdir/file $((nnr * blksz)) $testdir/file$nr.$nnr $((nnr * blksz)) $blksz >> $seqres.full
+	done
+done
+_scratch_cycle_mount
+
+echo "Check output"
+md5sum $testdir/file $testdir/file*.0 | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/925.out b/tests/generic/925.out
new file mode 100644
index 0000000..099d6d3
--- /dev/null
+++ b/tests/generic/925.out
@@ -0,0 +1,69 @@
+QA output created by 925
+Format and mount
+Initialize file
+Share the file n-ways
+Check output
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-925/file
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-925/file1.0
+399c239a8d72b5b2beb15565cf14f6d6  SCRATCH_MNT/test-925/file10.0
+7f783291615a5db41ba33d6c50318095  SCRATCH_MNT/test-925/file11.0
+4feff1bdae53d042e572a5e240b1183f  SCRATCH_MNT/test-925/file12.0
+ac2b0a907cd84c091c1cc36384246e42  SCRATCH_MNT/test-925/file13.0
+ff420a8abc25ff0a012638ddd9b81e6c  SCRATCH_MNT/test-925/file14.0
+3eb1751bcb7cff809df2ec376e45fe6f  SCRATCH_MNT/test-925/file15.0
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-925/file16.0
+7b0fea2a208aa4738d8b9433c7b8421d  SCRATCH_MNT/test-925/file17.0
+c6b6ec99b28741ffb3be2d7ff361ad89  SCRATCH_MNT/test-925/file18.0
+d609dcbdc972b8cff16acd74414a8dc9  SCRATCH_MNT/test-925/file19.0
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-925/file2.0
+d97ae5fdb25c4622d5a2f313460a2b96  SCRATCH_MNT/test-925/file20.0
+afae74f7a13edf57f43bab5da6e411d6  SCRATCH_MNT/test-925/file21.0
+0ed53c341d0154d68c336eaa9d05990d  SCRATCH_MNT/test-925/file22.0
+ab20d0025b58cbf9fc49e436b7d7acef  SCRATCH_MNT/test-925/file23.0
+5279106ed91359051fbdb61e87d5077d  SCRATCH_MNT/test-925/file24.0
+9a8719c84c1a42d030fc6d700046eaf5  SCRATCH_MNT/test-925/file25.0
+d9b21a065727fd8118d493f7c62e7fb2  SCRATCH_MNT/test-925/file26.0
+d74ee01c55b2474f91a3723a01c83591  SCRATCH_MNT/test-925/file27.0
+ba7202bfc4b9cda564156562d8672a3f  SCRATCH_MNT/test-925/file28.0
+1b3d697355ca662451eb12419cab8eef  SCRATCH_MNT/test-925/file29.0
+998b4ba52f2940dc515001e75926b19f  SCRATCH_MNT/test-925/file3.0
+6b2648f84c57f58786cf75ac06e37217  SCRATCH_MNT/test-925/file30.0
+c400b872b0fb3fb58920c4e570937a32  SCRATCH_MNT/test-925/file31.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-925/file32.0
+cac15c2eeaf1b63614469f675ec71c5f  SCRATCH_MNT/test-925/file33.0
+ebd2d819d56725bd1a2a35ababd06cad  SCRATCH_MNT/test-925/file34.0
+a26ebf37da9976dfd7c86b4271c59501  SCRATCH_MNT/test-925/file35.0
+11f61aaa1f5f726929c91c6d434edf72  SCRATCH_MNT/test-925/file36.0
+1f73d21c457843ea20048726d461648e  SCRATCH_MNT/test-925/file37.0
+9ed53cefd1548008ed1948286e471233  SCRATCH_MNT/test-925/file38.0
+af5195351947da43e7a57f69086aa7d7  SCRATCH_MNT/test-925/file39.0
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-925/file4.0
+f31ecd4106278b5fb1aeabdedd43036a  SCRATCH_MNT/test-925/file40.0
+e8a8d1a0873e25697171ebb87125d794  SCRATCH_MNT/test-925/file41.0
+5920fd86bc7be6a0ef5d7ea283e16307  SCRATCH_MNT/test-925/file42.0
+8360c3c368143821045f9b7994ab8344  SCRATCH_MNT/test-925/file43.0
+6c76a6c9e2b039c82e62d985479f73ee  SCRATCH_MNT/test-925/file44.0
+8b5c6cab2f0da5ba2d3b2d3ca205ca75  SCRATCH_MNT/test-925/file45.0
+b4ef05d705b8e99d8824d85e993bf8fa  SCRATCH_MNT/test-925/file46.0
+0db1f2d5ad692ccd8941a8bc308cdba2  SCRATCH_MNT/test-925/file47.0
+6a11a8872b36343799a15617bea78cef  SCRATCH_MNT/test-925/file48.0
+015ab57c35525eeb776308e14fe2e731  SCRATCH_MNT/test-925/file49.0
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-925/file5.0
+fbc6203955f9c6e9010f831971a073b2  SCRATCH_MNT/test-925/file50.0
+aae01cd767e508bdf2d01f647d10c4b8  SCRATCH_MNT/test-925/file51.0
+4d942a936328991bcd9821072ac0fd9e  SCRATCH_MNT/test-925/file52.0
+b77f243bb207746743aeaafbdef4203a  SCRATCH_MNT/test-925/file53.0
+9fc7f158bd2ded9df3965ef4fe2fa932  SCRATCH_MNT/test-925/file54.0
+36dff6091853c946411bc40fdae79e84  SCRATCH_MNT/test-925/file55.0
+82a2f6d28f1bff4ce7edc1a7a31b02cb  SCRATCH_MNT/test-925/file56.0
+b0d123bf023332bba783abb5b68e4c98  SCRATCH_MNT/test-925/file57.0
+26b49b145b128c0abef0f92b3ccaf1d6  SCRATCH_MNT/test-925/file58.0
+b5ef5d86d6ef15a535ee95b8069d29c9  SCRATCH_MNT/test-925/file59.0
+cd3eccbf2f0126c4141740007ba70c3f  SCRATCH_MNT/test-925/file6.0
+205cb48615014f6f2377345b62442609  SCRATCH_MNT/test-925/file60.0
+89691c001b3a3d5473081687ae519a18  SCRATCH_MNT/test-925/file61.0
+a040ce9774652bd00c3cbf493a006e00  SCRATCH_MNT/test-925/file62.0
+970b42855c15ee8caa824cd5e177759a  SCRATCH_MNT/test-925/file63.0
+eb74da58c6e4f93b4bf82a62fef4ab93  SCRATCH_MNT/test-925/file7.0
+30c2557e8302a5beb290c71520d87f42  SCRATCH_MNT/test-925/file8.0
+6dc42f5ed1007a3e20d08af71e198cdc  SCRATCH_MNT/test-925/file9.0
diff --git a/tests/generic/926 b/tests/generic/926
new file mode 100755
index 0000000..7dedc3f
--- /dev/null
+++ b/tests/generic/926
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 926
+#
+# Make sure that the reference counting mechanism can handle the case
+# where we share the first 1/4 of an extent with a file, share the
+# last 1/4 of the extent with a second file, share the first half of
+# the extent with N files, and share the second half of the extent
+# with a different set of N files.  The key point here is to test that
+# we handle the case where a refcount extent record doesn't coincide
+# exactly with the block mapping records.
+#
+#-----------------------------------------------------------------------
+# 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
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=64
+blksz=65536
+nr=4
+halfway=$((blocks / 2 * blksz))
+quarter=$((blocks / 4 * blksz))
+
+echo "Initialize file"
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
+
+echo "Share the first half of the extent"
+seq 1 $nr | while read nr; do
+	_reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
+done
+
+echo "Share the last half of the extent"
+seq 1 $nr | while read nr; do
+	_reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
+done
+
+echo "Share the first quarter of the extent"
+_reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
+
+echo "Share the last quarter of the extent"
+_reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
+
+_scratch_cycle_mount
+
+echo "Check output"
+md5sum $testdir/file $testdir/file* | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/926.out b/tests/generic/926.out
new file mode 100644
index 0000000..d3e6b59
--- /dev/null
+++ b/tests/generic/926.out
@@ -0,0 +1,20 @@
+QA output created by 926
+Format and mount
+Initialize file
+Share the first half of the extent
+Share the last half of the extent
+Share the first quarter of the extent
+Share the last quarter of the extent
+Check output
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-926/file
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-926/file
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-926/file.2
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-926/file.3
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file1.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file1.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file2.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file2.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file3.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file3.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file4.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file4.1
diff --git a/tests/generic/group b/tests/generic/group
index 6fdf109..2bd40a1 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -356,3 +356,5 @@
 351 blockdev quick rw
 923 auto quick clone
 924 auto quick clone
+925 auto quick clone
+926 auto quick clone


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

* [PATCH 07/20] reflink: test changing sharers of a block while keeping refcount the same
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Ensure that we can handle the case where the refcount stays the same
even though the actual sharers changes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/925     |   80 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/925.out |   69 ++++++++++++++++++++++++++++++++++++
 tests/generic/926     |   94 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/926.out |   20 ++++++++++
 tests/generic/group   |    2 +
 5 files changed, 265 insertions(+)
 create mode 100755 tests/generic/925
 create mode 100644 tests/generic/925.out
 create mode 100755 tests/generic/926
 create mode 100644 tests/generic/926.out


diff --git a/tests/generic/925 b/tests/generic/925
new file mode 100755
index 0000000..9fa4ba9
--- /dev/null
+++ b/tests/generic/925
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test No. 925
+#
+# Share an extent amongst a bunch of files such that the refcount
+# stays the same while the rate of change of the set of owners is
+# steadily increasing.  For example, an extent of 32 blocks is owned
+# by 32 files.  At block 1, change one of the owners.  At block 2,
+# change 2 of the owners, and so on.
+#
+#-----------------------------------------------------------------------
+# 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
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=64
+blksz=65536
+
+echo "Initialize file"
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
+
+echo "Share the file n-ways"
+seq 1 $((blocks - 1)) | while read nr; do
+	_reflink_range $testdir/file 0 $testdir/file$nr.0 0 $((nr * blksz)) >> $seqres.full
+	seq $nr $((blocks - 1)) | while read nnr; do
+		_reflink_range $testdir/file $((nnr * blksz)) $testdir/file$nr.$nnr $((nnr * blksz)) $blksz >> $seqres.full
+	done
+done
+_scratch_cycle_mount
+
+echo "Check output"
+md5sum $testdir/file $testdir/file*.0 | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/925.out b/tests/generic/925.out
new file mode 100644
index 0000000..099d6d3
--- /dev/null
+++ b/tests/generic/925.out
@@ -0,0 +1,69 @@
+QA output created by 925
+Format and mount
+Initialize file
+Share the file n-ways
+Check output
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-925/file
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-925/file1.0
+399c239a8d72b5b2beb15565cf14f6d6  SCRATCH_MNT/test-925/file10.0
+7f783291615a5db41ba33d6c50318095  SCRATCH_MNT/test-925/file11.0
+4feff1bdae53d042e572a5e240b1183f  SCRATCH_MNT/test-925/file12.0
+ac2b0a907cd84c091c1cc36384246e42  SCRATCH_MNT/test-925/file13.0
+ff420a8abc25ff0a012638ddd9b81e6c  SCRATCH_MNT/test-925/file14.0
+3eb1751bcb7cff809df2ec376e45fe6f  SCRATCH_MNT/test-925/file15.0
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-925/file16.0
+7b0fea2a208aa4738d8b9433c7b8421d  SCRATCH_MNT/test-925/file17.0
+c6b6ec99b28741ffb3be2d7ff361ad89  SCRATCH_MNT/test-925/file18.0
+d609dcbdc972b8cff16acd74414a8dc9  SCRATCH_MNT/test-925/file19.0
+81615449a98aaaad8dc179b3bec87f38  SCRATCH_MNT/test-925/file2.0
+d97ae5fdb25c4622d5a2f313460a2b96  SCRATCH_MNT/test-925/file20.0
+afae74f7a13edf57f43bab5da6e411d6  SCRATCH_MNT/test-925/file21.0
+0ed53c341d0154d68c336eaa9d05990d  SCRATCH_MNT/test-925/file22.0
+ab20d0025b58cbf9fc49e436b7d7acef  SCRATCH_MNT/test-925/file23.0
+5279106ed91359051fbdb61e87d5077d  SCRATCH_MNT/test-925/file24.0
+9a8719c84c1a42d030fc6d700046eaf5  SCRATCH_MNT/test-925/file25.0
+d9b21a065727fd8118d493f7c62e7fb2  SCRATCH_MNT/test-925/file26.0
+d74ee01c55b2474f91a3723a01c83591  SCRATCH_MNT/test-925/file27.0
+ba7202bfc4b9cda564156562d8672a3f  SCRATCH_MNT/test-925/file28.0
+1b3d697355ca662451eb12419cab8eef  SCRATCH_MNT/test-925/file29.0
+998b4ba52f2940dc515001e75926b19f  SCRATCH_MNT/test-925/file3.0
+6b2648f84c57f58786cf75ac06e37217  SCRATCH_MNT/test-925/file30.0
+c400b872b0fb3fb58920c4e570937a32  SCRATCH_MNT/test-925/file31.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-925/file32.0
+cac15c2eeaf1b63614469f675ec71c5f  SCRATCH_MNT/test-925/file33.0
+ebd2d819d56725bd1a2a35ababd06cad  SCRATCH_MNT/test-925/file34.0
+a26ebf37da9976dfd7c86b4271c59501  SCRATCH_MNT/test-925/file35.0
+11f61aaa1f5f726929c91c6d434edf72  SCRATCH_MNT/test-925/file36.0
+1f73d21c457843ea20048726d461648e  SCRATCH_MNT/test-925/file37.0
+9ed53cefd1548008ed1948286e471233  SCRATCH_MNT/test-925/file38.0
+af5195351947da43e7a57f69086aa7d7  SCRATCH_MNT/test-925/file39.0
+c946b71bb69c07daf25470742c967e7c  SCRATCH_MNT/test-925/file4.0
+f31ecd4106278b5fb1aeabdedd43036a  SCRATCH_MNT/test-925/file40.0
+e8a8d1a0873e25697171ebb87125d794  SCRATCH_MNT/test-925/file41.0
+5920fd86bc7be6a0ef5d7ea283e16307  SCRATCH_MNT/test-925/file42.0
+8360c3c368143821045f9b7994ab8344  SCRATCH_MNT/test-925/file43.0
+6c76a6c9e2b039c82e62d985479f73ee  SCRATCH_MNT/test-925/file44.0
+8b5c6cab2f0da5ba2d3b2d3ca205ca75  SCRATCH_MNT/test-925/file45.0
+b4ef05d705b8e99d8824d85e993bf8fa  SCRATCH_MNT/test-925/file46.0
+0db1f2d5ad692ccd8941a8bc308cdba2  SCRATCH_MNT/test-925/file47.0
+6a11a8872b36343799a15617bea78cef  SCRATCH_MNT/test-925/file48.0
+015ab57c35525eeb776308e14fe2e731  SCRATCH_MNT/test-925/file49.0
+17af09af790a9b4c79cddf72f6b642cb  SCRATCH_MNT/test-925/file5.0
+fbc6203955f9c6e9010f831971a073b2  SCRATCH_MNT/test-925/file50.0
+aae01cd767e508bdf2d01f647d10c4b8  SCRATCH_MNT/test-925/file51.0
+4d942a936328991bcd9821072ac0fd9e  SCRATCH_MNT/test-925/file52.0
+b77f243bb207746743aeaafbdef4203a  SCRATCH_MNT/test-925/file53.0
+9fc7f158bd2ded9df3965ef4fe2fa932  SCRATCH_MNT/test-925/file54.0
+36dff6091853c946411bc40fdae79e84  SCRATCH_MNT/test-925/file55.0
+82a2f6d28f1bff4ce7edc1a7a31b02cb  SCRATCH_MNT/test-925/file56.0
+b0d123bf023332bba783abb5b68e4c98  SCRATCH_MNT/test-925/file57.0
+26b49b145b128c0abef0f92b3ccaf1d6  SCRATCH_MNT/test-925/file58.0
+b5ef5d86d6ef15a535ee95b8069d29c9  SCRATCH_MNT/test-925/file59.0
+cd3eccbf2f0126c4141740007ba70c3f  SCRATCH_MNT/test-925/file6.0
+205cb48615014f6f2377345b62442609  SCRATCH_MNT/test-925/file60.0
+89691c001b3a3d5473081687ae519a18  SCRATCH_MNT/test-925/file61.0
+a040ce9774652bd00c3cbf493a006e00  SCRATCH_MNT/test-925/file62.0
+970b42855c15ee8caa824cd5e177759a  SCRATCH_MNT/test-925/file63.0
+eb74da58c6e4f93b4bf82a62fef4ab93  SCRATCH_MNT/test-925/file7.0
+30c2557e8302a5beb290c71520d87f42  SCRATCH_MNT/test-925/file8.0
+6dc42f5ed1007a3e20d08af71e198cdc  SCRATCH_MNT/test-925/file9.0
diff --git a/tests/generic/926 b/tests/generic/926
new file mode 100755
index 0000000..7dedc3f
--- /dev/null
+++ b/tests/generic/926
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 926
+#
+# Make sure that the reference counting mechanism can handle the case
+# where we share the first 1/4 of an extent with a file, share the
+# last 1/4 of the extent with a second file, share the first half of
+# the extent with N files, and share the second half of the extent
+# with a different set of N files.  The key point here is to test that
+# we handle the case where a refcount extent record doesn't coincide
+# exactly with the block mapping records.
+#
+#-----------------------------------------------------------------------
+# 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
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blocks=64
+blksz=65536
+nr=4
+halfway=$((blocks / 2 * blksz))
+quarter=$((blocks / 4 * blksz))
+
+echo "Initialize file"
+_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
+
+echo "Share the first half of the extent"
+seq 1 $nr | while read nr; do
+	_reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
+done
+
+echo "Share the last half of the extent"
+seq 1 $nr | while read nr; do
+	_reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
+done
+
+echo "Share the first quarter of the extent"
+_reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
+
+echo "Share the last quarter of the extent"
+_reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
+
+_scratch_cycle_mount
+
+echo "Check output"
+md5sum $testdir/file $testdir/file* | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/926.out b/tests/generic/926.out
new file mode 100644
index 0000000..d3e6b59
--- /dev/null
+++ b/tests/generic/926.out
@@ -0,0 +1,20 @@
+QA output created by 926
+Format and mount
+Initialize file
+Share the first half of the extent
+Share the last half of the extent
+Share the first quarter of the extent
+Share the last quarter of the extent
+Check output
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-926/file
+bdbcf02ee0aa977795a79d25fcfdccb1  SCRATCH_MNT/test-926/file
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-926/file.2
+7202826a7791073fe2787f0c94603278  SCRATCH_MNT/test-926/file.3
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file1.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file1.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file2.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file2.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file3.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file3.1
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file4.0
+de89461b64701958984c95d1bfb0065a  SCRATCH_MNT/test-926/file4.1
diff --git a/tests/generic/group b/tests/generic/group
index 6fdf109..2bd40a1 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -356,3 +356,5 @@
 351 blockdev quick rw
 923 auto quick clone
 924 auto quick clone
+925 auto quick clone
+926 auto quick clone

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

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

* [PATCH 08/20] xfs/122: don't break on old xfsprogs
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

If we're running against a old version of xfsprogs that lacks some of
the structures that the golden output knows about, copy the structure
size definition from the golden output to the program output.  This
way we can check for structure size mutations on old xfsprogs without
generating false error reports for structs that don't exist in the
old release.

v2: Remove the xfsprogs 2.9.8 compatibility cruft.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/122     |   17 ++++++-----------
 tests/xfs/122.out |    1 +
 2 files changed, 7 insertions(+), 11 deletions(-)


diff --git a/tests/xfs/122 b/tests/xfs/122
index 845cdd2..330d3ac 100755
--- a/tests/xfs/122
+++ b/tests/xfs/122
@@ -73,6 +73,7 @@ _attribute_filter()
 cprog=$tmp.get_structs.c
 oprog=$tmp.get_structs
 progout=$tmp.output
+keyfile=$tmp.keys
 
 cat >$cprog <<EOF
 #define _GNU_SOURCE
@@ -226,18 +227,12 @@ cc -o $oprog $cprog >> $seqres.full 2>&1 || \
   _notrun "Could not compile test program (see end of $seqres.full)"
 $oprog | _type_size_filter | _type_name_filter > $progout
 
-#
-# add addition sizes and xfs_sb_t fields that don't exist in the version
-# being tested.
-#
+# Find all the items that only exist in the golden output
+comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
+	 <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
 
-# xfsprogs 2.9.8: sb_bad_features2 in pv 978822
-if [ $XFSPROGS_VERSION -lt 20908 ]; then
-	echo 'offsetof(xfs_sb_t, sb_bad_features2 ) = 204' >>$progout
-fi
-if [ $XFSPROGS_VERSION -lt 30000 ]; then
-	echo 'sizeof( xfs_dsb_t ) = 208' >>$progout;
-fi
+# Copy those items to the program output
+grep -F -f $keyfile $0.out >> $progout
 
 LC_COLLATE=POSIX sort $progout
 
diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 451871e..46d1dd4 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -147,3 +147,4 @@ sizeof(xfs_lookup_t) = 4
 sizeof(xfs_qoff_logformat_t) = 20
 sizeof(xfs_timestamp_t) = 8
 sizeof(xfs_trans_header_t) = 16
+sizeof(xfs_zzzz_test_the_test_program) = -47


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

* [PATCH 08/20] xfs/122: don't break on old xfsprogs
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

If we're running against a old version of xfsprogs that lacks some of
the structures that the golden output knows about, copy the structure
size definition from the golden output to the program output.  This
way we can check for structure size mutations on old xfsprogs without
generating false error reports for structs that don't exist in the
old release.

v2: Remove the xfsprogs 2.9.8 compatibility cruft.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/122     |   17 ++++++-----------
 tests/xfs/122.out |    1 +
 2 files changed, 7 insertions(+), 11 deletions(-)


diff --git a/tests/xfs/122 b/tests/xfs/122
index 845cdd2..330d3ac 100755
--- a/tests/xfs/122
+++ b/tests/xfs/122
@@ -73,6 +73,7 @@ _attribute_filter()
 cprog=$tmp.get_structs.c
 oprog=$tmp.get_structs
 progout=$tmp.output
+keyfile=$tmp.keys
 
 cat >$cprog <<EOF
 #define _GNU_SOURCE
@@ -226,18 +227,12 @@ cc -o $oprog $cprog >> $seqres.full 2>&1 || \
   _notrun "Could not compile test program (see end of $seqres.full)"
 $oprog | _type_size_filter | _type_name_filter > $progout
 
-#
-# add addition sizes and xfs_sb_t fields that don't exist in the version
-# being tested.
-#
+# Find all the items that only exist in the golden output
+comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
+	 <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
 
-# xfsprogs 2.9.8: sb_bad_features2 in pv 978822
-if [ $XFSPROGS_VERSION -lt 20908 ]; then
-	echo 'offsetof(xfs_sb_t, sb_bad_features2 ) = 204' >>$progout
-fi
-if [ $XFSPROGS_VERSION -lt 30000 ]; then
-	echo 'sizeof( xfs_dsb_t ) = 208' >>$progout;
-fi
+# Copy those items to the program output
+grep -F -f $keyfile $0.out >> $progout
 
 LC_COLLATE=POSIX sort $progout
 
diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 451871e..46d1dd4 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -147,3 +147,4 @@ sizeof(xfs_lookup_t) = 4
 sizeof(xfs_qoff_logformat_t) = 20
 sizeof(xfs_timestamp_t) = 8
 sizeof(xfs_trans_header_t) = 16
+sizeof(xfs_zzzz_test_the_test_program) = -47

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

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

* [PATCH 09/20] xfs/122: fix test output to reflect latest xfsprogs
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:46   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Since we're getting rid of the rmapxbt, don't test for it.
Add back the log inode structure.

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


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 46d1dd4..ebc4421 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -75,11 +75,11 @@ 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_log_dinode) = 176
 sizeof(struct xfs_refcount_key) = 4
 sizeof(struct xfs_refcount_rec) = 12
-sizeof(struct xfs_rmap_key) = 4
+sizeof(struct xfs_rmap_key) = 20
 sizeof(struct xfs_rmap_rec) = 24
-sizeof(struct xfs_rmapx_key) = 20
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336


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

* [PATCH 09/20] xfs/122: fix test output to reflect latest xfsprogs
@ 2016-06-17  1:46   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:46 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Since we're getting rid of the rmapxbt, don't test for it.
Add back the log inode structure.

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


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index 46d1dd4..ebc4421 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -75,11 +75,11 @@ 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_log_dinode) = 176
 sizeof(struct xfs_refcount_key) = 4
 sizeof(struct xfs_refcount_rec) = 12
-sizeof(struct xfs_rmap_key) = 4
+sizeof(struct xfs_rmap_key) = 20
 sizeof(struct xfs_rmap_rec) = 24
-sizeof(struct xfs_rmapx_key) = 20
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336

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

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

* [PATCH 10/20] xfs/122: list the new log redo items
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

List the new log redo items.  These should have stable sizes.

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


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index ebc4421..c4ed725 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -60,7 +60,11 @@ sizeof(struct xfs_attr3_leaf_hdr) = 80
 sizeof(struct xfs_attr3_leafblock) = 88
 sizeof(struct xfs_attr3_rmt_hdr) = 56
 sizeof(struct xfs_btree_block) = 72
+sizeof(struct xfs_bud_log_format) = 48
+sizeof(struct xfs_bui_log_format) = 48
 sizeof(struct xfs_clone_args) = 32
+sizeof(struct xfs_cud_log_format) = 32
+sizeof(struct xfs_cui_log_format) = 32
 sizeof(struct xfs_da3_blkinfo) = 56
 sizeof(struct xfs_da3_intnode) = 64
 sizeof(struct xfs_da3_node_hdr) = 64
@@ -76,10 +80,14 @@ sizeof(struct xfs_extent_data_info) = 32
 sizeof(struct xfs_fs_eofblocks) = 128
 sizeof(struct xfs_icreate_log) = 28
 sizeof(struct xfs_log_dinode) = 176
+sizeof(struct xfs_map_extent) = 32
+sizeof(struct xfs_phys_extent) = 16
 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(struct xfs_rud_log_format) = 48
+sizeof(struct xfs_rui_log_format) = 48
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336


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

* [PATCH 10/20] xfs/122: list the new log redo items
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

List the new log redo items.  These should have stable sizes.

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


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index ebc4421..c4ed725 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -60,7 +60,11 @@ sizeof(struct xfs_attr3_leaf_hdr) = 80
 sizeof(struct xfs_attr3_leafblock) = 88
 sizeof(struct xfs_attr3_rmt_hdr) = 56
 sizeof(struct xfs_btree_block) = 72
+sizeof(struct xfs_bud_log_format) = 48
+sizeof(struct xfs_bui_log_format) = 48
 sizeof(struct xfs_clone_args) = 32
+sizeof(struct xfs_cud_log_format) = 32
+sizeof(struct xfs_cui_log_format) = 32
 sizeof(struct xfs_da3_blkinfo) = 56
 sizeof(struct xfs_da3_intnode) = 64
 sizeof(struct xfs_da3_node_hdr) = 64
@@ -76,10 +80,14 @@ sizeof(struct xfs_extent_data_info) = 32
 sizeof(struct xfs_fs_eofblocks) = 128
 sizeof(struct xfs_icreate_log) = 28
 sizeof(struct xfs_log_dinode) = 176
+sizeof(struct xfs_map_extent) = 32
+sizeof(struct xfs_phys_extent) = 16
 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(struct xfs_rud_log_format) = 48
+sizeof(struct xfs_rui_log_format) = 48
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36
 sizeof(xfs_agi_t) = 336

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

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

* [PATCH 11/20] xfs: inject errors at various parts of the deferred op completion
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/inject     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 common/log        |   28 ++++++++++++++
 common/rc         |    8 ++++
 tests/xfs/857     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/857.out |   18 +++++++++
 tests/xfs/858     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/858.out |   18 +++++++++
 tests/xfs/859     |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/859.out |   18 +++++++++
 tests/xfs/860     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/860.out |   16 ++++++++
 tests/xfs/861     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/861.out |   16 ++++++++
 tests/xfs/862     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/862.out |   16 ++++++++
 tests/xfs/863     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/863.out |   15 +++++++
 tests/xfs/864     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/864.out |   19 +++++++++
 tests/xfs/865     |   96 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/865.out |   18 +++++++++
 tests/xfs/866     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/866.out |   17 ++++++++
 tests/xfs/867     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/867.out |   17 ++++++++
 tests/xfs/868     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/868.out |   17 ++++++++
 tests/xfs/869     |  101 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/869.out |   17 ++++++++
 tests/xfs/870     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/870.out |   15 +++++++
 tests/xfs/871     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/871.out |   18 +++++++++
 tests/xfs/group   |   15 +++++++
 34 files changed, 1883 insertions(+)
 create mode 100644 common/inject
 create mode 100755 tests/xfs/857
 create mode 100644 tests/xfs/857.out
 create mode 100755 tests/xfs/858
 create mode 100644 tests/xfs/858.out
 create mode 100755 tests/xfs/859
 create mode 100644 tests/xfs/859.out
 create mode 100755 tests/xfs/860
 create mode 100644 tests/xfs/860.out
 create mode 100755 tests/xfs/861
 create mode 100644 tests/xfs/861.out
 create mode 100755 tests/xfs/862
 create mode 100644 tests/xfs/862.out
 create mode 100755 tests/xfs/863
 create mode 100644 tests/xfs/863.out
 create mode 100755 tests/xfs/864
 create mode 100644 tests/xfs/864.out
 create mode 100755 tests/xfs/865
 create mode 100644 tests/xfs/865.out
 create mode 100755 tests/xfs/866
 create mode 100644 tests/xfs/866.out
 create mode 100755 tests/xfs/867
 create mode 100644 tests/xfs/867.out
 create mode 100755 tests/xfs/868
 create mode 100644 tests/xfs/868.out
 create mode 100755 tests/xfs/869
 create mode 100644 tests/xfs/869.out
 create mode 100755 tests/xfs/870
 create mode 100644 tests/xfs/870.out
 create mode 100755 tests/xfs/871
 create mode 100644 tests/xfs/871.out


diff --git a/common/inject b/common/inject
new file mode 100644
index 0000000..e666d6d
--- /dev/null
+++ b/common/inject
@@ -0,0 +1,93 @@
+##/bin/bash
+# Routines for injecting errors into filesystems
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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/
+#-----------------------------------------------------------------------
+. ./common/log
+
+# Tests whether $FSTYP is one of the filesystems that supports error injection
+_require_error_injection()
+{
+	case "$FSTYP" in
+	"xfs")
+		grep -q 'debug 1' /proc/fs/xfs/stat || \
+			_notrun "XFS error injection requires CONFIG_XFS_DEBUG"
+		;;
+	*)
+		_notrun "Error injection not supported on filesystem type: $FSTYP"
+	esac
+}
+
+# Requires that xfs_io inject command knows about this error type
+_require_xfs_io_error_injection()
+{
+	type="$1"
+	_require_error_injection
+
+	# NOTE: We can't actually test error injection here because xfs
+	# hasn't always range checked the argument to xfs_errortag_add.
+	# We also don't want to trip an error before we're ready to deal
+	# with it.
+
+	$XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \
+		_notrun "XFS error injection $type unknown."
+}
+
+# Inject an error into the test fs
+_test_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $TEST_DIR
+}
+
+# Inject an error into the scratch fs
+_scratch_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT
+}
+
+# Unmount and remount the scratch device, dumping the log
+_scratch_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_scratch_unmount
+	_scratch_dump_log
+	_scratch_mount "$opts"
+}
+
+# Unmount and remount the test device, dumping the log
+_test_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_test_unmount
+	_test_dump_log
+	_test_mount "$opts"
+}
diff --git a/common/log b/common/log
index cb687d2..44b9625 100644
--- a/common/log
+++ b/common/log
@@ -228,6 +228,34 @@ _scratch_f2fs_logstate()
     echo $?
 }
 
+_scratch_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _scratch_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $SCRATCH_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
+_test_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _test_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $TEST_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
 _print_logstate()
 {
     case "$FSTYP" in
diff --git a/common/rc b/common/rc
index 1648a8a..1225047 100644
--- a/common/rc
+++ b/common/rc
@@ -982,6 +982,14 @@ _scratch_xfs_logprint()
     $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_test_xfs_logprint()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="-l$TEST_LOGDEV"
+    $XFS_LOGPRINT_PROG $TEST_OPTIONS $* $TEST_DEV
+}
+
 _scratch_xfs_check()
 {
     SCRATCH_OPTIONS=""
diff --git a/tests/xfs/857 b/tests/xfs/857
new file mode 100755
index 0000000..7798362
--- /dev/null
+++ b/tests/xfs/857
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 857
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/857.out b/tests/xfs/857.out
new file mode 100644
index 0000000..ecc8e04
--- /dev/null
+++ b/tests/xfs/857.out
@@ -0,0 +1,18 @@
+QA output created by 857
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/858 b/tests/xfs/858
new file mode 100755
index 0000000..fe3ac07
--- /dev/null
+++ b/tests/xfs/858
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 858
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/858.out b/tests/xfs/858.out
new file mode 100644
index 0000000..f5302de
--- /dev/null
+++ b/tests/xfs/858.out
@@ -0,0 +1,18 @@
+QA output created by 858
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/859 b/tests/xfs/859
new file mode 100755
index 0000000..c36cc5b
--- /dev/null
+++ b/tests/xfs/859
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 859
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during rmap updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/859.out b/tests/xfs/859.out
new file mode 100644
index 0000000..b83e963
--- /dev/null
+++ b/tests/xfs/859.out
@@ -0,0 +1,18 @@
+QA output created by 859
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/860 b/tests/xfs/860
new file mode 100755
index 0000000..15716c1
--- /dev/null
+++ b/tests/xfs/860
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 860
+#
+# Reflink a file with a few dozen extents and CoW a few blocks.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=4
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/860.out b/tests/xfs/860.out
new file mode 100644
index 0000000..0a6d763
--- /dev/null
+++ b/tests/xfs/860.out
@@ -0,0 +1,16 @@
+QA output created by 860
+Format filesystem
+Create files
+Check files
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+fe9070b9c9deb97ed53811efda5c4ad5  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/861 b/tests/xfs/861
new file mode 100755
index 0000000..6f716a4
--- /dev/null
+++ b/tests/xfs/861
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 861
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "CoW all the blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $((blks * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/861.out b/tests/xfs/861.out
new file mode 100644
index 0000000..d353526
--- /dev/null
+++ b/tests/xfs/861.out
@@ -0,0 +1,16 @@
+QA output created by 861
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/862 b/tests/xfs/862
new file mode 100755
index 0000000..167386c
--- /dev/null
+++ b/tests/xfs/862
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 862
+#
+# Simulate rmap update errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/862.out b/tests/xfs/862.out
new file mode 100644
index 0000000..1f6b47b
--- /dev/null
+++ b/tests/xfs/862.out
@@ -0,0 +1,16 @@
+QA output created by 862
+Format filesystem
+Create files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+Inject error
+Write files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/863 b/tests/xfs/863
new file mode 100755
index 0000000..5069245
--- /dev/null
+++ b/tests/xfs/863
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 863
+#
+# Simulate free extent errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Remove files"
+rm -rf $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/863.out b/tests/xfs/863.out
new file mode 100644
index 0000000..718691f
--- /dev/null
+++ b/tests/xfs/863.out
@@ -0,0 +1,15 @@
+QA output created by 863
+Format filesystem
+Create files
+Write files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file1
+Inject error
+Remove files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+md5sum: SCRATCH_MNT/file1: No such file or directory
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/864 b/tests/xfs/864
new file mode 100755
index 0000000..6483639
--- /dev/null
+++ b/tests/xfs/864
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 864
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/864.out b/tests/xfs/864.out
new file mode 100644
index 0000000..cd16235
--- /dev/null
+++ b/tests/xfs/864.out
@@ -0,0 +1,19 @@
+QA output created by 864
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/865 b/tests/xfs/865
new file mode 100755
index 0000000..9e2bf05
--- /dev/null
+++ b/tests/xfs/865
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 865
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_cp_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks - 17))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 2>&1 | _filter_scratch
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/865.out b/tests/xfs/865.out
new file mode 100644
index 0000000..9a2b04d
--- /dev/null
+++ b/tests/xfs/865.out
@@ -0,0 +1,18 @@
+QA output created by 865
+Format filesystem
+Create files
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+Inject error
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/file3' from 'SCRATCH_MNT/file1': Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/866 b/tests/xfs/866
new file mode 100755
index 0000000..9405325
--- /dev/null
+++ b/tests/xfs/866
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 866
+#
+# Reflink a file.
+# Inject an error during refcount update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/866.out b/tests/xfs/866.out
new file mode 100644
index 0000000..f2ca58c
--- /dev/null
+++ b/tests/xfs/866.out
@@ -0,0 +1,17 @@
+QA output created by 866
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/867 b/tests/xfs/867
new file mode 100755
index 0000000..5037a88
--- /dev/null
+++ b/tests/xfs/867
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 867
+#
+# Reflink a file.
+# Inject an error during rmap update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/867.out b/tests/xfs/867.out
new file mode 100644
index 0000000..78a4e5a
--- /dev/null
+++ b/tests/xfs/867.out
@@ -0,0 +1,17 @@
+QA output created by 867
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/868 b/tests/xfs/868
new file mode 100755
index 0000000..71cf7ee
--- /dev/null
+++ b/tests/xfs/868
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 868
+#
+# Reflink a file.
+# Inject an error during extent free to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/868.out b/tests/xfs/868.out
new file mode 100644
index 0000000..583b1f9
--- /dev/null
+++ b/tests/xfs/868.out
@@ -0,0 +1,17 @@
+QA output created by 868
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/869 b/tests/xfs/869
new file mode 100755
index 0000000..97c803b
--- /dev/null
+++ b/tests/xfs/869
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 869
+#
+# Reflink a file with a few dozen extents.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "Reflink all the blocks"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file4
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+md5sum $SCRATCH_MNT/file4 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/869.out b/tests/xfs/869.out
new file mode 100644
index 0000000..1e7822e
--- /dev/null
+++ b/tests/xfs/869.out
@@ -0,0 +1,17 @@
+QA output created by 869
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+Reflink all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file4
+Done
diff --git a/tests/xfs/870 b/tests/xfs/870
new file mode 100755
index 0000000..fc13f53
--- /dev/null
+++ b/tests/xfs/870
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 870
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=30
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+rm $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/870.out b/tests/xfs/870.out
new file mode 100644
index 0000000..49c4e4b
--- /dev/null
+++ b/tests/xfs/870.out
@@ -0,0 +1,15 @@
+QA output created by 870
+Format filesystem
+Create files
+Check files
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file1
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+7629bd70d19d7291b448221ac44b26d9  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/871 b/tests/xfs/871
new file mode 100755
index 0000000..69bb637
--- /dev/null
+++ b/tests/xfs/871
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 871
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log recovery.  Use
+# cowextsize so that the refcount failure is somewhere in the CoW remap
+# instead of when we're stashing the CoW orphan record.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full
+sync
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/871.out b/tests/xfs/871.out
new file mode 100644
index 0000000..c0aba73
--- /dev/null
+++ b/tests/xfs/871.out
@@ -0,0 +1,18 @@
+QA output created by 871
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 1ad37ff..0f94794 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -289,3 +289,18 @@
 854 auto quick clone
 855 auto clone
 856 auto quick clone rmap
+857 auto quick clone
+858 auto quick clone
+859 auto quick clone
+860 auto quick clone
+861 auto quick clone
+862 auto quick rmap
+863 auto quick rw
+864 auto quick clone
+865 auto quick clone
+866 auto quick clone
+867 auto quick clone
+868 auto quick clone
+869 auto quick clone
+870 auto quick clone
+871 auto quick clone


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

* [PATCH 11/20] xfs: inject errors at various parts of the deferred op completion
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/inject     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 common/log        |   28 ++++++++++++++
 common/rc         |    8 ++++
 tests/xfs/857     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/857.out |   18 +++++++++
 tests/xfs/858     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/858.out |   18 +++++++++
 tests/xfs/859     |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/859.out |   18 +++++++++
 tests/xfs/860     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/860.out |   16 ++++++++
 tests/xfs/861     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/861.out |   16 ++++++++
 tests/xfs/862     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/862.out |   16 ++++++++
 tests/xfs/863     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/863.out |   15 +++++++
 tests/xfs/864     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/864.out |   19 +++++++++
 tests/xfs/865     |   96 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/865.out |   18 +++++++++
 tests/xfs/866     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/866.out |   17 ++++++++
 tests/xfs/867     |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/867.out |   17 ++++++++
 tests/xfs/868     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/868.out |   17 ++++++++
 tests/xfs/869     |  101 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/869.out |   17 ++++++++
 tests/xfs/870     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/870.out |   15 +++++++
 tests/xfs/871     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/871.out |   18 +++++++++
 tests/xfs/group   |   15 +++++++
 34 files changed, 1883 insertions(+)
 create mode 100644 common/inject
 create mode 100755 tests/xfs/857
 create mode 100644 tests/xfs/857.out
 create mode 100755 tests/xfs/858
 create mode 100644 tests/xfs/858.out
 create mode 100755 tests/xfs/859
 create mode 100644 tests/xfs/859.out
 create mode 100755 tests/xfs/860
 create mode 100644 tests/xfs/860.out
 create mode 100755 tests/xfs/861
 create mode 100644 tests/xfs/861.out
 create mode 100755 tests/xfs/862
 create mode 100644 tests/xfs/862.out
 create mode 100755 tests/xfs/863
 create mode 100644 tests/xfs/863.out
 create mode 100755 tests/xfs/864
 create mode 100644 tests/xfs/864.out
 create mode 100755 tests/xfs/865
 create mode 100644 tests/xfs/865.out
 create mode 100755 tests/xfs/866
 create mode 100644 tests/xfs/866.out
 create mode 100755 tests/xfs/867
 create mode 100644 tests/xfs/867.out
 create mode 100755 tests/xfs/868
 create mode 100644 tests/xfs/868.out
 create mode 100755 tests/xfs/869
 create mode 100644 tests/xfs/869.out
 create mode 100755 tests/xfs/870
 create mode 100644 tests/xfs/870.out
 create mode 100755 tests/xfs/871
 create mode 100644 tests/xfs/871.out


diff --git a/common/inject b/common/inject
new file mode 100644
index 0000000..e666d6d
--- /dev/null
+++ b/common/inject
@@ -0,0 +1,93 @@
+##/bin/bash
+# Routines for injecting errors into filesystems
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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/
+#-----------------------------------------------------------------------
+. ./common/log
+
+# Tests whether $FSTYP is one of the filesystems that supports error injection
+_require_error_injection()
+{
+	case "$FSTYP" in
+	"xfs")
+		grep -q 'debug 1' /proc/fs/xfs/stat || \
+			_notrun "XFS error injection requires CONFIG_XFS_DEBUG"
+		;;
+	*)
+		_notrun "Error injection not supported on filesystem type: $FSTYP"
+	esac
+}
+
+# Requires that xfs_io inject command knows about this error type
+_require_xfs_io_error_injection()
+{
+	type="$1"
+	_require_error_injection
+
+	# NOTE: We can't actually test error injection here because xfs
+	# hasn't always range checked the argument to xfs_errortag_add.
+	# We also don't want to trip an error before we're ready to deal
+	# with it.
+
+	$XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \
+		_notrun "XFS error injection $type unknown."
+}
+
+# Inject an error into the test fs
+_test_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $TEST_DIR
+}
+
+# Inject an error into the scratch fs
+_scratch_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT
+}
+
+# Unmount and remount the scratch device, dumping the log
+_scratch_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_scratch_unmount
+	_scratch_dump_log
+	_scratch_mount "$opts"
+}
+
+# Unmount and remount the test device, dumping the log
+_test_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_test_unmount
+	_test_dump_log
+	_test_mount "$opts"
+}
diff --git a/common/log b/common/log
index cb687d2..44b9625 100644
--- a/common/log
+++ b/common/log
@@ -228,6 +228,34 @@ _scratch_f2fs_logstate()
     echo $?
 }
 
+_scratch_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _scratch_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $SCRATCH_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
+_test_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _test_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $TEST_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
 _print_logstate()
 {
     case "$FSTYP" in
diff --git a/common/rc b/common/rc
index 1648a8a..1225047 100644
--- a/common/rc
+++ b/common/rc
@@ -982,6 +982,14 @@ _scratch_xfs_logprint()
     $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_test_xfs_logprint()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="-l$TEST_LOGDEV"
+    $XFS_LOGPRINT_PROG $TEST_OPTIONS $* $TEST_DEV
+}
+
 _scratch_xfs_check()
 {
     SCRATCH_OPTIONS=""
diff --git a/tests/xfs/857 b/tests/xfs/857
new file mode 100755
index 0000000..7798362
--- /dev/null
+++ b/tests/xfs/857
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 857
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/857.out b/tests/xfs/857.out
new file mode 100644
index 0000000..ecc8e04
--- /dev/null
+++ b/tests/xfs/857.out
@@ -0,0 +1,18 @@
+QA output created by 857
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/858 b/tests/xfs/858
new file mode 100755
index 0000000..fe3ac07
--- /dev/null
+++ b/tests/xfs/858
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 858
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/858.out b/tests/xfs/858.out
new file mode 100644
index 0000000..f5302de
--- /dev/null
+++ b/tests/xfs/858.out
@@ -0,0 +1,18 @@
+QA output created by 858
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/859 b/tests/xfs/859
new file mode 100755
index 0000000..c36cc5b
--- /dev/null
+++ b/tests/xfs/859
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 859
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during rmap updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/859.out b/tests/xfs/859.out
new file mode 100644
index 0000000..b83e963
--- /dev/null
+++ b/tests/xfs/859.out
@@ -0,0 +1,18 @@
+QA output created by 859
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/860 b/tests/xfs/860
new file mode 100755
index 0000000..15716c1
--- /dev/null
+++ b/tests/xfs/860
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 860
+#
+# Reflink a file with a few dozen extents and CoW a few blocks.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=4
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/860.out b/tests/xfs/860.out
new file mode 100644
index 0000000..0a6d763
--- /dev/null
+++ b/tests/xfs/860.out
@@ -0,0 +1,16 @@
+QA output created by 860
+Format filesystem
+Create files
+Check files
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+fe9070b9c9deb97ed53811efda5c4ad5  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/861 b/tests/xfs/861
new file mode 100755
index 0000000..6f716a4
--- /dev/null
+++ b/tests/xfs/861
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 861
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "CoW all the blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $((blks * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/861.out b/tests/xfs/861.out
new file mode 100644
index 0000000..d353526
--- /dev/null
+++ b/tests/xfs/861.out
@@ -0,0 +1,16 @@
+QA output created by 861
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/862 b/tests/xfs/862
new file mode 100755
index 0000000..167386c
--- /dev/null
+++ b/tests/xfs/862
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 862
+#
+# Simulate rmap update errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/862.out b/tests/xfs/862.out
new file mode 100644
index 0000000..1f6b47b
--- /dev/null
+++ b/tests/xfs/862.out
@@ -0,0 +1,16 @@
+QA output created by 862
+Format filesystem
+Create files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+Inject error
+Write files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/863 b/tests/xfs/863
new file mode 100755
index 0000000..5069245
--- /dev/null
+++ b/tests/xfs/863
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 863
+#
+# Simulate free extent errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Remove files"
+rm -rf $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/863.out b/tests/xfs/863.out
new file mode 100644
index 0000000..718691f
--- /dev/null
+++ b/tests/xfs/863.out
@@ -0,0 +1,15 @@
+QA output created by 863
+Format filesystem
+Create files
+Write files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file1
+Inject error
+Remove files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+md5sum: SCRATCH_MNT/file1: No such file or directory
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/864 b/tests/xfs/864
new file mode 100755
index 0000000..6483639
--- /dev/null
+++ b/tests/xfs/864
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 864
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/864.out b/tests/xfs/864.out
new file mode 100644
index 0000000..cd16235
--- /dev/null
+++ b/tests/xfs/864.out
@@ -0,0 +1,19 @@
+QA output created by 864
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/865 b/tests/xfs/865
new file mode 100755
index 0000000..9e2bf05
--- /dev/null
+++ b/tests/xfs/865
@@ -0,0 +1,96 @@
+#! /bin/bash
+# FS QA Test No. 865
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_cp_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks - 17))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 2>&1 | _filter_scratch
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/865.out b/tests/xfs/865.out
new file mode 100644
index 0000000..9a2b04d
--- /dev/null
+++ b/tests/xfs/865.out
@@ -0,0 +1,18 @@
+QA output created by 865
+Format filesystem
+Create files
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+Inject error
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/file3' from 'SCRATCH_MNT/file1': Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/866 b/tests/xfs/866
new file mode 100755
index 0000000..9405325
--- /dev/null
+++ b/tests/xfs/866
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 866
+#
+# Reflink a file.
+# Inject an error during refcount update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/866.out b/tests/xfs/866.out
new file mode 100644
index 0000000..f2ca58c
--- /dev/null
+++ b/tests/xfs/866.out
@@ -0,0 +1,17 @@
+QA output created by 866
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/867 b/tests/xfs/867
new file mode 100755
index 0000000..5037a88
--- /dev/null
+++ b/tests/xfs/867
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 867
+#
+# Reflink a file.
+# Inject an error during rmap update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/867.out b/tests/xfs/867.out
new file mode 100644
index 0000000..78a4e5a
--- /dev/null
+++ b/tests/xfs/867.out
@@ -0,0 +1,17 @@
+QA output created by 867
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/868 b/tests/xfs/868
new file mode 100755
index 0000000..71cf7ee
--- /dev/null
+++ b/tests/xfs/868
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 868
+#
+# Reflink a file.
+# Inject an error during extent free to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_scratch_reflink
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/868.out b/tests/xfs/868.out
new file mode 100644
index 0000000..583b1f9
--- /dev/null
+++ b/tests/xfs/868.out
@@ -0,0 +1,17 @@
+QA output created by 868
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/869 b/tests/xfs/869
new file mode 100755
index 0000000..97c803b
--- /dev/null
+++ b/tests/xfs/869
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 869
+#
+# Reflink a file with a few dozen extents.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "Reflink all the blocks"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file4
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+md5sum $SCRATCH_MNT/file4 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/869.out b/tests/xfs/869.out
new file mode 100644
index 0000000..1e7822e
--- /dev/null
+++ b/tests/xfs/869.out
@@ -0,0 +1,17 @@
+QA output created by 869
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+Reflink all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file4
+Done
diff --git a/tests/xfs/870 b/tests/xfs/870
new file mode 100755
index 0000000..fc13f53
--- /dev/null
+++ b/tests/xfs/870
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 870
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=30
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+rm $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/870.out b/tests/xfs/870.out
new file mode 100644
index 0000000..49c4e4b
--- /dev/null
+++ b/tests/xfs/870.out
@@ -0,0 +1,15 @@
+QA output created by 870
+Format filesystem
+Create files
+Check files
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file1
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+7629bd70d19d7291b448221ac44b26d9  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/871 b/tests/xfs/871
new file mode 100755
index 0000000..69bb637
--- /dev/null
+++ b/tests/xfs/871
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 871
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log recovery.  Use
+# cowextsize so that the refcount failure is somewhere in the CoW remap
+# instead of when we're stashing the CoW orphan record.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full
+sync
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/871.out b/tests/xfs/871.out
new file mode 100644
index 0000000..c0aba73
--- /dev/null
+++ b/tests/xfs/871.out
@@ -0,0 +1,18 @@
+QA output created by 871
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 1ad37ff..0f94794 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -289,3 +289,18 @@
 854 auto quick clone
 855 auto clone
 856 auto quick clone rmap
+857 auto quick clone
+858 auto quick clone
+859 auto quick clone
+860 auto quick clone
+861 auto quick clone
+862 auto quick rmap
+863 auto quick rw
+864 auto quick clone
+865 auto quick clone
+866 auto quick clone
+867 auto quick clone
+868 auto quick clone
+869 auto quick clone
+870 auto quick clone
+871 auto quick clone

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

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

* [PATCH 12/20] xfs/235: fix logic errors when checking rmap usage after failures
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

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


diff --git a/tests/xfs/235 b/tests/xfs/235
index c388af1..c2e0340 100755
--- a/tests/xfs/235
+++ b/tests/xfs/235
@@ -80,8 +80,8 @@ 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"
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((blksz * 64))" -c "fsync" ${SCRATCH_MNT}/file4 >> $seqres.full 2>&1
+test -s ${SCRATCH_MNT}/file4 && _fail "should not be able to copy with busted rmap btree"
 umount ${SCRATCH_MNT}
 
 echo "+ repair fs"
diff --git a/tests/xfs/235.out b/tests/xfs/235.out
index 89a11d6..7640224 100644
--- a/tests/xfs/235.out
+++ b/tests/xfs/235.out
@@ -6,7 +6,6 @@ QA output created by 235
 + corrupt image
 + mount image
 + copy more
-fsync: Structure needs cleaning
 + repair fs
 + mount image (2)
 + chattr -R -i


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

* [PATCH 12/20] xfs/235: fix logic errors when checking rmap usage after failures
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

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


diff --git a/tests/xfs/235 b/tests/xfs/235
index c388af1..c2e0340 100755
--- a/tests/xfs/235
+++ b/tests/xfs/235
@@ -80,8 +80,8 @@ 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"
+$XFS_IO_PROG -f -c "pwrite -S 0x63 0 $((blksz * 64))" -c "fsync" ${SCRATCH_MNT}/file4 >> $seqres.full 2>&1
+test -s ${SCRATCH_MNT}/file4 && _fail "should not be able to copy with busted rmap btree"
 umount ${SCRATCH_MNT}
 
 echo "+ repair fs"
diff --git a/tests/xfs/235.out b/tests/xfs/235.out
index 89a11d6..7640224 100644
--- a/tests/xfs/235.out
+++ b/tests/xfs/235.out
@@ -6,7 +6,6 @@ QA output created by 235
 + corrupt image
 + mount image
 + copy more
-fsync: Structure needs cleaning
 + repair fs
 + mount image (2)
 + chattr -R -i

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

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

* [PATCH 13/20] xfs/229: require 3GB of space
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

This test requires 3GB of space, so check for that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/229 |    1 +
 1 file changed, 1 insertion(+)


diff --git a/tests/xfs/229 b/tests/xfs/229
index c057677..b8fd914 100755
--- a/tests/xfs/229
+++ b/tests/xfs/229
@@ -50,6 +50,7 @@ trap "_cleanup ; exit \$status" 0 1 2 3 15
 _supported_fs xfs
 _supported_os Linux
 _require_test
+_require_fs_space $TEST_DIR 3200000
 
 TDIR="${TEST_DIR}/t_holes"
 NFILES="10"


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

* [PATCH 13/20] xfs/229: require 3GB of space
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

This test requires 3GB of space, so check for that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/229 |    1 +
 1 file changed, 1 insertion(+)


diff --git a/tests/xfs/229 b/tests/xfs/229
index c057677..b8fd914 100755
--- a/tests/xfs/229
+++ b/tests/xfs/229
@@ -50,6 +50,7 @@ trap "_cleanup ; exit \$status" 0 1 2 3 15
 _supported_fs xfs
 _supported_os Linux
 _require_test
+_require_fs_space $TEST_DIR 3200000
 
 TDIR="${TEST_DIR}/t_holes"
 NFILES="10"

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

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

* [PATCH 14/20] xfs: test clearing reflink inode flag
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Check that xfs_repair can clear the reflink inode flag.

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


diff --git a/tests/xfs/872 b/tests/xfs/872
new file mode 100755
index 0000000..1a13f50
--- /dev/null
+++ b/tests/xfs/872
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 872
+#
+# Create 100 reflinked files, CoW them all, and see if xfs_repair will
+# clear the reflink flag.  There was a buffer handling bug in xfs_repair
+# that (fortunately) triggered asserts in the rmap code when clearing
+# the reflink flag.
+#
+#-----------------------------------------------------------------------
+# 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_cp_reflink
+_require_scratch
+
+rm -f $seqres.full
+
+nr=128 # spanning at least one inode chunk tickles a bug in xfs_repair
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full
+seq 1 $nr | while read i; do
+	_cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i
+done
+sync
+
+echo "Check files"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "CoW all files"
+seq 1 $nr | while read i; do
+	echo m >> $SCRATCH_MNT/file.$i
+done
+
+echo "Repair filesystem"
+_scratch_unmount
+_repair_scratch_fs >> $seqres.full
+_scratch_mount
+
+echo "Check files again"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/872.out b/tests/xfs/872.out
new file mode 100644
index 0000000..316cb0a
--- /dev/null
+++ b/tests/xfs/872.out
@@ -0,0 +1,20 @@
+QA output created by 872
+Format filesystem
+Create files
+Check files
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[reflink] SCRATCH_MNT/file.0 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.64
+[reflink] SCRATCH_MNT/file.64 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.128
+[reflink] SCRATCH_MNT/file.128 
+CoW all files
+Repair filesystem
+Check files again
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[] SCRATCH_MNT/file.0 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.64
+[] SCRATCH_MNT/file.64 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.128
+[] SCRATCH_MNT/file.128 
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 0f94794..ca36ad6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -304,3 +304,4 @@
 869 auto quick clone
 870 auto quick clone
 871 auto quick clone
+872 auto quick clone


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

* [PATCH 14/20] xfs: test clearing reflink inode flag
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Check that xfs_repair can clear the reflink inode flag.

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


diff --git a/tests/xfs/872 b/tests/xfs/872
new file mode 100755
index 0000000..1a13f50
--- /dev/null
+++ b/tests/xfs/872
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 872
+#
+# Create 100 reflinked files, CoW them all, and see if xfs_repair will
+# clear the reflink flag.  There was a buffer handling bug in xfs_repair
+# that (fortunately) triggered asserts in the rmap code when clearing
+# the reflink flag.
+#
+#-----------------------------------------------------------------------
+# 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_cp_reflink
+_require_scratch
+
+rm -f $seqres.full
+
+nr=128 # spanning at least one inode chunk tickles a bug in xfs_repair
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full
+seq 1 $nr | while read i; do
+	_cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i
+done
+sync
+
+echo "Check files"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "CoW all files"
+seq 1 $nr | while read i; do
+	echo m >> $SCRATCH_MNT/file.$i
+done
+
+echo "Repair filesystem"
+_scratch_unmount
+_repair_scratch_fs >> $seqres.full
+_scratch_mount
+
+echo "Check files again"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/872.out b/tests/xfs/872.out
new file mode 100644
index 0000000..316cb0a
--- /dev/null
+++ b/tests/xfs/872.out
@@ -0,0 +1,20 @@
+QA output created by 872
+Format filesystem
+Create files
+Check files
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[reflink] SCRATCH_MNT/file.0 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.64
+[reflink] SCRATCH_MNT/file.64 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.128
+[reflink] SCRATCH_MNT/file.128 
+CoW all files
+Repair filesystem
+Check files again
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[] SCRATCH_MNT/file.0 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.64
+[] SCRATCH_MNT/file.64 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.128
+[] SCRATCH_MNT/file.128 
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 0f94794..ca36ad6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -304,3 +304,4 @@
 869 auto quick clone
 870 auto quick clone
 871 auto quick clone
+872 auto quick clone

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

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

* [PATCH 15/20] xfstests: fix unreferenced variables in generic/186 and generic/187
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, Christoph Hellwig, fstests, xfs

From: Christoph Hellwig <hch@lst.de>

There is not i variable in scope, and the comments suggest the operation
is to be done on ${file}.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/186 |    2 +-
 tests/generic/187 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/tests/generic/186 b/tests/generic/186
index 70a0280..5de120a 100755
--- a/tests/generic/186
+++ b/tests/generic/186
@@ -87,7 +87,7 @@ _fragment_freesp()
 
 	# Try again anyway
 	avail=`_get_available_space $SCRATCH_MNT`
-	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}.${i}
+	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}
 
 	# Punch out whatever we need
 	seq 1 $((nr * 4)) | while read f; do
diff --git a/tests/generic/187 b/tests/generic/187
index 25cbcd9..3f534c8 100755
--- a/tests/generic/187
+++ b/tests/generic/187
@@ -88,7 +88,7 @@ _fragment_freesp()
 
 	# Try again anyway
 	avail=`_get_available_space $SCRATCH_MNT`
-	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}.${i}
+	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}
 
 	# Punch out whatever we need
 	seq 1 $((nr * 4)) | while read f; do


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

* [PATCH 15/20] xfstests: fix unreferenced variables in generic/186 and generic/187
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, Christoph Hellwig, linux-btrfs, xfs

From: Christoph Hellwig <hch@lst.de>

There is not i variable in scope, and the comments suggest the operation
is to be done on ${file}.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/186 |    2 +-
 tests/generic/187 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/tests/generic/186 b/tests/generic/186
index 70a0280..5de120a 100755
--- a/tests/generic/186
+++ b/tests/generic/186
@@ -87,7 +87,7 @@ _fragment_freesp()
 
 	# Try again anyway
 	avail=`_get_available_space $SCRATCH_MNT`
-	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}.${i}
+	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}
 
 	# Punch out whatever we need
 	seq 1 $((nr * 4)) | while read f; do
diff --git a/tests/generic/187 b/tests/generic/187
index 25cbcd9..3f534c8 100755
--- a/tests/generic/187
+++ b/tests/generic/187
@@ -88,7 +88,7 @@ _fragment_freesp()
 
 	# Try again anyway
 	avail=`_get_available_space $SCRATCH_MNT`
-	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}.${i}
+	$XFS_IO_PROG -fc "pwrite -S 0x65 0 $avail" ${file}
 
 	# Punch out whatever we need
 	seq 1 $((nr * 4)) | while read f; do

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

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

* [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Test sharing blocks via reflink and dedupe between two different
mountpoints of the same filesystem.  This shouldn't work, since
we don't allow cross-mountpoint functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink        |    2 +
 tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/927.out |    9 +++++
 tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/928.out |   10 ++++++
 tests/generic/group   |    2 +
 6 files changed, 196 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/927
 create mode 100644 tests/generic/927.out
 create mode 100755 tests/generic/928
 create mode 100644 tests/generic/928.out


diff --git a/common/reflink b/common/reflink
index 4ec390d..1363971 100644
--- a/common/reflink
+++ b/common/reflink
@@ -107,7 +107,7 @@ _require_scratch_dedupe()
 	_scratch_mount
 	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
 	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
-	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
+	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
 	echo $testio | grep -q "Operation not supported" && \
 		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
 	echo $testio | grep -q "Inappropriate ioctl for device" && \
diff --git a/tests/generic/927 b/tests/generic/927
new file mode 100755
index 0000000..e1c30bd
--- /dev/null
+++ b/tests/generic/927
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 927
+#
+# Check that cross-mountpoint reflink doesn't work.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+otherdir=/tmp/m.$seq
+othertestdir=$otherdir/test-$seq
+rm -rf $otherdir
+mkdir $otherdir
+
+blocks=1
+blksz=65536
+sz=$((blksz * blocks))
+
+echo "Mount otherdir"
+SCRATCH_MNT=$otherdir _scratch_mount
+
+echo "Create file"
+_pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
+
+filter_md5() {
+	_filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
+}
+
+echo "Reflink one file to another"
+_cp_reflink $testdir/file $othertestdir/otherfiles 2>&1 | filter_md5
+
+echo "Check output"
+md5sum $testdir/file | _filter_scratch
+test -e $othertestdir/otherfile && echo "otherfile should not exist"
+
+echo "Unmount otherdir"
+umount $otherdir
+rm -rf $otherdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/927.out b/tests/generic/927.out
new file mode 100644
index 0000000..3ef3057
--- /dev/null
+++ b/tests/generic/927.out
@@ -0,0 +1,9 @@
+QA output created by 927
+Format and mount
+Mount otherdir
+Create file
+Reflink one file to another
+cp: failed to clone 'OTHER_DIR/test-927/otherfiles' from 'SCRATCH_MNT/test-927/file': Invalid cross-device link
+Check output
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-927/file
+Unmount otherdir
diff --git a/tests/generic/928 b/tests/generic/928
new file mode 100755
index 0000000..050f34b
--- /dev/null
+++ b/tests/generic/928
@@ -0,0 +1,86 @@
+#! /bin/bash
+# FS QA Test No. 928
+#
+# Check that cross-mountpoint dedupe doesn't work.
+#
+#-----------------------------------------------------------------------
+# 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_dedupe
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+otherdir=/tmp/m.$seq
+othertestdir=$otherdir/test-$seq
+rm -rf $otherdir
+mkdir $otherdir
+
+blocks=1
+blksz=65536
+sz=$((blocks * blksz))
+
+echo "Mount otherdir"
+SCRATCH_MNT=$otherdir _scratch_mount
+
+echo "Create file"
+_pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
+_pwrite_byte 0x61 0 $sz $testdir/otherfile >> $seqres.full
+
+echo "Dedupe one file to another"
+_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz >> $seqres.full
+
+filter_md5() {
+	_filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
+}
+echo "Check output"
+md5sum $testdir/file $othertestdir/otherfile | filter_md5
+
+echo "Unmount otherdir"
+umount $otherdir
+rm -rf $otherdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/928.out b/tests/generic/928.out
new file mode 100644
index 0000000..ef35c5b
--- /dev/null
+++ b/tests/generic/928.out
@@ -0,0 +1,10 @@
+QA output created by 928
+Format and mount
+Mount otherdir
+Create file
+Dedupe one file to another
+dedupe: Invalid cross-device link
+Check output
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-928/file
+2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-928/otherfile
+Unmount otherdir
diff --git a/tests/generic/group b/tests/generic/group
index 2bd40a1..3286b0f 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -358,3 +358,5 @@
 924 auto quick clone
 925 auto quick clone
 926 auto quick clone
+927 auto quick clone
+928 auto quick clone dedupe


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

* [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Test sharing blocks via reflink and dedupe between two different
mountpoints of the same filesystem.  This shouldn't work, since
we don't allow cross-mountpoint functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink        |    2 +
 tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/927.out |    9 +++++
 tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/928.out |   10 ++++++
 tests/generic/group   |    2 +
 6 files changed, 196 insertions(+), 1 deletion(-)
 create mode 100755 tests/generic/927
 create mode 100644 tests/generic/927.out
 create mode 100755 tests/generic/928
 create mode 100644 tests/generic/928.out


diff --git a/common/reflink b/common/reflink
index 4ec390d..1363971 100644
--- a/common/reflink
+++ b/common/reflink
@@ -107,7 +107,7 @@ _require_scratch_dedupe()
 	_scratch_mount
 	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
 	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
-	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
+	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
 	echo $testio | grep -q "Operation not supported" && \
 		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
 	echo $testio | grep -q "Inappropriate ioctl for device" && \
diff --git a/tests/generic/927 b/tests/generic/927
new file mode 100755
index 0000000..e1c30bd
--- /dev/null
+++ b/tests/generic/927
@@ -0,0 +1,88 @@
+#! /bin/bash
+# FS QA Test No. 927
+#
+# Check that cross-mountpoint reflink doesn't work.
+#
+#-----------------------------------------------------------------------
+# 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 > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+otherdir=/tmp/m.$seq
+othertestdir=$otherdir/test-$seq
+rm -rf $otherdir
+mkdir $otherdir
+
+blocks=1
+blksz=65536
+sz=$((blksz * blocks))
+
+echo "Mount otherdir"
+SCRATCH_MNT=$otherdir _scratch_mount
+
+echo "Create file"
+_pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
+
+filter_md5() {
+	_filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
+}
+
+echo "Reflink one file to another"
+_cp_reflink $testdir/file $othertestdir/otherfiles 2>&1 | filter_md5
+
+echo "Check output"
+md5sum $testdir/file | _filter_scratch
+test -e $othertestdir/otherfile && echo "otherfile should not exist"
+
+echo "Unmount otherdir"
+umount $otherdir
+rm -rf $otherdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/927.out b/tests/generic/927.out
new file mode 100644
index 0000000..3ef3057
--- /dev/null
+++ b/tests/generic/927.out
@@ -0,0 +1,9 @@
+QA output created by 927
+Format and mount
+Mount otherdir
+Create file
+Reflink one file to another
+cp: failed to clone 'OTHER_DIR/test-927/otherfiles' from 'SCRATCH_MNT/test-927/file': Invalid cross-device link
+Check output
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-927/file
+Unmount otherdir
diff --git a/tests/generic/928 b/tests/generic/928
new file mode 100755
index 0000000..050f34b
--- /dev/null
+++ b/tests/generic/928
@@ -0,0 +1,86 @@
+#! /bin/bash
+# FS QA Test No. 928
+#
+# Check that cross-mountpoint dedupe doesn't work.
+#
+#-----------------------------------------------------------------------
+# 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_dedupe
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+otherdir=/tmp/m.$seq
+othertestdir=$otherdir/test-$seq
+rm -rf $otherdir
+mkdir $otherdir
+
+blocks=1
+blksz=65536
+sz=$((blocks * blksz))
+
+echo "Mount otherdir"
+SCRATCH_MNT=$otherdir _scratch_mount
+
+echo "Create file"
+_pwrite_byte 0x61 0 $sz $testdir/file >> $seqres.full
+_pwrite_byte 0x61 0 $sz $testdir/otherfile >> $seqres.full
+
+echo "Dedupe one file to another"
+_dedupe_range $testdir/file 0 $othertestdir/otherfile 0 $sz >> $seqres.full
+
+filter_md5() {
+	_filter_scratch | sed -e "s,$otherdir,OTHER_DIR,g"
+}
+echo "Check output"
+md5sum $testdir/file $othertestdir/otherfile | filter_md5
+
+echo "Unmount otherdir"
+umount $otherdir
+rm -rf $otherdir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/928.out b/tests/generic/928.out
new file mode 100644
index 0000000..ef35c5b
--- /dev/null
+++ b/tests/generic/928.out
@@ -0,0 +1,10 @@
+QA output created by 928
+Format and mount
+Mount otherdir
+Create file
+Dedupe one file to another
+dedupe: Invalid cross-device link
+Check output
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-928/file
+2d61aa54b58c2e94403fb092c3dbc027  OTHER_DIR/test-928/otherfile
+Unmount otherdir
diff --git a/tests/generic/group b/tests/generic/group
index 2bd40a1..3286b0f 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -358,3 +358,5 @@
 924 auto quick clone
 925 auto quick clone
 926 auto quick clone
+927 auto quick clone
+928 auto quick clone dedupe

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

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

* [PATCH 17/20] generic/204: increase log size for rmap/reflink
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

We're going to need a bigger log for rmap & reflink on XFS, so
increase the size of the log and the fs appropriately.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/204 |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/tests/generic/204 b/tests/generic/204
index 42985ab..7b0dc2a 100755
--- a/tests/generic/204
+++ b/tests/generic/204
@@ -55,9 +55,9 @@ _scratch_mkfs 2> /dev/null | _filter_mkfs 2> $tmp.mkfs > /dev/null
 # versions of mkfs create. All should be valid with a 7MB log, so use that.
 # And v4/512 v5/1k xfs don't have enough free inodes, set imaxpct=50 at mkfs
 # time solves this problem.
-[ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=7m -i maxpct=50"
+[ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=16m -i maxpct=50"
 
-SIZE=`expr 106 \* 1024 \* 1024`
+SIZE=`expr 115 \* 1024 \* 1024`
 _scratch_mkfs_sized $SIZE $dbsize 2> /dev/null \
 		| _filter_mkfs 2> $tmp.mkfs > /dev/null
 _scratch_mount


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

* [PATCH 17/20] generic/204: increase log size for rmap/reflink
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

We're going to need a bigger log for rmap & reflink on XFS, so
increase the size of the log and the fs appropriately.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/204 |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/tests/generic/204 b/tests/generic/204
index 42985ab..7b0dc2a 100755
--- a/tests/generic/204
+++ b/tests/generic/204
@@ -55,9 +55,9 @@ _scratch_mkfs 2> /dev/null | _filter_mkfs 2> $tmp.mkfs > /dev/null
 # versions of mkfs create. All should be valid with a 7MB log, so use that.
 # And v4/512 v5/1k xfs don't have enough free inodes, set imaxpct=50 at mkfs
 # time solves this problem.
-[ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=7m -i maxpct=50"
+[ $FSTYP = "xfs" ] && MKFS_OPTIONS="$MKFS_OPTIONS -l size=16m -i maxpct=50"
 
-SIZE=`expr 106 \* 1024 \* 1024`
+SIZE=`expr 115 \* 1024 \* 1024`
 _scratch_mkfs_sized $SIZE $dbsize 2> /dev/null \
 		| _filter_mkfs 2> $tmp.mkfs > /dev/null
 _scratch_mount

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

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

* [PATCH 18/20] xfs/128: use $XFS_FSR_PROG instead of xfs_fsr directly
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:47   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128 |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


diff --git a/tests/xfs/128 b/tests/xfs/128
index 68f6f94..8758d7e 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -97,10 +97,10 @@ c14=$(_md5_checksum $testdir/file4)
 
 echo "Defragment"
 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
-xfs_fsr -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
+$XFS_FSR_PROG -v -d $testdir/file1 >> $seqres.full
+$XFS_FSR_PROG -v -d $testdir/file2 >> $seqres.full # fsr probably breaks the link
+$XFS_FSR_PROG -v -d $testdir/file3 >> $seqres.full # fsr probably breaks the link
+$XFS_FSR_PROG -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
 _test_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 


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

* [PATCH 18/20] xfs/128: use $XFS_FSR_PROG instead of xfs_fsr directly
@ 2016-06-17  1:47   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:47 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128 |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


diff --git a/tests/xfs/128 b/tests/xfs/128
index 68f6f94..8758d7e 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -97,10 +97,10 @@ c14=$(_md5_checksum $testdir/file4)
 
 echo "Defragment"
 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
-xfs_fsr -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
+$XFS_FSR_PROG -v -d $testdir/file1 >> $seqres.full
+$XFS_FSR_PROG -v -d $testdir/file2 >> $seqres.full # fsr probably breaks the link
+$XFS_FSR_PROG -v -d $testdir/file3 >> $seqres.full # fsr probably breaks the link
+$XFS_FSR_PROG -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
 _test_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 

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

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

* [PATCH 19/20] xfs: run xfs_repair at the end of each test
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:48   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:48 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Run xfs_repair twice at the end of each test -- once to rebuild
the btree indices, and again with -n to check the rebuild work.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc |    3 +++
 1 file changed, 3 insertions(+)


diff --git a/common/rc b/common/rc
index 1225047..847191e 100644
--- a/common/rc
+++ b/common/rc
@@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
         ok=0
     fi
 
+    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
+    cat $tmp.repair | _fix_malloc		>>$seqres.full
+
     $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
     if [ $? -ne 0 ]
     then


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

* [PATCH 19/20] xfs: run xfs_repair at the end of each test
@ 2016-06-17  1:48   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:48 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Run xfs_repair twice at the end of each test -- once to rebuild
the btree indices, and again with -n to check the rebuild work.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/rc |    3 +++
 1 file changed, 3 insertions(+)


diff --git a/common/rc b/common/rc
index 1225047..847191e 100644
--- a/common/rc
+++ b/common/rc
@@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
         ok=0
     fi
 
+    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
+    cat $tmp.repair | _fix_malloc		>>$seqres.full
+
     $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
     if [ $? -ne 0 ]
     then

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

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

* [PATCH 20/20] xfs: scrub fs (if still mounted) at the end of the test
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-17  1:48   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:48 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: linux-btrfs, fstests, xfs

Teach _check_xfs_filesystem to scrub mounted filesystems before
unmounting and fscking them.  This is mostly to test the online
scrub tool...

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/config |    1 +
 common/rc     |    7 +++++++
 2 files changed, 8 insertions(+)


diff --git a/common/config b/common/config
index cacd815..41edb0c 100644
--- a/common/config
+++ b/common/config
@@ -163,6 +163,7 @@ export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
 export XFS_DB_PROG="`set_prog_path xfs_db`"
 export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
 export XFS_IO_PROG="`set_prog_path xfs_io`"
+export XFS_SCRUB_PROG="`set_prog_path xfs_scrub`"
 export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
 export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
 export __XFSDUMP_PROG="`set_prog_path xfsdump`"
diff --git a/common/rc b/common/rc
index 847191e..ea5baea 100644
--- a/common/rc
+++ b/common/rc
@@ -2188,6 +2188,13 @@ _check_xfs_filesystem()
 
     if [ "$type" = "xfs" ]
     then
+	if [ -x "$XFS_SCRUB_PROG" ]; then
+		"$XFS_SCRUB_PROG" $scrubflag -vd $device >>$seqres.full
+		if [ $? -ne 0 ]; then
+			echo "filesystem on $device failed scrub (see $seqres.full)"
+			ok=0
+		fi
+	fi
         # mounted ...
         mountpoint=`_umount_or_remount_ro $device`
     fi


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

* [PATCH 20/20] xfs: scrub fs (if still mounted) at the end of the test
@ 2016-06-17  1:48   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17  1:48 UTC (permalink / raw)
  To: david, darrick.wong; +Cc: fstests, linux-btrfs, xfs

Teach _check_xfs_filesystem to scrub mounted filesystems before
unmounting and fscking them.  This is mostly to test the online
scrub tool...

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/config |    1 +
 common/rc     |    7 +++++++
 2 files changed, 8 insertions(+)


diff --git a/common/config b/common/config
index cacd815..41edb0c 100644
--- a/common/config
+++ b/common/config
@@ -163,6 +163,7 @@ export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
 export XFS_DB_PROG="`set_prog_path xfs_db`"
 export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
 export XFS_IO_PROG="`set_prog_path xfs_io`"
+export XFS_SCRUB_PROG="`set_prog_path xfs_scrub`"
 export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
 export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
 export __XFSDUMP_PROG="`set_prog_path xfsdump`"
diff --git a/common/rc b/common/rc
index 847191e..ea5baea 100644
--- a/common/rc
+++ b/common/rc
@@ -2188,6 +2188,13 @@ _check_xfs_filesystem()
 
     if [ "$type" = "xfs" ]
     then
+	if [ -x "$XFS_SCRUB_PROG" ]; then
+		"$XFS_SCRUB_PROG" $scrubflag -vd $device >>$seqres.full
+		if [ $? -ne 0 ]; then
+			echo "filesystem on $device failed scrub (see $seqres.full)"
+			ok=0
+		fi
+	fi
         # mounted ...
         mountpoint=`_umount_or_remount_ro $device`
     fi

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

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

* [PATCH v2 11/20] xfs: inject errors at various parts of the deferred op completion
  2016-06-17  1:47   ` Darrick J. Wong
@ 2016-06-17 16:39     ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17 16:39 UTC (permalink / raw)
  To: david; +Cc: linux-btrfs, fstests, xfs

Use the error injection mechanism to test log recovery of deferred
work.

v2: fix the tests to _require_scratch_reflink, since most of the
deferred work is done on behalf of reflinky operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/inject     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 common/log        |   28 ++++++++++++++
 common/rc         |    8 ++++
 tests/xfs/857     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/857.out |   18 +++++++++
 tests/xfs/858     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/858.out |   18 +++++++++
 tests/xfs/859     |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/859.out |   18 +++++++++
 tests/xfs/860     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/860.out |   16 ++++++++
 tests/xfs/861     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/861.out |   16 ++++++++
 tests/xfs/862     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/862.out |   16 ++++++++
 tests/xfs/863     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/863.out |   15 +++++++
 tests/xfs/864     |   97 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/864.out |   19 +++++++++
 tests/xfs/865     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/865.out |   18 +++++++++
 tests/xfs/866     |   94 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/866.out |   17 ++++++++
 tests/xfs/867     |   97 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/867.out |   17 ++++++++
 tests/xfs/868     |   94 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/868.out |   17 ++++++++
 tests/xfs/869     |  101 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/869.out |   17 ++++++++
 tests/xfs/870     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/870.out |   15 +++++++
 tests/xfs/871     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/871.out |   18 +++++++++
 tests/xfs/group   |   15 +++++++
 34 files changed, 1878 insertions(+)
 create mode 100644 common/inject
 create mode 100755 tests/xfs/857
 create mode 100644 tests/xfs/857.out
 create mode 100755 tests/xfs/858
 create mode 100644 tests/xfs/858.out
 create mode 100755 tests/xfs/859
 create mode 100644 tests/xfs/859.out
 create mode 100755 tests/xfs/860
 create mode 100644 tests/xfs/860.out
 create mode 100755 tests/xfs/861
 create mode 100644 tests/xfs/861.out
 create mode 100755 tests/xfs/862
 create mode 100644 tests/xfs/862.out
 create mode 100755 tests/xfs/863
 create mode 100644 tests/xfs/863.out
 create mode 100755 tests/xfs/864
 create mode 100644 tests/xfs/864.out
 create mode 100755 tests/xfs/865
 create mode 100644 tests/xfs/865.out
 create mode 100755 tests/xfs/866
 create mode 100644 tests/xfs/866.out
 create mode 100755 tests/xfs/867
 create mode 100644 tests/xfs/867.out
 create mode 100755 tests/xfs/868
 create mode 100644 tests/xfs/868.out
 create mode 100755 tests/xfs/869
 create mode 100644 tests/xfs/869.out
 create mode 100755 tests/xfs/870
 create mode 100644 tests/xfs/870.out
 create mode 100755 tests/xfs/871
 create mode 100644 tests/xfs/871.out

diff --git a/common/inject b/common/inject
new file mode 100644
index 0000000..e666d6d
--- /dev/null
+++ b/common/inject
@@ -0,0 +1,93 @@
+##/bin/bash
+# Routines for injecting errors into filesystems
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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/
+#-----------------------------------------------------------------------
+. ./common/log
+
+# Tests whether $FSTYP is one of the filesystems that supports error injection
+_require_error_injection()
+{
+	case "$FSTYP" in
+	"xfs")
+		grep -q 'debug 1' /proc/fs/xfs/stat || \
+			_notrun "XFS error injection requires CONFIG_XFS_DEBUG"
+		;;
+	*)
+		_notrun "Error injection not supported on filesystem type: $FSTYP"
+	esac
+}
+
+# Requires that xfs_io inject command knows about this error type
+_require_xfs_io_error_injection()
+{
+	type="$1"
+	_require_error_injection
+
+	# NOTE: We can't actually test error injection here because xfs
+	# hasn't always range checked the argument to xfs_errortag_add.
+	# We also don't want to trip an error before we're ready to deal
+	# with it.
+
+	$XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \
+		_notrun "XFS error injection $type unknown."
+}
+
+# Inject an error into the test fs
+_test_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $TEST_DIR
+}
+
+# Inject an error into the scratch fs
+_scratch_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT
+}
+
+# Unmount and remount the scratch device, dumping the log
+_scratch_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_scratch_unmount
+	_scratch_dump_log
+	_scratch_mount "$opts"
+}
+
+# Unmount and remount the test device, dumping the log
+_test_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_test_unmount
+	_test_dump_log
+	_test_mount "$opts"
+}
diff --git a/common/log b/common/log
index cb687d2..44b9625 100644
--- a/common/log
+++ b/common/log
@@ -228,6 +228,34 @@ _scratch_f2fs_logstate()
     echo $?
 }
 
+_scratch_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _scratch_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $SCRATCH_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
+_test_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _test_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $TEST_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
 _print_logstate()
 {
     case "$FSTYP" in
diff --git a/common/rc b/common/rc
index 1648a8a..1225047 100644
--- a/common/rc
+++ b/common/rc
@@ -982,6 +982,14 @@ _scratch_xfs_logprint()
     $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_test_xfs_logprint()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="-l$TEST_LOGDEV"
+    $XFS_LOGPRINT_PROG $TEST_OPTIONS $* $TEST_DEV
+}
+
 _scratch_xfs_check()
 {
     SCRATCH_OPTIONS=""
diff --git a/tests/xfs/857 b/tests/xfs/857
new file mode 100755
index 0000000..eff6e4d
--- /dev/null
+++ b/tests/xfs/857
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 857
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/857.out b/tests/xfs/857.out
new file mode 100644
index 0000000..ecc8e04
--- /dev/null
+++ b/tests/xfs/857.out
@@ -0,0 +1,18 @@
+QA output created by 857
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/858 b/tests/xfs/858
new file mode 100755
index 0000000..c13733a
--- /dev/null
+++ b/tests/xfs/858
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 858
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/858.out b/tests/xfs/858.out
new file mode 100644
index 0000000..f5302de
--- /dev/null
+++ b/tests/xfs/858.out
@@ -0,0 +1,18 @@
+QA output created by 858
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/859 b/tests/xfs/859
new file mode 100755
index 0000000..96c3390
--- /dev/null
+++ b/tests/xfs/859
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 859
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during rmap updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/859.out b/tests/xfs/859.out
new file mode 100644
index 0000000..b83e963
--- /dev/null
+++ b/tests/xfs/859.out
@@ -0,0 +1,18 @@
+QA output created by 859
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/860 b/tests/xfs/860
new file mode 100755
index 0000000..cec7509
--- /dev/null
+++ b/tests/xfs/860
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 860
+#
+# Reflink a file with a few dozen extents and CoW a few blocks.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=4
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/860.out b/tests/xfs/860.out
new file mode 100644
index 0000000..0a6d763
--- /dev/null
+++ b/tests/xfs/860.out
@@ -0,0 +1,16 @@
+QA output created by 860
+Format filesystem
+Create files
+Check files
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+fe9070b9c9deb97ed53811efda5c4ad5  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/861 b/tests/xfs/861
new file mode 100755
index 0000000..49d90bc
--- /dev/null
+++ b/tests/xfs/861
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 861
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "CoW all the blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $((blks * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/861.out b/tests/xfs/861.out
new file mode 100644
index 0000000..d353526
--- /dev/null
+++ b/tests/xfs/861.out
@@ -0,0 +1,16 @@
+QA output created by 861
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/862 b/tests/xfs/862
new file mode 100755
index 0000000..167386c
--- /dev/null
+++ b/tests/xfs/862
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 862
+#
+# Simulate rmap update errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/862.out b/tests/xfs/862.out
new file mode 100644
index 0000000..1f6b47b
--- /dev/null
+++ b/tests/xfs/862.out
@@ -0,0 +1,16 @@
+QA output created by 862
+Format filesystem
+Create files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+Inject error
+Write files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/863 b/tests/xfs/863
new file mode 100755
index 0000000..5069245
--- /dev/null
+++ b/tests/xfs/863
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 863
+#
+# Simulate free extent errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Remove files"
+rm -rf $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/863.out b/tests/xfs/863.out
new file mode 100644
index 0000000..718691f
--- /dev/null
+++ b/tests/xfs/863.out
@@ -0,0 +1,15 @@
+QA output created by 863
+Format filesystem
+Create files
+Write files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file1
+Inject error
+Remove files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+md5sum: SCRATCH_MNT/file1: No such file or directory
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/864 b/tests/xfs/864
new file mode 100755
index 0000000..928bd3b
--- /dev/null
+++ b/tests/xfs/864
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 864
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/864.out b/tests/xfs/864.out
new file mode 100644
index 0000000..cd16235
--- /dev/null
+++ b/tests/xfs/864.out
@@ -0,0 +1,19 @@
+QA output created by 864
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/865 b/tests/xfs/865
new file mode 100755
index 0000000..043ce77
--- /dev/null
+++ b/tests/xfs/865
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 865
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks - 17))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 2>&1 | _filter_scratch
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/865.out b/tests/xfs/865.out
new file mode 100644
index 0000000..9a2b04d
--- /dev/null
+++ b/tests/xfs/865.out
@@ -0,0 +1,18 @@
+QA output created by 865
+Format filesystem
+Create files
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+Inject error
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/file3' from 'SCRATCH_MNT/file1': Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/866 b/tests/xfs/866
new file mode 100755
index 0000000..e4137a5
--- /dev/null
+++ b/tests/xfs/866
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 866
+#
+# Reflink a file.
+# Inject an error during refcount update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/866.out b/tests/xfs/866.out
new file mode 100644
index 0000000..f2ca58c
--- /dev/null
+++ b/tests/xfs/866.out
@@ -0,0 +1,17 @@
+QA output created by 866
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/867 b/tests/xfs/867
new file mode 100755
index 0000000..fcae947
--- /dev/null
+++ b/tests/xfs/867
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 867
+#
+# Reflink a file.
+# Inject an error during rmap update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/867.out b/tests/xfs/867.out
new file mode 100644
index 0000000..78a4e5a
--- /dev/null
+++ b/tests/xfs/867.out
@@ -0,0 +1,17 @@
+QA output created by 867
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/868 b/tests/xfs/868
new file mode 100755
index 0000000..b8303de
--- /dev/null
+++ b/tests/xfs/868
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 868
+#
+# Reflink a file.
+# Inject an error during extent free to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/868.out b/tests/xfs/868.out
new file mode 100644
index 0000000..583b1f9
--- /dev/null
+++ b/tests/xfs/868.out
@@ -0,0 +1,17 @@
+QA output created by 868
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/869 b/tests/xfs/869
new file mode 100755
index 0000000..3ab2b0d
--- /dev/null
+++ b/tests/xfs/869
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 869
+#
+# Reflink a file with a few dozen extents.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "Reflink all the blocks"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file4
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+md5sum $SCRATCH_MNT/file4 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/869.out b/tests/xfs/869.out
new file mode 100644
index 0000000..1e7822e
--- /dev/null
+++ b/tests/xfs/869.out
@@ -0,0 +1,17 @@
+QA output created by 869
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+Reflink all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file4
+Done
diff --git a/tests/xfs/870 b/tests/xfs/870
new file mode 100755
index 0000000..270e4a3
--- /dev/null
+++ b/tests/xfs/870
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 870
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=30
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+rm $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/870.out b/tests/xfs/870.out
new file mode 100644
index 0000000..49c4e4b
--- /dev/null
+++ b/tests/xfs/870.out
@@ -0,0 +1,15 @@
+QA output created by 870
+Format filesystem
+Create files
+Check files
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file1
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+7629bd70d19d7291b448221ac44b26d9  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/871 b/tests/xfs/871
new file mode 100755
index 0000000..03fa0ba
--- /dev/null
+++ b/tests/xfs/871
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 871
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log recovery.  Use
+# cowextsize so that the refcount failure is somewhere in the CoW remap
+# instead of when we're stashing the CoW orphan record.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full
+sync
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/871.out b/tests/xfs/871.out
new file mode 100644
index 0000000..c0aba73
--- /dev/null
+++ b/tests/xfs/871.out
@@ -0,0 +1,18 @@
+QA output created by 871
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 1ad37ff..0f94794 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -289,3 +289,18 @@
 854 auto quick clone
 855 auto clone
 856 auto quick clone rmap
+857 auto quick clone
+858 auto quick clone
+859 auto quick clone
+860 auto quick clone
+861 auto quick clone
+862 auto quick rmap
+863 auto quick rw
+864 auto quick clone
+865 auto quick clone
+866 auto quick clone
+867 auto quick clone
+868 auto quick clone
+869 auto quick clone
+870 auto quick clone
+871 auto quick clone

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

* [PATCH v2 11/20] xfs: inject errors at various parts of the deferred op completion
@ 2016-06-17 16:39     ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17 16:39 UTC (permalink / raw)
  To: david; +Cc: fstests, linux-btrfs, xfs

Use the error injection mechanism to test log recovery of deferred
work.

v2: fix the tests to _require_scratch_reflink, since most of the
deferred work is done on behalf of reflinky operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/inject     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 common/log        |   28 ++++++++++++++
 common/rc         |    8 ++++
 tests/xfs/857     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/857.out |   18 +++++++++
 tests/xfs/858     |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/858.out |   18 +++++++++
 tests/xfs/859     |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/859.out |   18 +++++++++
 tests/xfs/860     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/860.out |   16 ++++++++
 tests/xfs/861     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/861.out |   16 ++++++++
 tests/xfs/862     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/862.out |   16 ++++++++
 tests/xfs/863     |   93 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/863.out |   15 +++++++
 tests/xfs/864     |   97 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/864.out |   19 +++++++++
 tests/xfs/865     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/865.out |   18 +++++++++
 tests/xfs/866     |   94 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/866.out |   17 ++++++++
 tests/xfs/867     |   97 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/867.out |   17 ++++++++
 tests/xfs/868     |   94 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/868.out |   17 ++++++++
 tests/xfs/869     |  101 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/869.out |   17 ++++++++
 tests/xfs/870     |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/870.out |   15 +++++++
 tests/xfs/871     |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/871.out |   18 +++++++++
 tests/xfs/group   |   15 +++++++
 34 files changed, 1878 insertions(+)
 create mode 100644 common/inject
 create mode 100755 tests/xfs/857
 create mode 100644 tests/xfs/857.out
 create mode 100755 tests/xfs/858
 create mode 100644 tests/xfs/858.out
 create mode 100755 tests/xfs/859
 create mode 100644 tests/xfs/859.out
 create mode 100755 tests/xfs/860
 create mode 100644 tests/xfs/860.out
 create mode 100755 tests/xfs/861
 create mode 100644 tests/xfs/861.out
 create mode 100755 tests/xfs/862
 create mode 100644 tests/xfs/862.out
 create mode 100755 tests/xfs/863
 create mode 100644 tests/xfs/863.out
 create mode 100755 tests/xfs/864
 create mode 100644 tests/xfs/864.out
 create mode 100755 tests/xfs/865
 create mode 100644 tests/xfs/865.out
 create mode 100755 tests/xfs/866
 create mode 100644 tests/xfs/866.out
 create mode 100755 tests/xfs/867
 create mode 100644 tests/xfs/867.out
 create mode 100755 tests/xfs/868
 create mode 100644 tests/xfs/868.out
 create mode 100755 tests/xfs/869
 create mode 100644 tests/xfs/869.out
 create mode 100755 tests/xfs/870
 create mode 100644 tests/xfs/870.out
 create mode 100755 tests/xfs/871
 create mode 100644 tests/xfs/871.out

diff --git a/common/inject b/common/inject
new file mode 100644
index 0000000..e666d6d
--- /dev/null
+++ b/common/inject
@@ -0,0 +1,93 @@
+##/bin/bash
+# Routines for injecting errors into filesystems
+#-----------------------------------------------------------------------
+#  Copyright (c) 2016 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/
+#-----------------------------------------------------------------------
+. ./common/log
+
+# Tests whether $FSTYP is one of the filesystems that supports error injection
+_require_error_injection()
+{
+	case "$FSTYP" in
+	"xfs")
+		grep -q 'debug 1' /proc/fs/xfs/stat || \
+			_notrun "XFS error injection requires CONFIG_XFS_DEBUG"
+		;;
+	*)
+		_notrun "Error injection not supported on filesystem type: $FSTYP"
+	esac
+}
+
+# Requires that xfs_io inject command knows about this error type
+_require_xfs_io_error_injection()
+{
+	type="$1"
+	_require_error_injection
+
+	# NOTE: We can't actually test error injection here because xfs
+	# hasn't always range checked the argument to xfs_errortag_add.
+	# We also don't want to trip an error before we're ready to deal
+	# with it.
+
+	$XFS_IO_PROG -x -c 'inject' $TEST_DIR | grep -q "$type" || \
+		_notrun "XFS error injection $type unknown."
+}
+
+# Inject an error into the test fs
+_test_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $TEST_DIR
+}
+
+# Inject an error into the scratch fs
+_scratch_inject_error()
+{
+	type="$1"
+	
+	$XFS_IO_PROG -x -c "inject $type" $SCRATCH_MNT
+}
+
+# Unmount and remount the scratch device, dumping the log
+_scratch_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_scratch_unmount
+	_scratch_dump_log
+	_scratch_mount "$opts"
+}
+
+# Unmount and remount the test device, dumping the log
+_test_inject_logprint()
+{
+	local opts="$1"
+
+	if test -n "$opts"; then
+		opts="-o $opts"
+	fi
+	_test_unmount
+	_test_dump_log
+	_test_mount "$opts"
+}
diff --git a/common/log b/common/log
index cb687d2..44b9625 100644
--- a/common/log
+++ b/common/log
@@ -228,6 +228,34 @@ _scratch_f2fs_logstate()
     echo $?
 }
 
+_scratch_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _scratch_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $SCRATCH_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
+_test_dump_log()
+{
+    case "$FSTYP" in
+    xfs)
+        _test_xfs_logprint
+        ;;
+    f2fs)
+        $DUMP_F2FS_PROG $TEST_DEV
+        ;;
+    *)
+        ;;
+    esac
+}
+
 _print_logstate()
 {
     case "$FSTYP" in
diff --git a/common/rc b/common/rc
index 1648a8a..1225047 100644
--- a/common/rc
+++ b/common/rc
@@ -982,6 +982,14 @@ _scratch_xfs_logprint()
     $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_test_xfs_logprint()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="-l$TEST_LOGDEV"
+    $XFS_LOGPRINT_PROG $TEST_OPTIONS $* $TEST_DEV
+}
+
 _scratch_xfs_check()
 {
     SCRATCH_OPTIONS=""
diff --git a/tests/xfs/857 b/tests/xfs/857
new file mode 100755
index 0000000..eff6e4d
--- /dev/null
+++ b/tests/xfs/857
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 857
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/857.out b/tests/xfs/857.out
new file mode 100644
index 0000000..ecc8e04
--- /dev/null
+++ b/tests/xfs/857.out
@@ -0,0 +1,18 @@
+QA output created by 857
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/858 b/tests/xfs/858
new file mode 100755
index 0000000..c13733a
--- /dev/null
+++ b/tests/xfs/858
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 858
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/858.out b/tests/xfs/858.out
new file mode 100644
index 0000000..f5302de
--- /dev/null
+++ b/tests/xfs/858.out
@@ -0,0 +1,18 @@
+QA output created by 858
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/859 b/tests/xfs/859
new file mode 100755
index 0000000..96c3390
--- /dev/null
+++ b/tests/xfs/859
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 859
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during rmap updates to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/859.out b/tests/xfs/859.out
new file mode 100644
index 0000000..b83e963
--- /dev/null
+++ b/tests/xfs/859.out
@@ -0,0 +1,18 @@
+QA output created by 859
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/860 b/tests/xfs/860
new file mode 100755
index 0000000..cec7509
--- /dev/null
+++ b/tests/xfs/860
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 860
+#
+# Reflink a file with a few dozen extents and CoW a few blocks.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=4
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/860.out b/tests/xfs/860.out
new file mode 100644
index 0000000..0a6d763
--- /dev/null
+++ b/tests/xfs/860.out
@@ -0,0 +1,16 @@
+QA output created by 860
+Format filesystem
+Create files
+Check files
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+fe9070b9c9deb97ed53811efda5c4ad5  SCRATCH_MNT/file1
+cf41e243bf211225660f3fabe6db9eb6  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/861 b/tests/xfs/861
new file mode 100755
index 0000000..49d90bc
--- /dev/null
+++ b/tests/xfs/861
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 861
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "CoW all the blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $((blks * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/861.out b/tests/xfs/861.out
new file mode 100644
index 0000000..d353526
--- /dev/null
+++ b/tests/xfs/861.out
@@ -0,0 +1,16 @@
+QA output created by 861
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/862 b/tests/xfs/862
new file mode 100755
index 0000000..167386c
--- /dev/null
+++ b/tests/xfs/862
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 862
+#
+# Simulate rmap update errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file0 | _filter_scratch
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/862.out b/tests/xfs/862.out
new file mode 100644
index 0000000..1f6b47b
--- /dev/null
+++ b/tests/xfs/862.out
@@ -0,0 +1,16 @@
+QA output created by 862
+Format filesystem
+Create files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+Inject error
+Write files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file0
+d41d8cd98f00b204e9800998ecf8427e  SCRATCH_MNT/file1
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/863 b/tests/xfs/863
new file mode 100755
index 0000000..5069245
--- /dev/null
+++ b/tests/xfs/863
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 863
+#
+# Simulate free extent errors with a file write and a file remove.
+#
+#-----------------------------------------------------------------------
+# 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/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_error_injection
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+touch $SCRATCH_MNT/file1
+
+echo "Write files"
+$XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Remove files"
+rm -rf $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/863.out b/tests/xfs/863.out
new file mode 100644
index 0000000..718691f
--- /dev/null
+++ b/tests/xfs/863.out
@@ -0,0 +1,15 @@
+QA output created by 863
+Format filesystem
+Create files
+Write files
+Check files
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file1
+Inject error
+Remove files
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+md5sum: SCRATCH_MNT/file1: No such file or directory
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/864 b/tests/xfs/864
new file mode 100755
index 0000000..928bd3b
--- /dev/null
+++ b/tests/xfs/864
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 864
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/864.out b/tests/xfs/864.out
new file mode 100644
index 0000000..cd16235
--- /dev/null
+++ b/tests/xfs/864.out
@@ -0,0 +1,19 @@
+QA output created by 864
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/865 b/tests/xfs/865
new file mode 100755
index 0000000..043ce77
--- /dev/null
+++ b/tests/xfs/865
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 865
+#
+# Reflink a file.
+# Inject an error during block remap to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "bmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks - 17))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "bmap_finish_one"
+
+echo "Try to reflink"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 2>&1 | _filter_scratch
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/865.out b/tests/xfs/865.out
new file mode 100644
index 0000000..9a2b04d
--- /dev/null
+++ b/tests/xfs/865.out
@@ -0,0 +1,18 @@
+QA output created by 865
+Format filesystem
+Create files
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+Inject error
+Try to reflink
+cp: failed to clone 'SCRATCH_MNT/file3' from 'SCRATCH_MNT/file1': Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file1
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file2
+a98e7df2a7a456009a493e47411c58d1  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/866 b/tests/xfs/866
new file mode 100755
index 0000000..e4137a5
--- /dev/null
+++ b/tests/xfs/866
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 866
+#
+# Reflink a file.
+# Inject an error during refcount update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/866.out b/tests/xfs/866.out
new file mode 100644
index 0000000..f2ca58c
--- /dev/null
+++ b/tests/xfs/866.out
@@ -0,0 +1,17 @@
+QA output created by 866
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/867 b/tests/xfs/867
new file mode 100755
index 0000000..fcae947
--- /dev/null
+++ b/tests/xfs/867
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 867
+#
+# Reflink a file.
+# Inject an error during rmap update to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "rmap_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+is_rmap=$(xfs_info $SCRATCH_MNT | grep -c "rmapbt=1")
+test $is_rmap -gt 0 || _notrun "rmap not supported on scratch fs"
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "rmap_finish_one"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/867.out b/tests/xfs/867.out
new file mode 100644
index 0000000..78a4e5a
--- /dev/null
+++ b/tests/xfs/867.out
@@ -0,0 +1,17 @@
+QA output created by 867
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+b5cfa9d6c8febd618f91ac2843d50a1c  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/868 b/tests/xfs/868
new file mode 100755
index 0000000..b8303de
--- /dev/null
+++ b/tests/xfs/868
@@ -0,0 +1,94 @@
+#! /bin/bash
+# FS QA Test No. 868
+#
+# Reflink a file.
+# Inject an error during extent free to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "Try to reflink"
+_reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/868.out b/tests/xfs/868.out
new file mode 100644
index 0000000..583b1f9
--- /dev/null
+++ b/tests/xfs/868.out
@@ -0,0 +1,17 @@
+QA output created by 868
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+4155b81ac6d45c0182fa2bc03960f230  SCRATCH_MNT/file3
+Inject error
+Try to reflink
+XFS_IOC_CLONE_RANGE: Input/output error
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file3
+FS should be online, touch should succeed
+Done
diff --git a/tests/xfs/869 b/tests/xfs/869
new file mode 100755
index 0000000..3ab2b0d
--- /dev/null
+++ b/tests/xfs/869
@@ -0,0 +1,101 @@
+#! /bin/bash
+# FS QA Test No. 869
+#
+# Reflink a file with a few dozen extents.
+# Force XFS into "two refcount updates per transaction" mode.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "refcount_continue_update"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "refcount_continue_update"
+
+echo "Reflink all the blocks"
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file4
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+md5sum $SCRATCH_MNT/file4 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/869.out b/tests/xfs/869.out
new file mode 100644
index 0000000..1e7822e
--- /dev/null
+++ b/tests/xfs/869.out
@@ -0,0 +1,17 @@
+QA output created by 869
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+Reflink all the blocks
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file4
+Done
diff --git a/tests/xfs/870 b/tests/xfs/870
new file mode 100755
index 0000000..270e4a3
--- /dev/null
+++ b/tests/xfs/870
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 870
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during extent freeing to test log 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 /
+    umount $SCRATCH_MNT > /dev/null 2>&1
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_error_injection
+_require_xfs_io_error_injection "free_extent"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=30
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Inject error"
+_scratch_inject_error "free_extent"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+rm $SCRATCH_MNT/file1
+sync
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/870.out b/tests/xfs/870.out
new file mode 100644
index 0000000..49c4e4b
--- /dev/null
+++ b/tests/xfs/870.out
@@ -0,0 +1,15 @@
+QA output created by 870
+Format filesystem
+Create files
+Check files
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file1
+d5a0ed0305c8df4180cb2bf975ecffe8  SCRATCH_MNT/file2
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+7629bd70d19d7291b448221ac44b26d9  SCRATCH_MNT/file2
+Done
diff --git a/tests/xfs/871 b/tests/xfs/871
new file mode 100755
index 0000000..03fa0ba
--- /dev/null
+++ b/tests/xfs/871
@@ -0,0 +1,109 @@
+#! /bin/bash
+# FS QA Test No. 871
+#
+# Reflink a file with a few dozen extents, CoW a few blocks, and rm.
+# Inject an error during refcount updates to test log recovery.  Use
+# cowextsize so that the refcount failure is somewhere in the CoW remap
+# instead of when we're stashing the CoW orphan record.
+#
+#-----------------------------------------------------------------------
+# 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
+. ./common/inject
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_cp_reflink
+_require_scratch_reflink
+_require_xfs_io_error_injection "refcount_finish_one"
+
+rm -f $seqres.full
+
+blksz=65536
+blks=64
+sz=$((blksz * blks))
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
+
+echo "Create files"
+_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
+_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3
+
+# Punch holes in file3
+seq 1 2 $blks | while read off; do
+	$XFS_IO_PROG -c "fpunch $((off * blksz)) $blksz" $SCRATCH_MNT/file3 >> $seqres.full
+done
+sync
+
+echo "Check files"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+$XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) 1" $SCRATCH_MNT/file2 >> $seqres.full
+sync
+
+echo "Inject error"
+_scratch_inject_error "refcount_finish_one"
+
+echo "CoW a few blocks"
+$XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
+
+echo "FS should be shut down, touch will fail"
+touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
+
+echo "Remount to replay log"
+_scratch_inject_logprint >> $seqres.full
+
+echo "FS should be online, touch should succeed"
+touch $SCRATCH_MNT/goodfs
+
+echo "Check files again"
+md5sum $SCRATCH_MNT/file1 | _filter_scratch
+md5sum $SCRATCH_MNT/file2 | _filter_scratch
+md5sum $SCRATCH_MNT/file3 | _filter_scratch
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/871.out b/tests/xfs/871.out
new file mode 100644
index 0000000..c0aba73
--- /dev/null
+++ b/tests/xfs/871.out
@@ -0,0 +1,18 @@
+QA output created by 871
+Format filesystem
+Create files
+Check files
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Inject error
+CoW a few blocks
+FS should be shut down, touch will fail
+touch: cannot touch 'SCRATCH_MNT/badfs': Input/output error
+Remount to replay log
+FS should be online, touch should succeed
+Check files again
+2a4f043bf9730a9e8882c9264b9797b3  SCRATCH_MNT/file1
+1e108771fba35e2f2961d1ad23efbff7  SCRATCH_MNT/file2
+153498e22f8ff52d7f60b466a5e65285  SCRATCH_MNT/file3
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 1ad37ff..0f94794 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -289,3 +289,18 @@
 854 auto quick clone
 855 auto clone
 856 auto quick clone rmap
+857 auto quick clone
+858 auto quick clone
+859 auto quick clone
+860 auto quick clone
+861 auto quick clone
+862 auto quick rmap
+863 auto quick rw
+864 auto quick clone
+865 auto quick clone
+866 auto quick clone
+867 auto quick clone
+868 auto quick clone
+869 auto quick clone
+870 auto quick clone
+871 auto quick clone

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

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

* [PATCH v2 14/20] xfs: test clearing reflink inode flag
  2016-06-17  1:47   ` Darrick J. Wong
@ 2016-06-17 16:40     ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17 16:40 UTC (permalink / raw)
  To: david; +Cc: linux-btrfs, fstests, xfs

Check that xfs_repair can clear the reflink inode flag.

v2: This is a reflink test; use _require_scratch_reflink

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

diff --git a/tests/xfs/872 b/tests/xfs/872
new file mode 100755
index 0000000..e4c987e
--- /dev/null
+++ b/tests/xfs/872
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 872
+#
+# Create 100 reflinked files, CoW them all, and see if xfs_repair will
+# clear the reflink flag.  There was a buffer handling bug in xfs_repair
+# that (fortunately) triggered asserts in the rmap code when clearing
+# the reflink flag.
+#
+#-----------------------------------------------------------------------
+# 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_cp_reflink
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+nr=128 # spanning at least one inode chunk tickles a bug in xfs_repair
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full
+seq 1 $nr | while read i; do
+	_cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i
+done
+sync
+
+echo "Check files"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "CoW all files"
+seq 1 $nr | while read i; do
+	echo m >> $SCRATCH_MNT/file.$i
+done
+
+echo "Repair filesystem"
+_scratch_unmount
+_repair_scratch_fs >> $seqres.full
+_scratch_mount
+
+echo "Check files again"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/872.out b/tests/xfs/872.out
new file mode 100644
index 0000000..316cb0a
--- /dev/null
+++ b/tests/xfs/872.out
@@ -0,0 +1,20 @@
+QA output created by 872
+Format filesystem
+Create files
+Check files
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[reflink] SCRATCH_MNT/file.0 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.64
+[reflink] SCRATCH_MNT/file.64 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.128
+[reflink] SCRATCH_MNT/file.128 
+CoW all files
+Repair filesystem
+Check files again
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[] SCRATCH_MNT/file.0 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.64
+[] SCRATCH_MNT/file.64 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.128
+[] SCRATCH_MNT/file.128 
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 0f94794..ca36ad6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -304,3 +304,4 @@
 869 auto quick clone
 870 auto quick clone
 871 auto quick clone
+872 auto quick clone

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

* [PATCH v2 14/20] xfs: test clearing reflink inode flag
@ 2016-06-17 16:40     ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-17 16:40 UTC (permalink / raw)
  To: david; +Cc: fstests, linux-btrfs, xfs

Check that xfs_repair can clear the reflink inode flag.

v2: This is a reflink test; use _require_scratch_reflink

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

diff --git a/tests/xfs/872 b/tests/xfs/872
new file mode 100755
index 0000000..e4c987e
--- /dev/null
+++ b/tests/xfs/872
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 872
+#
+# Create 100 reflinked files, CoW them all, and see if xfs_repair will
+# clear the reflink flag.  There was a buffer handling bug in xfs_repair
+# that (fortunately) triggered asserts in the rmap code when clearing
+# the reflink flag.
+#
+#-----------------------------------------------------------------------
+# 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_cp_reflink
+_require_scratch_reflink
+
+rm -f $seqres.full
+
+nr=128 # spanning at least one inode chunk tickles a bug in xfs_repair
+echo "Format filesystem"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount >> $seqres.full
+
+echo "Create files"
+_pwrite_byte 0x66 0 1 $SCRATCH_MNT/file.0 >> $seqres.full
+seq 1 $nr | while read i; do
+	_cp_reflink $SCRATCH_MNT/file.0 $SCRATCH_MNT/file.$i
+done
+sync
+
+echo "Check files"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "CoW all files"
+seq 1 $nr | while read i; do
+	echo m >> $SCRATCH_MNT/file.$i
+done
+
+echo "Repair filesystem"
+_scratch_unmount
+_repair_scratch_fs >> $seqres.full
+_scratch_mount
+
+echo "Check files again"
+for i in 0 $((nr / 2)) $nr; do
+	md5sum $SCRATCH_MNT/file.$i | _filter_scratch
+	$XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+done
+
+echo "Done"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/872.out b/tests/xfs/872.out
new file mode 100644
index 0000000..316cb0a
--- /dev/null
+++ b/tests/xfs/872.out
@@ -0,0 +1,20 @@
+QA output created by 872
+Format filesystem
+Create files
+Check files
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[reflink] SCRATCH_MNT/file.0 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.64
+[reflink] SCRATCH_MNT/file.64 
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.128
+[reflink] SCRATCH_MNT/file.128 
+CoW all files
+Repair filesystem
+Check files again
+8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
+[] SCRATCH_MNT/file.0 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.64
+[] SCRATCH_MNT/file.64 
+0f17fd72b7bbf5bda0ff433e6d1fc118  SCRATCH_MNT/file.128
+[] SCRATCH_MNT/file.128 
+Done
diff --git a/tests/xfs/group b/tests/xfs/group
index 0f94794..ca36ad6 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -304,3 +304,4 @@
 869 auto quick clone
 870 auto quick clone
 871 auto quick clone
+872 auto quick clone

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

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

* [PATCH 21/20] xfs/128: cycle_mount the scratch device, not the test device
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-06-29  3:36   ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-29  3:36 UTC (permalink / raw)
  To: david; +Cc: linux-btrfs, fstests, xfs

This test uses the scratch device, so cycle that, not the test dev.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128 |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/xfs/128 b/tests/xfs/128
index 8758d7e..2e756d5 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -66,7 +66,7 @@ _pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file2
 _cp_reflink $testdir/file2 $testdir/file3
 _cp_reflink $testdir/file3 $testdir/file4
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks1=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch
@@ -82,7 +82,7 @@ c04=$(_md5_checksum $testdir/file4)
 echo "CoW the reflink copies"
 _pwrite_byte 0x62 $blksz $blksz $testdir/file2 >> $seqres.full
 _pwrite_byte 0x63 $(( blksz * (blks - 1) )) $blksz $testdir/file3 >> $seqres.full
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks2=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch
@@ -97,11 +97,12 @@ c14=$(_md5_checksum $testdir/file4)
 
 echo "Defragment"
 lsattr -l $testdir/ | _filter_scratch | _filter_spaces
+filefrag -v $testdir/file* >> $seqres.full
 $XFS_FSR_PROG -v -d $testdir/file1 >> $seqres.full
 $XFS_FSR_PROG -v -d $testdir/file2 >> $seqres.full # fsr probably breaks the link
 $XFS_FSR_PROG -v -d $testdir/file3 >> $seqres.full # fsr probably breaks the link
 $XFS_FSR_PROG -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch

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

* [PATCH 21/20] xfs/128: cycle_mount the scratch device, not the test device
@ 2016-06-29  3:36   ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-06-29  3:36 UTC (permalink / raw)
  To: david; +Cc: fstests, linux-btrfs, xfs

This test uses the scratch device, so cycle that, not the test dev.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/128 |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/xfs/128 b/tests/xfs/128
index 8758d7e..2e756d5 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -66,7 +66,7 @@ _pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file2
 _cp_reflink $testdir/file2 $testdir/file3
 _cp_reflink $testdir/file3 $testdir/file4
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks1=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch
@@ -82,7 +82,7 @@ c04=$(_md5_checksum $testdir/file4)
 echo "CoW the reflink copies"
 _pwrite_byte 0x62 $blksz $blksz $testdir/file2 >> $seqres.full
 _pwrite_byte 0x63 $(( blksz * (blks - 1) )) $blksz $testdir/file3 >> $seqres.full
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks2=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch
@@ -97,11 +97,12 @@ c14=$(_md5_checksum $testdir/file4)
 
 echo "Defragment"
 lsattr -l $testdir/ | _filter_scratch | _filter_spaces
+filefrag -v $testdir/file* >> $seqres.full
 $XFS_FSR_PROG -v -d $testdir/file1 >> $seqres.full
 $XFS_FSR_PROG -v -d $testdir/file2 >> $seqres.full # fsr probably breaks the link
 $XFS_FSR_PROG -v -d $testdir/file3 >> $seqres.full # fsr probably breaks the link
 $XFS_FSR_PROG -v -d $testdir/file4 >> $seqres.full # fsr probably ignores this file
-_test_cycle_mount
+_scratch_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 
 md5sum $testdir/file1 | _filter_scratch

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

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

* Re: [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
  2016-06-17  1:47   ` Darrick J. Wong
@ 2016-07-04  6:51     ` Eryu Guan
  -1 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-04  6:51 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-btrfs, fstests, xfs

On Thu, Jun 16, 2016 at 06:47:42PM -0700, Darrick J. Wong wrote:
> Test sharing blocks via reflink and dedupe between two different
> mountpoints of the same filesystem.  This shouldn't work, since
> we don't allow cross-mountpoint functions.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/reflink        |    2 +
>  tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/927.out |    9 +++++
>  tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/928.out |   10 ++++++
>  tests/generic/group   |    2 +
>  6 files changed, 196 insertions(+), 1 deletion(-)
>  create mode 100755 tests/generic/927
>  create mode 100644 tests/generic/927.out
>  create mode 100755 tests/generic/928
>  create mode 100644 tests/generic/928.out
> 
> 
> diff --git a/common/reflink b/common/reflink
> index 4ec390d..1363971 100644
> --- a/common/reflink
> +++ b/common/reflink
> @@ -107,7 +107,7 @@ _require_scratch_dedupe()
>  	_scratch_mount
>  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
>  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
> -	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
> +	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
>  	echo $testio | grep -q "Operation not supported" && \
>  		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
>  	echo $testio | grep -q "Inappropriate ioctl for device" && \

I think this hunk belongs to a seperate patch.

Thanks,
Eryu

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

* Re: [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
@ 2016-07-04  6:51     ` Eryu Guan
  0 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-04  6:51 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Thu, Jun 16, 2016 at 06:47:42PM -0700, Darrick J. Wong wrote:
> Test sharing blocks via reflink and dedupe between two different
> mountpoints of the same filesystem.  This shouldn't work, since
> we don't allow cross-mountpoint functions.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/reflink        |    2 +
>  tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/927.out |    9 +++++
>  tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/928.out |   10 ++++++
>  tests/generic/group   |    2 +
>  6 files changed, 196 insertions(+), 1 deletion(-)
>  create mode 100755 tests/generic/927
>  create mode 100644 tests/generic/927.out
>  create mode 100755 tests/generic/928
>  create mode 100644 tests/generic/928.out
> 
> 
> diff --git a/common/reflink b/common/reflink
> index 4ec390d..1363971 100644
> --- a/common/reflink
> +++ b/common/reflink
> @@ -107,7 +107,7 @@ _require_scratch_dedupe()
>  	_scratch_mount
>  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
>  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
> -	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
> +	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
>  	echo $testio | grep -q "Operation not supported" && \
>  		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
>  	echo $testio | grep -q "Inappropriate ioctl for device" && \

I think this hunk belongs to a seperate patch.

Thanks,
Eryu

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

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

* Re: [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
  2016-07-04  6:51     ` Eryu Guan
@ 2016-07-04 19:11       ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-04 19:11 UTC (permalink / raw)
  To: Eryu Guan; +Cc: david, linux-btrfs, fstests, xfs

On Mon, Jul 04, 2016 at 02:51:37PM +0800, Eryu Guan wrote:
> On Thu, Jun 16, 2016 at 06:47:42PM -0700, Darrick J. Wong wrote:
> > Test sharing blocks via reflink and dedupe between two different
> > mountpoints of the same filesystem.  This shouldn't work, since
> > we don't allow cross-mountpoint functions.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/reflink        |    2 +
> >  tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/927.out |    9 +++++
> >  tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/928.out |   10 ++++++
> >  tests/generic/group   |    2 +
> >  6 files changed, 196 insertions(+), 1 deletion(-)
> >  create mode 100755 tests/generic/927
> >  create mode 100644 tests/generic/927.out
> >  create mode 100755 tests/generic/928
> >  create mode 100644 tests/generic/928.out
> > 
> > 
> > diff --git a/common/reflink b/common/reflink
> > index 4ec390d..1363971 100644
> > --- a/common/reflink
> > +++ b/common/reflink
> > @@ -107,7 +107,7 @@ _require_scratch_dedupe()
> >  	_scratch_mount
> >  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
> >  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
> > -	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
> > +	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
> >  	echo $testio | grep -q "Operation not supported" && \
> >  		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
> >  	echo $testio | grep -q "Inappropriate ioctl for device" && \
> 
> I think this hunk belongs to a seperate patch.

Ok, will do.

--D

> 
> Thanks,
> Eryu
> --
> 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] 66+ messages in thread

* Re: [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe
@ 2016-07-04 19:11       ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-04 19:11 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, linux-btrfs, xfs

On Mon, Jul 04, 2016 at 02:51:37PM +0800, Eryu Guan wrote:
> On Thu, Jun 16, 2016 at 06:47:42PM -0700, Darrick J. Wong wrote:
> > Test sharing blocks via reflink and dedupe between two different
> > mountpoints of the same filesystem.  This shouldn't work, since
> > we don't allow cross-mountpoint functions.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/reflink        |    2 +
> >  tests/generic/927     |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/927.out |    9 +++++
> >  tests/generic/928     |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/928.out |   10 ++++++
> >  tests/generic/group   |    2 +
> >  6 files changed, 196 insertions(+), 1 deletion(-)
> >  create mode 100755 tests/generic/927
> >  create mode 100644 tests/generic/927.out
> >  create mode 100755 tests/generic/928
> >  create mode 100644 tests/generic/928.out
> > 
> > 
> > diff --git a/common/reflink b/common/reflink
> > index 4ec390d..1363971 100644
> > --- a/common/reflink
> > +++ b/common/reflink
> > @@ -107,7 +107,7 @@ _require_scratch_dedupe()
> >  	_scratch_mount
> >  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
> >  	"$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
> > -	testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
> > +	testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)"
> >  	echo $testio | grep -q "Operation not supported" && \
> >  		_notrun "Dedupe not supported by test filesystem type: $FSTYP"
> >  	echo $testio | grep -q "Inappropriate ioctl for device" && \
> 
> I think this hunk belongs to a seperate patch.

Ok, will do.

--D

> 
> Thanks,
> Eryu
> --
> 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] 66+ messages in thread

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
  2016-06-17  1:48   ` Darrick J. Wong
@ 2016-07-05  3:56     ` Eryu Guan
  -1 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-05  3:56 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-btrfs, fstests, xfs

On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> Run xfs_repair twice at the end of each test -- once to rebuild
> the btree indices, and again with -n to check the rebuild work.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc |    3 +++
>  1 file changed, 3 insertions(+)
> 
> 
> diff --git a/common/rc b/common/rc
> index 1225047..847191e 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
>          ok=0
>      fi
>  
> +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> +

Won't this hide fs corruptions? Did I miss anything?

Thanks,
Eryu

>      $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
>      if [ $? -ne 0 ]
>      then
> 
> --
> 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] 66+ messages in thread

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
@ 2016-07-05  3:56     ` Eryu Guan
  0 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-05  3:56 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> Run xfs_repair twice at the end of each test -- once to rebuild
> the btree indices, and again with -n to check the rebuild work.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/rc |    3 +++
>  1 file changed, 3 insertions(+)
> 
> 
> diff --git a/common/rc b/common/rc
> index 1225047..847191e 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
>          ok=0
>      fi
>  
> +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> +

Won't this hide fs corruptions? Did I miss anything?

Thanks,
Eryu

>      $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
>      if [ $? -ne 0 ]
>      then
> 
> --
> 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] 66+ messages in thread

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
  2016-07-05  3:56     ` Eryu Guan
@ 2016-07-05  4:11       ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-05  4:11 UTC (permalink / raw)
  To: Eryu Guan; +Cc: david, linux-btrfs, fstests, xfs

On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > Run xfs_repair twice at the end of each test -- once to rebuild
> > the btree indices, and again with -n to check the rebuild work.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/rc |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > 
> > diff --git a/common/rc b/common/rc
> > index 1225047..847191e 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> >          ok=0
> >      fi
> >  
> > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > +
> 
> Won't this hide fs corruptions? Did I miss anything?

I could've sworn it did:

xfs_repair -n
(complain if corrupt)

xfs_repair

xfs_repair -n
(complain if still corrupt)

But that first xfs_repair -n hunk disappeared. :(

Ok, will fix and resend.

--D

> 
> Thanks,
> Eryu
> 
> >      $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> >      if [ $? -ne 0 ]
> >      then
> > 
> > --
> > 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] 66+ messages in thread

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
@ 2016-07-05  4:11       ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-05  4:11 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, linux-btrfs, xfs

On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > Run xfs_repair twice at the end of each test -- once to rebuild
> > the btree indices, and again with -n to check the rebuild work.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/rc |    3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > 
> > diff --git a/common/rc b/common/rc
> > index 1225047..847191e 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> >          ok=0
> >      fi
> >  
> > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > +
> 
> Won't this hide fs corruptions? Did I miss anything?

I could've sworn it did:

xfs_repair -n
(complain if corrupt)

xfs_repair

xfs_repair -n
(complain if still corrupt)

But that first xfs_repair -n hunk disappeared. :(

Ok, will fix and resend.

--D

> 
> Thanks,
> Eryu
> 
> >      $XFS_REPAIR_PROG -n $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> >      if [ $? -ne 0 ]
> >      then
> > 
> > --
> > 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] 66+ messages in thread

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
  2016-06-17  1:46 ` Darrick J. Wong
@ 2016-07-05  4:31   ` Eryu Guan
  -1 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-05  4:31 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-btrfs, fstests, xfs

Hi Darrick,

On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> Hi all,
> 
> This is the sixth revision of a patchset that adds to xfstests
> support for testing reverse-mappings of physical blocks to file and
> metadata (rmap); support for testing multiple file logical blocks to
> the same physical block (reflink); and implements the beginnings of
> online metadata scrubbing.
> 
> The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> Those patches haven't changed, but they're not yet in the upstream
> repo.
> 
> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> There are also updates for xfs-docs[4].  The kernel patches should
> apply to dchinner's for-next; xfsprogs patches to for-next; and
> xfstest to master.  The kernel git tree already has for-next included.
> 
> The patches have been xfstested with x64, i386, and armv7l--arm64,
> ppc64, and ppc64le no longer boot in qemu.  All three architectures
> pass all 'clone' group tests except xfs/128 (which is the swapext
> test), and AFAICT don't cause any new failures for the 'auto' group.
> 
> This is an extraordinary way to eat your data.  Enjoy! 
> Comments and questions are, as always, welcome.

I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
online filesystem scrub program), with x86_64 host & 4k block size XFS.

A './check -g auto' run looked fine overall. Besides the comments I
replied to some patches, other common minor issues are:
- space indention in _cleanup not tab
- bare 'umount $SCRATCH_MNT' not _scratch_unmount
- whitespace issues in _test|scratch_inject_error

(I can fix all these minor issues at commit time, if you don't have
other major updates to these patches).

And the review of changes to xfs/122 needs help from other XFS
developers :) (09/20 and 10/20)

And besides the first 8 patches, 15/20 has been in upstream as well.

Thanks,
Eryu

P.S.
The failed tests I saw when testing with reflink-enabled kernel &
xfsprogs:

Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293

generic/108 generic/204 and xfs/004 are new failures compared to stock
kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).

Just FYI.

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

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
@ 2016-07-05  4:31   ` Eryu Guan
  0 siblings, 0 replies; 66+ messages in thread
From: Eryu Guan @ 2016-07-05  4:31 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, xfs

Hi Darrick,

On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> Hi all,
> 
> This is the sixth revision of a patchset that adds to xfstests
> support for testing reverse-mappings of physical blocks to file and
> metadata (rmap); support for testing multiple file logical blocks to
> the same physical block (reflink); and implements the beginnings of
> online metadata scrubbing.
> 
> The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> Those patches haven't changed, but they're not yet in the upstream
> repo.
> 
> If you're going to start using this mess, you probably ought to just
> pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> There are also updates for xfs-docs[4].  The kernel patches should
> apply to dchinner's for-next; xfsprogs patches to for-next; and
> xfstest to master.  The kernel git tree already has for-next included.
> 
> The patches have been xfstested with x64, i386, and armv7l--arm64,
> ppc64, and ppc64le no longer boot in qemu.  All three architectures
> pass all 'clone' group tests except xfs/128 (which is the swapext
> test), and AFAICT don't cause any new failures for the 'auto' group.
> 
> This is an extraordinary way to eat your data.  Enjoy! 
> Comments and questions are, as always, welcome.

I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
online filesystem scrub program), with x86_64 host & 4k block size XFS.

A './check -g auto' run looked fine overall. Besides the comments I
replied to some patches, other common minor issues are:
- space indention in _cleanup not tab
- bare 'umount $SCRATCH_MNT' not _scratch_unmount
- whitespace issues in _test|scratch_inject_error

(I can fix all these minor issues at commit time, if you don't have
other major updates to these patches).

And the review of changes to xfs/122 needs help from other XFS
developers :) (09/20 and 10/20)

And besides the first 8 patches, 15/20 has been in upstream as well.

Thanks,
Eryu

P.S.
The failed tests I saw when testing with reflink-enabled kernel &
xfsprogs:

Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293

generic/108 generic/204 and xfs/004 are new failures compared to stock
kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).

Just FYI.

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

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

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
  2016-07-05  4:31   ` Eryu Guan
@ 2016-07-06 22:44     ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-06 22:44 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, linux-btrfs, xfs

On Tue, Jul 05, 2016 at 12:31:30PM +0800, Eryu Guan wrote:
> Hi Darrick,
> 
> On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> > Hi all,
> > 
> > This is the sixth revision of a patchset that adds to xfstests
> > support for testing reverse-mappings of physical blocks to file and
> > metadata (rmap); support for testing multiple file logical blocks to
> > the same physical block (reflink); and implements the beginnings of
> > online metadata scrubbing.
> > 
> > The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> > Those patches haven't changed, but they're not yet in the upstream
> > repo.
> > 
> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > There are also updates for xfs-docs[4].  The kernel patches should
> > apply to dchinner's for-next; xfsprogs patches to for-next; and
> > xfstest to master.  The kernel git tree already has for-next included.
> > 
> > The patches have been xfstested with x64, i386, and armv7l--arm64,
> > ppc64, and ppc64le no longer boot in qemu.  All three architectures
> > pass all 'clone' group tests except xfs/128 (which is the swapext
> > test), and AFAICT don't cause any new failures for the 'auto' group.
> > 
> > This is an extraordinary way to eat your data.  Enjoy! 
> > Comments and questions are, as always, welcome.
> 
> I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
> btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
> online filesystem scrub program), with x86_64 host & 4k block size XFS.
> 
> A './check -g auto' run looked fine overall. Besides the comments I
> replied to some patches, other common minor issues are:
> - space indention in _cleanup not tab
> - bare 'umount $SCRATCH_MNT' not _scratch_unmount
> - whitespace issues in _test|scratch_inject_error
> 
> (I can fix all these minor issues at commit time, if you don't have
> other major updates to these patches).

I don't have any major updates to any of those patches; go ahead.

FWIW I usually have unposted patches at all points in time, so if you want to
fix minor nits in things I've already posted for review and commit them to
upstream, that's fine.  I pull down the latest xfstest git and rebase prior to
sending a new patch series, so I'll absorb whatever you change. :)

When I'm getting ready to do another big release, I inquire with the
maintainers if they're about to push commits upstream to avoid the race
post patches -> upstream push -> rebase patches -> repost patches.

> And the review of changes to xfs/122 needs help from other XFS
> developers :) (09/20 and 10/20)

09/20 (remove rmapx cruft) should be pretty straightforward, since I withdrew
'rmapx' and related changes from xfs.

10/20 (new log items) will probably remain outstanding for a while since
those changes haven't really made it upstream yet.

> And besides the first 8 patches, 15/20 has been in upstream as well.

Oh, ok.

> Thanks,
> Eryu
> 
> P.S.
> The failed tests I saw when testing with reflink-enabled kernel &
> xfsprogs:
> 
> Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293
> 
> generic/108 generic/204 and xfs/004 are new failures compared to stock
> kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).

I think I have fixes for some of those that will go out during the next
patchbomb.  But thanks for the heads up, I'll have a look at a -g auto
run before I submit again.

--D

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

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

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
@ 2016-07-06 22:44     ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-06 22:44 UTC (permalink / raw)
  To: Eryu Guan; +Cc: linux-btrfs, fstests, xfs

On Tue, Jul 05, 2016 at 12:31:30PM +0800, Eryu Guan wrote:
> Hi Darrick,
> 
> On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> > Hi all,
> > 
> > This is the sixth revision of a patchset that adds to xfstests
> > support for testing reverse-mappings of physical blocks to file and
> > metadata (rmap); support for testing multiple file logical blocks to
> > the same physical block (reflink); and implements the beginnings of
> > online metadata scrubbing.
> > 
> > The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> > Those patches haven't changed, but they're not yet in the upstream
> > repo.
> > 
> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > There are also updates for xfs-docs[4].  The kernel patches should
> > apply to dchinner's for-next; xfsprogs patches to for-next; and
> > xfstest to master.  The kernel git tree already has for-next included.
> > 
> > The patches have been xfstested with x64, i386, and armv7l--arm64,
> > ppc64, and ppc64le no longer boot in qemu.  All three architectures
> > pass all 'clone' group tests except xfs/128 (which is the swapext
> > test), and AFAICT don't cause any new failures for the 'auto' group.
> > 
> > This is an extraordinary way to eat your data.  Enjoy! 
> > Comments and questions are, as always, welcome.
> 
> I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
> btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
> online filesystem scrub program), with x86_64 host & 4k block size XFS.
> 
> A './check -g auto' run looked fine overall. Besides the comments I
> replied to some patches, other common minor issues are:
> - space indention in _cleanup not tab
> - bare 'umount $SCRATCH_MNT' not _scratch_unmount
> - whitespace issues in _test|scratch_inject_error
> 
> (I can fix all these minor issues at commit time, if you don't have
> other major updates to these patches).

I don't have any major updates to any of those patches; go ahead.

FWIW I usually have unposted patches at all points in time, so if you want to
fix minor nits in things I've already posted for review and commit them to
upstream, that's fine.  I pull down the latest xfstest git and rebase prior to
sending a new patch series, so I'll absorb whatever you change. :)

When I'm getting ready to do another big release, I inquire with the
maintainers if they're about to push commits upstream to avoid the race
post patches -> upstream push -> rebase patches -> repost patches.

> And the review of changes to xfs/122 needs help from other XFS
> developers :) (09/20 and 10/20)

09/20 (remove rmapx cruft) should be pretty straightforward, since I withdrew
'rmapx' and related changes from xfs.

10/20 (new log items) will probably remain outstanding for a while since
those changes haven't really made it upstream yet.

> And besides the first 8 patches, 15/20 has been in upstream as well.

Oh, ok.

> Thanks,
> Eryu
> 
> P.S.
> The failed tests I saw when testing with reflink-enabled kernel &
> xfsprogs:
> 
> Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293
> 
> generic/108 generic/204 and xfs/004 are new failures compared to stock
> kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).

I think I have fixes for some of those that will go out during the next
patchbomb.  But thanks for the heads up, I'll have a look at a -g auto
run before I submit again.

--D

> 
> Just FYI.
> 
> _______________________________________________
> 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] 66+ messages in thread

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
  2016-07-05  4:11       ` Darrick J. Wong
@ 2016-07-06 23:13         ` Dave Chinner
  -1 siblings, 0 replies; 66+ messages in thread
From: Dave Chinner @ 2016-07-06 23:13 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eryu Guan, linux-btrfs, fstests, xfs

On Mon, Jul 04, 2016 at 09:11:34PM -0700, Darrick J. Wong wrote:
> On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> > On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > > Run xfs_repair twice at the end of each test -- once to rebuild
> > > the btree indices, and again with -n to check the rebuild work.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  common/rc |    3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > 
> > > diff --git a/common/rc b/common/rc
> > > index 1225047..847191e 100644
> > > --- a/common/rc
> > > +++ b/common/rc
> > > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> > >          ok=0
> > >      fi
> > >  
> > > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > > +
> > 
> > Won't this hide fs corruptions? Did I miss anything?
> 
> I could've sworn it did:
> 
> xfs_repair -n
> (complain if corrupt)
> 
> xfs_repair
> 
> xfs_repair -n
> (complain if still corrupt)
> 
> But that first xfs_repair -n hunk disappeared. :(
> 
> Ok, will fix and resend.

Not sure this is the best idea - when repair on an aged test device
takes 10s, this means the test harness overhead increases by a
factor of 3. i.e. test takes 1s to run, checking the filesystem
between tests now takes 30s. i.e. this will badly blow out the run
time of the test suite on aged test devices....

What does this overhead actually gain us that we couldn't encode
explicitly into a single test or two? e.g the test itself runs
repair on the aged test device....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
@ 2016-07-06 23:13         ` Dave Chinner
  0 siblings, 0 replies; 66+ messages in thread
From: Dave Chinner @ 2016-07-06 23:13 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, Eryu Guan, linux-btrfs, xfs

On Mon, Jul 04, 2016 at 09:11:34PM -0700, Darrick J. Wong wrote:
> On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> > On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > > Run xfs_repair twice at the end of each test -- once to rebuild
> > > the btree indices, and again with -n to check the rebuild work.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > ---
> > >  common/rc |    3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > 
> > > diff --git a/common/rc b/common/rc
> > > index 1225047..847191e 100644
> > > --- a/common/rc
> > > +++ b/common/rc
> > > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> > >          ok=0
> > >      fi
> > >  
> > > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > > +
> > 
> > Won't this hide fs corruptions? Did I miss anything?
> 
> I could've sworn it did:
> 
> xfs_repair -n
> (complain if corrupt)
> 
> xfs_repair
> 
> xfs_repair -n
> (complain if still corrupt)
> 
> But that first xfs_repair -n hunk disappeared. :(
> 
> Ok, will fix and resend.

Not sure this is the best idea - when repair on an aged test device
takes 10s, this means the test harness overhead increases by a
factor of 3. i.e. test takes 1s to run, checking the filesystem
between tests now takes 30s. i.e. this will badly blow out the run
time of the test suite on aged test devices....

What does this overhead actually gain us that we couldn't encode
explicitly into a single test or two? e.g the test itself runs
repair on the aged test device....

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

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
  2016-07-06 23:13         ` Dave Chinner
@ 2016-07-06 23:49           ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-06 23:49 UTC (permalink / raw)
  To: Dave Chinner; +Cc: fstests, Eryu Guan, linux-btrfs, xfs

On Thu, Jul 07, 2016 at 09:13:40AM +1000, Dave Chinner wrote:
> On Mon, Jul 04, 2016 at 09:11:34PM -0700, Darrick J. Wong wrote:
> > On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> > > On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > > > Run xfs_repair twice at the end of each test -- once to rebuild
> > > > the btree indices, and again with -n to check the rebuild work.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > > ---
> > > >  common/rc |    3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > 
> > > > diff --git a/common/rc b/common/rc
> > > > index 1225047..847191e 100644
> > > > --- a/common/rc
> > > > +++ b/common/rc
> > > > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> > > >          ok=0
> > > >      fi
> > > >  
> > > > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > > > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > > > +
> > > 
> > > Won't this hide fs corruptions? Did I miss anything?
> > 
> > I could've sworn it did:
> > 
> > xfs_repair -n
> > (complain if corrupt)
> > 
> > xfs_repair
> > 
> > xfs_repair -n
> > (complain if still corrupt)
> > 
> > But that first xfs_repair -n hunk disappeared. :(
> > 
> > Ok, will fix and resend.
> 
> Not sure this is the best idea - when repair on an aged test device
> takes 10s, this means the test harness overhead increases by a
> factor of 3. i.e. test takes 1s to run, checking the filesystem
> between tests now takes 30s. i.e. this will badly blow out the run
> time of the test suite on aged test devices....
> 
> What does this overhead actually gain us that we couldn't encode
> explicitly into a single test or two? e.g the test itself runs
> repair on the aged test device....

I'm primarily using it as a way to expose the new rmap/refcount/rtrmap btree
rebuilding code to a wider variety of filesystems.  But you're right, there's
no need to expose /everyone/ to this behavior.  Shall I rework the change
so that one can turn it on or off as desired?

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

* Re: [PATCH 19/20] xfs: run xfs_repair at the end of each test
@ 2016-07-06 23:49           ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-06 23:49 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-btrfs, Eryu Guan, fstests, xfs

On Thu, Jul 07, 2016 at 09:13:40AM +1000, Dave Chinner wrote:
> On Mon, Jul 04, 2016 at 09:11:34PM -0700, Darrick J. Wong wrote:
> > On Tue, Jul 05, 2016 at 11:56:17AM +0800, Eryu Guan wrote:
> > > On Thu, Jun 16, 2016 at 06:48:01PM -0700, Darrick J. Wong wrote:
> > > > Run xfs_repair twice at the end of each test -- once to rebuild
> > > > the btree indices, and again with -n to check the rebuild work.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > > ---
> > > >  common/rc |    3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > 
> > > > diff --git a/common/rc b/common/rc
> > > > index 1225047..847191e 100644
> > > > --- a/common/rc
> > > > +++ b/common/rc
> > > > @@ -2225,6 +2225,9 @@ _check_xfs_filesystem()
> > > >          ok=0
> > > >      fi
> > > >  
> > > > +    $XFS_REPAIR_PROG $extra_options $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
> > > > +    cat $tmp.repair | _fix_malloc		>>$seqres.full
> > > > +
> > > 
> > > Won't this hide fs corruptions? Did I miss anything?
> > 
> > I could've sworn it did:
> > 
> > xfs_repair -n
> > (complain if corrupt)
> > 
> > xfs_repair
> > 
> > xfs_repair -n
> > (complain if still corrupt)
> > 
> > But that first xfs_repair -n hunk disappeared. :(
> > 
> > Ok, will fix and resend.
> 
> Not sure this is the best idea - when repair on an aged test device
> takes 10s, this means the test harness overhead increases by a
> factor of 3. i.e. test takes 1s to run, checking the filesystem
> between tests now takes 30s. i.e. this will badly blow out the run
> time of the test suite on aged test devices....
> 
> What does this overhead actually gain us that we couldn't encode
> explicitly into a single test or two? e.g the test itself runs
> repair on the aged test device....

I'm primarily using it as a way to expose the new rmap/refcount/rtrmap btree
rebuilding code to a wider variety of filesystems.  But you're right, there's
no need to expose /everyone/ to this behavior.  Shall I rework the change
so that one can turn it on or off as desired?

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

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
  2016-07-05  4:31   ` Eryu Guan
@ 2016-07-13  5:28     ` Darrick J. Wong
  -1 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-13  5:28 UTC (permalink / raw)
  To: Eryu Guan; +Cc: david, linux-btrfs, fstests, xfs

On Tue, Jul 05, 2016 at 12:31:30PM +0800, Eryu Guan wrote:
> Hi Darrick,
> 
> On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> > Hi all,
> > 
> > This is the sixth revision of a patchset that adds to xfstests
> > support for testing reverse-mappings of physical blocks to file and
> > metadata (rmap); support for testing multiple file logical blocks to
> > the same physical block (reflink); and implements the beginnings of
> > online metadata scrubbing.
> > 
> > The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> > Those patches haven't changed, but they're not yet in the upstream
> > repo.
> > 
> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > There are also updates for xfs-docs[4].  The kernel patches should
> > apply to dchinner's for-next; xfsprogs patches to for-next; and
> > xfstest to master.  The kernel git tree already has for-next included.
> > 
> > The patches have been xfstested with x64, i386, and armv7l--arm64,
> > ppc64, and ppc64le no longer boot in qemu.  All three architectures
> > pass all 'clone' group tests except xfs/128 (which is the swapext
> > test), and AFAICT don't cause any new failures for the 'auto' group.
> > 
> > This is an extraordinary way to eat your data.  Enjoy! 
> > Comments and questions are, as always, welcome.
> 
> I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
> btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
> online filesystem scrub program), with x86_64 host & 4k block size XFS.
> 
> A './check -g auto' run looked fine overall. Besides the comments I
> replied to some patches, other common minor issues are:
> - space indention in _cleanup not tab
> - bare 'umount $SCRATCH_MNT' not _scratch_unmount
> - whitespace issues in _test|scratch_inject_error
> 
> (I can fix all these minor issues at commit time, if you don't have
> other major updates to these patches).
> 
> And the review of changes to xfs/122 needs help from other XFS
> developers :) (09/20 and 10/20)
> 
> And besides the first 8 patches, 15/20 has been in upstream as well.
> 
> Thanks,
> Eryu
> 
> P.S.
> The failed tests I saw when testing with reflink-enabled kernel &
> xfsprogs:
> 
> Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293
> 
> generic/108 generic/204 and xfs/004 are new failures compared to stock
> kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).
> 
> Just FYI.

Thanks for doing this.  I'm seeing some of the same failures you are,
and will fix them up in the next patch bundle.

--D

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

* Re: [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests
@ 2016-07-13  5:28     ` Darrick J. Wong
  0 siblings, 0 replies; 66+ messages in thread
From: Darrick J. Wong @ 2016-07-13  5:28 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, linux-btrfs, xfs

On Tue, Jul 05, 2016 at 12:31:30PM +0800, Eryu Guan wrote:
> Hi Darrick,
> 
> On Thu, Jun 16, 2016 at 06:46:02PM -0700, Darrick J. Wong wrote:
> > Hi all,
> > 
> > This is the sixth revision of a patchset that adds to xfstests
> > support for testing reverse-mappings of physical blocks to file and
> > metadata (rmap); support for testing multiple file logical blocks to
> > the same physical block (reflink); and implements the beginnings of
> > online metadata scrubbing.
> > 
> > The first eight patches are in Eryu Guan's pull request on 2016-06-15.
> > Those patches haven't changed, but they're not yet in the upstream
> > repo.
> > 
> > If you're going to start using this mess, you probably ought to just
> > pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].
> > There are also updates for xfs-docs[4].  The kernel patches should
> > apply to dchinner's for-next; xfsprogs patches to for-next; and
> > xfstest to master.  The kernel git tree already has for-next included.
> > 
> > The patches have been xfstested with x64, i386, and armv7l--arm64,
> > ppc64, and ppc64le no longer boot in qemu.  All three architectures
> > pass all 'clone' group tests except xfs/128 (which is the swapext
> > test), and AFAICT don't cause any new failures for the 'auto' group.
> > 
> > This is an extraordinary way to eat your data.  Enjoy! 
> > Comments and questions are, as always, welcome.
> 
> I tested your xfstests patches with your kernel(HEAD f0b34b6 xfs: add
> btree scrub tracepoints) and xfsprogs(HEAD 34bd754 xfs_scrub: create
> online filesystem scrub program), with x86_64 host & 4k block size XFS.
> 
> A './check -g auto' run looked fine overall. Besides the comments I
> replied to some patches, other common minor issues are:
> - space indention in _cleanup not tab
> - bare 'umount $SCRATCH_MNT' not _scratch_unmount
> - whitespace issues in _test|scratch_inject_error
> 
> (I can fix all these minor issues at commit time, if you don't have
> other major updates to these patches).
> 
> And the review of changes to xfs/122 needs help from other XFS
> developers :) (09/20 and 10/20)
> 
> And besides the first 8 patches, 15/20 has been in upstream as well.
> 
> Thanks,
> Eryu
> 
> P.S.
> The failed tests I saw when testing with reflink-enabled kernel &
> xfsprogs:
> 
> Failures: generic/054 generic/055 generic/108 generic/204 generic/356 generic/357 xfs/004 xfs/096 xfs/122 xfs/293
> 
> generic/108 generic/204 and xfs/004 are new failures compared to stock
> kernel and xfsprogs (kernel 4.7-rc5, xfsprogs 4.7-rc1).
> 
> Just FYI.

Thanks for doing this.  I'm seeing some of the same failures you are,
and will fix them up in the next patch bundle.

--D

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

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

end of thread, other threads:[~2016-07-13  5:28 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-17  1:46 [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests Darrick J. Wong
2016-06-17  1:46 ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 01/20] xfs/104: don't enospc when ag metadata overhead grows Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 02/20] tests: don't put loop control files on the scratch mount Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 03/20] xfs: test copy-on-write leftover recovery Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 04/20] xfs: test per-ag allocation accounting during truncate-caused refcountbt expansion Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 05/20] reflink: test interaction with swap files Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 06/20] xfs: test rmap behavior when multiple bmbt records map to a single rmapbt record Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 07/20] reflink: test changing sharers of a block while keeping refcount the same Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 08/20] xfs/122: don't break on old xfsprogs Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:46 ` [PATCH 09/20] xfs/122: fix test output to reflect latest xfsprogs Darrick J. Wong
2016-06-17  1:46   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 10/20] xfs/122: list the new log redo items Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 11/20] xfs: inject errors at various parts of the deferred op completion Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17 16:39   ` [PATCH v2 " Darrick J. Wong
2016-06-17 16:39     ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 12/20] xfs/235: fix logic errors when checking rmap usage after failures Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 13/20] xfs/229: require 3GB of space Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 14/20] xfs: test clearing reflink inode flag Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17 16:40   ` [PATCH v2 " Darrick J. Wong
2016-06-17 16:40     ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 15/20] xfstests: fix unreferenced variables in generic/186 and generic/187 Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 16/20] reflink: test cross-mountpoint reflink and dedupe Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-07-04  6:51   ` Eryu Guan
2016-07-04  6:51     ` Eryu Guan
2016-07-04 19:11     ` Darrick J. Wong
2016-07-04 19:11       ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 17/20] generic/204: increase log size for rmap/reflink Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:47 ` [PATCH 18/20] xfs/128: use $XFS_FSR_PROG instead of xfs_fsr directly Darrick J. Wong
2016-06-17  1:47   ` Darrick J. Wong
2016-06-17  1:48 ` [PATCH 19/20] xfs: run xfs_repair at the end of each test Darrick J. Wong
2016-06-17  1:48   ` Darrick J. Wong
2016-07-05  3:56   ` Eryu Guan
2016-07-05  3:56     ` Eryu Guan
2016-07-05  4:11     ` Darrick J. Wong
2016-07-05  4:11       ` Darrick J. Wong
2016-07-06 23:13       ` Dave Chinner
2016-07-06 23:13         ` Dave Chinner
2016-07-06 23:49         ` Darrick J. Wong
2016-07-06 23:49           ` Darrick J. Wong
2016-06-17  1:48 ` [PATCH 20/20] xfs: scrub fs (if still mounted) at the end of the test Darrick J. Wong
2016-06-17  1:48   ` Darrick J. Wong
2016-06-29  3:36 ` [PATCH 21/20] xfs/128: cycle_mount the scratch device, not the test device Darrick J. Wong
2016-06-29  3:36   ` Darrick J. Wong
2016-07-05  4:31 ` [PATCH v6 00/20] xfstests: minor fixes for the reflink/dedupe tests Eryu Guan
2016-07-05  4:31   ` Eryu Guan
2016-07-06 22:44   ` Darrick J. Wong
2016-07-06 22:44     ` Darrick J. Wong
2016-07-13  5:28   ` Darrick J. Wong
2016-07-13  5:28     ` 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.