From: Darrick J. Wong Date: Mon, 21 Dec 2015 07:13:37 +0000 (+1100) Subject: reflink: more tests X-Git-Tag: v2022.05.01~2699 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1b3dc467e458cc219828a6db030e782b30a92b89;p=xfstests-dev.git reflink: more tests Add more tests for unaligned copy-on-write things, and explicitly test the ability to pass "len == 0" to mean reflink/dedupe all the way to the end of the file". Signed-off-by: Darrick J. Wong Signed-off-by: Dave Chinner --- diff --git a/tests/generic/178 b/tests/generic/178 new file mode 100755 index 00000000..9828dac5 --- /dev/null +++ b/tests/generic/178 @@ -0,0 +1,77 @@ +#! /bin/bash +# FS QA Test No. 178 +# +# Ensure that punch-hole doesn't clobber CoW. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename "$0"` +seqres="$RESULT_DIR/$seq" +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf "$tmp".* "$TESTDIR" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink +_require_xfs_io_command "fpunch" + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +NR=512 +_pwrite_byte 0x61 0 $((BLKSZ * NR)) "$TESTDIR/file1" >> "$seqres.full" + +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir + +echo "Write and punch" +_pwrite_byte 0x62 0 $((BLKSZ * 256)) "$TESTDIR/file2" >> "$seqres.full" +"$XFS_IO_PROG" -f -c "fpunch $BLKSZ $((BLKSZ * 254))" "$TESTDIR/file2" +_test_remount + +echo "Compare results" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir + +# success, all done +status=0 +exit diff --git a/tests/generic/178.out b/tests/generic/178.out new file mode 100644 index 00000000..ad74c10b --- /dev/null +++ b/tests/generic/178.out @@ -0,0 +1,8 @@ +QA output created by 178 +Create the original files +bc3d7c2ff64219e33239f2e13c2d21db TEST_DIR/test-178/file1 +bc3d7c2ff64219e33239f2e13c2d21db TEST_DIR/test-178/file2 +Write and punch +Compare results +bc3d7c2ff64219e33239f2e13c2d21db TEST_DIR/test-178/file1 +95cfd19ce56010430dc2057413d7efc5 TEST_DIR/test-178/file2 diff --git a/tests/generic/179 b/tests/generic/179 new file mode 100755 index 00000000..9312d4d7 --- /dev/null +++ b/tests/generic/179 @@ -0,0 +1,96 @@ +#! /bin/bash +# FS QA Test No. 179 +# +# Ensure that unaligned punch-hole steps around reflinked ranges: +# - Create a reflink clone of a file +# - Perform an unaligned punch in the middle of the file. +# - Check that the reflinked areas are still there. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename "$0"` +seqres="$RESULT_DIR/$seq" +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf "$tmp".* "$TESTDIR" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink +_require_xfs_io_command "fpunch" + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 3)) "$TESTDIR/file1" >> "$seqres.full" + +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" + +_pwrite_byte 0x61 0 $((BLKSZ * 3)) "$TESTDIR/file2.chk" >> "$seqres.full" +_pwrite_byte 0x00 $((BLKSZ - 17)) $((BLKSZ + 17)) "$TESTDIR/file2.chk" >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" = "${C2}" || echo "file1 and file2 should match" + +echo "fpunch files" +"$XFS_IO_PROG" -f -c "fpunch $((BLKSZ - 17)) $((BLKSZ + 17))" "$TESTDIR/file2" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" != "${C2}" || echo "file1 and file2 should not match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/179.out b/tests/generic/179.out new file mode 100644 index 00000000..1eaf9b27 --- /dev/null +++ b/tests/generic/179.out @@ -0,0 +1,11 @@ +QA output created by 179 +Create the original files +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-179/file1 +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-179/file2 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-179/file2.chk +fpunch files +Compare files +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-179/file1 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-179/file2 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-179/file2.chk +Compare against check files diff --git a/tests/generic/180 b/tests/generic/180 new file mode 100755 index 00000000..af6f2aee --- /dev/null +++ b/tests/generic/180 @@ -0,0 +1,96 @@ +#! /bin/bash +# FS QA Test No. 180 +# +# Ensure that unaligned zero-range steps around reflinked ranges: +# - Create a reflink clone of a file +# - Perform an unaligned zero-range in the middle of the file. +# - Check that the reflinked areas are still there. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename "$0"` +seqres="$RESULT_DIR/$seq" +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf "$tmp".* "$TESTDIR" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink +_require_xfs_io_command "fzero" + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 3)) "$TESTDIR/file1" >> "$seqres.full" + +_cp_reflink "$TESTDIR/file1" "$TESTDIR/file2" + +_pwrite_byte 0x61 0 $((BLKSZ * 3)) "$TESTDIR/file2.chk" >> "$seqres.full" +_pwrite_byte 0x00 $((BLKSZ - 17)) $((BLKSZ + 17)) "$TESTDIR/file2.chk" >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" = "${C2}" || echo "file1 and file2 should match" + +echo "fzero files" +"$XFS_IO_PROG" -f -c "fzero $((BLKSZ - 17)) $((BLKSZ + 17))" "$TESTDIR/file2" +_test_remount + +echo "Compare files" +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" != "${C2}" || echo "file1 and file2 should not match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/180.out b/tests/generic/180.out new file mode 100644 index 00000000..0a83c00f --- /dev/null +++ b/tests/generic/180.out @@ -0,0 +1,11 @@ +QA output created by 180 +Create the original files +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-180/file1 +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-180/file2 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-180/file2.chk +fzero files +Compare files +998b4ba52f2940dc515001e75926b19f TEST_DIR/test-180/file1 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-180/file2 +8cdf70c9cfb33bdc7397806b87e7c7ea TEST_DIR/test-180/file2.chk +Compare against check files diff --git a/tests/generic/181 b/tests/generic/181 new file mode 100755 index 00000000..03c9ccc5 --- /dev/null +++ b/tests/generic/181 @@ -0,0 +1,80 @@ +#! /bin/bash +# FS QA Test No. 181 +# +# Test the convention that reflink with length == 0 means "to the end of fileA" +# - Create a file. +# - Try to reflink "zero" bytes. +# - Check that the reflink happened. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename "$0"` +seqres="$RESULT_DIR/$seq" +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf "$tmp".* "$TESTDIR" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_pwrite_byte 0x62 0 $((BLKSZ * 256)) "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x62 0 $((BLKSZ * 2)) "$TESTDIR/file2.chk" >> "$seqres.full" +_pwrite_byte 0x61 $((BLKSZ * 2)) $((BLKSZ * 255)) "$TESTDIR/file2.chk" >> "$seqres.full" +_reflink_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" != "${C2}" || echo "file1 and file2 should not match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/181.out b/tests/generic/181.out new file mode 100644 index 00000000..918b4572 --- /dev/null +++ b/tests/generic/181.out @@ -0,0 +1,6 @@ +QA output created by 181 +Create the original files +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-181/file1 +dc881c004745c49f7f4e9cc766f57bc8 TEST_DIR/test-181/file2 +dc881c004745c49f7f4e9cc766f57bc8 TEST_DIR/test-181/file2.chk +Compare against check files diff --git a/tests/generic/182 b/tests/generic/182 new file mode 100755 index 00000000..885159e5 --- /dev/null +++ b/tests/generic/182 @@ -0,0 +1,117 @@ +#! /bin/bash +# FS QA Test No. 182 +# +# Test the convention that reflink with length == 0 means "to the end of fileA" +# - Create a file. +# - Try to reflink "zero" bytes (which means reflink to EOF). +# - Check that the reflink happened. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename "$0"` +seqres="$RESULT_DIR/$seq" +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -rf "$tmp".* "$TESTDIR" +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_require_test_reflink +_require_cp_reflink + +rm -f "$seqres.full" + +TESTDIR="$TEST_DIR/test-$seq" +rm -rf "$TESTDIR" +mkdir "$TESTDIR" + +echo "Create the original files" +BLKSZ=65536 +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_pwrite_byte 0x62 0 $((BLKSZ * 257)) "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x62 0 $((BLKSZ * 257)) "$TESTDIR/file2.chk" >> "$seqres.full" +_dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" != "${C2}" || echo "file1 and file2 should not match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +echo "Make the original file almost dedup-able" +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file2.chk" >> "$seqres.full" +_dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" != "${C2}" || echo "file1 and file2 should not match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +echo "Make the original file dedup-able" +_pwrite_byte 0x61 0 $((BLKSZ * 256)) "$TESTDIR/file1" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 257)) "$TESTDIR/file2" >> "$seqres.full" +_pwrite_byte 0x61 0 $((BLKSZ * 257)) "$TESTDIR/file2.chk" >> "$seqres.full" +_dedupe_range "$TESTDIR/file1" $BLKSZ "$TESTDIR/file2" $((BLKSZ * 2)) 0 >> "$seqres.full" +_test_remount + +md5sum "$TESTDIR/file1" | _filter_test_dir +md5sum "$TESTDIR/file2" | _filter_test_dir +md5sum "$TESTDIR/file2.chk" | _filter_test_dir + +C1="$(_md5_checksum "$TESTDIR/file1")" +C2="$(_md5_checksum "$TESTDIR/file2")" + +test "${C1}" = "${C2}" || echo "file1 and file2 should match" + +echo "Compare against check files" +cmp -s "$TESTDIR/file2" "$TESTDIR/file2.chk" || echo "file2 and file2.chk do not match" + +# success, all done +status=0 +exit diff --git a/tests/generic/182.out b/tests/generic/182.out new file mode 100644 index 00000000..9841b76e --- /dev/null +++ b/tests/generic/182.out @@ -0,0 +1,17 @@ +QA output created by 182 +Create the original files +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-182/file1 +69ad53078a16243d98e21d9f8704a071 TEST_DIR/test-182/file2 +69ad53078a16243d98e21d9f8704a071 TEST_DIR/test-182/file2.chk +Compare against check files +Make the original file almost dedup-able +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-182/file1 +158d4e3578b94b89cbb44493a2110fb9 TEST_DIR/test-182/file2 +158d4e3578b94b89cbb44493a2110fb9 TEST_DIR/test-182/file2.chk +Compare against check files +Make the original file dedup-able +f4820540fc0ac02750739896fe028d56 TEST_DIR/test-182/file1 +113c7055ffe3d24d2dec27e82ab55abd TEST_DIR/test-182/file2 +113c7055ffe3d24d2dec27e82ab55abd TEST_DIR/test-182/file2.chk +file1 and file2 should match +Compare against check files diff --git a/tests/generic/group b/tests/generic/group index 59de174e..b37d0633 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -180,6 +180,11 @@ 175 clone_stress 176 clone_stress 177 auto quick prealloc metadata +178 auto quick clone +179 auto quick clone +180 auto quick clone +181 auto quick clone +182 auto quick clone 184 metadata auto quick 192 atime auto 193 metadata auto quick