4 # Ensuring that mmap copy on write through the page cache works:
5 # - Reflink two files together
6 # - Write to the beginning, middle, and end
7 # - Check that the files are now different where we say they're different.
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
53 testdir=$TEST_DIR/test-$seq
57 echo "Create the original files"
59 _pwrite_byte 0x61 0 $((blksz * 48 - 3)) $testdir/file1 >> $seqres.full
60 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
61 _pwrite_byte 0x61 0 $((blksz * 48 - 3)) $testdir/file3 >> $seqres.full
65 md5sum $testdir/file1 | _filter_test_dir
66 md5sum $testdir/file2 | _filter_test_dir
67 md5sum $testdir/file3 | _filter_test_dir
69 cmp -s $testdir/file1 $testdir/file2 || echo "Files 1-2 do not match"
70 cmp -s $testdir/file1 $testdir/file3 || echo "Files 1-3 do not match"
71 cmp -s $testdir/file2 $testdir/file3 || echo "Files 2-3 do not match"
73 echo "mmap CoW the second file"
74 _mwrite_byte 0x62 0 17 $((blksz * 48 - 3)) $testdir/file2 >> $seqres.full
75 _mwrite_byte 0x62 0 17 $((blksz * 48 - 3)) $testdir/file3 >> $seqres.full
77 _mwrite_byte 0x62 $((blksz * 16 - 34)) 17 $((blksz * 48 - 3)) $testdir/file2 >> $seqres.full
78 _mwrite_byte 0x62 $((blksz * 16 - 34)) 17 $((blksz * 48 - 3)) $testdir/file3 >> $seqres.full
80 _mwrite_byte 0x62 $((blksz * 48 - 20)) 17 $((blksz * 48 - 3)) $testdir/file2 >> $seqres.full
81 _mwrite_byte 0x62 $((blksz * 48 - 20)) 17 $((blksz * 48 - 3)) $testdir/file3 >> $seqres.full
85 md5sum $testdir/file1 | _filter_test_dir
86 md5sum $testdir/file2 | _filter_test_dir
87 md5sum $testdir/file3 | _filter_test_dir
89 cmp -s $testdir/file1 $testdir/file2 || echo "Files 1-2 do not match (intentional)"
90 cmp -s $testdir/file1 $testdir/file3 || echo "Files 1-3 do not match (intentional)"
91 cmp -s $testdir/file2 $testdir/file3 || echo "Files 2-3 do not match"
93 echo "Compare the CoW'd section to the before file"
94 _compare_range $testdir/file1 0 $testdir/file2 0 17 \
95 || echo "Start sections do not match (intentional)"
97 _compare_range $testdir/file1 $((blksz * 16 - 34)) \
98 $testdir/file2 $((blksz * 16 - 34)) 17 \
99 || echo "Middle sections do not match (intentional)"
101 _compare_range $testdir/file1 $((blksz * 48 - 20)) \
102 $testdir/file2 $((blksz * 48 - 20)) 17 \
103 || echo "End sections do not match (intentional)"
105 echo "Compare the CoW'd section to the after file"
106 _compare_range $testdir/file2 0 $testdir/file3 0 17 \
107 || echo "Start sections do not match"
109 _compare_range $testdir/file2 $((blksz * 16 - 34)) \
110 $testdir/file3 $((blksz * 16 - 34)) 17 \
111 || echo "Middle sections do not match"
113 _compare_range $testdir/file2 $((blksz * 48 - 20)) \
114 $testdir/file3 $((blksz * 48 - 20)) 17 \
115 || echo "End sections do not match"
117 echo "Compare the not CoW'd sections"
118 _compare_range $testdir/file1 18 $testdir/file2 18 17 \
119 || echo "Start sections of 1-2 do not match"
121 _compare_range $testdir/file2 18 $testdir/file3 18 17 \
122 || echo "Start sections of 2-3 do not match"
125 _compare_range $testdir/file1 $((blksz * 16 - 17)) \
126 $testdir/file2 $((blksz * 16 - 17)) 82 \
127 || echo "Middle sections of 1-2 do not match"
129 _compare_range $testdir/file2 $((blksz * 16 - 17)) \
130 $testdir/file3 $((blksz * 16 - 17)) 82 \
131 || echo "Middle sections of 2-3 do not match"
133 _compare_range $testdir/file1 $((blksz * 48 - 120)) \
134 $testdir/file2 $((blksz * 48 - 120)) 100 \
135 || echo "End sections of 1-2 do not match"
137 _compare_range $testdir/file2 $((blksz * 48 - 120)) \
138 $testdir/file3 $((blksz * 48 - 120)) 100 \
139 || echo "End sections of 2-3 do not match"
142 _compare_range $testdir/file1 $((blksz * 14)) \
143 $testdir/file2 $((blksz * 14)) $blksz \
144 || echo "Untouched sections of 1-2 do not match"
146 _compare_range $testdir/file2 $((blksz * 14)) \
147 $testdir/file3 $((blksz * 14)) $blksz \
148 || echo "Untouched sections of 2-3 do not match"