4 # Ensure that punch-hole steps around reflinked ranges:
5 # - Create three reflink clones of a file
6 # - Punch the start, middle, and end of the reflink range of each
7 # of the three files, respectively
8 # - Check that the reflinked areas are still there.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
39 rm -rf $tmp.* $testdir
42 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_xfs_io_command "fpunch"
55 testdir=$TEST_DIR/test-$seq
59 echo "Create the original files"
61 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
62 _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full
63 _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full
65 _cp_reflink $testdir/file1 $testdir/file2
66 _cp_reflink $testdir/file1 $testdir/file3
67 _cp_reflink $testdir/file1 $testdir/file4
69 _pwrite_byte 0x00 0 $blksz $testdir/file2.chk >> $seqres.full
70 _pwrite_byte 0x62 $blksz $blksz $testdir/file2.chk >> $seqres.full
71 _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
73 _pwrite_byte 0x61 0 $blksz $testdir/file3.chk >> $seqres.full
74 _pwrite_byte 0x00 $blksz $blksz $testdir/file3.chk >> $seqres.full
75 _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file3.chk >> $seqres.full
77 _pwrite_byte 0x61 0 $blksz $testdir/file4.chk >> $seqres.full
78 _pwrite_byte 0x62 $blksz $blksz $testdir/file4.chk >> $seqres.full
79 _pwrite_byte 0x00 $((blksz * 2)) $blksz $testdir/file4.chk >> $seqres.full
82 md5sum $testdir/file1 | _filter_test_dir
83 md5sum $testdir/file2 | _filter_test_dir
84 md5sum $testdir/file3 | _filter_test_dir
85 md5sum $testdir/file4 | _filter_test_dir
86 md5sum $testdir/file2.chk | _filter_test_dir
87 md5sum $testdir/file3.chk | _filter_test_dir
88 md5sum $testdir/file4.chk | _filter_test_dir
90 c1=$(_md5_checksum $testdir/file1)
91 c2=$(_md5_checksum $testdir/file2)
92 c3=$(_md5_checksum $testdir/file3)
93 c4=$(_md5_checksum $testdir/file4)
95 test ${c1} = ${c2} || echo "file1 and file2 should match"
96 test ${c1} = ${c3} || echo "file1 and file3 should match"
97 test ${c1} = ${c4} || echo "file1 and file4 should match"
98 test ${c2} = ${c3} || echo "file2 and file3 should match"
99 test ${c2} = ${c4} || echo "file2 and file4 should match"
100 test ${c3} = ${c4} || echo "file3 and file4 should match"
103 $XFS_IO_PROG -f -c "fpunch 0 $blksz" $testdir/file2
104 $XFS_IO_PROG -f -c "fpunch $blksz $blksz" $testdir/file3
105 $XFS_IO_PROG -f -c "fpunch $((blksz * 2)) $blksz" $testdir/file4
109 md5sum $testdir/file1 | _filter_test_dir
110 md5sum $testdir/file2 | _filter_test_dir
111 md5sum $testdir/file3 | _filter_test_dir
112 md5sum $testdir/file4 | _filter_test_dir
113 md5sum $testdir/file2.chk | _filter_test_dir
114 md5sum $testdir/file3.chk | _filter_test_dir
115 md5sum $testdir/file4.chk | _filter_test_dir
117 c1=$(_md5_checksum $testdir/file1)
118 c2=$(_md5_checksum $testdir/file2)
119 c3=$(_md5_checksum $testdir/file3)
120 c4=$(_md5_checksum $testdir/file4)
122 test ${c1} != ${c2} || echo "file1 and file2 should not match"
123 test ${c1} != ${c3} || echo "file1 and file3 should not match"
124 test ${c1} != ${c4} || echo "file1 and file4 should not match"
125 test ${c2} != ${c3} || echo "file2 and file3 should not match"
126 test ${c2} != ${c4} || echo "file2 and file4 should not match"
127 test ${c3} != ${c4} || echo "file3 and file4 should not match"
129 echo "Compare against check files"
130 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
131 cmp -s $testdir/file3 $testdir/file3.chk || echo "file3 and file3.chk do not match"
132 cmp -s $testdir/file4 $testdir/file4.chk || echo "file4 and file4.chk do not match"