4 # Ensure that collapse range steps around reflinked ranges:
5 # - Create three reflink clones of a file
6 # - Collapse 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 "falloc"
52 _require_xfs_io_command "fcollapse"
56 testdir=$TEST_DIR/test-$seq
60 echo "Create the original files"
62 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
63 _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full
64 _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full
66 _cp_reflink $testdir/file1 $testdir/file2
67 _cp_reflink $testdir/file1 $testdir/file3
68 _cp_reflink $testdir/file1 $testdir/file4
70 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 4))" $testdir/file1
71 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 4))" $testdir/file2
72 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 4))" $testdir/file3
73 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 4))" $testdir/file4
75 _pwrite_byte 0x62 0 $blksz $testdir/file2.chk >> $seqres.full
76 _pwrite_byte 0x63 $blksz $blksz $testdir/file2.chk >> $seqres.full
77 _pwrite_byte 0x00 $((blksz * 2)) $blksz $testdir/file2.chk >> $seqres.full
79 _pwrite_byte 0x61 0 $blksz $testdir/file3.chk >> $seqres.full
80 _pwrite_byte 0x63 $blksz $blksz $testdir/file3.chk >> $seqres.full
81 _pwrite_byte 0x00 $((blksz * 2)) $blksz $testdir/file3.chk >> $seqres.full
83 _pwrite_byte 0x61 0 $blksz $testdir/file4.chk >> $seqres.full
84 _pwrite_byte 0x62 $blksz $blksz $testdir/file4.chk >> $seqres.full
85 _pwrite_byte 0x00 $((blksz * 2)) $blksz $testdir/file4.chk >> $seqres.full
88 md5sum $testdir/file1 | _filter_test_dir
89 md5sum $testdir/file2 | _filter_test_dir
90 md5sum $testdir/file3 | _filter_test_dir
91 md5sum $testdir/file4 | _filter_test_dir
92 md5sum $testdir/file2.chk | _filter_test_dir
93 md5sum $testdir/file3.chk | _filter_test_dir
94 md5sum $testdir/file4.chk | _filter_test_dir
96 c1=$(_md5_checksum $testdir/file1)
97 c2=$(_md5_checksum $testdir/file2)
98 c3=$(_md5_checksum $testdir/file3)
99 c4=$(_md5_checksum $testdir/file4)
101 test ${c1} = ${c2} || echo "file1 and file2 should match"
102 test ${c1} = ${c3} || echo "file1 and file3 should match"
103 test ${c1} = ${c4} || echo "file1 and file4 should match"
104 test ${c2} = ${c3} || echo "file2 and file3 should match"
105 test ${c2} = ${c4} || echo "file2 and file4 should match"
106 test ${c3} = ${c4} || echo "file3 and file4 should match"
108 echo "fcollapse files"
109 $XFS_IO_PROG -f -c "fcollapse 0 $blksz" $testdir/file2
110 $XFS_IO_PROG -f -c "fcollapse $blksz $blksz" $testdir/file3
111 $XFS_IO_PROG -f -c "fcollapse $((blksz * 2)) $blksz" $testdir/file4
115 md5sum $testdir/file1 | _filter_test_dir
116 md5sum $testdir/file2 | _filter_test_dir
117 md5sum $testdir/file3 | _filter_test_dir
118 md5sum $testdir/file4 | _filter_test_dir
119 md5sum $testdir/file2.chk | _filter_test_dir
120 md5sum $testdir/file3.chk | _filter_test_dir
121 md5sum $testdir/file4.chk | _filter_test_dir
123 c1=$(_md5_checksum $testdir/file1)
124 c2=$(_md5_checksum $testdir/file2)
125 c3=$(_md5_checksum $testdir/file3)
126 c4=$(_md5_checksum $testdir/file4)
128 test ${c1} != ${c2} || echo "file1 and file2 should not match"
129 test ${c1} != ${c3} || echo "file1 and file3 should not match"
130 test ${c1} != ${c4} || echo "file1 and file4 should not match"
131 test ${c2} != ${c3} || echo "file2 and file3 should not match"
132 test ${c2} != ${c4} || echo "file2 and file4 should not match"
133 test ${c3} != ${c4} || echo "file3 and file4 should not match"
135 echo "Compare against check files"
136 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
137 cmp -s $testdir/file3 $testdir/file3.chk || echo "file3 and file3.chk do not match"
138 cmp -s $testdir/file4 $testdir/file4.chk || echo "file4 and file4.chk do not match"