4 # Ensure that fallocate steps around reflinked ranges:
5 # - Reflink parts of two files together
6 # - Fallocate all the other sparse space.
7 # - Check that the reflinked areas are still there.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 rm -rf $tmp.* $testdir
41 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_xfs_io_command "falloc"
51 _require_xfs_io_command "truncate"
55 testdir=$TEST_DIR/test-$seq
59 echo "Create the original files"
61 _pwrite_byte 0x61 0 $((blksz * 5 + 37)) $testdir/file1 >> $seqres.full
63 _reflink_range $testdir/file1 $blksz $testdir/file2 $blksz \
64 $((blksz * 4 + 37)) >> $seqres.full
66 $XFS_IO_PROG -f -c "truncate $((blksz * 5 + 37))" $testdir/file3 >> $seqres.full
67 _reflink_range $testdir/file1 0 $testdir/file3 0 $blksz >> $seqres.full
69 $XFS_IO_PROG -f -c "truncate $((blksz * 5 + 37))" $testdir/file4 >> $seqres.full
70 _reflink_range $testdir/file1 $blksz $testdir/file4 $blksz $blksz >> $seqres.full
71 _reflink_range $testdir/file1 $((blksz * 3)) $testdir/file4 $((blksz * 3)) \
72 $blksz >> $seqres.full
74 _cp_reflink $testdir/file1 $testdir/file5
77 echo "Compare sections"
78 md5sum $testdir/file1 | _filter_test_dir
79 md5sum $testdir/file2 | _filter_test_dir
80 md5sum $testdir/file3 | _filter_test_dir
81 md5sum $testdir/file4 | _filter_test_dir
82 md5sum $testdir/file5 | _filter_test_dir
84 _compare_range $testdir/file1 $blksz $testdir/file2 $blksz \
86 || echo "shared parts of files 1-2 changed"
88 _compare_range $testdir/file1 0 $testdir/file3 0 $blksz \
89 || echo "shared parts of files 1-3 changed"
91 _compare_range $testdir/file1 $blksz $testdir/file4 $blksz $blksz \
92 || echo "shared parts of files 1-4 changed"
94 _compare_range $testdir/file1 0 $testdir/file5 0 $((blksz * 5 + 37)) \
95 || echo "shared parts of files 1-5 changed"
98 c1=$(_md5_checksum $testdir/file1)
99 c2=$(_md5_checksum $testdir/file2)
100 c3=$(_md5_checksum $testdir/file3)
101 c4=$(_md5_checksum $testdir/file4)
102 c5=$(_md5_checksum $testdir/file5)
104 test ${c1} != ${c2} || echo "file1 and file2 should not match"
105 test ${c1} != ${c3} || echo "file1 and file3 should not match"
106 test ${c1} != ${c4} || echo "file1 and file4 should not match"
107 test ${c1} = ${c5} || echo "file1 and file5 should match"
108 test ${c2} != ${c3} || echo "file2 and file3 should not match"
109 test ${c2} != ${c4} || echo "file2 and file4 should not match"
110 test ${c2} != ${c5} || echo "file2 and file5 should not match"
111 test ${c3} != ${c4} || echo "file3 and file4 should not match"
112 test ${c3} != ${c5} || echo "file3 and file5 should not match"
113 test ${c4} != ${c5} || echo "file4 and file5 should not match"
115 echo "falloc everything"
116 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 5))" $testdir/file2 >> $seqres.full
117 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 5))" $testdir/file3 >> $seqres.full
118 $XFS_IO_PROG -f -c "falloc 0 $((blksz * 5))" $testdir/file4 >> $seqres.full
122 md5sum $testdir/file1 | _filter_test_dir
123 md5sum $testdir/file2 | _filter_test_dir
124 md5sum $testdir/file3 | _filter_test_dir
125 md5sum $testdir/file4 | _filter_test_dir
126 md5sum $testdir/file5 | _filter_test_dir
128 d1=$(_md5_checksum $testdir/file1)
129 d2=$(_md5_checksum $testdir/file2)
130 d3=$(_md5_checksum $testdir/file3)
131 d4=$(_md5_checksum $testdir/file4)
132 d5=$(_md5_checksum $testdir/file5)
134 test ${c1} = ${d1} || echo "file1 should not change"
135 test ${c2} = ${d2} || echo "file2 should not change"
136 test ${c3} = ${d3} || echo "file3 should not change"
137 test ${c4} = ${d4} || echo "file4 should not change"
138 test ${c5} = ${d5} || echo "file2 should not change"