Commit | Line | Data |
---|---|---|
e29d1b70 JA |
1 | /* |
2 | * IO verification helpers | |
3 | */ | |
4 | #include <unistd.h> | |
5 | #include <fcntl.h> | |
6 | #include <string.h> | |
97af62ce | 7 | #include <assert.h> |
e8462bd8 | 8 | #include <pthread.h> |
79402a12 | 9 | #include <libgen.h> |
e29d1b70 JA |
10 | |
11 | #include "fio.h" | |
4f5af7b2 | 12 | #include "verify.h" |
0d29de83 | 13 | #include "trim.h" |
637ef8d9 | 14 | #include "lib/rand.h" |
51aa2da8 | 15 | #include "lib/hweight.h" |
e29d1b70 | 16 | |
eef6eea1 JA |
17 | #include "crc/md5.h" |
18 | #include "crc/crc64.h" | |
19 | #include "crc/crc32.h" | |
bac39e0e | 20 | #include "crc/crc32c.h" |
eef6eea1 JA |
21 | #include "crc/crc16.h" |
22 | #include "crc/crc7.h" | |
23 | #include "crc/sha256.h" | |
24 | #include "crc/sha512.h" | |
7c353ceb | 25 | #include "crc/sha1.h" |
844ea602 | 26 | #include "crc/xxhash.h" |
cd14cc10 | 27 | |
7d9fb455 JA |
28 | static void populate_hdr(struct thread_data *td, struct io_u *io_u, |
29 | struct verify_header *hdr, unsigned int header_num, | |
30 | unsigned int header_len); | |
31 | ||
ce35b1ec JA |
32 | void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len) |
33 | { | |
632ae347 | 34 | fill_pattern(p, len, td->o.buffer_pattern, td->o.buffer_pattern_bytes); |
ce35b1ec JA |
35 | } |
36 | ||
37 | void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, | |
38 | struct io_u *io_u, unsigned long seed, int use_seed) | |
39 | { | |
40 | if (!td->o.verify_pattern_bytes) { | |
41 | dprint(FD_VERIFY, "fill random bytes len=%u\n", len); | |
42 | ||
43 | if (use_seed) | |
44 | __fill_random_buf(p, len, seed); | |
45 | else | |
d6b72507 | 46 | io_u->rand_seed = fill_random_buf(&td->verify_state, p, len); |
ce35b1ec JA |
47 | return; |
48 | } | |
c4b6117b | 49 | |
ce35b1ec JA |
50 | if (io_u->buf_filled_len >= len) { |
51 | dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n", | |
52 | td->o.verify_pattern_bytes, len); | |
53 | return; | |
54 | } | |
55 | ||
632ae347 | 56 | fill_pattern(p, len, td->o.verify_pattern, td->o.verify_pattern_bytes); |
ce35b1ec JA |
57 | |
58 | io_u->buf_filled_len = len; | |
59 | } | |
60 | ||
cfbcd0dc JA |
61 | static unsigned int get_hdr_inc(struct thread_data *td, struct io_u *io_u) |
62 | { | |
63 | unsigned int hdr_inc; | |
64 | ||
65 | hdr_inc = io_u->buflen; | |
8a99fdf6 | 66 | if (td->o.verify_interval && td->o.verify_interval <= io_u->buflen) |
cfbcd0dc JA |
67 | hdr_inc = td->o.verify_interval; |
68 | ||
69 | return hdr_inc; | |
70 | } | |
71 | ||
c50ca7bd JA |
72 | static void fill_pattern_headers(struct thread_data *td, struct io_u *io_u, |
73 | unsigned long seed, int use_seed) | |
74 | { | |
75 | unsigned int hdr_inc, header_num; | |
76 | struct verify_header *hdr; | |
77 | void *p = io_u->buf; | |
78 | ||
ce35b1ec | 79 | fill_verify_pattern(td, p, io_u->buflen, io_u, seed, use_seed); |
c50ca7bd | 80 | |
cfbcd0dc | 81 | hdr_inc = get_hdr_inc(td, io_u); |
c50ca7bd JA |
82 | header_num = 0; |
83 | for (; p < io_u->buf + io_u->buflen; p += hdr_inc) { | |
84 | hdr = p; | |
85 | populate_hdr(td, io_u, hdr, header_num, hdr_inc); | |
86 | header_num++; | |
87 | } | |
88 | } | |
89 | ||
4764aec9 | 90 | static void memswp(void *buf1, void *buf2, unsigned int len) |
546a9142 | 91 | { |
dee6de74 SL |
92 | char swap[200]; |
93 | ||
94 | assert(len <= sizeof(swap)); | |
90059d65 | 95 | |
546a9142 SL |
96 | memcpy(&swap, buf1, len); |
97 | memcpy(buf1, buf2, len); | |
98 | memcpy(buf2, &swap, len); | |
99 | } | |
100 | ||
e29d1b70 JA |
101 | static void hexdump(void *buffer, int len) |
102 | { | |
103 | unsigned char *p = buffer; | |
104 | int i; | |
105 | ||
106 | for (i = 0; i < len; i++) | |
bfacf389 JA |
107 | log_err("%02x", p[i]); |
108 | log_err("\n"); | |
e29d1b70 JA |
109 | } |
110 | ||
87677832 | 111 | /* |
de8f6de9 | 112 | * Prepare for separation of verify_header and checksum header |
87677832 | 113 | */ |
546dfd9f | 114 | static inline unsigned int __hdr_size(int verify_type) |
87677832 | 115 | { |
03e20d68 | 116 | unsigned int len = 0; |
87677832 | 117 | |
546dfd9f JA |
118 | switch (verify_type) { |
119 | case VERIFY_NONE: | |
120 | case VERIFY_NULL: | |
121 | len = 0; | |
122 | break; | |
123 | case VERIFY_MD5: | |
124 | len = sizeof(struct vhdr_md5); | |
125 | break; | |
126 | case VERIFY_CRC64: | |
127 | len = sizeof(struct vhdr_crc64); | |
128 | break; | |
bac39e0e | 129 | case VERIFY_CRC32C: |
546dfd9f | 130 | case VERIFY_CRC32: |
3845591f | 131 | case VERIFY_CRC32C_INTEL: |
546dfd9f JA |
132 | len = sizeof(struct vhdr_crc32); |
133 | break; | |
134 | case VERIFY_CRC16: | |
135 | len = sizeof(struct vhdr_crc16); | |
136 | break; | |
137 | case VERIFY_CRC7: | |
138 | len = sizeof(struct vhdr_crc7); | |
139 | break; | |
140 | case VERIFY_SHA256: | |
141 | len = sizeof(struct vhdr_sha256); | |
142 | break; | |
143 | case VERIFY_SHA512: | |
144 | len = sizeof(struct vhdr_sha512); | |
145 | break; | |
844ea602 JA |
146 | case VERIFY_XXHASH: |
147 | len = sizeof(struct vhdr_xxhash); | |
148 | break; | |
7437ee87 SL |
149 | case VERIFY_META: |
150 | len = sizeof(struct vhdr_meta); | |
151 | break; | |
7c353ceb JA |
152 | case VERIFY_SHA1: |
153 | len = sizeof(struct vhdr_sha1); | |
154 | break; | |
92bf48d5 JA |
155 | case VERIFY_PATTERN: |
156 | len = 0; | |
157 | break; | |
546dfd9f JA |
158 | default: |
159 | log_err("fio: unknown verify header!\n"); | |
160 | assert(0); | |
161 | } | |
162 | ||
163 | return len + sizeof(struct verify_header); | |
87677832 JA |
164 | } |
165 | ||
166 | static inline unsigned int hdr_size(struct verify_header *hdr) | |
167 | { | |
546dfd9f JA |
168 | return __hdr_size(hdr->verify_type); |
169 | } | |
170 | ||
171 | static void *hdr_priv(struct verify_header *hdr) | |
172 | { | |
173 | void *priv = hdr; | |
174 | ||
175 | return priv + sizeof(struct verify_header); | |
87677832 JA |
176 | } |
177 | ||
936216f8 JA |
178 | /* |
179 | * Verify container, pass info to verify handlers and allow them to | |
180 | * pass info back in case of error | |
181 | */ | |
182 | struct vcont { | |
183 | /* | |
184 | * Input | |
185 | */ | |
186 | struct io_u *io_u; | |
187 | unsigned int hdr_num; | |
7d9fb455 | 188 | struct thread_data *td; |
936216f8 JA |
189 | |
190 | /* | |
191 | * Output, only valid in case of error | |
192 | */ | |
bfacf389 JA |
193 | const char *name; |
194 | void *good_crc; | |
195 | void *bad_crc; | |
936216f8 JA |
196 | unsigned int crc_len; |
197 | }; | |
198 | ||
dacbbb88 JA |
199 | #define DUMP_BUF_SZ 255 |
200 | static int dump_buf_warned; | |
201 | ||
c50ca7bd JA |
202 | static void dump_buf(char *buf, unsigned int len, unsigned long long offset, |
203 | const char *type, struct fio_file *f) | |
7d9fb455 | 204 | { |
dacbbb88 JA |
205 | char *ptr, fname[DUMP_BUF_SZ]; |
206 | size_t buf_left = DUMP_BUF_SZ; | |
7d9fb455 JA |
207 | int ret, fd; |
208 | ||
6f260b31 | 209 | ptr = strdup(f->file_name); |
c50ca7bd | 210 | |
dacbbb88 JA |
211 | fname[DUMP_BUF_SZ - 1] = '\0'; |
212 | strncpy(fname, basename(ptr), DUMP_BUF_SZ - 1); | |
213 | ||
214 | buf_left -= strlen(fname); | |
215 | if (buf_left <= 0) { | |
216 | if (!dump_buf_warned) { | |
217 | log_err("fio: verify failure dump buffer too small\n"); | |
218 | dump_buf_warned = 1; | |
219 | } | |
220 | free(ptr); | |
221 | return; | |
222 | } | |
223 | ||
224 | snprintf(fname + strlen(fname), buf_left, ".%llu.%s", offset, type); | |
7d9fb455 JA |
225 | |
226 | fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644); | |
227 | if (fd < 0) { | |
228 | perror("open verify buf file"); | |
229 | return; | |
230 | } | |
231 | ||
232 | while (len) { | |
233 | ret = write(fd, buf, len); | |
234 | if (!ret) | |
235 | break; | |
236 | else if (ret < 0) { | |
237 | perror("write verify buf file"); | |
238 | break; | |
239 | } | |
240 | len -= ret; | |
241 | buf += ret; | |
242 | } | |
243 | ||
244 | close(fd); | |
c50ca7bd | 245 | log_err(" %s data dumped as %s\n", type, fname); |
6f260b31 | 246 | free(ptr); |
7d9fb455 JA |
247 | } |
248 | ||
c50ca7bd JA |
249 | /* |
250 | * Dump the contents of the read block and re-generate the correct data | |
251 | * and dump that too. | |
252 | */ | |
7d9fb455 JA |
253 | static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc) |
254 | { | |
255 | struct thread_data *td = vc->td; | |
256 | struct io_u *io_u = vc->io_u; | |
257 | unsigned long hdr_offset; | |
7d9fb455 | 258 | struct io_u dummy; |
c50ca7bd | 259 | void *buf; |
7d9fb455 | 260 | |
0dce9bc9 SL |
261 | if (!td->o.verify_dump) |
262 | return; | |
263 | ||
c50ca7bd JA |
264 | /* |
265 | * Dump the contents we just read off disk | |
266 | */ | |
7d9fb455 JA |
267 | hdr_offset = vc->hdr_num * hdr->len; |
268 | ||
c50ca7bd JA |
269 | dump_buf(io_u->buf + hdr_offset, hdr->len, io_u->offset + hdr_offset, |
270 | "received", vc->io_u->file); | |
7d9fb455 | 271 | |
c50ca7bd JA |
272 | /* |
273 | * Allocate a new buf and re-generate the original data | |
274 | */ | |
275 | buf = malloc(io_u->buflen); | |
7d9fb455 | 276 | dummy = *io_u; |
c50ca7bd | 277 | dummy.buf = buf; |
4aae38a6 | 278 | dummy.rand_seed = hdr->rand_seed; |
cfbcd0dc | 279 | dummy.buf_filled_len = 0; |
0d81daf9 | 280 | dummy.buflen = io_u->buflen; |
7d9fb455 | 281 | |
c50ca7bd | 282 | fill_pattern_headers(td, &dummy, hdr->rand_seed, 1); |
7d9fb455 | 283 | |
c50ca7bd JA |
284 | dump_buf(buf + hdr_offset, hdr->len, io_u->offset + hdr_offset, |
285 | "expected", vc->io_u->file); | |
7d9fb455 JA |
286 | free(buf); |
287 | } | |
288 | ||
bfacf389 JA |
289 | static void log_verify_failure(struct verify_header *hdr, struct vcont *vc) |
290 | { | |
291 | unsigned long long offset; | |
292 | ||
293 | offset = vc->io_u->offset; | |
294 | offset += vc->hdr_num * hdr->len; | |
32c17adf JA |
295 | log_err("%.8s: verify failed at file %s offset %llu, length %u\n", |
296 | vc->name, vc->io_u->file->file_name, offset, hdr->len); | |
bfacf389 JA |
297 | |
298 | if (vc->good_crc && vc->bad_crc) { | |
299 | log_err(" Expected CRC: "); | |
300 | hexdump(vc->good_crc, vc->crc_len); | |
301 | log_err(" Received CRC: "); | |
302 | hexdump(vc->bad_crc, vc->crc_len); | |
303 | } | |
7d9fb455 JA |
304 | |
305 | dump_verify_buffers(hdr, vc); | |
bfacf389 JA |
306 | } |
307 | ||
d9f2caf3 JA |
308 | /* |
309 | * Return data area 'header_num' | |
310 | */ | |
936216f8 | 311 | static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc) |
d9f2caf3 | 312 | { |
936216f8 | 313 | return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(hdr); |
d9f2caf3 JA |
314 | } |
315 | ||
92bf48d5 JA |
316 | static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc) |
317 | { | |
318 | struct thread_data *td = vc->td; | |
319 | struct io_u *io_u = vc->io_u; | |
320 | char *buf, *pattern; | |
2b13e716 | 321 | unsigned int header_size = __hdr_size(td->o.verify); |
9a2a86d0 | 322 | unsigned int len, mod, i, size, pattern_size; |
92bf48d5 JA |
323 | |
324 | pattern = td->o.verify_pattern; | |
9a2a86d0 SL |
325 | pattern_size = td->o.verify_pattern_bytes; |
326 | if (pattern_size <= 1) | |
327 | pattern_size = MAX_PATTERN_SIZE; | |
2b13e716 JA |
328 | buf = (void *) hdr + header_size; |
329 | len = get_hdr_inc(td, io_u) - header_size; | |
9a2a86d0 SL |
330 | mod = header_size % pattern_size; |
331 | ||
332 | for (i = 0; i < len; i += size) { | |
333 | size = pattern_size - mod; | |
334 | if (size > (len - i)) | |
335 | size = len - i; | |
336 | if (memcmp(buf + i, pattern + mod, size)) | |
e4ad68b1 | 337 | /* Let the slow compare find the first mismatch byte. */ |
9a2a86d0 SL |
338 | break; |
339 | mod = 0; | |
340 | } | |
92bf48d5 | 341 | |
9a2a86d0 | 342 | for (; i < len; i++) { |
92bf48d5 JA |
343 | if (buf[i] != pattern[mod]) { |
344 | unsigned int bits; | |
345 | ||
346 | bits = hweight8(buf[i] ^ pattern[mod]); | |
347 | log_err("fio: got pattern %x, wanted %x. Bad bits %d\n", | |
348 | buf[i], pattern[mod], bits); | |
349 | log_err("fio: bad pattern block offset %u\n", i); | |
350 | dump_verify_buffers(hdr, vc); | |
351 | return EILSEQ; | |
352 | } | |
353 | mod++; | |
354 | if (mod == td->o.verify_pattern_bytes) | |
355 | mod = 0; | |
356 | } | |
357 | ||
358 | return 0; | |
359 | } | |
360 | ||
361 | static int verify_io_u_meta(struct verify_header *hdr, struct vcont *vc) | |
7437ee87 | 362 | { |
92bf48d5 | 363 | struct thread_data *td = vc->td; |
7437ee87 | 364 | struct vhdr_meta *vh = hdr_priv(hdr); |
936216f8 | 365 | struct io_u *io_u = vc->io_u; |
92bf48d5 | 366 | int ret = EILSEQ; |
7437ee87 | 367 | |
bd6f78b2 JA |
368 | dprint(FD_VERIFY, "meta verify io_u %p, len %u\n", io_u, hdr->len); |
369 | ||
bfacf389 | 370 | if (vh->offset == io_u->offset + vc->hdr_num * td->o.verify_interval) |
92bf48d5 JA |
371 | ret = 0; |
372 | ||
373 | if (td->o.verify_pattern_bytes) | |
374 | ret |= verify_io_u_pattern(hdr, vc); | |
375 | ||
da0a7bd2 JC |
376 | /* |
377 | * For read-only workloads, the program cannot be certain of the | |
8bca6016 JA |
378 | * last numberio written to a block. Checking of numberio will be |
379 | * done only for workloads that write data. For verify_only, | |
380 | * numberio will be checked in the last iteration when the correct | |
381 | * state of numberio, that would have been written to each block | |
382 | * in a previous run of fio, has been reached. | |
da0a7bd2 | 383 | */ |
b7f5c00d JA |
384 | if ((td_write(td) || td_rw(td)) && (td_min_bs(td) == td_max_bs(td)) && |
385 | !td->o.time_based) | |
62167762 JC |
386 | if (!td->o.verify_only || td->o.loops == 0) |
387 | if (vh->numberio != io_u->numberio) | |
388 | ret = EILSEQ; | |
da0a7bd2 | 389 | |
92bf48d5 | 390 | if (!ret) |
bfacf389 | 391 | return 0; |
7437ee87 | 392 | |
bfacf389 JA |
393 | vc->name = "meta"; |
394 | log_verify_failure(hdr, vc); | |
92bf48d5 | 395 | return ret; |
7437ee87 SL |
396 | } |
397 | ||
844ea602 JA |
398 | static int verify_io_u_xxhash(struct verify_header *hdr, struct vcont *vc) |
399 | { | |
400 | void *p = io_u_verify_off(hdr, vc); | |
401 | struct vhdr_xxhash *vh = hdr_priv(hdr); | |
402 | uint32_t hash; | |
403 | void *state; | |
404 | ||
405 | dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len); | |
406 | ||
407 | state = XXH32_init(1); | |
408 | XXH32_update(state, p, hdr->len - hdr_size(hdr)); | |
409 | hash = XXH32_digest(state); | |
410 | ||
411 | if (vh->hash == hash) | |
412 | return 0; | |
413 | ||
414 | vc->name = "xxhash"; | |
415 | vc->good_crc = &vh->hash; | |
416 | vc->bad_crc = &hash; | |
417 | vc->crc_len = sizeof(hash); | |
418 | log_verify_failure(hdr, vc); | |
419 | return EILSEQ; | |
420 | } | |
421 | ||
936216f8 | 422 | static int verify_io_u_sha512(struct verify_header *hdr, struct vcont *vc) |
cd14cc10 | 423 | { |
936216f8 | 424 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 425 | struct vhdr_sha512 *vh = hdr_priv(hdr); |
cd14cc10 | 426 | uint8_t sha512[128]; |
25dfa848 | 427 | struct fio_sha512_ctx sha512_ctx = { |
cd14cc10 JA |
428 | .buf = sha512, |
429 | }; | |
430 | ||
936216f8 | 431 | dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 432 | |
25dfa848 JA |
433 | fio_sha512_init(&sha512_ctx); |
434 | fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(hdr)); | |
cd14cc10 | 435 | |
bfacf389 JA |
436 | if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512))) |
437 | return 0; | |
cd14cc10 | 438 | |
bfacf389 JA |
439 | vc->name = "sha512"; |
440 | vc->good_crc = vh->sha512; | |
441 | vc->bad_crc = sha512_ctx.buf; | |
442 | vc->crc_len = sizeof(vh->sha512); | |
443 | log_verify_failure(hdr, vc); | |
444 | return EILSEQ; | |
cd14cc10 JA |
445 | } |
446 | ||
936216f8 | 447 | static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc) |
cd14cc10 | 448 | { |
936216f8 | 449 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 450 | struct vhdr_sha256 *vh = hdr_priv(hdr); |
bc77f56f | 451 | uint8_t sha256[64]; |
25dfa848 | 452 | struct fio_sha256_ctx sha256_ctx = { |
cd14cc10 JA |
453 | .buf = sha256, |
454 | }; | |
455 | ||
936216f8 | 456 | dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 457 | |
25dfa848 JA |
458 | fio_sha256_init(&sha256_ctx); |
459 | fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr)); | |
cd14cc10 | 460 | |
bfacf389 JA |
461 | if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256))) |
462 | return 0; | |
cd14cc10 | 463 | |
bfacf389 JA |
464 | vc->name = "sha256"; |
465 | vc->good_crc = vh->sha256; | |
466 | vc->bad_crc = sha256_ctx.buf; | |
467 | vc->crc_len = sizeof(vh->sha256); | |
468 | log_verify_failure(hdr, vc); | |
469 | return EILSEQ; | |
cd14cc10 JA |
470 | } |
471 | ||
936216f8 | 472 | static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc) |
7c353ceb | 473 | { |
936216f8 | 474 | void *p = io_u_verify_off(hdr, vc); |
7c353ceb JA |
475 | struct vhdr_sha1 *vh = hdr_priv(hdr); |
476 | uint32_t sha1[5]; | |
25dfa848 | 477 | struct fio_sha1_ctx sha1_ctx = { |
7c353ceb JA |
478 | .H = sha1, |
479 | }; | |
480 | ||
936216f8 | 481 | dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
7c353ceb | 482 | |
25dfa848 JA |
483 | fio_sha1_init(&sha1_ctx); |
484 | fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr)); | |
7c353ceb | 485 | |
bfacf389 JA |
486 | if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1))) |
487 | return 0; | |
7c353ceb | 488 | |
bfacf389 JA |
489 | vc->name = "sha1"; |
490 | vc->good_crc = vh->sha1; | |
491 | vc->bad_crc = sha1_ctx.H; | |
492 | vc->crc_len = sizeof(vh->sha1); | |
493 | log_verify_failure(hdr, vc); | |
494 | return EILSEQ; | |
7c353ceb JA |
495 | } |
496 | ||
936216f8 | 497 | static int verify_io_u_crc7(struct verify_header *hdr, struct vcont *vc) |
1e154bdb | 498 | { |
936216f8 | 499 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 500 | struct vhdr_crc7 *vh = hdr_priv(hdr); |
1e154bdb JA |
501 | unsigned char c; |
502 | ||
936216f8 | 503 | dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 504 | |
25dfa848 | 505 | c = fio_crc7(p, hdr->len - hdr_size(hdr)); |
1e154bdb | 506 | |
bfacf389 JA |
507 | if (c == vh->crc7) |
508 | return 0; | |
1e154bdb | 509 | |
bfacf389 JA |
510 | vc->name = "crc7"; |
511 | vc->good_crc = &vh->crc7; | |
512 | vc->bad_crc = &c; | |
513 | vc->crc_len = 1; | |
514 | log_verify_failure(hdr, vc); | |
515 | return EILSEQ; | |
1e154bdb JA |
516 | } |
517 | ||
936216f8 | 518 | static int verify_io_u_crc16(struct verify_header *hdr, struct vcont *vc) |
969f7ed3 | 519 | { |
936216f8 | 520 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 521 | struct vhdr_crc16 *vh = hdr_priv(hdr); |
969f7ed3 JA |
522 | unsigned short c; |
523 | ||
936216f8 | 524 | dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 525 | |
25dfa848 | 526 | c = fio_crc16(p, hdr->len - hdr_size(hdr)); |
969f7ed3 | 527 | |
bfacf389 JA |
528 | if (c == vh->crc16) |
529 | return 0; | |
969f7ed3 | 530 | |
bfacf389 JA |
531 | vc->name = "crc16"; |
532 | vc->good_crc = &vh->crc16; | |
533 | vc->bad_crc = &c; | |
534 | vc->crc_len = 2; | |
535 | log_verify_failure(hdr, vc); | |
536 | return EILSEQ; | |
969f7ed3 JA |
537 | } |
538 | ||
936216f8 | 539 | static int verify_io_u_crc64(struct verify_header *hdr, struct vcont *vc) |
d77a7af3 | 540 | { |
936216f8 | 541 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 542 | struct vhdr_crc64 *vh = hdr_priv(hdr); |
d77a7af3 JA |
543 | unsigned long long c; |
544 | ||
936216f8 | 545 | dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 546 | |
25dfa848 | 547 | c = fio_crc64(p, hdr->len - hdr_size(hdr)); |
d77a7af3 | 548 | |
bfacf389 JA |
549 | if (c == vh->crc64) |
550 | return 0; | |
d77a7af3 | 551 | |
bfacf389 JA |
552 | vc->name = "crc64"; |
553 | vc->good_crc = &vh->crc64; | |
554 | vc->bad_crc = &c; | |
555 | vc->crc_len = 8; | |
556 | log_verify_failure(hdr, vc); | |
557 | return EILSEQ; | |
d77a7af3 JA |
558 | } |
559 | ||
936216f8 | 560 | static int verify_io_u_crc32(struct verify_header *hdr, struct vcont *vc) |
e29d1b70 | 561 | { |
936216f8 | 562 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f JA |
563 | struct vhdr_crc32 *vh = hdr_priv(hdr); |
564 | uint32_t c; | |
e29d1b70 | 565 | |
936216f8 | 566 | dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 567 | |
25dfa848 | 568 | c = fio_crc32(p, hdr->len - hdr_size(hdr)); |
e29d1b70 | 569 | |
bfacf389 JA |
570 | if (c == vh->crc32) |
571 | return 0; | |
e29d1b70 | 572 | |
bfacf389 JA |
573 | vc->name = "crc32"; |
574 | vc->good_crc = &vh->crc32; | |
575 | vc->bad_crc = &c; | |
576 | vc->crc_len = 4; | |
577 | log_verify_failure(hdr, vc); | |
578 | return EILSEQ; | |
e29d1b70 JA |
579 | } |
580 | ||
936216f8 | 581 | static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc) |
bac39e0e | 582 | { |
936216f8 | 583 | void *p = io_u_verify_off(hdr, vc); |
bac39e0e JA |
584 | struct vhdr_crc32 *vh = hdr_priv(hdr); |
585 | uint32_t c; | |
586 | ||
936216f8 | 587 | dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bac39e0e | 588 | |
25dfa848 | 589 | c = fio_crc32c(p, hdr->len - hdr_size(hdr)); |
bac39e0e | 590 | |
bfacf389 JA |
591 | if (c == vh->crc32) |
592 | return 0; | |
bac39e0e | 593 | |
bfacf389 JA |
594 | vc->name = "crc32c"; |
595 | vc->good_crc = &vh->crc32; | |
596 | vc->bad_crc = &c; | |
597 | vc->crc_len = 4; | |
598 | log_verify_failure(hdr, vc); | |
599 | return EILSEQ; | |
bac39e0e JA |
600 | } |
601 | ||
936216f8 | 602 | static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc) |
e29d1b70 | 603 | { |
936216f8 | 604 | void *p = io_u_verify_off(hdr, vc); |
546dfd9f | 605 | struct vhdr_md5 *vh = hdr_priv(hdr); |
8c432325 | 606 | uint32_t hash[MD5_HASH_WORDS]; |
25dfa848 | 607 | struct fio_md5_ctx md5_ctx = { |
8c432325 JA |
608 | .hash = hash, |
609 | }; | |
e29d1b70 | 610 | |
936216f8 | 611 | dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len); |
bd6f78b2 | 612 | |
25dfa848 JA |
613 | fio_md5_init(&md5_ctx); |
614 | fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr)); | |
e29d1b70 | 615 | |
bfacf389 JA |
616 | if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash))) |
617 | return 0; | |
e29d1b70 | 618 | |
bfacf389 JA |
619 | vc->name = "md5"; |
620 | vc->good_crc = vh->md5_digest; | |
621 | vc->bad_crc = md5_ctx.hash; | |
622 | vc->crc_len = sizeof(hash); | |
623 | log_verify_failure(hdr, vc); | |
624 | return EILSEQ; | |
e29d1b70 JA |
625 | } |
626 | ||
e8462bd8 JA |
627 | /* |
628 | * Push IO verification to a separate thread | |
629 | */ | |
f8b0bd10 | 630 | int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr) |
e8462bd8 | 631 | { |
f8b0bd10 | 632 | struct io_u *io_u = *io_u_ptr; |
e8462bd8 | 633 | |
e8462bd8 | 634 | pthread_mutex_lock(&td->io_u_lock); |
d7ee2a7d | 635 | |
f8b0bd10 JA |
636 | if (io_u->file) |
637 | put_file_log(td, io_u->file); | |
638 | ||
0c41214f RR |
639 | if (io_u->flags & IO_U_F_IN_CUR_DEPTH) { |
640 | td->cur_depth--; | |
641 | io_u->flags &= ~IO_U_F_IN_CUR_DEPTH; | |
642 | } | |
2ae0b204 | 643 | flist_add_tail(&io_u->verify_list, &td->verify_list); |
f8b0bd10 | 644 | *io_u_ptr = NULL; |
e8462bd8 JA |
645 | pthread_mutex_unlock(&td->io_u_lock); |
646 | ||
647 | pthread_cond_signal(&td->verify_cond); | |
e8462bd8 JA |
648 | return 0; |
649 | } | |
650 | ||
0d29de83 JA |
651 | static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u) |
652 | { | |
653 | static char zero_buf[1024]; | |
654 | unsigned int this_len, len; | |
655 | int ret = 0; | |
656 | void *p; | |
657 | ||
658 | if (!td->o.trim_zero) | |
659 | return 0; | |
660 | ||
661 | len = io_u->buflen; | |
662 | p = io_u->buf; | |
663 | do { | |
664 | this_len = sizeof(zero_buf); | |
665 | if (this_len > len) | |
666 | this_len = len; | |
667 | if (memcmp(p, zero_buf, this_len)) { | |
668 | ret = EILSEQ; | |
669 | break; | |
670 | } | |
671 | len -= this_len; | |
672 | p += this_len; | |
673 | } while (len); | |
674 | ||
675 | if (!ret) | |
676 | return 0; | |
677 | ||
a917a8b3 JA |
678 | log_err("trim: verify failed at file %s offset %llu, length %lu" |
679 | ", block offset %lu\n", | |
680 | io_u->file->file_name, io_u->offset, io_u->buflen, | |
2f68124f | 681 | (unsigned long) (p - io_u->buf)); |
0d29de83 JA |
682 | return ret; |
683 | } | |
684 | ||
5964842c AG |
685 | static int verify_header(struct io_u *io_u, struct verify_header *hdr, |
686 | unsigned int hdr_num, unsigned int hdr_len) | |
f65d1c26 JA |
687 | { |
688 | void *p = hdr; | |
689 | uint32_t crc; | |
690 | ||
5964842c AG |
691 | if (hdr->magic != FIO_HDR_MAGIC) { |
692 | log_err("verify: bad magic header %x, wanted %x", | |
693 | hdr->magic, FIO_HDR_MAGIC); | |
694 | goto err; | |
695 | } | |
4445856a | 696 | if (hdr->len != hdr_len) { |
5964842c AG |
697 | log_err("verify: bad header length %u, wanted %u", |
698 | hdr->len, hdr_len); | |
699 | goto err; | |
700 | } | |
701 | if (hdr->rand_seed != io_u->rand_seed) { | |
702 | log_err("verify: bad header rand_seed %"PRIu64 | |
703 | ", wanted %"PRIu64, | |
704 | hdr->rand_seed, io_u->rand_seed); | |
705 | goto err; | |
706 | } | |
ae38c0dc | 707 | |
25dfa848 | 708 | crc = fio_crc32c(p, offsetof(struct verify_header, crc32)); |
5964842c AG |
709 | if (crc != hdr->crc32) { |
710 | log_err("verify: bad header crc %x, calculated %x", | |
711 | hdr->crc32, crc); | |
712 | goto err; | |
713 | } | |
714 | return 0; | |
715 | ||
716 | err: | |
717 | log_err(" at file %s offset %llu, length %u\n", | |
718 | io_u->file->file_name, | |
719 | io_u->offset + hdr_num * hdr_len, hdr_len); | |
720 | return EILSEQ; | |
f65d1c26 JA |
721 | } |
722 | ||
f8b0bd10 | 723 | int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr) |
e29d1b70 | 724 | { |
3f9f4e26 | 725 | struct verify_header *hdr; |
f8b0bd10 | 726 | struct io_u *io_u = *io_u_ptr; |
2b13e716 | 727 | unsigned int header_size, hdr_inc, hdr_num = 0; |
95646108 | 728 | void *p; |
e29d1b70 JA |
729 | int ret; |
730 | ||
1dcc0498 | 731 | if (td->o.verify == VERIFY_NULL || io_u->ddir != DDIR_READ) |
36690c9b | 732 | return 0; |
5c57c084 JA |
733 | /* |
734 | * If the IO engine is faking IO (like null), then just pretend | |
735 | * we verified everything. | |
736 | */ | |
737 | if (td->io_ops->flags & FIO_FAKEIO) | |
738 | return 0; | |
739 | ||
0d29de83 JA |
740 | if (io_u->flags & IO_U_F_TRIMMED) { |
741 | ret = verify_trimmed_io_u(td, io_u); | |
742 | goto done; | |
743 | } | |
36690c9b | 744 | |
cfbcd0dc | 745 | hdr_inc = get_hdr_inc(td, io_u); |
e29d1b70 | 746 | |
a12a3b4d | 747 | ret = 0; |
5ec10eaa JA |
748 | for (p = io_u->buf; p < io_u->buf + io_u->buflen; |
749 | p += hdr_inc, hdr_num++) { | |
bfacf389 JA |
750 | struct vcont vc = { |
751 | .io_u = io_u, | |
752 | .hdr_num = hdr_num, | |
7d9fb455 | 753 | .td = td, |
bfacf389 | 754 | }; |
f00b210f | 755 | unsigned int verify_type; |
936216f8 | 756 | |
f3e6cb95 | 757 | if (ret && td->o.verify_fatal) |
a12a3b4d | 758 | break; |
f3e6cb95 | 759 | |
2b13e716 | 760 | header_size = __hdr_size(td->o.verify); |
a59e170d | 761 | if (td->o.verify_offset) |
2b13e716 | 762 | memswp(p, p + td->o.verify_offset, header_size); |
95646108 | 763 | hdr = p; |
e29d1b70 | 764 | |
c4b6117b PV |
765 | /* |
766 | * Make rand_seed check pass when have verifysort or | |
767 | * verify_backlog. | |
768 | */ | |
769 | if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG)) | |
770 | io_u->rand_seed = hdr->rand_seed; | |
771 | ||
5964842c AG |
772 | ret = verify_header(io_u, hdr, hdr_num, hdr_inc); |
773 | if (ret) | |
774 | return ret; | |
3f199b01 | 775 | |
f00b210f JA |
776 | if (td->o.verify != VERIFY_NONE) |
777 | verify_type = td->o.verify; | |
778 | else | |
779 | verify_type = hdr->verify_type; | |
780 | ||
781 | switch (verify_type) { | |
3f9f4e26 | 782 | case VERIFY_MD5: |
936216f8 | 783 | ret = verify_io_u_md5(hdr, &vc); |
3f9f4e26 SL |
784 | break; |
785 | case VERIFY_CRC64: | |
936216f8 | 786 | ret = verify_io_u_crc64(hdr, &vc); |
3f9f4e26 | 787 | break; |
bac39e0e | 788 | case VERIFY_CRC32C: |
3845591f | 789 | case VERIFY_CRC32C_INTEL: |
936216f8 | 790 | ret = verify_io_u_crc32c(hdr, &vc); |
bac39e0e | 791 | break; |
3f9f4e26 | 792 | case VERIFY_CRC32: |
936216f8 | 793 | ret = verify_io_u_crc32(hdr, &vc); |
3f9f4e26 SL |
794 | break; |
795 | case VERIFY_CRC16: | |
936216f8 | 796 | ret = verify_io_u_crc16(hdr, &vc); |
3f9f4e26 SL |
797 | break; |
798 | case VERIFY_CRC7: | |
936216f8 | 799 | ret = verify_io_u_crc7(hdr, &vc); |
3f9f4e26 | 800 | break; |
cd14cc10 | 801 | case VERIFY_SHA256: |
936216f8 | 802 | ret = verify_io_u_sha256(hdr, &vc); |
cd14cc10 JA |
803 | break; |
804 | case VERIFY_SHA512: | |
936216f8 | 805 | ret = verify_io_u_sha512(hdr, &vc); |
cd14cc10 | 806 | break; |
844ea602 JA |
807 | case VERIFY_XXHASH: |
808 | ret = verify_io_u_xxhash(hdr, &vc); | |
809 | break; | |
7437ee87 | 810 | case VERIFY_META: |
92bf48d5 | 811 | ret = verify_io_u_meta(hdr, &vc); |
7437ee87 | 812 | break; |
7c353ceb | 813 | case VERIFY_SHA1: |
936216f8 | 814 | ret = verify_io_u_sha1(hdr, &vc); |
7c353ceb | 815 | break; |
92bf48d5 JA |
816 | case VERIFY_PATTERN: |
817 | ret = verify_io_u_pattern(hdr, &vc); | |
818 | break; | |
3f9f4e26 SL |
819 | default: |
820 | log_err("Bad verify type %u\n", hdr->verify_type); | |
d16d4e09 | 821 | ret = EINVAL; |
3f9f4e26 | 822 | } |
f00b210f JA |
823 | |
824 | if (ret && verify_type != hdr->verify_type) | |
825 | log_err("fio: verify type mismatch (%u media, %u given)\n", | |
826 | hdr->verify_type, verify_type); | |
3f9f4e26 | 827 | } |
a7dfe862 | 828 | |
0d29de83 | 829 | done: |
f3e6cb95 | 830 | if (ret && td->o.verify_fatal) |
ebea2133 | 831 | fio_mark_td_terminate(td); |
f3e6cb95 | 832 | |
a12a3b4d | 833 | return ret; |
e29d1b70 JA |
834 | } |
835 | ||
7437ee87 | 836 | static void fill_meta(struct verify_header *hdr, struct thread_data *td, |
5ec10eaa | 837 | struct io_u *io_u, unsigned int header_num) |
7437ee87 SL |
838 | { |
839 | struct vhdr_meta *vh = hdr_priv(hdr); | |
840 | ||
841 | vh->thread = td->thread_number; | |
842 | ||
843 | vh->time_sec = io_u->start_time.tv_sec; | |
844 | vh->time_usec = io_u->start_time.tv_usec; | |
845 | ||
da0a7bd2 | 846 | vh->numberio = io_u->numberio; |
7437ee87 SL |
847 | |
848 | vh->offset = io_u->offset + header_num * td->o.verify_interval; | |
849 | } | |
850 | ||
844ea602 JA |
851 | static void fill_xxhash(struct verify_header *hdr, void *p, unsigned int len) |
852 | { | |
853 | struct vhdr_xxhash *vh = hdr_priv(hdr); | |
854 | void *state; | |
855 | ||
856 | state = XXH32_init(1); | |
857 | XXH32_update(state, p, len); | |
858 | vh->hash = XXH32_digest(state); | |
859 | } | |
860 | ||
cd14cc10 JA |
861 | static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len) |
862 | { | |
546dfd9f | 863 | struct vhdr_sha512 *vh = hdr_priv(hdr); |
25dfa848 | 864 | struct fio_sha512_ctx sha512_ctx = { |
546dfd9f | 865 | .buf = vh->sha512, |
cd14cc10 JA |
866 | }; |
867 | ||
25dfa848 JA |
868 | fio_sha512_init(&sha512_ctx); |
869 | fio_sha512_update(&sha512_ctx, p, len); | |
cd14cc10 JA |
870 | } |
871 | ||
872 | static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len) | |
873 | { | |
546dfd9f | 874 | struct vhdr_sha256 *vh = hdr_priv(hdr); |
25dfa848 | 875 | struct fio_sha256_ctx sha256_ctx = { |
546dfd9f | 876 | .buf = vh->sha256, |
cd14cc10 JA |
877 | }; |
878 | ||
25dfa848 JA |
879 | fio_sha256_init(&sha256_ctx); |
880 | fio_sha256_update(&sha256_ctx, p, len); | |
cd14cc10 JA |
881 | } |
882 | ||
7c353ceb JA |
883 | static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len) |
884 | { | |
885 | struct vhdr_sha1 *vh = hdr_priv(hdr); | |
25dfa848 | 886 | struct fio_sha1_ctx sha1_ctx = { |
7c353ceb JA |
887 | .H = vh->sha1, |
888 | }; | |
889 | ||
25dfa848 JA |
890 | fio_sha1_init(&sha1_ctx); |
891 | fio_sha1_update(&sha1_ctx, p, len); | |
7c353ceb JA |
892 | } |
893 | ||
1e154bdb JA |
894 | static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len) |
895 | { | |
546dfd9f JA |
896 | struct vhdr_crc7 *vh = hdr_priv(hdr); |
897 | ||
25dfa848 | 898 | vh->crc7 = fio_crc7(p, len); |
1e154bdb JA |
899 | } |
900 | ||
969f7ed3 JA |
901 | static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len) |
902 | { | |
546dfd9f JA |
903 | struct vhdr_crc16 *vh = hdr_priv(hdr); |
904 | ||
25dfa848 | 905 | vh->crc16 = fio_crc16(p, len); |
969f7ed3 JA |
906 | } |
907 | ||
e29d1b70 JA |
908 | static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len) |
909 | { | |
546dfd9f JA |
910 | struct vhdr_crc32 *vh = hdr_priv(hdr); |
911 | ||
25dfa848 | 912 | vh->crc32 = fio_crc32(p, len); |
e29d1b70 JA |
913 | } |
914 | ||
bac39e0e JA |
915 | static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len) |
916 | { | |
917 | struct vhdr_crc32 *vh = hdr_priv(hdr); | |
918 | ||
25dfa848 | 919 | vh->crc32 = fio_crc32c(p, len); |
bac39e0e JA |
920 | } |
921 | ||
d77a7af3 JA |
922 | static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len) |
923 | { | |
546dfd9f JA |
924 | struct vhdr_crc64 *vh = hdr_priv(hdr); |
925 | ||
25dfa848 | 926 | vh->crc64 = fio_crc64(p, len); |
d77a7af3 JA |
927 | } |
928 | ||
e29d1b70 JA |
929 | static void fill_md5(struct verify_header *hdr, void *p, unsigned int len) |
930 | { | |
546dfd9f | 931 | struct vhdr_md5 *vh = hdr_priv(hdr); |
25dfa848 | 932 | struct fio_md5_ctx md5_ctx = { |
546dfd9f | 933 | .hash = (uint32_t *) vh->md5_digest, |
8c432325 | 934 | }; |
e29d1b70 | 935 | |
25dfa848 JA |
936 | fio_md5_init(&md5_ctx); |
937 | fio_md5_update(&md5_ctx, p, len); | |
e29d1b70 JA |
938 | } |
939 | ||
7d9fb455 JA |
940 | static void populate_hdr(struct thread_data *td, struct io_u *io_u, |
941 | struct verify_header *hdr, unsigned int header_num, | |
942 | unsigned int header_len) | |
943 | { | |
944 | unsigned int data_len; | |
945 | void *data, *p; | |
946 | ||
947 | p = (void *) hdr; | |
948 | ||
d3a173a9 | 949 | hdr->magic = FIO_HDR_MAGIC; |
7d9fb455 | 950 | hdr->verify_type = td->o.verify; |
d3a173a9 | 951 | hdr->len = header_len; |
7d9fb455 | 952 | hdr->rand_seed = io_u->rand_seed; |
25dfa848 | 953 | hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32)); |
f65d1c26 | 954 | |
7d9fb455 JA |
955 | data_len = header_len - hdr_size(hdr); |
956 | ||
957 | data = p + hdr_size(hdr); | |
958 | switch (td->o.verify) { | |
959 | case VERIFY_MD5: | |
960 | dprint(FD_VERIFY, "fill md5 io_u %p, len %u\n", | |
961 | io_u, hdr->len); | |
962 | fill_md5(hdr, data, data_len); | |
963 | break; | |
964 | case VERIFY_CRC64: | |
965 | dprint(FD_VERIFY, "fill crc64 io_u %p, len %u\n", | |
966 | io_u, hdr->len); | |
967 | fill_crc64(hdr, data, data_len); | |
968 | break; | |
969 | case VERIFY_CRC32C: | |
970 | case VERIFY_CRC32C_INTEL: | |
971 | dprint(FD_VERIFY, "fill crc32c io_u %p, len %u\n", | |
972 | io_u, hdr->len); | |
973 | fill_crc32c(hdr, data, data_len); | |
974 | break; | |
975 | case VERIFY_CRC32: | |
976 | dprint(FD_VERIFY, "fill crc32 io_u %p, len %u\n", | |
977 | io_u, hdr->len); | |
978 | fill_crc32(hdr, data, data_len); | |
979 | break; | |
980 | case VERIFY_CRC16: | |
981 | dprint(FD_VERIFY, "fill crc16 io_u %p, len %u\n", | |
982 | io_u, hdr->len); | |
983 | fill_crc16(hdr, data, data_len); | |
984 | break; | |
985 | case VERIFY_CRC7: | |
986 | dprint(FD_VERIFY, "fill crc7 io_u %p, len %u\n", | |
987 | io_u, hdr->len); | |
988 | fill_crc7(hdr, data, data_len); | |
989 | break; | |
990 | case VERIFY_SHA256: | |
991 | dprint(FD_VERIFY, "fill sha256 io_u %p, len %u\n", | |
992 | io_u, hdr->len); | |
993 | fill_sha256(hdr, data, data_len); | |
994 | break; | |
995 | case VERIFY_SHA512: | |
996 | dprint(FD_VERIFY, "fill sha512 io_u %p, len %u\n", | |
997 | io_u, hdr->len); | |
998 | fill_sha512(hdr, data, data_len); | |
999 | break; | |
844ea602 JA |
1000 | case VERIFY_XXHASH: |
1001 | dprint(FD_VERIFY, "fill xxhash io_u %p, len %u\n", | |
1002 | io_u, hdr->len); | |
1003 | fill_xxhash(hdr, data, data_len); | |
1004 | break; | |
7d9fb455 JA |
1005 | case VERIFY_META: |
1006 | dprint(FD_VERIFY, "fill meta io_u %p, len %u\n", | |
1007 | io_u, hdr->len); | |
1008 | fill_meta(hdr, td, io_u, header_num); | |
1009 | break; | |
1010 | case VERIFY_SHA1: | |
1011 | dprint(FD_VERIFY, "fill sha1 io_u %p, len %u\n", | |
1012 | io_u, hdr->len); | |
1013 | fill_sha1(hdr, data, data_len); | |
1014 | break; | |
92bf48d5 JA |
1015 | case VERIFY_PATTERN: |
1016 | /* nothing to do here */ | |
1017 | break; | |
7d9fb455 JA |
1018 | default: |
1019 | log_err("fio: bad verify type: %d\n", td->o.verify); | |
1020 | assert(0); | |
1021 | } | |
1022 | if (td->o.verify_offset) | |
1023 | memswp(p, p + td->o.verify_offset, hdr_size(hdr)); | |
1024 | } | |
1025 | ||
e29d1b70 JA |
1026 | /* |
1027 | * fill body of io_u->buf with random data and add a header with the | |
c50ca7bd | 1028 | * checksum of choice |
e29d1b70 JA |
1029 | */ |
1030 | void populate_verify_io_u(struct thread_data *td, struct io_u *io_u) | |
1031 | { | |
9cc3d150 JA |
1032 | if (td->o.verify == VERIFY_NULL) |
1033 | return; | |
1034 | ||
da0a7bd2 JC |
1035 | io_u->numberio = td->io_issues[io_u->ddir]; |
1036 | ||
c50ca7bd | 1037 | fill_pattern_headers(td, io_u, 0, 0); |
e29d1b70 JA |
1038 | } |
1039 | ||
1040 | int get_next_verify(struct thread_data *td, struct io_u *io_u) | |
1041 | { | |
8de8f047 | 1042 | struct io_piece *ipo = NULL; |
e29d1b70 | 1043 | |
d2d7fa53 JA |
1044 | /* |
1045 | * this io_u is from a requeue, we already filled the offsets | |
1046 | */ | |
1047 | if (io_u->file) | |
1048 | return 0; | |
1049 | ||
8de8f047 JA |
1050 | if (!RB_EMPTY_ROOT(&td->io_hist_tree)) { |
1051 | struct rb_node *n = rb_first(&td->io_hist_tree); | |
e29d1b70 | 1052 | |
8de8f047 | 1053 | ipo = rb_entry(n, struct io_piece, rb_node); |
f9401285 JA |
1054 | |
1055 | /* | |
1056 | * Ensure that the associated IO has completed | |
1057 | */ | |
1058 | read_barrier(); | |
1059 | if (ipo->flags & IP_F_IN_FLIGHT) | |
1060 | goto nothing; | |
1061 | ||
4b87898e | 1062 | rb_erase(n, &td->io_hist_tree); |
a917a8b3 JA |
1063 | assert(ipo->flags & IP_F_ONRB); |
1064 | ipo->flags &= ~IP_F_ONRB; | |
01743ee1 | 1065 | } else if (!flist_empty(&td->io_hist_list)) { |
9342d5f8 | 1066 | ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list); |
f9401285 JA |
1067 | |
1068 | /* | |
1069 | * Ensure that the associated IO has completed | |
1070 | */ | |
1071 | read_barrier(); | |
1072 | if (ipo->flags & IP_F_IN_FLIGHT) | |
1073 | goto nothing; | |
1074 | ||
01743ee1 | 1075 | flist_del(&ipo->list); |
a917a8b3 JA |
1076 | assert(ipo->flags & IP_F_ONLIST); |
1077 | ipo->flags &= ~IP_F_ONLIST; | |
8de8f047 | 1078 | } |
e29d1b70 | 1079 | |
8de8f047 | 1080 | if (ipo) { |
0d29de83 JA |
1081 | td->io_hist_len--; |
1082 | ||
e29d1b70 JA |
1083 | io_u->offset = ipo->offset; |
1084 | io_u->buflen = ipo->len; | |
da0a7bd2 | 1085 | io_u->numberio = ipo->numberio; |
36167d82 | 1086 | io_u->file = ipo->file; |
82af2a7c | 1087 | io_u->flags |= IO_U_F_VER_LIST; |
97af62ce | 1088 | |
0d29de83 JA |
1089 | if (ipo->flags & IP_F_TRIMMED) |
1090 | io_u->flags |= IO_U_F_TRIMMED; | |
1091 | ||
d6aed795 | 1092 | if (!fio_file_open(io_u->file)) { |
97af62ce JA |
1093 | int r = td_io_open_file(td, io_u->file); |
1094 | ||
bd6f78b2 JA |
1095 | if (r) { |
1096 | dprint(FD_VERIFY, "failed file %s open\n", | |
1097 | io_u->file->file_name); | |
97af62ce | 1098 | return 1; |
bd6f78b2 | 1099 | } |
97af62ce JA |
1100 | } |
1101 | ||
1102 | get_file(ipo->file); | |
d6aed795 | 1103 | assert(fio_file_open(io_u->file)); |
e29d1b70 | 1104 | io_u->ddir = DDIR_READ; |
36167d82 JA |
1105 | io_u->xfer_buf = io_u->buf; |
1106 | io_u->xfer_buflen = io_u->buflen; | |
0d29de83 JA |
1107 | |
1108 | remove_trim_entry(td, ipo); | |
e29d1b70 | 1109 | free(ipo); |
bd6f78b2 | 1110 | dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u); |
c4b6117b PV |
1111 | |
1112 | if (!td->o.verify_pattern_bytes) { | |
d6b72507 | 1113 | io_u->rand_seed = __rand(&td->verify_state); |
c4b6117b | 1114 | if (sizeof(int) != sizeof(long *)) |
d6b72507 | 1115 | io_u->rand_seed *= __rand(&td->verify_state); |
c4b6117b | 1116 | } |
e29d1b70 JA |
1117 | return 0; |
1118 | } | |
1119 | ||
f9401285 | 1120 | nothing: |
bd6f78b2 | 1121 | dprint(FD_VERIFY, "get_next_verify: empty\n"); |
e29d1b70 JA |
1122 | return 1; |
1123 | } | |
e8462bd8 | 1124 | |
dc5bfbb2 JA |
1125 | void fio_verify_init(struct thread_data *td) |
1126 | { | |
1127 | if (td->o.verify == VERIFY_CRC32C_INTEL || | |
1128 | td->o.verify == VERIFY_CRC32C) { | |
1129 | crc32c_intel_probe(); | |
1130 | } | |
1131 | } | |
1132 | ||
e8462bd8 JA |
1133 | static void *verify_async_thread(void *data) |
1134 | { | |
1135 | struct thread_data *td = data; | |
1136 | struct io_u *io_u; | |
1137 | int ret = 0; | |
1138 | ||
1139 | if (td->o.verify_cpumask_set && | |
1140 | fio_setaffinity(td->pid, td->o.verify_cpumask)) { | |
1141 | log_err("fio: failed setting verify thread affinity\n"); | |
1142 | goto done; | |
1143 | } | |
1144 | ||
1145 | do { | |
e53ab27c JA |
1146 | FLIST_HEAD(list); |
1147 | ||
e8462bd8 JA |
1148 | read_barrier(); |
1149 | if (td->verify_thread_exit) | |
1150 | break; | |
1151 | ||
1152 | pthread_mutex_lock(&td->io_u_lock); | |
1153 | ||
1154 | while (flist_empty(&td->verify_list) && | |
1155 | !td->verify_thread_exit) { | |
b36e298b JA |
1156 | ret = pthread_cond_wait(&td->verify_cond, |
1157 | &td->io_u_lock); | |
e8462bd8 JA |
1158 | if (ret) { |
1159 | pthread_mutex_unlock(&td->io_u_lock); | |
1160 | break; | |
1161 | } | |
1162 | } | |
1163 | ||
e53ab27c JA |
1164 | flist_splice_init(&td->verify_list, &list); |
1165 | pthread_mutex_unlock(&td->io_u_lock); | |
1166 | ||
1167 | if (flist_empty(&list)) | |
e8462bd8 | 1168 | continue; |
e8462bd8 | 1169 | |
e53ab27c | 1170 | while (!flist_empty(&list)) { |
9342d5f8 | 1171 | io_u = flist_first_entry(&list, struct io_u, verify_list); |
f8b0bd10 JA |
1172 | flist_del_init(&io_u->verify_list); |
1173 | ||
1174 | io_u->flags |= IO_U_F_NO_FILE_PUT; | |
1175 | ret = verify_io_u(td, &io_u); | |
e8462bd8 | 1176 | |
e53ab27c | 1177 | put_io_u(td, io_u); |
d561f2ab JA |
1178 | if (!ret) |
1179 | continue; | |
8b28bd41 | 1180 | if (td_non_fatal_error(td, ERROR_TYPE_VERIFY_BIT, ret)) { |
d561f2ab JA |
1181 | update_error_count(td, ret); |
1182 | td_clear_error(td); | |
1183 | ret = 0; | |
1184 | } | |
e53ab27c | 1185 | } |
e8462bd8 JA |
1186 | } while (!ret); |
1187 | ||
d561f2ab JA |
1188 | if (ret) { |
1189 | td_verror(td, ret, "async_verify"); | |
f3e6cb95 | 1190 | if (td->o.verify_fatal) |
ebea2133 | 1191 | fio_mark_td_terminate(td); |
d561f2ab JA |
1192 | } |
1193 | ||
e8462bd8 JA |
1194 | done: |
1195 | pthread_mutex_lock(&td->io_u_lock); | |
1196 | td->nr_verify_threads--; | |
1197 | pthread_mutex_unlock(&td->io_u_lock); | |
1198 | ||
1199 | pthread_cond_signal(&td->free_cond); | |
1200 | return NULL; | |
1201 | } | |
1202 | ||
1203 | int verify_async_init(struct thread_data *td) | |
1204 | { | |
1205 | int i, ret; | |
304a47c7 VA |
1206 | pthread_attr_t attr; |
1207 | ||
1208 | pthread_attr_init(&attr); | |
1209 | pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); | |
e8462bd8 JA |
1210 | |
1211 | td->verify_thread_exit = 0; | |
1212 | ||
1213 | td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async); | |
1214 | for (i = 0; i < td->o.verify_async; i++) { | |
304a47c7 | 1215 | ret = pthread_create(&td->verify_threads[i], &attr, |
e8462bd8 JA |
1216 | verify_async_thread, td); |
1217 | if (ret) { | |
1218 | log_err("fio: async verify creation failed: %s\n", | |
1219 | strerror(ret)); | |
1220 | break; | |
1221 | } | |
1222 | ret = pthread_detach(td->verify_threads[i]); | |
1223 | if (ret) { | |
1224 | log_err("fio: async verify thread detach failed: %s\n", | |
1225 | strerror(ret)); | |
1226 | break; | |
1227 | } | |
1228 | td->nr_verify_threads++; | |
1229 | } | |
1230 | ||
304a47c7 VA |
1231 | pthread_attr_destroy(&attr); |
1232 | ||
e8462bd8 | 1233 | if (i != td->o.verify_async) { |
e40823b1 | 1234 | log_err("fio: only %d verify threads started, exiting\n", i); |
e8462bd8 JA |
1235 | td->verify_thread_exit = 1; |
1236 | write_barrier(); | |
1237 | pthread_cond_broadcast(&td->verify_cond); | |
1238 | return 1; | |
1239 | } | |
1240 | ||
1241 | return 0; | |
1242 | } | |
1243 | ||
1244 | void verify_async_exit(struct thread_data *td) | |
1245 | { | |
1246 | td->verify_thread_exit = 1; | |
1247 | write_barrier(); | |
1248 | pthread_cond_broadcast(&td->verify_cond); | |
1249 | ||
1250 | pthread_mutex_lock(&td->io_u_lock); | |
1251 | ||
1252 | while (td->nr_verify_threads) | |
1253 | pthread_cond_wait(&td->free_cond, &td->io_u_lock); | |
1254 | ||
1255 | pthread_mutex_unlock(&td->io_u_lock); | |
1256 | free(td->verify_threads); | |
1257 | td->verify_threads = NULL; | |
1258 | } | |
ca09be4b JA |
1259 | |
1260 | struct all_io_list *get_all_io_list(int save_mask, size_t *sz) | |
1261 | { | |
1262 | struct all_io_list *rep; | |
1263 | struct thread_data *td; | |
1264 | size_t depth; | |
1265 | void *next; | |
1266 | int i, nr; | |
1267 | ||
1268 | compiletime_assert(sizeof(struct all_io_list) == 8, "all_io_list"); | |
1269 | ||
1270 | /* | |
1271 | * Calculate reply space needed. We need one 'io_state' per thread, | |
1272 | * and the size will vary depending on depth. | |
1273 | */ | |
1274 | depth = 0; | |
1275 | nr = 0; | |
1276 | for_each_td(td, i) { | |
1277 | if (save_mask != IO_LIST_ALL && (i + 1) != save_mask) | |
1278 | continue; | |
1279 | td->stop_io = 1; | |
1280 | td->flags |= TD_F_VSTATE_SAVED; | |
1281 | depth += td->o.iodepth; | |
1282 | nr++; | |
1283 | } | |
1284 | ||
1285 | if (!nr) | |
1286 | return NULL; | |
1287 | ||
1288 | *sz = sizeof(*rep); | |
1289 | *sz += nr * sizeof(struct thread_io_list); | |
1290 | *sz += depth * sizeof(uint64_t); | |
1291 | rep = malloc(*sz); | |
1292 | ||
1293 | rep->threads = cpu_to_le64((uint64_t) nr); | |
1294 | ||
1295 | next = &rep->state[0]; | |
1296 | for_each_td(td, i) { | |
1297 | struct thread_io_list *s = next; | |
1298 | unsigned int comps; | |
1299 | ||
1300 | if (save_mask != IO_LIST_ALL && (i + 1) != save_mask) | |
1301 | continue; | |
1302 | ||
1303 | if (td->last_write_comp) { | |
1304 | int j, k; | |
1305 | ||
1306 | if (td->io_blocks[DDIR_WRITE] < td->o.iodepth) | |
1307 | comps = td->io_blocks[DDIR_WRITE]; | |
1308 | else | |
1309 | comps = td->o.iodepth; | |
1310 | ||
1311 | k = td->last_write_idx - 1; | |
1312 | for (j = 0; j < comps; j++) { | |
1313 | if (k == -1) | |
1314 | k = td->o.iodepth - 1; | |
1315 | s->offsets[j] = cpu_to_le64(td->last_write_comp[k]); | |
1316 | k--; | |
1317 | } | |
1318 | } else | |
1319 | comps = 0; | |
1320 | ||
1321 | s->no_comps = cpu_to_le64((uint64_t) comps); | |
1322 | s->depth = cpu_to_le64((uint64_t) td->o.iodepth); | |
1323 | s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]); | |
1324 | s->index = cpu_to_le64((uint64_t) i); | |
1325 | s->rand.s[0] = cpu_to_le32(td->random_state.s1); | |
1326 | s->rand.s[1] = cpu_to_le32(td->random_state.s2); | |
1327 | s->rand.s[2] = cpu_to_le32(td->random_state.s3); | |
1328 | s->rand.s[3] = 0; | |
1329 | strncpy((char *) s->name, td->o.name, sizeof(s->name)); | |
1330 | next = io_list_next(s); | |
1331 | } | |
1332 | ||
1333 | return rep; | |
1334 | } | |
1335 | ||
1336 | static int open_state_file(const char *name, const char *prefix, int num, | |
1337 | int for_write) | |
1338 | { | |
1339 | char out[64]; | |
1340 | int flags; | |
1341 | int fd; | |
1342 | ||
1343 | if (for_write) | |
1344 | flags = O_CREAT | O_TRUNC | O_WRONLY | O_SYNC; | |
1345 | else | |
1346 | flags = O_RDONLY; | |
1347 | ||
e499aedc | 1348 | verify_state_gen_name(out, sizeof(out), name, prefix, num); |
ca09be4b JA |
1349 | |
1350 | fd = open(out, flags, 0644); | |
1351 | if (fd == -1) { | |
1352 | perror("fio: open state file"); | |
1353 | return -1; | |
1354 | } | |
1355 | ||
1356 | return fd; | |
1357 | } | |
1358 | ||
1359 | static int write_thread_list_state(struct thread_io_list *s, | |
1360 | const char *prefix) | |
1361 | { | |
1362 | struct verify_state_hdr hdr; | |
1363 | uint64_t crc; | |
1364 | ssize_t ret; | |
1365 | int fd; | |
1366 | ||
1367 | fd = open_state_file((const char *) s->name, prefix, s->index, 1); | |
1368 | if (fd == -1) | |
1369 | return 1; | |
1370 | ||
1371 | crc = fio_crc32c((void *)s, thread_io_list_sz(s)); | |
1372 | ||
1373 | hdr.version = cpu_to_le64((uint64_t) VSTATE_HDR_VERSION); | |
1374 | hdr.size = cpu_to_le64((uint64_t) thread_io_list_sz(s)); | |
1375 | hdr.crc = cpu_to_le64(crc); | |
1376 | ret = write(fd, &hdr, sizeof(hdr)); | |
1377 | if (ret != sizeof(hdr)) | |
1378 | goto write_fail; | |
1379 | ||
1380 | ret = write(fd, s, thread_io_list_sz(s)); | |
1381 | if (ret != thread_io_list_sz(s)) { | |
1382 | write_fail: | |
1383 | if (ret < 0) | |
1384 | perror("fio: write state file"); | |
1385 | log_err("fio: failed to write state file\n"); | |
1386 | ret = 1; | |
1387 | } else | |
1388 | ret = 0; | |
1389 | ||
1390 | close(fd); | |
1391 | return ret; | |
1392 | } | |
1393 | ||
1394 | void __verify_save_state(struct all_io_list *state, const char *prefix) | |
1395 | { | |
1396 | struct thread_io_list *s = &state->state[0]; | |
1397 | unsigned int i; | |
1398 | ||
1399 | for (i = 0; i < le64_to_cpu(state->threads); i++) { | |
1400 | write_thread_list_state(s, prefix); | |
1401 | s = io_list_next(s); | |
1402 | } | |
1403 | } | |
1404 | ||
1405 | void verify_save_state(void) | |
1406 | { | |
1407 | struct all_io_list *state; | |
1408 | size_t sz; | |
1409 | ||
1410 | state = get_all_io_list(IO_LIST_ALL, &sz); | |
1411 | if (state) { | |
1412 | __verify_save_state(state, "local"); | |
1413 | free(state); | |
1414 | } | |
1415 | } | |
1416 | ||
1417 | void verify_free_state(struct thread_data *td) | |
1418 | { | |
1419 | if (td->vstate) | |
1420 | free(td->vstate); | |
1421 | } | |
1422 | ||
1423 | void verify_convert_assign_state(struct thread_data *td, | |
1424 | struct thread_io_list *s) | |
1425 | { | |
1426 | int i; | |
1427 | ||
1428 | s->no_comps = le64_to_cpu(s->no_comps); | |
1429 | s->depth = le64_to_cpu(s->depth); | |
1430 | s->numberio = le64_to_cpu(s->numberio); | |
1431 | for (i = 0; i < 4; i++) | |
1432 | s->rand.s[i] = le32_to_cpu(s->rand.s[i]); | |
1433 | for (i = 0; i < s->no_comps; i++) | |
1434 | s->offsets[i] = le64_to_cpu(s->offsets[i]); | |
1435 | ||
1436 | td->vstate = s; | |
1437 | } | |
1438 | ||
1439 | int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s) | |
1440 | { | |
1441 | uint64_t crc; | |
1442 | ||
1443 | hdr->version = le64_to_cpu(hdr->version); | |
1444 | hdr->size = le64_to_cpu(hdr->size); | |
1445 | hdr->crc = le64_to_cpu(hdr->crc); | |
1446 | ||
1447 | if (hdr->version != VSTATE_HDR_VERSION) | |
1448 | return 1; | |
1449 | ||
1450 | crc = fio_crc32c((void *)s, hdr->size); | |
1451 | if (crc != hdr->crc) | |
1452 | return 1; | |
1453 | ||
1454 | return 0; | |
1455 | } | |
1456 | ||
1457 | int verify_load_state(struct thread_data *td, const char *prefix) | |
1458 | { | |
1459 | struct thread_io_list *s = NULL; | |
1460 | struct verify_state_hdr hdr; | |
1461 | uint64_t crc; | |
1462 | ssize_t ret; | |
1463 | int fd; | |
1464 | ||
1465 | if (!td->o.verify_state) | |
1466 | return 0; | |
1467 | ||
1468 | fd = open_state_file(td->o.name, prefix, td->thread_number - 1, 0); | |
1469 | if (fd == -1) | |
1470 | return 1; | |
1471 | ||
1472 | ret = read(fd, &hdr, sizeof(hdr)); | |
1473 | if (ret != sizeof(hdr)) { | |
1474 | if (ret < 0) | |
1475 | td_verror(td, errno, "read verify state hdr"); | |
1476 | log_err("fio: failed reading verify state header\n"); | |
1477 | goto err; | |
1478 | } | |
1479 | ||
1480 | hdr.version = le64_to_cpu(hdr.version); | |
1481 | hdr.size = le64_to_cpu(hdr.size); | |
1482 | hdr.crc = le64_to_cpu(hdr.crc); | |
1483 | ||
1484 | if (hdr.version != VSTATE_HDR_VERSION) { | |
1485 | log_err("fio: bad version in verify state header\n"); | |
1486 | goto err; | |
1487 | } | |
1488 | ||
1489 | s = malloc(hdr.size); | |
1490 | ret = read(fd, s, hdr.size); | |
1491 | if (ret != hdr.size) { | |
1492 | if (ret < 0) | |
1493 | td_verror(td, errno, "read verify state"); | |
1494 | log_err("fio: failed reading verity state\n"); | |
1495 | goto err; | |
1496 | } | |
1497 | ||
1498 | crc = fio_crc32c((void *)s, hdr.size); | |
1499 | if (crc != hdr.crc) { | |
1500 | log_err("fio: verify state is corrupt\n"); | |
1501 | goto err; | |
1502 | } | |
1503 | ||
1504 | close(fd); | |
1505 | ||
1506 | verify_convert_assign_state(td, s); | |
1507 | return 0; | |
1508 | err: | |
1509 | if (s) | |
1510 | free(s); | |
1511 | close(fd); | |
1512 | return 1; | |
1513 | } | |
1514 | ||
1515 | /* | |
1516 | * Use the loaded verify state to know when to stop doing verification | |
1517 | */ | |
1518 | int verify_state_should_stop(struct thread_data *td, struct io_u *io_u) | |
1519 | { | |
1520 | struct thread_io_list *s = td->vstate; | |
1521 | int i; | |
1522 | ||
1523 | if (!s) | |
1524 | return 0; | |
1525 | ||
1526 | /* | |
1527 | * If we're not into the window of issues - depth yet, continue | |
1528 | */ | |
1529 | if (td->io_blocks[DDIR_READ] < s->depth || | |
1530 | s->numberio - td->io_blocks[DDIR_READ] > s->depth) | |
1531 | return 0; | |
1532 | ||
1533 | /* | |
1534 | * We're in the window of having to check if this io was | |
1535 | * completed or not. If the IO was seen as completed, then | |
1536 | * lets verify it. | |
1537 | */ | |
1538 | for (i = 0; i < s->no_comps; i++) | |
1539 | if (io_u->offset == s->offsets[i]) | |
1540 | return 0; | |
1541 | ||
1542 | /* | |
1543 | * Not found, we have to stop | |
1544 | */ | |
1545 | return 1; | |
1546 | } |