xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / ceph / 001
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. ceph/001
6 #
7 # Test remote copy operation (CEPH_OSD_OP_COPY_FROM) with several combinations
8 # of both object sizes and copy sizes.  It also uses several combinations of
9 # copy ranges.  For example, copying the 1st object in the src file into
10 # 1) the beginning (1st object) of dst file, 2) the end (last object) of dst
11 # file and 3) the middle of the dst file.
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1    # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -rf $tmp.*
26 }
27
28 # get standard environment
29 . common/rc
30 . common/filter
31 . common/attr
32 . common/reflink
33
34 # real QA test starts here
35 _supported_fs ceph
36
37 _require_xfs_io_command "copy_range"
38 _require_attrs
39 _require_test
40
41 workdir=$TEST_DIR/test-$seq
42 rm -rf $workdir
43 mkdir $workdir
44 rm -f $seqres.full
45
46 check_range()
47 {
48         local file=$1
49         local off0=$2
50         local off1=$3
51         local val=$4
52         _read_range $file $off0 $off1 | grep -v -q $val
53         [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
54 }
55
56 run_copy_range_tests()
57 {
58         objsz=$1
59         halfobj=$(($objsz / 2))
60         file="$workdir/file-$objsz"
61         copy="$workdir/copy-$objsz"
62         dest="$workdir/dest-$objsz"
63
64         # create files and set file layout, which needs to be done before
65         # writing any data
66         _ceph_create_file_layout $file $objsz 1 $objsz
67         _ceph_create_file_layout $copy $objsz 1 $objsz
68         _ceph_create_file_layout $dest $objsz 1 $objsz
69
70         # file containing 3 objects with 'aaaa|bbbb|cccc'
71         $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
72         $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
73         $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
74
75         echo "  Copy whole file (3 objects):"
76         echo "    aaaa|bbbb|cccc => aaaa|bbbb|cccc"
77         $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$copy"
78         cmp $file $copy
79
80         echo "  Copy single object to beginning:"
81         # dest file with 3 objects with 'dddd|dddd|dddd'
82         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 3))" $dest >> $seqres.full 2>&1
83
84         echo "    dddd|dddd|dddd => aaaa|dddd|dddd"
85         $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $objsz $file" "$dest"
86         check_range $dest 0 $objsz 61
87         check_range $dest $objsz $(($objsz * 2)) 64
88
89         echo "    aaaa|dddd|dddd => bbbb|dddd|dddd"
90         $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$dest"
91         check_range $dest 0 $objsz 62
92         check_range $dest $objsz $(($objsz * 2)) 64
93
94         echo "    bbbb|dddd|dddd => cccc|dddd|dddd"
95         $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d 0 -l $objsz $file" "$dest"
96         check_range $dest 0 $objsz 63
97         check_range $dest $objsz $(($objsz * 2)) 64
98
99         echo "  Copy single object to middle:"
100
101         echo "    cccc|dddd|dddd => cccc|aaaa|dddd"
102         $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $objsz $file" "$dest"
103         check_range $dest 0 $objsz 63
104         check_range $dest $objsz $objsz 61
105         check_range $dest $(($objsz * 2)) $objsz 64
106
107         echo "    cccc|aaaa|dddd => cccc|bbbb|dddd"
108         $XFS_IO_PROG -c "copy_range -s $objsz -d $objsz -l $objsz $file" "$dest"
109         check_range $dest 0 $objsz 63
110         check_range $dest $objsz $objsz 62
111         check_range $dest $(($objsz * 2)) $objsz 64
112
113         echo "    cccc|bbbb|dddd => cccc|cccc|dddd"
114         $XFS_IO_PROG -c "copy_range -s $((objsz * 2)) -d $objsz -l $objsz $file" "$dest"
115         check_range $dest 0 $objsz 63
116         check_range $dest $objsz $objsz 63
117         check_range $dest $(($objsz * 2)) $objsz 64
118
119         echo "  Copy single object to end:"
120
121         echo "    cccc|cccc|dddd => cccc|cccc|aaaa"
122         $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$dest"
123         check_range $dest 0 $(($objsz * 2)) 63
124         check_range $dest $(($objsz * 2)) $objsz 61
125
126         echo "    cccc|cccc|aaaa => cccc|cccc|bbbb"
127         $XFS_IO_PROG -c "copy_range -s $objsz -d $(($objsz * 2)) -l $objsz $file" "$dest"
128         check_range $dest 0 $(($objsz * 2)) 63
129         check_range $dest $(($objsz * 2)) $objsz 62
130
131         echo "    cccc|cccc|aaaa => cccc|cccc|cccc"
132         $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $(($objsz * 2)) -l $objsz $file" "$dest"
133         check_range $dest 0 $(($objsz * 3)) 63
134
135         echo "  Copy 2 objects to beginning:"
136
137         echo "    cccc|cccc|cccc => aaaa|bbbb|cccc"
138         $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 2)) $file" "$dest"
139         cmp $file $dest
140
141         echo "    aaaa|bbbb|cccc => bbbb|cccc|cccc"
142         $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $(($objsz * 2)) $file" "$dest"
143         check_range $dest 0 $objsz 62
144         check_range $dest $objsz $(($objsz * 2)) 63
145
146         echo "  Copy 2 objects to end:"
147
148         echo "    bbbb|cccc|cccc => bbbb|aaaa|bbbb"
149         $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $(($objsz * 2)) $file" "$dest"
150         check_range $dest 0 $objsz 62
151         check_range $dest $objsz $objsz 61
152         check_range $dest $(($objsz * 2)) $objsz 62
153
154         echo "    bbbb|aaaa|bbbb => bbbb|bbbb|cccc"
155         $XFS_IO_PROG -c "copy_range -s $objsz -d $objsz -l $(($objsz * 2)) $file" "$dest"
156         check_range $dest 0 $(($objsz * 2)) 62
157         check_range $dest $(($objsz * 2)) $objsz 63
158
159         echo "  Append 1 object:"
160
161         echo "    bbbb|bbbb|cccc => bbbb|bbbb|cccc|aaaa"
162         $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 3)) -l $objsz $file" "$dest"
163         check_range $dest 0 $(($objsz * 2)) 62
164         check_range $dest $(($objsz * 2)) $objsz 63
165         check_range $dest $(($objsz * 3)) $objsz 61
166
167         echo "  Cross object boundary (no full object copy)"
168         echo "    dddd|dddd|dddd|dddd => ddaa|aadd|dddd|dddd"
169         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
170         $XFS_IO_PROG -c "copy_range -s 0 -d $halfobj -l $objsz $file" "$dest"
171         check_range $dest 0 $halfobj 64
172         check_range $dest $halfobj $objsz 61
173         check_range $dest $(($objsz + $halfobj)) $(($objsz * 2 + $halfobj)) 64
174
175         echo "    dddd|dddd|dddd|dddd => ddaa|bbdd|dddd|dddd"
176         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
177         $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $objsz $file" "$dest"
178         check_range $dest 0 $halfobj 64
179         check_range $dest $halfobj $halfobj 61
180         check_range $dest $objsz $halfobj 62
181         check_range $dest $(($objsz + $halfobj)) $(($objsz * 2 + $halfobj)) 64
182
183         echo "  Cross object boundaries (with full object copy)"
184         echo "    dddd|dddd|dddd|dddd => ddaa|bbbb|dddd|dddd"
185         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
186         $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $(($objsz + $halfobj)) $file" "$dest"
187         check_range $dest 0 $halfobj 64
188         check_range $dest $halfobj $halfobj 61
189         check_range $dest $objsz $objsz 62
190         check_range $dest $(($objsz * 2)) $(($objsz * 2)) 64
191
192         echo "    dddd|dddd|dddd|dddd => ddaa|bbbb|ccdd|dddd"
193         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
194         $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $(($objsz * 2)) $file" "$dest"
195         check_range $dest 0 $halfobj 64
196         check_range $dest $halfobj $halfobj 61
197         check_range $dest $objsz $objsz 62
198         check_range $dest $(($objsz * 2)) $halfobj 63
199         check_range $dest $(($objsz * 2 + $halfobj)) $(($objsz + $halfobj)) 64
200
201         echo "    dddd|dddd|dddd|dddd => dddd|aaaa|bbdd|dddd"
202         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
203         $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $(($objsz + $halfobj)) $file" "$dest"
204         check_range $dest 0 $objsz 64
205         check_range $dest $objsz $objsz 61
206         check_range $dest $(($objsz * 2)) $halfobj 62
207         check_range $dest $(($objsz * 2 + $halfobj)) $(($objsz + $halfobj)) 64
208
209         echo "  Cross object boundaries (with 2 full object copies)"
210         echo "    dddd|dddd|dddd|dddd => ddaa|aabb|bbcc|ccdd"
211         $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
212         $XFS_IO_PROG -c "copy_range -s 0 -d $halfobj -l $(($objsz * 3)) $file" "$dest"
213         check_range $dest 0 $halfobj 64
214         check_range $dest $halfobj $objsz 61
215         check_range $dest $(($objsz + $halfobj)) $objsz 62
216         check_range $dest $(($objsz * 2 + $halfobj)) $objsz 63
217         check_range $dest $(($objsz * 3 + $halfobj)) $halfobj 64
218
219 }
220
221 echo "Object size: 65536" # CEPH_MIN_STRIPE_UNIT
222 run_copy_range_tests 65536
223 echo "Object size: 1M"
224 run_copy_range_tests 1048576
225 echo "Object size: 4M"
226 run_copy_range_tests 4194304
227 # the max object size is 1TB, but by default OSDs only accept a max of 128M objects
228 echo "Object size: 128M"
229 run_copy_range_tests 134217728
230
231 # success, all done
232 status=0
233 exit