2 * IO verification helpers
15 #include "lib/hweight.h"
16 #include "lib/pattern.h"
19 #include "crc/crc64.h"
20 #include "crc/crc32.h"
21 #include "crc/crc32c.h"
22 #include "crc/crc16.h"
24 #include "crc/sha256.h"
25 #include "crc/sha512.h"
27 #include "crc/xxhash.h"
30 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
31 struct verify_header *hdr, unsigned int header_num,
32 unsigned int header_len);
33 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
34 struct verify_header *hdr, unsigned int header_num,
35 unsigned int header_len, uint64_t rand_seed);
37 void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len)
39 (void)cpy_pattern(td->o.buffer_pattern, td->o.buffer_pattern_bytes, p, len);
42 static void __fill_buffer(struct thread_options *o, unsigned long seed, void *p,
45 __fill_random_buf_percentage(seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
48 static unsigned long fill_buffer(struct thread_data *td, void *p,
51 struct frand_state *fs = &td->verify_state;
52 struct thread_options *o = &td->o;
54 return fill_random_buf_percentage(fs, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
57 void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,
58 struct io_u *io_u, unsigned long seed, int use_seed)
60 struct thread_options *o = &td->o;
62 if (!o->verify_pattern_bytes) {
63 dprint(FD_VERIFY, "fill random bytes len=%u\n", len);
66 __fill_buffer(o, seed, p, len);
68 io_u->rand_seed = fill_buffer(td, p, len);
72 /* Skip if we were here and we do not need to patch pattern
74 if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len) {
75 dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n",
76 o->verify_pattern_bytes, len);
80 (void)paste_format(td->o.verify_pattern, td->o.verify_pattern_bytes,
81 td->o.verify_fmt, td->o.verify_fmt_sz,
83 io_u->buf_filled_len = len;
86 static unsigned int get_hdr_inc(struct thread_data *td, struct io_u *io_u)
91 * If we use bs_unaligned, buflen can be larger than the verify
92 * interval (which just defaults to the smallest blocksize possible).
94 hdr_inc = io_u->buflen;
95 if (td->o.verify_interval && td->o.verify_interval <= io_u->buflen &&
97 hdr_inc = td->o.verify_interval;
102 static void fill_pattern_headers(struct thread_data *td, struct io_u *io_u,
103 unsigned long seed, int use_seed)
105 unsigned int hdr_inc, header_num;
106 struct verify_header *hdr;
109 fill_verify_pattern(td, p, io_u->buflen, io_u, seed, use_seed);
111 hdr_inc = get_hdr_inc(td, io_u);
113 for (; p < io_u->buf + io_u->buflen; p += hdr_inc) {
115 populate_hdr(td, io_u, hdr, header_num, hdr_inc);
120 static void memswp(void *buf1, void *buf2, unsigned int len)
124 assert(len <= sizeof(swap));
126 memcpy(&swap, buf1, len);
127 memcpy(buf1, buf2, len);
128 memcpy(buf2, &swap, len);
131 static void hexdump(void *buffer, int len)
133 unsigned char *p = buffer;
136 for (i = 0; i < len; i++)
137 log_err("%02x", p[i]);
142 * Prepare for separation of verify_header and checksum header
144 static inline unsigned int __hdr_size(int verify_type)
146 unsigned int len = 0;
148 switch (verify_type) {
150 case VERIFY_HDR_ONLY:
156 len = sizeof(struct vhdr_md5);
159 len = sizeof(struct vhdr_crc64);
163 case VERIFY_CRC32C_INTEL:
164 len = sizeof(struct vhdr_crc32);
167 len = sizeof(struct vhdr_crc16);
170 len = sizeof(struct vhdr_crc7);
173 len = sizeof(struct vhdr_sha256);
176 len = sizeof(struct vhdr_sha512);
178 case VERIFY_SHA3_224:
179 len = sizeof(struct vhdr_sha3_224);
181 case VERIFY_SHA3_256:
182 len = sizeof(struct vhdr_sha3_256);
184 case VERIFY_SHA3_384:
185 len = sizeof(struct vhdr_sha3_384);
187 case VERIFY_SHA3_512:
188 len = sizeof(struct vhdr_sha3_512);
191 len = sizeof(struct vhdr_xxhash);
194 len = sizeof(struct vhdr_sha1);
196 case VERIFY_PATTERN_NO_HDR:
199 log_err("fio: unknown verify header!\n");
203 return len + sizeof(struct verify_header);
206 static inline unsigned int hdr_size(struct thread_data *td,
207 struct verify_header *hdr)
209 if (td->o.verify == VERIFY_PATTERN_NO_HDR)
212 return __hdr_size(hdr->verify_type);
215 static void *hdr_priv(struct verify_header *hdr)
219 return priv + sizeof(struct verify_header);
223 * Verify container, pass info to verify handlers and allow them to
224 * pass info back in case of error
231 unsigned int hdr_num;
232 struct thread_data *td;
235 * Output, only valid in case of error
240 unsigned int crc_len;
243 #define DUMP_BUF_SZ 255
245 static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
246 const char *type, struct fio_file *f)
249 char sep[2] = { FIO_OS_PATH_SEPARATOR, 0 };
252 ptr = strdup(f->file_name);
254 if (asprintf(&fname, "%s%s%s.%llu.%s", aux_path ? : "",
255 aux_path ? sep : "", basename(ptr), offset, type) < 0) {
256 if (!fio_did_warn(FIO_WARN_VERIFY_BUF))
257 log_err("fio: not enough memory for dump buffer filename\n");
261 fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644);
263 perror("open verify buf file");
268 ret = write(fd, buf, len);
272 perror("write verify buf file");
280 log_err(" %s data dumped as %s\n", type, fname);
290 * Dump the contents of the read block and re-generate the correct data
293 static void __dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
295 struct thread_data *td = vc->td;
296 struct io_u *io_u = vc->io_u;
297 unsigned long hdr_offset;
301 if (!td->o.verify_dump)
305 * Dump the contents we just read off disk
307 hdr_offset = vc->hdr_num * hdr->len;
309 dump_buf(io_u->buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
310 "received", vc->io_u->file);
313 * Allocate a new buf and re-generate the original data
315 buf = malloc(io_u->buflen);
318 dummy.rand_seed = hdr->rand_seed;
319 dummy.buf_filled_len = 0;
320 dummy.buflen = io_u->buflen;
322 fill_pattern_headers(td, &dummy, hdr->rand_seed, 1);
324 dump_buf(buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
325 "expected", vc->io_u->file);
329 static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
331 struct thread_data *td = vc->td;
332 struct verify_header shdr;
334 if (td->o.verify == VERIFY_PATTERN_NO_HDR) {
335 __fill_hdr(td, vc->io_u, &shdr, 0, vc->io_u->buflen, 0);
339 __dump_verify_buffers(hdr, vc);
342 static void log_verify_failure(struct verify_header *hdr, struct vcont *vc)
344 unsigned long long offset;
346 offset = vc->io_u->offset;
347 offset += vc->hdr_num * hdr->len;
348 log_err("%.8s: verify failed at file %s offset %llu, length %u"
349 " (requested block: offset=%llu, length=%llu)\n",
350 vc->name, vc->io_u->file->file_name, offset, hdr->len,
351 vc->io_u->offset, vc->io_u->buflen);
353 if (vc->good_crc && vc->bad_crc) {
354 log_err(" Expected CRC: ");
355 hexdump(vc->good_crc, vc->crc_len);
356 log_err(" Received CRC: ");
357 hexdump(vc->bad_crc, vc->crc_len);
360 dump_verify_buffers(hdr, vc);
364 * Return data area 'header_num'
366 static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
368 return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(vc->td, hdr);
371 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
373 struct thread_data *td = vc->td;
374 struct io_u *io_u = vc->io_u;
376 unsigned int header_size = __hdr_size(td->o.verify);
377 unsigned int len, mod, i, pattern_size;
380 pattern = td->o.verify_pattern;
381 pattern_size = td->o.verify_pattern_bytes;
382 assert(pattern_size != 0);
384 (void)paste_format_inplace(pattern, pattern_size,
385 td->o.verify_fmt, td->o.verify_fmt_sz, io_u);
387 buf = (char *) hdr + header_size;
388 len = get_hdr_inc(td, io_u) - header_size;
389 mod = (get_hdr_inc(td, io_u) * vc->hdr_num + header_size) % pattern_size;
391 rc = cmp_pattern(pattern, pattern_size, mod, buf, len);
395 /* Slow path, compare each byte */
396 for (i = 0; i < len; i++) {
397 if (buf[i] != pattern[mod]) {
400 bits = hweight8(buf[i] ^ pattern[mod]);
401 log_err("fio: got pattern '%02x', wanted '%02x'. Bad bits %d\n",
402 (unsigned char)buf[i],
403 (unsigned char)pattern[mod],
405 log_err("fio: bad pattern block offset %u\n", i);
406 vc->name = "pattern";
407 log_verify_failure(hdr, vc);
411 if (mod == td->o.verify_pattern_bytes)
415 /* Unreachable line */
420 static int verify_io_u_xxhash(struct verify_header *hdr, struct vcont *vc)
422 void *p = io_u_verify_off(hdr, vc);
423 struct vhdr_xxhash *vh = hdr_priv(hdr);
427 dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len);
429 state = XXH32_init(1);
430 XXH32_update(state, p, hdr->len - hdr_size(vc->td, hdr));
431 hash = XXH32_digest(state);
433 if (vh->hash == hash)
437 vc->good_crc = &vh->hash;
439 vc->crc_len = sizeof(hash);
440 log_verify_failure(hdr, vc);
444 static int verify_io_u_sha3(struct verify_header *hdr, struct vcont *vc,
445 struct fio_sha3_ctx *sha3_ctx, uint8_t *sha,
446 unsigned int sha_size, const char *name)
448 void *p = io_u_verify_off(hdr, vc);
450 dprint(FD_VERIFY, "%s verify io_u %p, len %u\n", name, vc->io_u, hdr->len);
452 fio_sha3_update(sha3_ctx, p, hdr->len - hdr_size(vc->td, hdr));
453 fio_sha3_final(sha3_ctx);
455 if (!memcmp(sha, sha3_ctx->sha, sha_size))
460 vc->bad_crc = sha3_ctx->sha;
461 vc->crc_len = sha_size;
462 log_verify_failure(hdr, vc);
466 static int verify_io_u_sha3_224(struct verify_header *hdr, struct vcont *vc)
468 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
469 uint8_t sha[SHA3_224_DIGEST_SIZE];
470 struct fio_sha3_ctx sha3_ctx = {
474 fio_sha3_224_init(&sha3_ctx);
476 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
477 SHA3_224_DIGEST_SIZE, "sha3-224");
480 static int verify_io_u_sha3_256(struct verify_header *hdr, struct vcont *vc)
482 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
483 uint8_t sha[SHA3_256_DIGEST_SIZE];
484 struct fio_sha3_ctx sha3_ctx = {
488 fio_sha3_256_init(&sha3_ctx);
490 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
491 SHA3_256_DIGEST_SIZE, "sha3-256");
494 static int verify_io_u_sha3_384(struct verify_header *hdr, struct vcont *vc)
496 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
497 uint8_t sha[SHA3_384_DIGEST_SIZE];
498 struct fio_sha3_ctx sha3_ctx = {
502 fio_sha3_384_init(&sha3_ctx);
504 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
505 SHA3_384_DIGEST_SIZE, "sha3-384");
508 static int verify_io_u_sha3_512(struct verify_header *hdr, struct vcont *vc)
510 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
511 uint8_t sha[SHA3_512_DIGEST_SIZE];
512 struct fio_sha3_ctx sha3_ctx = {
516 fio_sha3_512_init(&sha3_ctx);
518 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
519 SHA3_512_DIGEST_SIZE, "sha3-512");
522 static int verify_io_u_sha512(struct verify_header *hdr, struct vcont *vc)
524 void *p = io_u_verify_off(hdr, vc);
525 struct vhdr_sha512 *vh = hdr_priv(hdr);
527 struct fio_sha512_ctx sha512_ctx = {
531 dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
533 fio_sha512_init(&sha512_ctx);
534 fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(vc->td, hdr));
536 if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
540 vc->good_crc = vh->sha512;
541 vc->bad_crc = sha512_ctx.buf;
542 vc->crc_len = sizeof(vh->sha512);
543 log_verify_failure(hdr, vc);
547 static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc)
549 void *p = io_u_verify_off(hdr, vc);
550 struct vhdr_sha256 *vh = hdr_priv(hdr);
552 struct fio_sha256_ctx sha256_ctx = {
556 dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
558 fio_sha256_init(&sha256_ctx);
559 fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(vc->td, hdr));
560 fio_sha256_final(&sha256_ctx);
562 if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
566 vc->good_crc = vh->sha256;
567 vc->bad_crc = sha256_ctx.buf;
568 vc->crc_len = sizeof(vh->sha256);
569 log_verify_failure(hdr, vc);
573 static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc)
575 void *p = io_u_verify_off(hdr, vc);
576 struct vhdr_sha1 *vh = hdr_priv(hdr);
578 struct fio_sha1_ctx sha1_ctx = {
582 dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
584 fio_sha1_init(&sha1_ctx);
585 fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(vc->td, hdr));
586 fio_sha1_final(&sha1_ctx);
588 if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
592 vc->good_crc = vh->sha1;
593 vc->bad_crc = sha1_ctx.H;
594 vc->crc_len = sizeof(vh->sha1);
595 log_verify_failure(hdr, vc);
599 static int verify_io_u_crc7(struct verify_header *hdr, struct vcont *vc)
601 void *p = io_u_verify_off(hdr, vc);
602 struct vhdr_crc7 *vh = hdr_priv(hdr);
605 dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
607 c = fio_crc7(p, hdr->len - hdr_size(vc->td, hdr));
613 vc->good_crc = &vh->crc7;
616 log_verify_failure(hdr, vc);
620 static int verify_io_u_crc16(struct verify_header *hdr, struct vcont *vc)
622 void *p = io_u_verify_off(hdr, vc);
623 struct vhdr_crc16 *vh = hdr_priv(hdr);
626 dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
628 c = fio_crc16(p, hdr->len - hdr_size(vc->td, hdr));
634 vc->good_crc = &vh->crc16;
637 log_verify_failure(hdr, vc);
641 static int verify_io_u_crc64(struct verify_header *hdr, struct vcont *vc)
643 void *p = io_u_verify_off(hdr, vc);
644 struct vhdr_crc64 *vh = hdr_priv(hdr);
645 unsigned long long c;
647 dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
649 c = fio_crc64(p, hdr->len - hdr_size(vc->td, hdr));
655 vc->good_crc = &vh->crc64;
658 log_verify_failure(hdr, vc);
662 static int verify_io_u_crc32(struct verify_header *hdr, struct vcont *vc)
664 void *p = io_u_verify_off(hdr, vc);
665 struct vhdr_crc32 *vh = hdr_priv(hdr);
668 dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
670 c = fio_crc32(p, hdr->len - hdr_size(vc->td, hdr));
676 vc->good_crc = &vh->crc32;
679 log_verify_failure(hdr, vc);
683 static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc)
685 void *p = io_u_verify_off(hdr, vc);
686 struct vhdr_crc32 *vh = hdr_priv(hdr);
689 dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
691 c = fio_crc32c(p, hdr->len - hdr_size(vc->td, hdr));
697 vc->good_crc = &vh->crc32;
700 log_verify_failure(hdr, vc);
704 static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc)
706 void *p = io_u_verify_off(hdr, vc);
707 struct vhdr_md5 *vh = hdr_priv(hdr);
708 uint32_t hash[MD5_HASH_WORDS];
709 struct fio_md5_ctx md5_ctx = {
713 dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
715 fio_md5_init(&md5_ctx);
716 fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(vc->td, hdr));
717 fio_md5_final(&md5_ctx);
719 if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
723 vc->good_crc = vh->md5_digest;
724 vc->bad_crc = md5_ctx.hash;
725 vc->crc_len = sizeof(hash);
726 log_verify_failure(hdr, vc);
731 * Push IO verification to a separate thread
733 int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr)
735 struct io_u *io_u = *io_u_ptr;
737 pthread_mutex_lock(&td->io_u_lock);
740 put_file_log(td, io_u->file);
742 if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
744 io_u_clear(td, io_u, IO_U_F_IN_CUR_DEPTH);
746 flist_add_tail(&io_u->verify_list, &td->verify_list);
749 pthread_cond_signal(&td->verify_cond);
750 pthread_mutex_unlock(&td->io_u_lock);
755 * Thanks Rusty, for spending the time so I don't have to.
757 * http://rusty.ozlabs.org/?p=560
759 static int mem_is_zero(const void *data, size_t length)
761 const unsigned char *p = data;
764 /* Check first 16 bytes manually */
765 for (len = 0; len < 16; len++) {
774 /* Now we know that's zero, memcmp with self. */
775 return memcmp(data, p, length) == 0;
778 static int mem_is_zero_slow(const void *data, size_t length, size_t *offset)
780 const unsigned char *p = data;
794 static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
798 if (!td->o.trim_zero)
801 if (mem_is_zero(io_u->buf, io_u->buflen))
804 mem_is_zero_slow(io_u->buf, io_u->buflen, &offset);
806 log_err("trim: verify failed at file %s offset %llu, length %llu"
807 ", block offset %lu\n",
808 io_u->file->file_name, io_u->offset, io_u->buflen,
809 (unsigned long) offset);
813 static int verify_header(struct io_u *io_u, struct thread_data *td,
814 struct verify_header *hdr, unsigned int hdr_num,
815 unsigned int hdr_len)
820 if (hdr->magic != FIO_HDR_MAGIC) {
821 log_err("verify: bad magic header %x, wanted %x",
822 hdr->magic, FIO_HDR_MAGIC);
825 if (hdr->len != hdr_len) {
826 log_err("verify: bad header length %u, wanted %u",
830 if (hdr->rand_seed != io_u->rand_seed) {
831 log_err("verify: bad header rand_seed %"PRIu64
833 hdr->rand_seed, io_u->rand_seed);
836 if (hdr->offset != io_u->offset + hdr_num * td->o.verify_interval) {
837 log_err("verify: bad header offset %"PRIu64
839 hdr->offset, io_u->offset);
844 * For read-only workloads, the program cannot be certain of the
845 * last numberio written to a block. Checking of numberio will be
846 * done only for workloads that write data. For verify_only,
847 * numberio will be checked in the last iteration when the correct
848 * state of numberio, that would have been written to each block
849 * in a previous run of fio, has been reached.
851 if (td_write(td) && (td_min_bs(td) == td_max_bs(td)) &&
853 if (!td->o.verify_only || td->o.loops == 0)
854 if (hdr->numberio != io_u->numberio) {
855 log_err("verify: bad header numberio %"PRIu16
857 hdr->numberio, io_u->numberio);
861 crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
862 if (crc != hdr->crc32) {
863 log_err("verify: bad header crc %x, calculated %x",
870 log_err(" at file %s offset %llu, length %u"
871 " (requested block: offset=%llu, length=%llu)\n",
872 io_u->file->file_name,
873 io_u->offset + hdr_num * hdr_len, hdr_len,
874 io_u->offset, io_u->buflen);
876 if (td->o.verify_dump)
877 dump_buf(p, hdr_len, io_u->offset + hdr_num * hdr_len,
878 "hdr_fail", io_u->file);
883 int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
885 struct verify_header *hdr;
886 struct io_u *io_u = *io_u_ptr;
887 unsigned int header_size, hdr_inc, hdr_num = 0;
891 if (td->o.verify == VERIFY_NULL || io_u->ddir != DDIR_READ)
894 * If the IO engine is faking IO (like null), then just pretend
895 * we verified everything.
897 if (td_ioengine_flagged(td, FIO_FAKEIO))
900 if (io_u->flags & IO_U_F_TRIMMED) {
901 ret = verify_trimmed_io_u(td, io_u);
905 hdr_inc = get_hdr_inc(td, io_u);
908 for (p = io_u->buf; p < io_u->buf + io_u->buflen;
909 p += hdr_inc, hdr_num++) {
915 unsigned int verify_type;
917 if (ret && td->o.verify_fatal)
920 header_size = __hdr_size(td->o.verify);
921 if (td->o.verify_offset)
922 memswp(p, p + td->o.verify_offset, header_size);
926 * Make rand_seed check pass when have verify_backlog.
928 if (!td_rw(td) || (td->flags & TD_F_VER_BACKLOG))
929 io_u->rand_seed = hdr->rand_seed;
931 if (td->o.verify != VERIFY_PATTERN_NO_HDR) {
932 ret = verify_header(io_u, td, hdr, hdr_num, hdr_inc);
937 if (td->o.verify != VERIFY_NONE)
938 verify_type = td->o.verify;
940 verify_type = hdr->verify_type;
942 switch (verify_type) {
943 case VERIFY_HDR_ONLY:
944 /* Header is always verified, check if pattern is left
945 * for verification. */
946 if (td->o.verify_pattern_bytes)
947 ret = verify_io_u_pattern(hdr, &vc);
950 ret = verify_io_u_md5(hdr, &vc);
953 ret = verify_io_u_crc64(hdr, &vc);
956 case VERIFY_CRC32C_INTEL:
957 ret = verify_io_u_crc32c(hdr, &vc);
960 ret = verify_io_u_crc32(hdr, &vc);
963 ret = verify_io_u_crc16(hdr, &vc);
966 ret = verify_io_u_crc7(hdr, &vc);
969 ret = verify_io_u_sha256(hdr, &vc);
972 ret = verify_io_u_sha512(hdr, &vc);
974 case VERIFY_SHA3_224:
975 ret = verify_io_u_sha3_224(hdr, &vc);
977 case VERIFY_SHA3_256:
978 ret = verify_io_u_sha3_256(hdr, &vc);
980 case VERIFY_SHA3_384:
981 ret = verify_io_u_sha3_384(hdr, &vc);
983 case VERIFY_SHA3_512:
984 ret = verify_io_u_sha3_512(hdr, &vc);
987 ret = verify_io_u_xxhash(hdr, &vc);
990 ret = verify_io_u_sha1(hdr, &vc);
993 case VERIFY_PATTERN_NO_HDR:
994 ret = verify_io_u_pattern(hdr, &vc);
997 log_err("Bad verify type %u\n", hdr->verify_type);
1001 if (ret && verify_type != hdr->verify_type)
1002 log_err("fio: verify type mismatch (%u media, %u given)\n",
1003 hdr->verify_type, verify_type);
1007 if (ret && td->o.verify_fatal)
1008 fio_mark_td_terminate(td);
1013 static void fill_xxhash(struct verify_header *hdr, void *p, unsigned int len)
1015 struct vhdr_xxhash *vh = hdr_priv(hdr);
1018 state = XXH32_init(1);
1019 XXH32_update(state, p, len);
1020 vh->hash = XXH32_digest(state);
1023 static void fill_sha3(struct fio_sha3_ctx *sha3_ctx, void *p, unsigned int len)
1025 fio_sha3_update(sha3_ctx, p, len);
1026 fio_sha3_final(sha3_ctx);
1029 static void fill_sha3_224(struct verify_header *hdr, void *p, unsigned int len)
1031 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
1032 struct fio_sha3_ctx sha3_ctx = {
1036 fio_sha3_224_init(&sha3_ctx);
1037 fill_sha3(&sha3_ctx, p, len);
1040 static void fill_sha3_256(struct verify_header *hdr, void *p, unsigned int len)
1042 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
1043 struct fio_sha3_ctx sha3_ctx = {
1047 fio_sha3_256_init(&sha3_ctx);
1048 fill_sha3(&sha3_ctx, p, len);
1051 static void fill_sha3_384(struct verify_header *hdr, void *p, unsigned int len)
1053 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
1054 struct fio_sha3_ctx sha3_ctx = {
1058 fio_sha3_384_init(&sha3_ctx);
1059 fill_sha3(&sha3_ctx, p, len);
1062 static void fill_sha3_512(struct verify_header *hdr, void *p, unsigned int len)
1064 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
1065 struct fio_sha3_ctx sha3_ctx = {
1069 fio_sha3_512_init(&sha3_ctx);
1070 fill_sha3(&sha3_ctx, p, len);
1073 static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
1075 struct vhdr_sha512 *vh = hdr_priv(hdr);
1076 struct fio_sha512_ctx sha512_ctx = {
1080 fio_sha512_init(&sha512_ctx);
1081 fio_sha512_update(&sha512_ctx, p, len);
1084 static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
1086 struct vhdr_sha256 *vh = hdr_priv(hdr);
1087 struct fio_sha256_ctx sha256_ctx = {
1091 fio_sha256_init(&sha256_ctx);
1092 fio_sha256_update(&sha256_ctx, p, len);
1093 fio_sha256_final(&sha256_ctx);
1096 static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
1098 struct vhdr_sha1 *vh = hdr_priv(hdr);
1099 struct fio_sha1_ctx sha1_ctx = {
1103 fio_sha1_init(&sha1_ctx);
1104 fio_sha1_update(&sha1_ctx, p, len);
1105 fio_sha1_final(&sha1_ctx);
1108 static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
1110 struct vhdr_crc7 *vh = hdr_priv(hdr);
1112 vh->crc7 = fio_crc7(p, len);
1115 static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
1117 struct vhdr_crc16 *vh = hdr_priv(hdr);
1119 vh->crc16 = fio_crc16(p, len);
1122 static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
1124 struct vhdr_crc32 *vh = hdr_priv(hdr);
1126 vh->crc32 = fio_crc32(p, len);
1129 static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
1131 struct vhdr_crc32 *vh = hdr_priv(hdr);
1133 vh->crc32 = fio_crc32c(p, len);
1136 static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
1138 struct vhdr_crc64 *vh = hdr_priv(hdr);
1140 vh->crc64 = fio_crc64(p, len);
1143 static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
1145 struct vhdr_md5 *vh = hdr_priv(hdr);
1146 struct fio_md5_ctx md5_ctx = {
1147 .hash = (uint32_t *) vh->md5_digest,
1150 fio_md5_init(&md5_ctx);
1151 fio_md5_update(&md5_ctx, p, len);
1152 fio_md5_final(&md5_ctx);
1155 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
1156 struct verify_header *hdr, unsigned int header_num,
1157 unsigned int header_len, uint64_t rand_seed)
1161 hdr->magic = FIO_HDR_MAGIC;
1162 hdr->verify_type = td->o.verify;
1163 hdr->len = header_len;
1164 hdr->rand_seed = rand_seed;
1165 hdr->offset = io_u->offset + header_num * td->o.verify_interval;
1166 hdr->time_sec = io_u->start_time.tv_sec;
1167 hdr->time_nsec = io_u->start_time.tv_nsec;
1168 hdr->thread = td->thread_number;
1169 hdr->numberio = io_u->numberio;
1170 hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
1174 static void fill_hdr(struct thread_data *td, struct io_u *io_u,
1175 struct verify_header *hdr, unsigned int header_num,
1176 unsigned int header_len, uint64_t rand_seed)
1178 if (td->o.verify != VERIFY_PATTERN_NO_HDR)
1179 __fill_hdr(td, io_u, hdr, header_num, header_len, rand_seed);
1182 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
1183 struct verify_header *hdr, unsigned int header_num,
1184 unsigned int header_len)
1186 unsigned int data_len;
1192 fill_hdr(td, io_u, hdr, header_num, header_len, io_u->rand_seed);
1194 data_len = header_len - hdr_size(td, hdr);
1196 data = p + hdr_size(td, hdr);
1197 switch (td->o.verify) {
1199 dprint(FD_VERIFY, "fill md5 io_u %p, len %u\n",
1201 fill_md5(hdr, data, data_len);
1204 dprint(FD_VERIFY, "fill crc64 io_u %p, len %u\n",
1206 fill_crc64(hdr, data, data_len);
1209 case VERIFY_CRC32C_INTEL:
1210 dprint(FD_VERIFY, "fill crc32c io_u %p, len %u\n",
1212 fill_crc32c(hdr, data, data_len);
1215 dprint(FD_VERIFY, "fill crc32 io_u %p, len %u\n",
1217 fill_crc32(hdr, data, data_len);
1220 dprint(FD_VERIFY, "fill crc16 io_u %p, len %u\n",
1222 fill_crc16(hdr, data, data_len);
1225 dprint(FD_VERIFY, "fill crc7 io_u %p, len %u\n",
1227 fill_crc7(hdr, data, data_len);
1230 dprint(FD_VERIFY, "fill sha256 io_u %p, len %u\n",
1232 fill_sha256(hdr, data, data_len);
1235 dprint(FD_VERIFY, "fill sha512 io_u %p, len %u\n",
1237 fill_sha512(hdr, data, data_len);
1239 case VERIFY_SHA3_224:
1240 dprint(FD_VERIFY, "fill sha3-224 io_u %p, len %u\n",
1242 fill_sha3_224(hdr, data, data_len);
1244 case VERIFY_SHA3_256:
1245 dprint(FD_VERIFY, "fill sha3-256 io_u %p, len %u\n",
1247 fill_sha3_256(hdr, data, data_len);
1249 case VERIFY_SHA3_384:
1250 dprint(FD_VERIFY, "fill sha3-384 io_u %p, len %u\n",
1252 fill_sha3_384(hdr, data, data_len);
1254 case VERIFY_SHA3_512:
1255 dprint(FD_VERIFY, "fill sha3-512 io_u %p, len %u\n",
1257 fill_sha3_512(hdr, data, data_len);
1260 dprint(FD_VERIFY, "fill xxhash io_u %p, len %u\n",
1262 fill_xxhash(hdr, data, data_len);
1265 dprint(FD_VERIFY, "fill sha1 io_u %p, len %u\n",
1267 fill_sha1(hdr, data, data_len);
1269 case VERIFY_HDR_ONLY:
1270 case VERIFY_PATTERN:
1271 case VERIFY_PATTERN_NO_HDR:
1272 /* nothing to do here */
1275 log_err("fio: bad verify type: %d\n", td->o.verify);
1279 if (td->o.verify_offset && hdr_size(td, hdr))
1280 memswp(p, p + td->o.verify_offset, hdr_size(td, hdr));
1284 * fill body of io_u->buf with random data and add a header with the
1285 * checksum of choice
1287 void populate_verify_io_u(struct thread_data *td, struct io_u *io_u)
1289 if (td->o.verify == VERIFY_NULL)
1292 io_u->numberio = td->io_issues[io_u->ddir];
1294 fill_pattern_headers(td, io_u, 0, 0);
1297 int get_next_verify(struct thread_data *td, struct io_u *io_u)
1299 struct io_piece *ipo = NULL;
1302 * this io_u is from a requeue, we already filled the offsets
1307 if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
1308 struct fio_rb_node *n = rb_first(&td->io_hist_tree);
1310 ipo = rb_entry(n, struct io_piece, rb_node);
1313 * Ensure that the associated IO has completed
1316 if (ipo->flags & IP_F_IN_FLIGHT)
1319 rb_erase(n, &td->io_hist_tree);
1320 assert(ipo->flags & IP_F_ONRB);
1321 ipo->flags &= ~IP_F_ONRB;
1322 } else if (!flist_empty(&td->io_hist_list)) {
1323 ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list);
1326 * Ensure that the associated IO has completed
1329 if (ipo->flags & IP_F_IN_FLIGHT)
1332 flist_del(&ipo->list);
1333 assert(ipo->flags & IP_F_ONLIST);
1334 ipo->flags &= ~IP_F_ONLIST;
1340 io_u->offset = ipo->offset;
1341 io_u->buflen = ipo->len;
1342 io_u->numberio = ipo->numberio;
1343 io_u->file = ipo->file;
1344 io_u_set(td, io_u, IO_U_F_VER_LIST);
1346 if (ipo->flags & IP_F_TRIMMED)
1347 io_u_set(td, io_u, IO_U_F_TRIMMED);
1349 if (!fio_file_open(io_u->file)) {
1350 int r = td_io_open_file(td, io_u->file);
1353 dprint(FD_VERIFY, "failed file %s open\n",
1354 io_u->file->file_name);
1359 get_file(ipo->file);
1360 assert(fio_file_open(io_u->file));
1361 io_u->ddir = DDIR_READ;
1362 io_u->xfer_buf = io_u->buf;
1363 io_u->xfer_buflen = io_u->buflen;
1365 remove_trim_entry(td, ipo);
1367 dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u);
1369 if (!td->o.verify_pattern_bytes) {
1370 io_u->rand_seed = __rand(&td->verify_state);
1371 if (sizeof(int) != sizeof(long *))
1372 io_u->rand_seed *= __rand(&td->verify_state);
1378 dprint(FD_VERIFY, "get_next_verify: empty\n");
1382 void fio_verify_init(struct thread_data *td)
1384 if (td->o.verify == VERIFY_CRC32C_INTEL ||
1385 td->o.verify == VERIFY_CRC32C) {
1386 crc32c_arm64_probe();
1387 crc32c_intel_probe();
1391 static void *verify_async_thread(void *data)
1393 struct thread_data *td = data;
1397 if (fio_option_is_set(&td->o, verify_cpumask) &&
1398 fio_setaffinity(td->pid, td->o.verify_cpumask)) {
1399 log_err("fio: failed setting verify thread affinity\n");
1407 if (td->verify_thread_exit)
1410 pthread_mutex_lock(&td->io_u_lock);
1412 while (flist_empty(&td->verify_list) &&
1413 !td->verify_thread_exit) {
1414 ret = pthread_cond_wait(&td->verify_cond,
1417 pthread_mutex_unlock(&td->io_u_lock);
1422 flist_splice_init(&td->verify_list, &list);
1423 pthread_mutex_unlock(&td->io_u_lock);
1425 if (flist_empty(&list))
1428 while (!flist_empty(&list)) {
1429 io_u = flist_first_entry(&list, struct io_u, verify_list);
1430 flist_del_init(&io_u->verify_list);
1432 io_u_set(td, io_u, IO_U_F_NO_FILE_PUT);
1433 ret = verify_io_u(td, &io_u);
1438 if (td_non_fatal_error(td, ERROR_TYPE_VERIFY_BIT, ret)) {
1439 update_error_count(td, ret);
1447 td_verror(td, ret, "async_verify");
1448 if (td->o.verify_fatal)
1449 fio_mark_td_terminate(td);
1453 pthread_mutex_lock(&td->io_u_lock);
1454 td->nr_verify_threads--;
1455 pthread_cond_signal(&td->free_cond);
1456 pthread_mutex_unlock(&td->io_u_lock);
1461 int verify_async_init(struct thread_data *td)
1464 pthread_attr_t attr;
1466 pthread_attr_init(&attr);
1467 pthread_attr_setstacksize(&attr, 2 * PTHREAD_STACK_MIN);
1469 td->verify_thread_exit = 0;
1471 td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async);
1472 for (i = 0; i < td->o.verify_async; i++) {
1473 ret = pthread_create(&td->verify_threads[i], &attr,
1474 verify_async_thread, td);
1476 log_err("fio: async verify creation failed: %s\n",
1480 ret = pthread_detach(td->verify_threads[i]);
1482 log_err("fio: async verify thread detach failed: %s\n",
1486 td->nr_verify_threads++;
1489 pthread_attr_destroy(&attr);
1491 if (i != td->o.verify_async) {
1492 log_err("fio: only %d verify threads started, exiting\n", i);
1494 pthread_mutex_lock(&td->io_u_lock);
1495 td->verify_thread_exit = 1;
1496 pthread_cond_broadcast(&td->verify_cond);
1497 pthread_mutex_unlock(&td->io_u_lock);
1505 void verify_async_exit(struct thread_data *td)
1507 pthread_mutex_lock(&td->io_u_lock);
1508 td->verify_thread_exit = 1;
1509 pthread_cond_broadcast(&td->verify_cond);
1511 while (td->nr_verify_threads)
1512 pthread_cond_wait(&td->free_cond, &td->io_u_lock);
1514 pthread_mutex_unlock(&td->io_u_lock);
1515 free(td->verify_threads);
1516 td->verify_threads = NULL;
1519 int paste_blockoff(char *buf, unsigned int len, void *priv)
1521 struct io_u *io = priv;
1522 unsigned long long off;
1524 typecheck(__typeof__(off), io->offset);
1525 off = cpu_to_le64((uint64_t)io->offset);
1526 len = min(len, (unsigned int)sizeof(off));
1527 memcpy(buf, &off, len);
1531 static int __fill_file_completions(struct thread_data *td,
1532 struct thread_io_list *s,
1533 struct fio_file *f, unsigned int *index)
1538 if (!f->last_write_comp)
1541 if (td->io_blocks[DDIR_WRITE] < td->o.iodepth)
1542 comps = td->io_blocks[DDIR_WRITE];
1544 comps = td->o.iodepth;
1546 j = f->last_write_idx - 1;
1547 for (i = 0; i < comps; i++) {
1549 j = td->o.iodepth - 1;
1550 s->comps[*index].fileno = __cpu_to_le64(f->fileno);
1551 s->comps[*index].offset = cpu_to_le64(f->last_write_comp[j]);
1559 static int fill_file_completions(struct thread_data *td,
1560 struct thread_io_list *s, unsigned int *index)
1566 for_each_file(td, f, i)
1567 comps += __fill_file_completions(td, s, f, index);
1572 struct all_io_list *get_all_io_list(int save_mask, size_t *sz)
1574 struct all_io_list *rep;
1575 struct thread_data *td;
1580 compiletime_assert(sizeof(struct all_io_list) == 8, "all_io_list");
1583 * Calculate reply space needed. We need one 'io_state' per thread,
1584 * and the size will vary depending on depth.
1588 for_each_td(td, i) {
1589 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1592 td->flags |= TD_F_VSTATE_SAVED;
1593 depth += (td->o.iodepth * td->o.nr_files);
1601 *sz += nr * sizeof(struct thread_io_list);
1602 *sz += depth * sizeof(struct file_comp);
1604 memset(rep, 0, *sz);
1606 rep->threads = cpu_to_le64((uint64_t) nr);
1608 next = &rep->state[0];
1609 for_each_td(td, i) {
1610 struct thread_io_list *s = next;
1611 unsigned int comps, index = 0;
1613 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1616 comps = fill_file_completions(td, s, &index);
1618 s->no_comps = cpu_to_le64((uint64_t) comps);
1619 s->depth = cpu_to_le64((uint64_t) td->o.iodepth);
1620 s->nofiles = cpu_to_le64((uint64_t) td->o.nr_files);
1621 s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]);
1622 s->index = cpu_to_le64((uint64_t) i);
1623 if (td->random_state.use64) {
1624 s->rand.state64.s[0] = cpu_to_le64(td->random_state.state64.s1);
1625 s->rand.state64.s[1] = cpu_to_le64(td->random_state.state64.s2);
1626 s->rand.state64.s[2] = cpu_to_le64(td->random_state.state64.s3);
1627 s->rand.state64.s[3] = cpu_to_le64(td->random_state.state64.s4);
1628 s->rand.state64.s[4] = cpu_to_le64(td->random_state.state64.s5);
1629 s->rand.state64.s[5] = 0;
1630 s->rand.use64 = cpu_to_le64((uint64_t)1);
1632 s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1);
1633 s->rand.state32.s[1] = cpu_to_le32(td->random_state.state32.s2);
1634 s->rand.state32.s[2] = cpu_to_le32(td->random_state.state32.s3);
1635 s->rand.state32.s[3] = 0;
1638 s->name[sizeof(s->name) - 1] = '\0';
1639 strncpy((char *) s->name, td->o.name, sizeof(s->name) - 1);
1640 next = io_list_next(s);
1646 static int open_state_file(const char *name, const char *prefix, int num,
1654 flags = O_CREAT | O_TRUNC | O_WRONLY | O_SYNC;
1658 verify_state_gen_name(out, sizeof(out), name, prefix, num);
1660 fd = open(out, flags, 0644);
1662 perror("fio: open state file");
1663 log_err("fio: state file: %s (for_write=%d)\n", out, for_write);
1670 static int write_thread_list_state(struct thread_io_list *s,
1673 struct verify_state_hdr hdr;
1678 fd = open_state_file((const char *) s->name, prefix, s->index, 1);
1682 crc = fio_crc32c((void *)s, thread_io_list_sz(s));
1684 hdr.version = cpu_to_le64((uint64_t) VSTATE_HDR_VERSION);
1685 hdr.size = cpu_to_le64((uint64_t) thread_io_list_sz(s));
1686 hdr.crc = cpu_to_le64(crc);
1687 ret = write(fd, &hdr, sizeof(hdr));
1688 if (ret != sizeof(hdr))
1691 ret = write(fd, s, thread_io_list_sz(s));
1692 if (ret != thread_io_list_sz(s)) {
1695 perror("fio: write state file");
1696 log_err("fio: failed to write state file\n");
1705 void __verify_save_state(struct all_io_list *state, const char *prefix)
1707 struct thread_io_list *s = &state->state[0];
1710 for (i = 0; i < le64_to_cpu(state->threads); i++) {
1711 write_thread_list_state(s, prefix);
1712 s = io_list_next(s);
1716 void verify_save_state(int mask)
1718 struct all_io_list *state;
1721 state = get_all_io_list(mask, &sz);
1723 char prefix[PATH_MAX];
1726 sprintf(prefix, "%s%clocal", aux_path, FIO_OS_PATH_SEPARATOR);
1728 strcpy(prefix, "local");
1730 __verify_save_state(state, prefix);
1735 void verify_free_state(struct thread_data *td)
1741 void verify_assign_state(struct thread_data *td, void *p)
1743 struct thread_io_list *s = p;
1746 s->no_comps = le64_to_cpu(s->no_comps);
1747 s->depth = le32_to_cpu(s->depth);
1748 s->nofiles = le32_to_cpu(s->nofiles);
1749 s->numberio = le64_to_cpu(s->numberio);
1750 s->rand.use64 = le64_to_cpu(s->rand.use64);
1752 if (s->rand.use64) {
1753 for (i = 0; i < 6; i++)
1754 s->rand.state64.s[i] = le64_to_cpu(s->rand.state64.s[i]);
1756 for (i = 0; i < 4; i++)
1757 s->rand.state32.s[i] = le32_to_cpu(s->rand.state32.s[i]);
1760 for (i = 0; i < s->no_comps; i++) {
1761 s->comps[i].fileno = le64_to_cpu(s->comps[i].fileno);
1762 s->comps[i].offset = le64_to_cpu(s->comps[i].offset);
1768 int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s)
1772 hdr->version = le64_to_cpu(hdr->version);
1773 hdr->size = le64_to_cpu(hdr->size);
1774 hdr->crc = le64_to_cpu(hdr->crc);
1776 if (hdr->version != VSTATE_HDR_VERSION)
1779 crc = fio_crc32c((void *)s, hdr->size);
1780 if (crc != hdr->crc)
1786 int verify_load_state(struct thread_data *td, const char *prefix)
1788 struct verify_state_hdr hdr;
1794 if (!td->o.verify_state)
1797 fd = open_state_file(td->o.name, prefix, td->thread_number - 1, 0);
1801 ret = read(fd, &hdr, sizeof(hdr));
1802 if (ret != sizeof(hdr)) {
1804 td_verror(td, errno, "read verify state hdr");
1805 log_err("fio: failed reading verify state header\n");
1809 hdr.version = le64_to_cpu(hdr.version);
1810 hdr.size = le64_to_cpu(hdr.size);
1811 hdr.crc = le64_to_cpu(hdr.crc);
1813 if (hdr.version != VSTATE_HDR_VERSION) {
1814 log_err("fio: unsupported (%d) version in verify state header\n",
1815 (unsigned int) hdr.version);
1819 s = malloc(hdr.size);
1820 ret = read(fd, s, hdr.size);
1821 if (ret != hdr.size) {
1823 td_verror(td, errno, "read verify state");
1824 log_err("fio: failed reading verity state\n");
1828 crc = fio_crc32c(s, hdr.size);
1829 if (crc != hdr.crc) {
1830 log_err("fio: verify state is corrupt\n");
1836 verify_assign_state(td, s);
1846 * Use the loaded verify state to know when to stop doing verification
1848 int verify_state_should_stop(struct thread_data *td, struct io_u *io_u)
1850 struct thread_io_list *s = td->vstate;
1851 struct fio_file *f = io_u->file;
1858 * If we're not into the window of issues - depth yet, continue. If
1859 * issue is shorter than depth, do check.
1861 if ((td->io_blocks[DDIR_READ] < s->depth ||
1862 s->numberio - td->io_blocks[DDIR_READ] > s->depth) &&
1863 s->numberio > s->depth)
1867 * We're in the window of having to check if this io was
1868 * completed or not. If the IO was seen as completed, then
1871 for (i = 0; i < s->no_comps; i++) {
1872 if (s->comps[i].fileno != f->fileno)
1874 if (io_u->offset == s->comps[i].offset)
1879 * Not found, we have to stop