new file mode 100755
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 161
+#
+# Test for race between delete a file while rewriting its reflinked twin
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=4096
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2"
+_scratch_remount
+
+echo "Delete while rewriting"
+rm -rf "$TESTDIR/file1" &
+_pwrite_byte 0x62 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+wait
+
+echo "Check fs"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,6 @@
+QA output created by 161
+Format and mount
+Initialize files
+Delete while rewriting
+Check fs
+Done
new file mode 100755
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 162
+#
+# Test for race between dedupe and writing the dest file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=512
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_scratch_remount
+
+overwrite() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ seq $nr_loops -1 0 | while read i; do
+ _pwrite_byte 0x61 $((i * BLKSZ)) $BLKSZ "$TESTDIR/file2" >> "$seqres.full"
+ done
+ done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+ seq $nr_loops -1 0 | while read i; do
+ _dedupe_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file2" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+done
+echo "Finished dedupeing"
+touch "$TESTDIR/finished"
+wait
+
+echo "Check fs"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,7 @@
+QA output created by 162
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
new file mode 100755
@@ -0,0 +1,95 @@
+#! /bin/bash
+# FS QA Test No. 163
+#
+# Test for race between dedupe and writing the source file
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=512
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_scratch_remount
+
+overwrite() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ seq $nr_loops -1 0 | while read i; do
+ _pwrite_byte 0x61 $((i * BLKSZ)) $BLKSZ "$TESTDIR/file1" >> "$seqres.full"
+ done
+ done
+}
+
+echo "Dedupe and rewrite the file!"
+overwrite &
+for i in `seq 1 2`; do
+ seq $nr_loops -1 0 | while read i; do
+ _dedupe_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file2" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+done
+echo "Finished dedupeing"
+touch "$TESTDIR/finished"
+wait
+
+echo "Check fs"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,7 @@
+QA output created by 163
+Format and mount
+Initialize files
+Dedupe and rewrite the file!
+Finished dedupeing
+Check fs
+Done
new file mode 100755
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 164
+#
+# Test for races or FS corruption between reflink and buffered I/O reading the
+# target file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=512
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_cp_reflink "$TESTDIR/file1" "$TESTDIR/file3"
+_scratch_remount
+
+fbytes() {
+ egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+}
+
+reader() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ _read_range "$TESTDIR/file3" 0 $((loops * BLKSZ)) | fbytes
+ done
+}
+
+echo "Reflink and reread the files!"
+reader &
+for i in `seq 1 2`; do
+ seq $nr_loops -1 0 | while read i; do
+ _reflink_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file3" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+ seq $nr_loops -1 0 | while read i; do
+ _reflink_range "$TESTDIR/file2" $((i * BLKSZ)) \
+ "$TESTDIR/file3" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+done
+echo "Finished reflinking"
+touch "$TESTDIR/finished"
+wait
+
+echo "Check fs"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,7 @@
+QA output created by 164
+Format and mount
+Initialize files
+Reflink and reread the files!
+Finished reflinking
+Check fs
+Done
new file mode 100755
@@ -0,0 +1,105 @@
+#! /bin/bash
+# FS QA Test No. 165
+#
+# Test for races or FS corruption between reflink and direct I/O reading the
+# target file.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=512
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_cp_reflink $TESTDIR/file1 $TESTDIR/file3
+_scratch_remount
+
+fbytes() {
+ egrep -v '(61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61|62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62)'
+}
+
+reader() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ _read_range "$TESTDIR/file3" 0 $((loops * BLKSZ)) -d | fbytes
+ done
+}
+
+echo "Reflink and dio reread the files!"
+reader &
+for i in `seq 1 2`; do
+ seq $nr_loops -1 0 | while read i; do
+ _reflink_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file3" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+ seq $nr_loops -1 0 | while read i; do
+ _reflink_range "$TESTDIR/file2" $((i * BLKSZ)) \
+ "$TESTDIR/file3" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && break
+ done
+done
+echo "Finished reflinking"
+touch "$TESTDIR/finished"
+wait
+
+echo "Check fs"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,7 @@
+QA output created by 165
+Format and mount
+Initialize files
+Reflink and dio reread the files!
+Finished reflinking
+Check fs
+Done
new file mode 100755
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 166
+#
+# Test for races or FS corruption when DIO writing to a file that's also
+# the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=1024
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+ n=0
+ while [ ! -e "$TESTDIR/finished" ]; do
+ _cp_reflink "$TESTDIR/file1" "$TESTDIR/snap_$n" || break
+ n=$((n + 1))
+ done
+}
+
+echo "Snapshot a file undergoing directio rewrite"
+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
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,6 @@
+QA output created by 166
+Format and mount
+Initialize file
+Snapshot a file undergoing directio rewrite
+Check for damage
+Done
new file mode 100755
@@ -0,0 +1,93 @@
+#! /bin/bash
+# FS QA Test No. 167
+#
+# Test for races or FS corruption when writing to a file that's also
+# the source of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=1024
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize file"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_scratch_remount
+
+# Snapshot creator...
+snappy() {
+ n=0
+ while [ ! -e "$TESTDIR/finished" ]; do
+ _cp_reflink "$TESTDIR/file1" "$TESTDIR/snap_$n" || break
+ n=$((n + 1))
+ done
+}
+
+echo "Snapshot a file undergoing buffered rewrite"
+snappy &
+seq $nr_loops -1 0 | while read i; do
+ _pwrite_byte 0x63 $((i * BLKSZ)) $BLKSZ "$TESTDIR/file1" >> "$seqres.full"
+done
+touch $TESTDIR/finished
+wait
+
+echo "Check for damage"
+umount $SCRATCH_MNT
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,6 @@
+QA output created by 167
+Format and mount
+Initialize file
+Snapshot a file undergoing buffered rewrite
+Check for damage
+Done
new file mode 100755
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 168
+#
+# Test for races or FS corruption when writing to a file that's also
+# the target of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=1024
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_scratch_remount
+
+# Direct I/O overwriter...
+overwrite() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ seq $nr_loops -1 0 | while read i; do
+ _pwrite_byte 0x63 $((i * BLKSZ)) $BLKSZ "$TESTDIR/file2" >> "$seqres.full"
+ done
+ done
+}
+
+echo "Reflink and write the target"
+overwrite &
+seq 1 10 | while read j; do
+ seq 0 $nr_loops | while read i; do
+ _reflink_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file2" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && exit
+ done
+done
+touch "$TESTDIR/finished"
+wait
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,6 @@
+QA output created by 168
+Format and mount
+Initialize files
+Reflink and write the target
+Check for damage
+Done
new file mode 100755
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 170
+#
+# Test for races or FS corruption when DIO writing to a file that's also
+# the target of a reflink operation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle, Inc. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 7 15
+
+_cleanup()
+{
+ cd /
+ rm -rf "$tmp".*
+ wait
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./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"
+rm -rf "$TESTDIR"
+mkdir "$TESTDIR"
+
+loops=1024
+nr_loops=$((loops - 1))
+BLKSZ=65536
+
+echo "Initialize files"
+echo > "$seqres.full"
+_pwrite_byte 0x61 0 $((loops * BLKSZ)) "$TESTDIR/file1" >> "$seqres.full"
+_pwrite_byte 0x62 0 $((loops * BLKSZ)) "$TESTDIR/file2" >> "$seqres.full"
+_scratch_remount
+
+# Direct I/O overwriter...
+overwrite() {
+ while [ ! -e "$TESTDIR/finished" ]; do
+ seq $nr_loops -1 0 | while read i; do
+ _pwrite_byte 0x63 $((i * BLKSZ)) $BLKSZ -d "$TESTDIR/file2" >> "$seqres.full"
+ done
+ done
+}
+
+echo "Reflink and dio write the target"
+overwrite &
+seq 1 10 | while read j; do
+ seq 0 $nr_loops | while read i; do
+ _reflink_range "$TESTDIR/file1" $((i * BLKSZ)) \
+ "$TESTDIR/file2" $((i * BLKSZ)) $BLKSZ >> "$seqres.full"
+ [ $? -ne 0 ] && exit
+ done
+done
+touch "$TESTDIR/finished"
+wait
+
+echo "Check for damage"
+umount "$SCRATCH_MNT"
+_check_scratch_fs
+
+echo "Done"
+
+# success, all done
+status=0
+exit
new file mode 100644
@@ -0,0 +1,6 @@
+QA output created by 170
+Format and mount
+Initialize files
+Reflink and dio write the target
+Check for damage
+Done
@@ -163,7 +163,16 @@
158 auto quick clone
159 auto quick clone
160 auto quick clone
+161 auto quick clone
+162 auto quick clone
+163 auto quick clone
+164 auto quick clone
+165 auto quick clone
+166 auto quick clone
+167 auto quick clone
+168 auto quick clone
169 rw metadata auto quick
+170 auto quick clone
184 metadata auto quick
192 atime auto
193 metadata auto quick
Make sure that running reflink ops while other IO is ongoing doesn't break the filesystem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> --- tests/generic/161 | 79 +++++++++++++++++++++++++++++++++++++ tests/generic/161.out | 6 +++ tests/generic/162 | 95 ++++++++++++++++++++++++++++++++++++++++++++ tests/generic/162.out | 7 +++ tests/generic/163 | 95 ++++++++++++++++++++++++++++++++++++++++++++ tests/generic/163.out | 7 +++ tests/generic/164 | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/164.out | 7 +++ tests/generic/165 | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/165.out | 7 +++ tests/generic/166 | 93 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/166.out | 6 +++ tests/generic/167 | 93 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/167.out | 6 +++ tests/generic/168 | 97 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/168.out | 6 +++ tests/generic/170 | 97 +++++++++++++++++++++++++++++++++++++++++++++ tests/generic/170.out | 6 +++ tests/generic/group | 9 ++++ 19 files changed, 926 insertions(+) create mode 100755 tests/generic/161 create mode 100644 tests/generic/161.out create mode 100755 tests/generic/162 create mode 100644 tests/generic/162.out create mode 100755 tests/generic/163 create mode 100644 tests/generic/163.out create mode 100755 tests/generic/164 create mode 100644 tests/generic/164.out create mode 100755 tests/generic/165 create mode 100644 tests/generic/165.out create mode 100755 tests/generic/166 create mode 100644 tests/generic/166.out create mode 100755 tests/generic/167 create mode 100644 tests/generic/167.out create mode 100755 tests/generic/168 create mode 100644 tests/generic/168.out create mode 100755 tests/generic/170 create mode 100644 tests/generic/170.out -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html