2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
5 # FS QA Test No. ceph/001
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.
14 _begin_fstest auto quick copy_range
16 # get standard environment
21 # real QA test starts here
24 _require_xfs_io_command "copy_range"
28 workdir=$TEST_DIR/test-$seq
38 _read_range $file $off0 $off1 | grep -v -q $val
39 [ $? -eq 0 ] && echo "file $file is not '$val' in [ $off0 $off1 ]"
42 run_copy_range_tests()
45 halfobj=$(($objsz / 2))
46 file="$workdir/file-$objsz"
47 copy="$workdir/copy-$objsz"
48 dest="$workdir/dest-$objsz"
50 # create files and set file layout, which needs to be done before
52 _ceph_create_file_layout $file $objsz 1 $objsz
53 _ceph_create_file_layout $copy $objsz 1 $objsz
54 _ceph_create_file_layout $dest $objsz 1 $objsz
56 # file containing 3 objects with 'aaaa|bbbb|cccc'
57 $XFS_IO_PROG -c "pwrite -S 0x61 0 $objsz" $file >> $seqres.full 2>&1
58 $XFS_IO_PROG -c "pwrite -S 0x62 $objsz $objsz" $file >> $seqres.full 2>&1
59 $XFS_IO_PROG -c "pwrite -S 0x63 $(($objsz * 2)) $objsz" $file >> $seqres.full 2>&1
61 echo " Copy whole file (3 objects):"
62 echo " aaaa|bbbb|cccc => aaaa|bbbb|cccc"
63 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 3)) $file" "$copy"
66 echo " Copy single object to beginning:"
67 # dest file with 3 objects with 'dddd|dddd|dddd'
68 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 3))" $dest >> $seqres.full 2>&1
70 echo " dddd|dddd|dddd => aaaa|dddd|dddd"
71 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $objsz $file" "$dest"
72 check_range $dest 0 $objsz 61
73 check_range $dest $objsz $(($objsz * 2)) 64
75 echo " aaaa|dddd|dddd => bbbb|dddd|dddd"
76 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $objsz $file" "$dest"
77 check_range $dest 0 $objsz 62
78 check_range $dest $objsz $(($objsz * 2)) 64
80 echo " bbbb|dddd|dddd => cccc|dddd|dddd"
81 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d 0 -l $objsz $file" "$dest"
82 check_range $dest 0 $objsz 63
83 check_range $dest $objsz $(($objsz * 2)) 64
85 echo " Copy single object to middle:"
87 echo " cccc|dddd|dddd => cccc|aaaa|dddd"
88 $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $objsz $file" "$dest"
89 check_range $dest 0 $objsz 63
90 check_range $dest $objsz $objsz 61
91 check_range $dest $(($objsz * 2)) $objsz 64
93 echo " cccc|aaaa|dddd => cccc|bbbb|dddd"
94 $XFS_IO_PROG -c "copy_range -s $objsz -d $objsz -l $objsz $file" "$dest"
95 check_range $dest 0 $objsz 63
96 check_range $dest $objsz $objsz 62
97 check_range $dest $(($objsz * 2)) $objsz 64
99 echo " cccc|bbbb|dddd => cccc|cccc|dddd"
100 $XFS_IO_PROG -c "copy_range -s $((objsz * 2)) -d $objsz -l $objsz $file" "$dest"
101 check_range $dest 0 $objsz 63
102 check_range $dest $objsz $objsz 63
103 check_range $dest $(($objsz * 2)) $objsz 64
105 echo " Copy single object to end:"
107 echo " cccc|cccc|dddd => cccc|cccc|aaaa"
108 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 2)) -l $objsz $file" "$dest"
109 check_range $dest 0 $(($objsz * 2)) 63
110 check_range $dest $(($objsz * 2)) $objsz 61
112 echo " cccc|cccc|aaaa => cccc|cccc|bbbb"
113 $XFS_IO_PROG -c "copy_range -s $objsz -d $(($objsz * 2)) -l $objsz $file" "$dest"
114 check_range $dest 0 $(($objsz * 2)) 63
115 check_range $dest $(($objsz * 2)) $objsz 62
117 echo " cccc|cccc|aaaa => cccc|cccc|cccc"
118 $XFS_IO_PROG -c "copy_range -s $(($objsz * 2)) -d $(($objsz * 2)) -l $objsz $file" "$dest"
119 check_range $dest 0 $(($objsz * 3)) 63
121 echo " Copy 2 objects to beginning:"
123 echo " cccc|cccc|cccc => aaaa|bbbb|cccc"
124 $XFS_IO_PROG -c "copy_range -s 0 -d 0 -l $(($objsz * 2)) $file" "$dest"
127 echo " aaaa|bbbb|cccc => bbbb|cccc|cccc"
128 $XFS_IO_PROG -c "copy_range -s $objsz -d 0 -l $(($objsz * 2)) $file" "$dest"
129 check_range $dest 0 $objsz 62
130 check_range $dest $objsz $(($objsz * 2)) 63
132 echo " Copy 2 objects to end:"
134 echo " bbbb|cccc|cccc => bbbb|aaaa|bbbb"
135 $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $(($objsz * 2)) $file" "$dest"
136 check_range $dest 0 $objsz 62
137 check_range $dest $objsz $objsz 61
138 check_range $dest $(($objsz * 2)) $objsz 62
140 echo " bbbb|aaaa|bbbb => bbbb|bbbb|cccc"
141 $XFS_IO_PROG -c "copy_range -s $objsz -d $objsz -l $(($objsz * 2)) $file" "$dest"
142 check_range $dest 0 $(($objsz * 2)) 62
143 check_range $dest $(($objsz * 2)) $objsz 63
145 echo " Append 1 object:"
147 echo " bbbb|bbbb|cccc => bbbb|bbbb|cccc|aaaa"
148 $XFS_IO_PROG -c "copy_range -s 0 -d $(($objsz * 3)) -l $objsz $file" "$dest"
149 check_range $dest 0 $(($objsz * 2)) 62
150 check_range $dest $(($objsz * 2)) $objsz 63
151 check_range $dest $(($objsz * 3)) $objsz 61
153 echo " Cross object boundary (no full object copy)"
154 echo " dddd|dddd|dddd|dddd => ddaa|aadd|dddd|dddd"
155 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
156 $XFS_IO_PROG -c "copy_range -s 0 -d $halfobj -l $objsz $file" "$dest"
157 check_range $dest 0 $halfobj 64
158 check_range $dest $halfobj $objsz 61
159 check_range $dest $(($objsz + $halfobj)) $(($objsz * 2 + $halfobj)) 64
161 echo " dddd|dddd|dddd|dddd => ddaa|bbdd|dddd|dddd"
162 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
163 $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $objsz $file" "$dest"
164 check_range $dest 0 $halfobj 64
165 check_range $dest $halfobj $halfobj 61
166 check_range $dest $objsz $halfobj 62
167 check_range $dest $(($objsz + $halfobj)) $(($objsz * 2 + $halfobj)) 64
169 echo " Cross object boundaries (with full object copy)"
170 echo " dddd|dddd|dddd|dddd => ddaa|bbbb|dddd|dddd"
171 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
172 $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $(($objsz + $halfobj)) $file" "$dest"
173 check_range $dest 0 $halfobj 64
174 check_range $dest $halfobj $halfobj 61
175 check_range $dest $objsz $objsz 62
176 check_range $dest $(($objsz * 2)) $(($objsz * 2)) 64
178 echo " dddd|dddd|dddd|dddd => ddaa|bbbb|ccdd|dddd"
179 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
180 $XFS_IO_PROG -c "copy_range -s $halfobj -d $halfobj -l $(($objsz * 2)) $file" "$dest"
181 check_range $dest 0 $halfobj 64
182 check_range $dest $halfobj $halfobj 61
183 check_range $dest $objsz $objsz 62
184 check_range $dest $(($objsz * 2)) $halfobj 63
185 check_range $dest $(($objsz * 2 + $halfobj)) $(($objsz + $halfobj)) 64
187 echo " dddd|dddd|dddd|dddd => dddd|aaaa|bbdd|dddd"
188 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
189 $XFS_IO_PROG -c "copy_range -s 0 -d $objsz -l $(($objsz + $halfobj)) $file" "$dest"
190 check_range $dest 0 $objsz 64
191 check_range $dest $objsz $objsz 61
192 check_range $dest $(($objsz * 2)) $halfobj 62
193 check_range $dest $(($objsz * 2 + $halfobj)) $(($objsz + $halfobj)) 64
195 echo " Cross object boundaries (with 2 full object copies)"
196 echo " dddd|dddd|dddd|dddd => ddaa|aabb|bbcc|ccdd"
197 $XFS_IO_PROG -c "pwrite -S 0x64 0 $(($objsz * 4))" $dest >> $seqres.full 2>&1
198 $XFS_IO_PROG -c "copy_range -s 0 -d $halfobj -l $(($objsz * 3)) $file" "$dest"
199 check_range $dest 0 $halfobj 64
200 check_range $dest $halfobj $objsz 61
201 check_range $dest $(($objsz + $halfobj)) $objsz 62
202 check_range $dest $(($objsz * 2 + $halfobj)) $objsz 63
203 check_range $dest $(($objsz * 3 + $halfobj)) $halfobj 64
207 echo "Object size: 65536" # CEPH_MIN_STRIPE_UNIT
208 run_copy_range_tests 65536
209 echo "Object size: 1M"
210 run_copy_range_tests 1048576
211 echo "Object size: 4M"
212 run_copy_range_tests 4194304
213 # the max object size is 1TB, but by default OSDs only accept a max of 128M objects
214 echo "Object size: 128M"
215 run_copy_range_tests 134217728