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"