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);
36 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
37 struct verify_header *hdr, unsigned int header_num,
38 unsigned int header_len, uint64_t rand_seed);
40 void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len)
42 (void)cpy_pattern(td->o.buffer_pattern, td->o.buffer_pattern_bytes, p, len);
45 static void __fill_buffer(struct thread_options *o, unsigned long seed, void *p,
48 __fill_random_buf_percentage(seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
51 static unsigned long fill_buffer(struct thread_data *td, void *p,
54 struct frand_state *fs = &td->verify_state;
55 struct thread_options *o = &td->o;
57 return fill_random_buf_percentage(fs, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
60 void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,
61 struct io_u *io_u, unsigned long seed, int use_seed)
63 struct thread_options *o = &td->o;
65 if (!o->verify_pattern_bytes) {
66 dprint(FD_VERIFY, "fill random bytes len=%u\n", len);
69 __fill_buffer(o, seed, p, len);
71 io_u->rand_seed = fill_buffer(td, p, len);
75 /* Skip if we were here and we do not need to patch pattern
77 if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len) {
78 dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n",
79 o->verify_pattern_bytes, len);
83 (void)paste_format(td->o.verify_pattern, td->o.verify_pattern_bytes,
84 td->o.verify_fmt, td->o.verify_fmt_sz,
86 io_u->buf_filled_len = len;
89 static unsigned int get_hdr_inc(struct thread_data *td, struct io_u *io_u)
93 hdr_inc = io_u->buflen;
94 if (td->o.verify_interval && td->o.verify_interval <= io_u->buflen)
95 hdr_inc = td->o.verify_interval;
100 static void fill_pattern_headers(struct thread_data *td, struct io_u *io_u,
101 unsigned long seed, int use_seed)
103 unsigned int hdr_inc, header_num;
104 struct verify_header *hdr;
107 fill_verify_pattern(td, p, io_u->buflen, io_u, seed, use_seed);
109 hdr_inc = get_hdr_inc(td, io_u);
111 for (; p < io_u->buf + io_u->buflen; p += hdr_inc) {
113 populate_hdr(td, io_u, hdr, header_num, hdr_inc);
118 static void memswp(void *buf1, void *buf2, unsigned int len)
122 assert(len <= sizeof(swap));
124 memcpy(&swap, buf1, len);
125 memcpy(buf1, buf2, len);
126 memcpy(buf2, &swap, len);
129 static void hexdump(void *buffer, int len)
131 unsigned char *p = buffer;
134 for (i = 0; i < len; i++)
135 log_err("%02x", p[i]);
140 * Prepare for separation of verify_header and checksum header
142 static inline unsigned int __hdr_size(int verify_type)
144 unsigned int len = 0;
146 switch (verify_type) {
148 case VERIFY_HDR_ONLY:
154 len = sizeof(struct vhdr_md5);
157 len = sizeof(struct vhdr_crc64);
161 case VERIFY_CRC32C_INTEL:
162 len = sizeof(struct vhdr_crc32);
165 len = sizeof(struct vhdr_crc16);
168 len = sizeof(struct vhdr_crc7);
171 len = sizeof(struct vhdr_sha256);
174 len = sizeof(struct vhdr_sha512);
176 case VERIFY_SHA3_224:
177 len = sizeof(struct vhdr_sha3_224);
179 case VERIFY_SHA3_256:
180 len = sizeof(struct vhdr_sha3_256);
182 case VERIFY_SHA3_384:
183 len = sizeof(struct vhdr_sha3_384);
185 case VERIFY_SHA3_512:
186 len = sizeof(struct vhdr_sha3_512);
189 len = sizeof(struct vhdr_xxhash);
192 len = sizeof(struct vhdr_sha1);
194 case VERIFY_PATTERN_NO_HDR:
197 log_err("fio: unknown verify header!\n");
201 return len + sizeof(struct verify_header);
204 static inline unsigned int hdr_size(struct thread_data *td,
205 struct verify_header *hdr)
207 if (td->o.verify == VERIFY_PATTERN_NO_HDR)
210 return __hdr_size(hdr->verify_type);
213 static void *hdr_priv(struct verify_header *hdr)
217 return priv + sizeof(struct verify_header);
221 * Verify container, pass info to verify handlers and allow them to
222 * pass info back in case of error
229 unsigned int hdr_num;
230 struct thread_data *td;
233 * Output, only valid in case of error
238 unsigned int crc_len;
241 #define DUMP_BUF_SZ 255
242 static int dump_buf_warned;
244 static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
245 const char *type, struct fio_file *f)
247 char *ptr, fname[DUMP_BUF_SZ];
248 size_t buf_left = DUMP_BUF_SZ;
251 ptr = strdup(f->file_name);
253 memset(fname, 0, sizeof(fname));
255 sprintf(fname, "%s%s", aux_path, FIO_OS_PATH_SEPARATOR);
257 strncpy(fname + strlen(fname), basename(ptr), buf_left - 1);
259 buf_left -= strlen(fname);
261 if (!dump_buf_warned) {
262 log_err("fio: verify failure dump buffer too small\n");
269 snprintf(fname + strlen(fname), buf_left, ".%llu.%s", offset, type);
271 fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644);
273 perror("open verify buf file");
279 ret = write(fd, buf, len);
283 perror("write verify buf file");
291 log_err(" %s data dumped as %s\n", type, fname);
296 * Dump the contents of the read block and re-generate the correct data
299 static void __dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
301 struct thread_data *td = vc->td;
302 struct io_u *io_u = vc->io_u;
303 unsigned long hdr_offset;
307 if (!td->o.verify_dump)
311 * Dump the contents we just read off disk
313 hdr_offset = vc->hdr_num * hdr->len;
315 dump_buf(io_u->buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
316 "received", vc->io_u->file);
319 * Allocate a new buf and re-generate the original data
321 buf = malloc(io_u->buflen);
324 dummy.rand_seed = hdr->rand_seed;
325 dummy.buf_filled_len = 0;
326 dummy.buflen = io_u->buflen;
328 fill_pattern_headers(td, &dummy, hdr->rand_seed, 1);
330 dump_buf(buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
331 "expected", vc->io_u->file);
335 static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
337 struct thread_data *td = vc->td;
338 struct verify_header shdr;
340 if (td->o.verify == VERIFY_PATTERN_NO_HDR) {
341 __fill_hdr(td, vc->io_u, &shdr, 0, vc->io_u->buflen, 0);
345 __dump_verify_buffers(hdr, vc);
348 static void log_verify_failure(struct verify_header *hdr, struct vcont *vc)
350 unsigned long long offset;
352 offset = vc->io_u->offset;
353 offset += vc->hdr_num * hdr->len;
354 log_err("%.8s: verify failed at file %s offset %llu, length %u\n",
355 vc->name, vc->io_u->file->file_name, offset, hdr->len);
357 if (vc->good_crc && vc->bad_crc) {
358 log_err(" Expected CRC: ");
359 hexdump(vc->good_crc, vc->crc_len);
360 log_err(" Received CRC: ");
361 hexdump(vc->bad_crc, vc->crc_len);
364 dump_verify_buffers(hdr, vc);
368 * Return data area 'header_num'
370 static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
372 return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(vc->td, hdr);
375 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
377 struct thread_data *td = vc->td;
378 struct io_u *io_u = vc->io_u;
380 unsigned int header_size = __hdr_size(td->o.verify);
381 unsigned int len, mod, i, pattern_size;
384 pattern = td->o.verify_pattern;
385 pattern_size = td->o.verify_pattern_bytes;
386 assert(pattern_size != 0);
388 (void)paste_format_inplace(pattern, pattern_size,
389 td->o.verify_fmt, td->o.verify_fmt_sz, io_u);
391 buf = (char *) hdr + header_size;
392 len = get_hdr_inc(td, io_u) - header_size;
393 mod = (get_hdr_inc(td, io_u) * vc->hdr_num + header_size) % pattern_size;
395 rc = cmp_pattern(pattern, pattern_size, mod, buf, len);
399 /* Slow path, compare each byte */
400 for (i = 0; i < len; i++) {
401 if (buf[i] != pattern[mod]) {
404 bits = hweight8(buf[i] ^ pattern[mod]);
405 log_err("fio: got pattern '%02x', wanted '%02x'. Bad bits %d\n",
406 (unsigned char)buf[i],
407 (unsigned char)pattern[mod],
409 log_err("fio: bad pattern block offset %u\n", i);
410 vc->name = "pattern";
411 log_verify_failure(hdr, vc);
415 if (mod == td->o.verify_pattern_bytes)
419 /* Unreachable line */
424 static int verify_io_u_xxhash(struct verify_header *hdr, struct vcont *vc)
426 void *p = io_u_verify_off(hdr, vc);
427 struct vhdr_xxhash *vh = hdr_priv(hdr);
431 dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len);
433 state = XXH32_init(1);
434 XXH32_update(state, p, hdr->len - hdr_size(vc->td, hdr));
435 hash = XXH32_digest(state);
437 if (vh->hash == hash)
441 vc->good_crc = &vh->hash;
443 vc->crc_len = sizeof(hash);
444 log_verify_failure(hdr, vc);
448 static int verify_io_u_sha3(struct verify_header *hdr, struct vcont *vc,
449 struct fio_sha3_ctx *sha3_ctx, uint8_t *sha,
450 unsigned int sha_size, const char *name)
452 void *p = io_u_verify_off(hdr, vc);
454 dprint(FD_VERIFY, "%s verify io_u %p, len %u\n", name, vc->io_u, hdr->len);
456 fio_sha3_update(sha3_ctx, p, hdr->len - hdr_size(vc->td, hdr));
457 fio_sha3_final(sha3_ctx);
459 if (!memcmp(sha, sha3_ctx->sha, sha_size))
464 vc->bad_crc = sha3_ctx->sha;
465 vc->crc_len = sha_size;
466 log_verify_failure(hdr, vc);
470 static int verify_io_u_sha3_224(struct verify_header *hdr, struct vcont *vc)
472 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
473 uint8_t sha[SHA3_224_DIGEST_SIZE];
474 struct fio_sha3_ctx sha3_ctx = {
478 fio_sha3_224_init(&sha3_ctx);
480 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
481 SHA3_224_DIGEST_SIZE, "sha3-224");
484 static int verify_io_u_sha3_256(struct verify_header *hdr, struct vcont *vc)
486 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
487 uint8_t sha[SHA3_256_DIGEST_SIZE];
488 struct fio_sha3_ctx sha3_ctx = {
492 fio_sha3_256_init(&sha3_ctx);
494 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
495 SHA3_256_DIGEST_SIZE, "sha3-256");
498 static int verify_io_u_sha3_384(struct verify_header *hdr, struct vcont *vc)
500 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
501 uint8_t sha[SHA3_384_DIGEST_SIZE];
502 struct fio_sha3_ctx sha3_ctx = {
506 fio_sha3_384_init(&sha3_ctx);
508 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
509 SHA3_384_DIGEST_SIZE, "sha3-384");
512 static int verify_io_u_sha3_512(struct verify_header *hdr, struct vcont *vc)
514 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
515 uint8_t sha[SHA3_512_DIGEST_SIZE];
516 struct fio_sha3_ctx sha3_ctx = {
520 fio_sha3_512_init(&sha3_ctx);
522 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
523 SHA3_512_DIGEST_SIZE, "sha3-512");
526 static int verify_io_u_sha512(struct verify_header *hdr, struct vcont *vc)
528 void *p = io_u_verify_off(hdr, vc);
529 struct vhdr_sha512 *vh = hdr_priv(hdr);
531 struct fio_sha512_ctx sha512_ctx = {
535 dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
537 fio_sha512_init(&sha512_ctx);
538 fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(vc->td, hdr));
540 if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
544 vc->good_crc = vh->sha512;
545 vc->bad_crc = sha512_ctx.buf;
546 vc->crc_len = sizeof(vh->sha512);
547 log_verify_failure(hdr, vc);
551 static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc)
553 void *p = io_u_verify_off(hdr, vc);
554 struct vhdr_sha256 *vh = hdr_priv(hdr);
556 struct fio_sha256_ctx sha256_ctx = {
560 dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
562 fio_sha256_init(&sha256_ctx);
563 fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(vc->td, hdr));
564 fio_sha256_final(&sha256_ctx);
566 if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
570 vc->good_crc = vh->sha256;
571 vc->bad_crc = sha256_ctx.buf;
572 vc->crc_len = sizeof(vh->sha256);
573 log_verify_failure(hdr, vc);
577 static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc)
579 void *p = io_u_verify_off(hdr, vc);
580 struct vhdr_sha1 *vh = hdr_priv(hdr);
582 struct fio_sha1_ctx sha1_ctx = {
586 dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
588 fio_sha1_init(&sha1_ctx);
589 fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(vc->td, hdr));
590 fio_sha1_final(&sha1_ctx);
592 if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
596 vc->good_crc = vh->sha1;
597 vc->bad_crc = sha1_ctx.H;
598 vc->crc_len = sizeof(vh->sha1);
599 log_verify_failure(hdr, vc);
603 static int verify_io_u_crc7(struct verify_header *hdr, struct vcont *vc)
605 void *p = io_u_verify_off(hdr, vc);
606 struct vhdr_crc7 *vh = hdr_priv(hdr);
609 dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
611 c = fio_crc7(p, hdr->len - hdr_size(vc->td, hdr));
617 vc->good_crc = &vh->crc7;
620 log_verify_failure(hdr, vc);
624 static int verify_io_u_crc16(struct verify_header *hdr, struct vcont *vc)
626 void *p = io_u_verify_off(hdr, vc);
627 struct vhdr_crc16 *vh = hdr_priv(hdr);
630 dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
632 c = fio_crc16(p, hdr->len - hdr_size(vc->td, hdr));
638 vc->good_crc = &vh->crc16;
641 log_verify_failure(hdr, vc);
645 static int verify_io_u_crc64(struct verify_header *hdr, struct vcont *vc)
647 void *p = io_u_verify_off(hdr, vc);
648 struct vhdr_crc64 *vh = hdr_priv(hdr);
649 unsigned long long c;
651 dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
653 c = fio_crc64(p, hdr->len - hdr_size(vc->td, hdr));
659 vc->good_crc = &vh->crc64;
662 log_verify_failure(hdr, vc);
666 static int verify_io_u_crc32(struct verify_header *hdr, struct vcont *vc)
668 void *p = io_u_verify_off(hdr, vc);
669 struct vhdr_crc32 *vh = hdr_priv(hdr);
672 dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
674 c = fio_crc32(p, hdr->len - hdr_size(vc->td, hdr));
680 vc->good_crc = &vh->crc32;
683 log_verify_failure(hdr, vc);
687 static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc)
689 void *p = io_u_verify_off(hdr, vc);
690 struct vhdr_crc32 *vh = hdr_priv(hdr);
693 dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
695 c = fio_crc32c(p, hdr->len - hdr_size(vc->td, hdr));
701 vc->good_crc = &vh->crc32;
704 log_verify_failure(hdr, vc);
708 static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc)
710 void *p = io_u_verify_off(hdr, vc);
711 struct vhdr_md5 *vh = hdr_priv(hdr);
712 uint32_t hash[MD5_HASH_WORDS];
713 struct fio_md5_ctx md5_ctx = {
717 dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
719 fio_md5_init(&md5_ctx);
720 fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(vc->td, hdr));
721 fio_md5_final(&md5_ctx);
723 if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
727 vc->good_crc = vh->md5_digest;
728 vc->bad_crc = md5_ctx.hash;
729 vc->crc_len = sizeof(hash);
730 log_verify_failure(hdr, vc);
735 * Push IO verification to a separate thread
737 int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr)
739 struct io_u *io_u = *io_u_ptr;
741 pthread_mutex_lock(&td->io_u_lock);
744 put_file_log(td, io_u->file);
746 if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
748 io_u_clear(td, io_u, IO_U_F_IN_CUR_DEPTH);
750 flist_add_tail(&io_u->verify_list, &td->verify_list);
752 pthread_mutex_unlock(&td->io_u_lock);
754 pthread_cond_signal(&td->verify_cond);
759 * Thanks Rusty, for spending the time so I don't have to.
761 * http://rusty.ozlabs.org/?p=560
763 static int mem_is_zero(const void *data, size_t length)
765 const unsigned char *p = data;
768 /* Check first 16 bytes manually */
769 for (len = 0; len < 16; len++) {
778 /* Now we know that's zero, memcmp with self. */
779 return memcmp(data, p, length) == 0;
782 static int mem_is_zero_slow(const void *data, size_t length, size_t *offset)
784 const unsigned char *p = data;
798 static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
802 if (!td->o.trim_zero)
805 if (mem_is_zero(io_u->buf, io_u->buflen))
808 mem_is_zero_slow(io_u->buf, io_u->buflen, &offset);
810 log_err("trim: verify failed at file %s offset %llu, length %lu"
811 ", block offset %lu\n",
812 io_u->file->file_name, io_u->offset, io_u->buflen,
813 (unsigned long) offset);
817 static int verify_header(struct io_u *io_u, struct thread_data *td,
818 struct verify_header *hdr, unsigned int hdr_num,
819 unsigned int hdr_len)
824 if (hdr->magic != FIO_HDR_MAGIC) {
825 log_err("verify: bad magic header %x, wanted %x",
826 hdr->magic, FIO_HDR_MAGIC);
829 if (hdr->len != hdr_len) {
830 log_err("verify: bad header length %u, wanted %u",
834 if (hdr->rand_seed != io_u->rand_seed) {
835 log_err("verify: bad header rand_seed %"PRIu64
837 hdr->rand_seed, io_u->rand_seed);
840 if (hdr->offset != io_u->offset + hdr_num * td->o.verify_interval) {
841 log_err("verify: bad header offset %"PRIu64
843 hdr->offset, io_u->offset);
848 * For read-only workloads, the program cannot be certain of the
849 * last numberio written to a block. Checking of numberio will be
850 * done only for workloads that write data. For verify_only,
851 * numberio will be checked in the last iteration when the correct
852 * state of numberio, that would have been written to each block
853 * in a previous run of fio, has been reached.
855 if (td_write(td) && (td_min_bs(td) == td_max_bs(td)) &&
857 if (!td->o.verify_only || td->o.loops == 0)
858 if (hdr->numberio != io_u->numberio) {
859 log_err("verify: bad header numberio %"PRIu16
861 hdr->numberio, io_u->numberio);
865 crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
866 if (crc != hdr->crc32) {
867 log_err("verify: bad header crc %x, calculated %x",
874 log_err(" at file %s offset %llu, length %u\n",
875 io_u->file->file_name,
876 io_u->offset + hdr_num * hdr_len, hdr_len);
878 if (td->o.verify_dump)
879 dump_buf(p, hdr_len, io_u->offset + hdr_num * hdr_len,
880 "hdr_fail", io_u->file);
885 int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
887 struct verify_header *hdr;
888 struct io_u *io_u = *io_u_ptr;
889 unsigned int header_size, hdr_inc, hdr_num = 0;
893 if (td->o.verify == VERIFY_NULL || io_u->ddir != DDIR_READ)
896 * If the IO engine is faking IO (like null), then just pretend
897 * we verified everything.
899 if (td_ioengine_flagged(td, FIO_FAKEIO))
902 if (io_u->flags & IO_U_F_TRIMMED) {
903 ret = verify_trimmed_io_u(td, io_u);
907 hdr_inc = get_hdr_inc(td, io_u);
910 for (p = io_u->buf; p < io_u->buf + io_u->buflen;
911 p += hdr_inc, hdr_num++) {
917 unsigned int verify_type;
919 if (ret && td->o.verify_fatal)
922 header_size = __hdr_size(td->o.verify);
923 if (td->o.verify_offset)
924 memswp(p, p + td->o.verify_offset, header_size);
928 * Make rand_seed check pass when have verifysort or
931 if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG))
932 io_u->rand_seed = hdr->rand_seed;
934 if (td->o.verify != VERIFY_PATTERN_NO_HDR) {
935 ret = verify_header(io_u, td, hdr, hdr_num, hdr_inc);
940 if (td->o.verify != VERIFY_NONE)
941 verify_type = td->o.verify;
943 verify_type = hdr->verify_type;
945 switch (verify_type) {
946 case VERIFY_HDR_ONLY:
947 /* Header is always verified, check if pattern is left
948 * for verification. */
949 if (td->o.verify_pattern_bytes)
950 ret = verify_io_u_pattern(hdr, &vc);
953 ret = verify_io_u_md5(hdr, &vc);
956 ret = verify_io_u_crc64(hdr, &vc);
959 case VERIFY_CRC32C_INTEL:
960 ret = verify_io_u_crc32c(hdr, &vc);
963 ret = verify_io_u_crc32(hdr, &vc);
966 ret = verify_io_u_crc16(hdr, &vc);
969 ret = verify_io_u_crc7(hdr, &vc);
972 ret = verify_io_u_sha256(hdr, &vc);
975 ret = verify_io_u_sha512(hdr, &vc);
977 case VERIFY_SHA3_224:
978 ret = verify_io_u_sha3_224(hdr, &vc);
980 case VERIFY_SHA3_256:
981 ret = verify_io_u_sha3_256(hdr, &vc);
983 case VERIFY_SHA3_384:
984 ret = verify_io_u_sha3_384(hdr, &vc);
986 case VERIFY_SHA3_512:
987 ret = verify_io_u_sha3_512(hdr, &vc);
990 ret = verify_io_u_xxhash(hdr, &vc);
993 ret = verify_io_u_sha1(hdr, &vc);
996 case VERIFY_PATTERN_NO_HDR:
997 ret = verify_io_u_pattern(hdr, &vc);
1000 log_err("Bad verify type %u\n", hdr->verify_type);
1004 if (ret && verify_type != hdr->verify_type)
1005 log_err("fio: verify type mismatch (%u media, %u given)\n",
1006 hdr->verify_type, verify_type);
1010 if (ret && td->o.verify_fatal)
1011 fio_mark_td_terminate(td);
1016 static void fill_xxhash(struct verify_header *hdr, void *p, unsigned int len)
1018 struct vhdr_xxhash *vh = hdr_priv(hdr);
1021 state = XXH32_init(1);
1022 XXH32_update(state, p, len);
1023 vh->hash = XXH32_digest(state);
1026 static void fill_sha3(struct fio_sha3_ctx *sha3_ctx, void *p, unsigned int len)
1028 fio_sha3_update(sha3_ctx, p, len);
1029 fio_sha3_final(sha3_ctx);
1032 static void fill_sha3_224(struct verify_header *hdr, void *p, unsigned int len)
1034 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
1035 struct fio_sha3_ctx sha3_ctx = {
1039 fio_sha3_224_init(&sha3_ctx);
1040 fill_sha3(&sha3_ctx, p, len);
1043 static void fill_sha3_256(struct verify_header *hdr, void *p, unsigned int len)
1045 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
1046 struct fio_sha3_ctx sha3_ctx = {
1050 fio_sha3_256_init(&sha3_ctx);
1051 fill_sha3(&sha3_ctx, p, len);
1054 static void fill_sha3_384(struct verify_header *hdr, void *p, unsigned int len)
1056 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
1057 struct fio_sha3_ctx sha3_ctx = {
1061 fio_sha3_384_init(&sha3_ctx);
1062 fill_sha3(&sha3_ctx, p, len);
1065 static void fill_sha3_512(struct verify_header *hdr, void *p, unsigned int len)
1067 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
1068 struct fio_sha3_ctx sha3_ctx = {
1072 fio_sha3_512_init(&sha3_ctx);
1073 fill_sha3(&sha3_ctx, p, len);
1076 static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
1078 struct vhdr_sha512 *vh = hdr_priv(hdr);
1079 struct fio_sha512_ctx sha512_ctx = {
1083 fio_sha512_init(&sha512_ctx);
1084 fio_sha512_update(&sha512_ctx, p, len);
1087 static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
1089 struct vhdr_sha256 *vh = hdr_priv(hdr);
1090 struct fio_sha256_ctx sha256_ctx = {
1094 fio_sha256_init(&sha256_ctx);
1095 fio_sha256_update(&sha256_ctx, p, len);
1096 fio_sha256_final(&sha256_ctx);
1099 static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
1101 struct vhdr_sha1 *vh = hdr_priv(hdr);
1102 struct fio_sha1_ctx sha1_ctx = {
1106 fio_sha1_init(&sha1_ctx);
1107 fio_sha1_update(&sha1_ctx, p, len);
1108 fio_sha1_final(&sha1_ctx);
1111 static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
1113 struct vhdr_crc7 *vh = hdr_priv(hdr);
1115 vh->crc7 = fio_crc7(p, len);
1118 static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
1120 struct vhdr_crc16 *vh = hdr_priv(hdr);
1122 vh->crc16 = fio_crc16(p, len);
1125 static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
1127 struct vhdr_crc32 *vh = hdr_priv(hdr);
1129 vh->crc32 = fio_crc32(p, len);
1132 static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
1134 struct vhdr_crc32 *vh = hdr_priv(hdr);
1136 vh->crc32 = fio_crc32c(p, len);
1139 static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
1141 struct vhdr_crc64 *vh = hdr_priv(hdr);
1143 vh->crc64 = fio_crc64(p, len);
1146 static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
1148 struct vhdr_md5 *vh = hdr_priv(hdr);
1149 struct fio_md5_ctx md5_ctx = {
1150 .hash = (uint32_t *) vh->md5_digest,
1153 fio_md5_init(&md5_ctx);
1154 fio_md5_update(&md5_ctx, p, len);
1155 fio_md5_final(&md5_ctx);
1158 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
1159 struct verify_header *hdr, unsigned int header_num,
1160 unsigned int header_len, uint64_t rand_seed)
1164 hdr->magic = FIO_HDR_MAGIC;
1165 hdr->verify_type = td->o.verify;
1166 hdr->len = header_len;
1167 hdr->rand_seed = rand_seed;
1168 hdr->offset = io_u->offset + header_num * td->o.verify_interval;
1169 hdr->time_sec = io_u->start_time.tv_sec;
1170 hdr->time_usec = io_u->start_time.tv_nsec / 1000;
1171 hdr->thread = td->thread_number;
1172 hdr->numberio = io_u->numberio;
1173 hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
1177 static void fill_hdr(struct thread_data *td, struct io_u *io_u,
1178 struct verify_header *hdr, unsigned int header_num,
1179 unsigned int header_len, uint64_t rand_seed)
1182 if (td->o.verify != VERIFY_PATTERN_NO_HDR)
1183 __fill_hdr(td, io_u, hdr, header_num, header_len, rand_seed);
1186 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
1187 struct verify_header *hdr, unsigned int header_num,
1188 unsigned int header_len)
1190 unsigned int data_len;
1196 fill_hdr(td, io_u, hdr, header_num, header_len, io_u->rand_seed);
1198 data_len = header_len - hdr_size(td, hdr);
1200 data = p + hdr_size(td, hdr);
1201 switch (td->o.verify) {
1203 dprint(FD_VERIFY, "fill md5 io_u %p, len %u\n",
1205 fill_md5(hdr, data, data_len);
1208 dprint(FD_VERIFY, "fill crc64 io_u %p, len %u\n",
1210 fill_crc64(hdr, data, data_len);
1213 case VERIFY_CRC32C_INTEL:
1214 dprint(FD_VERIFY, "fill crc32c io_u %p, len %u\n",
1216 fill_crc32c(hdr, data, data_len);
1219 dprint(FD_VERIFY, "fill crc32 io_u %p, len %u\n",
1221 fill_crc32(hdr, data, data_len);
1224 dprint(FD_VERIFY, "fill crc16 io_u %p, len %u\n",
1226 fill_crc16(hdr, data, data_len);
1229 dprint(FD_VERIFY, "fill crc7 io_u %p, len %u\n",
1231 fill_crc7(hdr, data, data_len);
1234 dprint(FD_VERIFY, "fill sha256 io_u %p, len %u\n",
1236 fill_sha256(hdr, data, data_len);
1239 dprint(FD_VERIFY, "fill sha512 io_u %p, len %u\n",
1241 fill_sha512(hdr, data, data_len);
1243 case VERIFY_SHA3_224:
1244 dprint(FD_VERIFY, "fill sha3-224 io_u %p, len %u\n",
1246 fill_sha3_224(hdr, data, data_len);
1248 case VERIFY_SHA3_256:
1249 dprint(FD_VERIFY, "fill sha3-256 io_u %p, len %u\n",
1251 fill_sha3_256(hdr, data, data_len);
1253 case VERIFY_SHA3_384:
1254 dprint(FD_VERIFY, "fill sha3-384 io_u %p, len %u\n",
1256 fill_sha3_384(hdr, data, data_len);
1258 case VERIFY_SHA3_512:
1259 dprint(FD_VERIFY, "fill sha3-512 io_u %p, len %u\n",
1261 fill_sha3_512(hdr, data, data_len);
1264 dprint(FD_VERIFY, "fill xxhash io_u %p, len %u\n",
1266 fill_xxhash(hdr, data, data_len);
1269 dprint(FD_VERIFY, "fill sha1 io_u %p, len %u\n",
1271 fill_sha1(hdr, data, data_len);
1273 case VERIFY_HDR_ONLY:
1274 case VERIFY_PATTERN:
1275 case VERIFY_PATTERN_NO_HDR:
1276 /* nothing to do here */
1279 log_err("fio: bad verify type: %d\n", td->o.verify);
1283 if (td->o.verify_offset && hdr_size(td, hdr))
1284 memswp(p, p + td->o.verify_offset, hdr_size(td, hdr));
1288 * fill body of io_u->buf with random data and add a header with the
1289 * checksum of choice
1291 void populate_verify_io_u(struct thread_data *td, struct io_u *io_u)
1293 if (td->o.verify == VERIFY_NULL)
1296 io_u->numberio = td->io_issues[io_u->ddir];
1298 fill_pattern_headers(td, io_u, 0, 0);
1301 int get_next_verify(struct thread_data *td, struct io_u *io_u)
1303 struct io_piece *ipo = NULL;
1306 * this io_u is from a requeue, we already filled the offsets
1311 if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
1312 struct rb_node *n = rb_first(&td->io_hist_tree);
1314 ipo = rb_entry(n, struct io_piece, rb_node);
1317 * Ensure that the associated IO has completed
1320 if (ipo->flags & IP_F_IN_FLIGHT)
1323 rb_erase(n, &td->io_hist_tree);
1324 assert(ipo->flags & IP_F_ONRB);
1325 ipo->flags &= ~IP_F_ONRB;
1326 } else if (!flist_empty(&td->io_hist_list)) {
1327 ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list);
1330 * Ensure that the associated IO has completed
1333 if (ipo->flags & IP_F_IN_FLIGHT)
1336 flist_del(&ipo->list);
1337 assert(ipo->flags & IP_F_ONLIST);
1338 ipo->flags &= ~IP_F_ONLIST;
1344 io_u->offset = ipo->offset;
1345 io_u->buflen = ipo->len;
1346 io_u->numberio = ipo->numberio;
1347 io_u->file = ipo->file;
1348 io_u_set(td, io_u, IO_U_F_VER_LIST);
1350 if (ipo->flags & IP_F_TRIMMED)
1351 io_u_set(td, io_u, IO_U_F_TRIMMED);
1353 if (!fio_file_open(io_u->file)) {
1354 int r = td_io_open_file(td, io_u->file);
1357 dprint(FD_VERIFY, "failed file %s open\n",
1358 io_u->file->file_name);
1363 get_file(ipo->file);
1364 assert(fio_file_open(io_u->file));
1365 io_u->ddir = DDIR_READ;
1366 io_u->xfer_buf = io_u->buf;
1367 io_u->xfer_buflen = io_u->buflen;
1369 remove_trim_entry(td, ipo);
1371 dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u);
1373 if (!td->o.verify_pattern_bytes) {
1374 io_u->rand_seed = __rand(&td->verify_state);
1375 if (sizeof(int) != sizeof(long *))
1376 io_u->rand_seed *= __rand(&td->verify_state);
1382 dprint(FD_VERIFY, "get_next_verify: empty\n");
1386 void fio_verify_init(struct thread_data *td)
1388 if (td->o.verify == VERIFY_CRC32C_INTEL ||
1389 td->o.verify == VERIFY_CRC32C) {
1390 crc32c_arm64_probe();
1391 crc32c_intel_probe();
1395 static void *verify_async_thread(void *data)
1397 struct thread_data *td = data;
1401 if (fio_option_is_set(&td->o, verify_cpumask) &&
1402 fio_setaffinity(td->pid, td->o.verify_cpumask)) {
1403 log_err("fio: failed setting verify thread affinity\n");
1411 if (td->verify_thread_exit)
1414 pthread_mutex_lock(&td->io_u_lock);
1416 while (flist_empty(&td->verify_list) &&
1417 !td->verify_thread_exit) {
1418 ret = pthread_cond_wait(&td->verify_cond,
1421 pthread_mutex_unlock(&td->io_u_lock);
1426 flist_splice_init(&td->verify_list, &list);
1427 pthread_mutex_unlock(&td->io_u_lock);
1429 if (flist_empty(&list))
1432 while (!flist_empty(&list)) {
1433 io_u = flist_first_entry(&list, struct io_u, verify_list);
1434 flist_del_init(&io_u->verify_list);
1436 io_u_set(td, io_u, IO_U_F_NO_FILE_PUT);
1437 ret = verify_io_u(td, &io_u);
1442 if (td_non_fatal_error(td, ERROR_TYPE_VERIFY_BIT, ret)) {
1443 update_error_count(td, ret);
1451 td_verror(td, ret, "async_verify");
1452 if (td->o.verify_fatal)
1453 fio_mark_td_terminate(td);
1457 pthread_mutex_lock(&td->io_u_lock);
1458 td->nr_verify_threads--;
1459 pthread_mutex_unlock(&td->io_u_lock);
1461 pthread_cond_signal(&td->free_cond);
1465 int verify_async_init(struct thread_data *td)
1468 pthread_attr_t attr;
1470 pthread_attr_init(&attr);
1471 pthread_attr_setstacksize(&attr, 2 * PTHREAD_STACK_MIN);
1473 td->verify_thread_exit = 0;
1475 td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async);
1476 for (i = 0; i < td->o.verify_async; i++) {
1477 ret = pthread_create(&td->verify_threads[i], &attr,
1478 verify_async_thread, td);
1480 log_err("fio: async verify creation failed: %s\n",
1484 ret = pthread_detach(td->verify_threads[i]);
1486 log_err("fio: async verify thread detach failed: %s\n",
1490 td->nr_verify_threads++;
1493 pthread_attr_destroy(&attr);
1495 if (i != td->o.verify_async) {
1496 log_err("fio: only %d verify threads started, exiting\n", i);
1497 td->verify_thread_exit = 1;
1499 pthread_cond_broadcast(&td->verify_cond);
1506 void verify_async_exit(struct thread_data *td)
1508 td->verify_thread_exit = 1;
1510 pthread_cond_broadcast(&td->verify_cond);
1512 pthread_mutex_lock(&td->io_u_lock);
1514 while (td->nr_verify_threads)
1515 pthread_cond_wait(&td->free_cond, &td->io_u_lock);
1517 pthread_mutex_unlock(&td->io_u_lock);
1518 free(td->verify_threads);
1519 td->verify_threads = NULL;
1522 int paste_blockoff(char *buf, unsigned int len, void *priv)
1524 struct io_u *io = priv;
1525 unsigned long long off;
1527 typecheck(typeof(off), io->offset);
1528 off = cpu_to_le64((uint64_t)io->offset);
1529 len = min(len, (unsigned int)sizeof(off));
1530 memcpy(buf, &off, len);
1534 static int __fill_file_completions(struct thread_data *td,
1535 struct thread_io_list *s,
1536 struct fio_file *f, unsigned int *index)
1541 if (!f->last_write_comp)
1544 if (td->io_blocks[DDIR_WRITE] < td->o.iodepth)
1545 comps = td->io_blocks[DDIR_WRITE];
1547 comps = td->o.iodepth;
1549 j = f->last_write_idx - 1;
1550 for (i = 0; i < comps; i++) {
1552 j = td->o.iodepth - 1;
1553 s->comps[*index].fileno = __cpu_to_le64(f->fileno);
1554 s->comps[*index].offset = cpu_to_le64(f->last_write_comp[j]);
1562 static int fill_file_completions(struct thread_data *td,
1563 struct thread_io_list *s, unsigned int *index)
1569 for_each_file(td, f, i)
1570 comps += __fill_file_completions(td, s, f, index);
1575 struct all_io_list *get_all_io_list(int save_mask, size_t *sz)
1577 struct all_io_list *rep;
1578 struct thread_data *td;
1583 compiletime_assert(sizeof(struct all_io_list) == 8, "all_io_list");
1586 * Calculate reply space needed. We need one 'io_state' per thread,
1587 * and the size will vary depending on depth.
1591 for_each_td(td, i) {
1592 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1595 td->flags |= TD_F_VSTATE_SAVED;
1596 depth += (td->o.iodepth * td->o.nr_files);
1604 *sz += nr * sizeof(struct thread_io_list);
1605 *sz += depth * sizeof(struct file_comp);
1607 memset(rep, 0, *sz);
1609 rep->threads = cpu_to_le64((uint64_t) nr);
1611 next = &rep->state[0];
1612 for_each_td(td, i) {
1613 struct thread_io_list *s = next;
1614 unsigned int comps, index = 0;
1616 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1619 comps = fill_file_completions(td, s, &index);
1621 s->no_comps = cpu_to_le64((uint64_t) comps);
1622 s->depth = cpu_to_le64((uint64_t) td->o.iodepth);
1623 s->nofiles = cpu_to_le64((uint64_t) td->o.nr_files);
1624 s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]);
1625 s->index = cpu_to_le64((uint64_t) i);
1626 if (td->random_state.use64) {
1627 s->rand.state64.s[0] = cpu_to_le64(td->random_state.state64.s1);
1628 s->rand.state64.s[1] = cpu_to_le64(td->random_state.state64.s2);
1629 s->rand.state64.s[2] = cpu_to_le64(td->random_state.state64.s3);
1630 s->rand.state64.s[3] = cpu_to_le64(td->random_state.state64.s4);
1631 s->rand.state64.s[4] = cpu_to_le64(td->random_state.state64.s5);
1632 s->rand.state64.s[5] = 0;
1633 s->rand.use64 = cpu_to_le64((uint64_t)1);
1635 s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1);
1636 s->rand.state32.s[1] = cpu_to_le32(td->random_state.state32.s2);
1637 s->rand.state32.s[2] = cpu_to_le32(td->random_state.state32.s3);
1638 s->rand.state32.s[3] = 0;
1641 s->name[sizeof(s->name) - 1] = '\0';
1642 strncpy((char *) s->name, td->o.name, sizeof(s->name) - 1);
1643 next = io_list_next(s);
1649 static int open_state_file(const char *name, const char *prefix, int num,
1657 flags = O_CREAT | O_TRUNC | O_WRONLY | O_SYNC;
1661 verify_state_gen_name(out, sizeof(out), name, prefix, num);
1663 fd = open(out, flags, 0644);
1665 perror("fio: open state file");
1666 log_err("fio: state file: %s (for_write=%d)\n", out, for_write);
1673 static int write_thread_list_state(struct thread_io_list *s,
1676 struct verify_state_hdr hdr;
1681 fd = open_state_file((const char *) s->name, prefix, s->index, 1);
1685 crc = fio_crc32c((void *)s, thread_io_list_sz(s));
1687 hdr.version = cpu_to_le64((uint64_t) VSTATE_HDR_VERSION);
1688 hdr.size = cpu_to_le64((uint64_t) thread_io_list_sz(s));
1689 hdr.crc = cpu_to_le64(crc);
1690 ret = write(fd, &hdr, sizeof(hdr));
1691 if (ret != sizeof(hdr))
1694 ret = write(fd, s, thread_io_list_sz(s));
1695 if (ret != thread_io_list_sz(s)) {
1698 perror("fio: write state file");
1699 log_err("fio: failed to write state file\n");
1708 void __verify_save_state(struct all_io_list *state, const char *prefix)
1710 struct thread_io_list *s = &state->state[0];
1713 for (i = 0; i < le64_to_cpu(state->threads); i++) {
1714 write_thread_list_state(s, prefix);
1715 s = io_list_next(s);
1719 void verify_save_state(int mask)
1721 struct all_io_list *state;
1724 state = get_all_io_list(mask, &sz);
1726 char prefix[PATH_MAX];
1729 sprintf(prefix, "%s%slocal", aux_path, FIO_OS_PATH_SEPARATOR);
1731 strcpy(prefix, "local");
1733 __verify_save_state(state, prefix);
1738 void verify_free_state(struct thread_data *td)
1744 void verify_assign_state(struct thread_data *td, void *p)
1746 struct thread_io_list *s = p;
1749 s->no_comps = le64_to_cpu(s->no_comps);
1750 s->depth = le32_to_cpu(s->depth);
1751 s->nofiles = le32_to_cpu(s->nofiles);
1752 s->numberio = le64_to_cpu(s->numberio);
1753 s->rand.use64 = le64_to_cpu(s->rand.use64);
1755 if (s->rand.use64) {
1756 for (i = 0; i < 6; i++)
1757 s->rand.state64.s[i] = le64_to_cpu(s->rand.state64.s[i]);
1759 for (i = 0; i < 4; i++)
1760 s->rand.state32.s[i] = le32_to_cpu(s->rand.state32.s[i]);
1763 for (i = 0; i < s->no_comps; i++) {
1764 s->comps[i].fileno = le64_to_cpu(s->comps[i].fileno);
1765 s->comps[i].offset = le64_to_cpu(s->comps[i].offset);
1771 int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s)
1775 hdr->version = le64_to_cpu(hdr->version);
1776 hdr->size = le64_to_cpu(hdr->size);
1777 hdr->crc = le64_to_cpu(hdr->crc);
1779 if (hdr->version != VSTATE_HDR_VERSION)
1782 crc = fio_crc32c((void *)s, hdr->size);
1783 if (crc != hdr->crc)
1789 int verify_load_state(struct thread_data *td, const char *prefix)
1791 struct verify_state_hdr hdr;
1797 if (!td->o.verify_state)
1800 fd = open_state_file(td->o.name, prefix, td->thread_number - 1, 0);
1804 ret = read(fd, &hdr, sizeof(hdr));
1805 if (ret != sizeof(hdr)) {
1807 td_verror(td, errno, "read verify state hdr");
1808 log_err("fio: failed reading verify state header\n");
1812 hdr.version = le64_to_cpu(hdr.version);
1813 hdr.size = le64_to_cpu(hdr.size);
1814 hdr.crc = le64_to_cpu(hdr.crc);
1816 if (hdr.version != VSTATE_HDR_VERSION) {
1817 log_err("fio: unsupported (%d) version in verify state header\n",
1818 (unsigned int) hdr.version);
1822 s = malloc(hdr.size);
1823 ret = read(fd, s, hdr.size);
1824 if (ret != hdr.size) {
1826 td_verror(td, errno, "read verify state");
1827 log_err("fio: failed reading verity state\n");
1831 crc = fio_crc32c(s, hdr.size);
1832 if (crc != hdr.crc) {
1833 log_err("fio: verify state is corrupt\n");
1839 verify_assign_state(td, s);
1849 * Use the loaded verify state to know when to stop doing verification
1851 int verify_state_should_stop(struct thread_data *td, struct io_u *io_u)
1853 struct thread_io_list *s = td->vstate;
1854 struct fio_file *f = io_u->file;
1861 * If we're not into the window of issues - depth yet, continue. If
1862 * issue is shorter than depth, do check.
1864 if ((td->io_blocks[DDIR_READ] < s->depth ||
1865 s->numberio - td->io_blocks[DDIR_READ] > s->depth) &&
1866 s->numberio > s->depth)
1870 * We're in the window of having to check if this io was
1871 * completed or not. If the IO was seen as completed, then
1874 for (i = 0; i < s->no_comps; i++) {
1875 if (s->comps[i].fileno != f->fileno)
1877 if (io_u->offset == s->comps[i].offset)
1882 * Not found, we have to stop