4 # Ensuring that copy on write in direct-io mode works:
5 # - Reflink two files together
6 # - Write to the beginning, middle, and end in direct-io mode
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
54 testdir=$TEST_DIR/test-$seq
58 echo "Create the original files"
60 _pwrite_byte 0x61 0 $((blksz * 48 - 3)) $testdir/file1 >> $seqres.full
61 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
62 _pwrite_byte 0x61 0 $((blksz * 48 - 3)) $testdir/file3 >> $seqres.full
66 md5sum $testdir/file1 | _filter_test_dir
67 md5sum $testdir/file2 | _filter_test_dir
68 md5sum $testdir/file3 | _filter_test_dir
70 cmp -s $testdir/file1 $testdir/file2 || echo "Files 1-2 should match"
71 cmp -s $testdir/file1 $testdir/file3 || echo "Files 1-3 should match"
72 cmp -s $testdir/file2 $testdir/file3 || echo "Files 2-3 should match"
74 echo "directio CoW the second file"
75 _pwrite_byte 0x62 0 $blksz $testdir/file2 -d >> $seqres.full
76 _pwrite_byte 0x62 0 $blksz $testdir/file3 -d >> $seqres.full
78 _pwrite_byte 0x62 $((blksz * 16 - 512)) 512 $testdir/file2 -d >> $seqres.full
79 _pwrite_byte 0x62 $((blksz * 16 - 512)) 512 $testdir/file3 -d >> $seqres.full
81 _pwrite_byte 0x62 $((blksz * 48)) $blksz $testdir/file2 -d >> $seqres.full
82 _pwrite_byte 0x62 $((blksz * 48)) $blksz $testdir/file3 -d >> $seqres.full
86 md5sum $testdir/file1 | _filter_test_dir
87 md5sum $testdir/file2 | _filter_test_dir
88 md5sum $testdir/file3 | _filter_test_dir
90 cmp -s $testdir/file1 $testdir/file2 || echo "Files 1-2 should not match (intentional)"
91 cmp -s $testdir/file1 $testdir/file3 || echo "Files 1-3 should not match (intentional)"
92 cmp -s $testdir/file2 $testdir/file3 || echo "Files 2-3 should match"
94 echo "Compare the CoW'd section to the before file"
95 _compare_range $testdir/file1 0 $testdir/file2 0 $blksz \
96 || echo "Start sections do not match (intentional)"
98 _compare_range $testdir/file1 $((blksz * 16 - 512)) \
99 $testdir/file2 $((blksz * 16 - 512)) 512 \
100 || echo "Middle sections do not match (intentional)"
102 _compare_range $testdir/file1 $((blksz * 48 - 512)) \
103 $testdir/file2 $((blksz * 48 - 512)) $blksz \
104 || echo "End sections do not match (intentional)"
106 echo "Compare the CoW'd section to the after file"
107 _compare_range $testdir/file2 0 $testdir/file3 0 $blksz \
108 || echo "Start sections do not match"
110 _compare_range $testdir/file2 $((blksz * 16 - 512)) \
111 $testdir/file3 $((blksz * 16 - 512)) 512 \
112 || echo "Middle sections do not match"
114 _compare_range $testdir/file2 $((blksz * 48 - 512)) \
115 $testdir/file3 $((blksz * 48 - 512)) $blksz \
116 || echo "End sections do not match"
118 echo "Compare the not CoW'd sections"
119 _compare_range $testdir/file1 $blksz $testdir/file2 $blksz 512 \
120 || echo "Start sections of 1-2 do not match"
121 _compare_range $testdir/file2 $blksz $testdir/file3 $blksz 512 \
122 || echo "Start sections of 2-3 do not match"
125 _compare_range $testdir/file1 $((blksz * 16 - 1024)) \
126 $testdir/file2 $((blksz * 16 - 1024)) 512 \
127 || echo "Middle sections of 1-2 do not match"
129 _compare_range $testdir/file2 $((blksz * 16 - 1024)) \
130 $testdir/file3 $((blksz * 16 - 1024)) 512 \
131 || echo "Middle sections of 2-3 do not match"
133 _compare_range $testdir/file1 $((blksz * 48 - 1024)) \
134 $testdir/file2 $((blksz * 48 - 1024)) 512 \
135 || echo "End sections of 1-2 do not match"
137 _compare_range $testdir/file2 $((blksz * 48 - 1024)) \
138 $testdir/file3 $((blksz * 48 - 1024)) 512 \
139 || echo "End sections of 2-3 do not match"
142 _compare_range $testdir/file1 $((blksz * 16)) \
143 $testdir/file2 $((blksz * 16)) 512 \
144 || echo "Untouched sections of 1-2 do not match"
146 _compare_range $testdir/file2 $((blksz * 16)) \
147 $testdir/file3 $((blksz * 16)) 512 \
148 || echo "Untouched sections of 2-3 do not match"