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");
278 ret = write(fd, buf, len);
282 perror("write verify buf file");
290 log_err(" %s data dumped as %s\n", type, fname);
295 * Dump the contents of the read block and re-generate the correct data
298 static void __dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
300 struct thread_data *td = vc->td;
301 struct io_u *io_u = vc->io_u;
302 unsigned long hdr_offset;
306 if (!td->o.verify_dump)
310 * Dump the contents we just read off disk
312 hdr_offset = vc->hdr_num * hdr->len;
314 dump_buf(io_u->buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
315 "received", vc->io_u->file);
318 * Allocate a new buf and re-generate the original data
320 buf = malloc(io_u->buflen);
323 dummy.rand_seed = hdr->rand_seed;
324 dummy.buf_filled_len = 0;
325 dummy.buflen = io_u->buflen;
327 fill_pattern_headers(td, &dummy, hdr->rand_seed, 1);
329 dump_buf(buf + hdr_offset, hdr->len, io_u->offset + hdr_offset,
330 "expected", vc->io_u->file);
334 static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
336 struct thread_data *td = vc->td;
337 struct verify_header shdr;
339 if (td->o.verify == VERIFY_PATTERN_NO_HDR) {
340 __fill_hdr(td, vc->io_u, &shdr, 0, vc->io_u->buflen, 0);
344 __dump_verify_buffers(hdr, vc);
347 static void log_verify_failure(struct verify_header *hdr, struct vcont *vc)
349 unsigned long long offset;
351 offset = vc->io_u->offset;
352 offset += vc->hdr_num * hdr->len;
353 log_err("%.8s: verify failed at file %s offset %llu, length %u\n",
354 vc->name, vc->io_u->file->file_name, offset, hdr->len);
356 if (vc->good_crc && vc->bad_crc) {
357 log_err(" Expected CRC: ");
358 hexdump(vc->good_crc, vc->crc_len);
359 log_err(" Received CRC: ");
360 hexdump(vc->bad_crc, vc->crc_len);
363 dump_verify_buffers(hdr, vc);
367 * Return data area 'header_num'
369 static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
371 return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(vc->td, hdr);
374 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
376 struct thread_data *td = vc->td;
377 struct io_u *io_u = vc->io_u;
379 unsigned int header_size = __hdr_size(td->o.verify);
380 unsigned int len, mod, i, pattern_size;
383 pattern = td->o.verify_pattern;
384 pattern_size = td->o.verify_pattern_bytes;
385 assert(pattern_size != 0);
387 (void)paste_format_inplace(pattern, pattern_size,
388 td->o.verify_fmt, td->o.verify_fmt_sz, io_u);
390 buf = (void *) hdr + header_size;
391 len = get_hdr_inc(td, io_u) - header_size;
392 mod = (get_hdr_inc(td, io_u) * vc->hdr_num + header_size) % pattern_size;
394 rc = cmp_pattern(pattern, pattern_size, mod, buf, len);
398 /* Slow path, compare each byte */
399 for (i = 0; i < len; i++) {
400 if (buf[i] != pattern[mod]) {
403 bits = hweight8(buf[i] ^ pattern[mod]);
404 log_err("fio: got pattern '%02x', wanted '%02x'. Bad bits %d\n",
405 (unsigned char)buf[i],
406 (unsigned char)pattern[mod],
408 log_err("fio: bad pattern block offset %u\n", i);
409 vc->name = "pattern";
410 log_verify_failure(hdr, vc);
414 if (mod == td->o.verify_pattern_bytes)
418 /* Unreachable line */
423 static int verify_io_u_xxhash(struct verify_header *hdr, struct vcont *vc)
425 void *p = io_u_verify_off(hdr, vc);
426 struct vhdr_xxhash *vh = hdr_priv(hdr);
430 dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len);
432 state = XXH32_init(1);
433 XXH32_update(state, p, hdr->len - hdr_size(vc->td, hdr));
434 hash = XXH32_digest(state);
436 if (vh->hash == hash)
440 vc->good_crc = &vh->hash;
442 vc->crc_len = sizeof(hash);
443 log_verify_failure(hdr, vc);
447 static int verify_io_u_sha3(struct verify_header *hdr, struct vcont *vc,
448 struct fio_sha3_ctx *sha3_ctx, uint8_t *sha,
449 unsigned int sha_size, const char *name)
451 void *p = io_u_verify_off(hdr, vc);
453 dprint(FD_VERIFY, "%s verify io_u %p, len %u\n", name, vc->io_u, hdr->len);
455 fio_sha3_update(sha3_ctx, p, hdr->len - hdr_size(vc->td, hdr));
456 fio_sha3_final(sha3_ctx);
458 if (!memcmp(sha, sha3_ctx->sha, sha_size))
463 vc->bad_crc = sha3_ctx->sha;
464 vc->crc_len = sha_size;
465 log_verify_failure(hdr, vc);
469 static int verify_io_u_sha3_224(struct verify_header *hdr, struct vcont *vc)
471 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
472 uint8_t sha[SHA3_224_DIGEST_SIZE];
473 struct fio_sha3_ctx sha3_ctx = {
477 fio_sha3_224_init(&sha3_ctx);
479 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
480 SHA3_224_DIGEST_SIZE, "sha3-224");
483 static int verify_io_u_sha3_256(struct verify_header *hdr, struct vcont *vc)
485 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
486 uint8_t sha[SHA3_256_DIGEST_SIZE];
487 struct fio_sha3_ctx sha3_ctx = {
491 fio_sha3_256_init(&sha3_ctx);
493 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
494 SHA3_256_DIGEST_SIZE, "sha3-256");
497 static int verify_io_u_sha3_384(struct verify_header *hdr, struct vcont *vc)
499 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
500 uint8_t sha[SHA3_384_DIGEST_SIZE];
501 struct fio_sha3_ctx sha3_ctx = {
505 fio_sha3_384_init(&sha3_ctx);
507 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
508 SHA3_384_DIGEST_SIZE, "sha3-384");
511 static int verify_io_u_sha3_512(struct verify_header *hdr, struct vcont *vc)
513 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
514 uint8_t sha[SHA3_512_DIGEST_SIZE];
515 struct fio_sha3_ctx sha3_ctx = {
519 fio_sha3_512_init(&sha3_ctx);
521 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
522 SHA3_512_DIGEST_SIZE, "sha3-512");
525 static int verify_io_u_sha512(struct verify_header *hdr, struct vcont *vc)
527 void *p = io_u_verify_off(hdr, vc);
528 struct vhdr_sha512 *vh = hdr_priv(hdr);
530 struct fio_sha512_ctx sha512_ctx = {
534 dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
536 fio_sha512_init(&sha512_ctx);
537 fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(vc->td, hdr));
539 if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
543 vc->good_crc = vh->sha512;
544 vc->bad_crc = sha512_ctx.buf;
545 vc->crc_len = sizeof(vh->sha512);
546 log_verify_failure(hdr, vc);
550 static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc)
552 void *p = io_u_verify_off(hdr, vc);
553 struct vhdr_sha256 *vh = hdr_priv(hdr);
555 struct fio_sha256_ctx sha256_ctx = {
559 dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
561 fio_sha256_init(&sha256_ctx);
562 fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(vc->td, hdr));
563 fio_sha256_final(&sha256_ctx);
565 if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
569 vc->good_crc = vh->sha256;
570 vc->bad_crc = sha256_ctx.buf;
571 vc->crc_len = sizeof(vh->sha256);
572 log_verify_failure(hdr, vc);
576 static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc)
578 void *p = io_u_verify_off(hdr, vc);
579 struct vhdr_sha1 *vh = hdr_priv(hdr);
581 struct fio_sha1_ctx sha1_ctx = {
585 dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
587 fio_sha1_init(&sha1_ctx);
588 fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(vc->td, hdr));
589 fio_sha1_final(&sha1_ctx);
591 if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
595 vc->good_crc = vh->sha1;
596 vc->bad_crc = sha1_ctx.H;
597 vc->crc_len = sizeof(vh->sha1);
598 log_verify_failure(hdr, vc);
602 static int verify_io_u_crc7(struct verify_header *hdr, struct vcont *vc)
604 void *p = io_u_verify_off(hdr, vc);
605 struct vhdr_crc7 *vh = hdr_priv(hdr);
608 dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
610 c = fio_crc7(p, hdr->len - hdr_size(vc->td, hdr));
616 vc->good_crc = &vh->crc7;
619 log_verify_failure(hdr, vc);
623 static int verify_io_u_crc16(struct verify_header *hdr, struct vcont *vc)
625 void *p = io_u_verify_off(hdr, vc);
626 struct vhdr_crc16 *vh = hdr_priv(hdr);
629 dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
631 c = fio_crc16(p, hdr->len - hdr_size(vc->td, hdr));
637 vc->good_crc = &vh->crc16;
640 log_verify_failure(hdr, vc);
644 static int verify_io_u_crc64(struct verify_header *hdr, struct vcont *vc)
646 void *p = io_u_verify_off(hdr, vc);
647 struct vhdr_crc64 *vh = hdr_priv(hdr);
648 unsigned long long c;
650 dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
652 c = fio_crc64(p, hdr->len - hdr_size(vc->td, hdr));
658 vc->good_crc = &vh->crc64;
661 log_verify_failure(hdr, vc);
665 static int verify_io_u_crc32(struct verify_header *hdr, struct vcont *vc)
667 void *p = io_u_verify_off(hdr, vc);
668 struct vhdr_crc32 *vh = hdr_priv(hdr);
671 dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
673 c = fio_crc32(p, hdr->len - hdr_size(vc->td, hdr));
679 vc->good_crc = &vh->crc32;
682 log_verify_failure(hdr, vc);
686 static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc)
688 void *p = io_u_verify_off(hdr, vc);
689 struct vhdr_crc32 *vh = hdr_priv(hdr);
692 dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
694 c = fio_crc32c(p, hdr->len - hdr_size(vc->td, hdr));
700 vc->good_crc = &vh->crc32;
703 log_verify_failure(hdr, vc);
707 static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc)
709 void *p = io_u_verify_off(hdr, vc);
710 struct vhdr_md5 *vh = hdr_priv(hdr);
711 uint32_t hash[MD5_HASH_WORDS];
712 struct fio_md5_ctx md5_ctx = {
716 dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
718 fio_md5_init(&md5_ctx);
719 fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(vc->td, hdr));
720 fio_md5_final(&md5_ctx);
722 if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
726 vc->good_crc = vh->md5_digest;
727 vc->bad_crc = md5_ctx.hash;
728 vc->crc_len = sizeof(hash);
729 log_verify_failure(hdr, vc);
734 * Push IO verification to a separate thread
736 int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr)
738 struct io_u *io_u = *io_u_ptr;
740 pthread_mutex_lock(&td->io_u_lock);
743 put_file_log(td, io_u->file);
745 if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
747 io_u_clear(td, io_u, IO_U_F_IN_CUR_DEPTH);
749 flist_add_tail(&io_u->verify_list, &td->verify_list);
751 pthread_mutex_unlock(&td->io_u_lock);
753 pthread_cond_signal(&td->verify_cond);
758 * Thanks Rusty, for spending the time so I don't have to.
760 * http://rusty.ozlabs.org/?p=560
762 static int mem_is_zero(const void *data, size_t length)
764 const unsigned char *p = data;
767 /* Check first 16 bytes manually */
768 for (len = 0; len < 16; len++) {
777 /* Now we know that's zero, memcmp with self. */
778 return memcmp(data, p, length) == 0;
781 static int mem_is_zero_slow(const void *data, size_t length, size_t *offset)
783 const unsigned char *p = data;
797 static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
801 if (!td->o.trim_zero)
804 if (mem_is_zero(io_u->buf, io_u->buflen))
807 mem_is_zero_slow(io_u->buf, io_u->buflen, &offset);
809 log_err("trim: verify failed at file %s offset %llu, length %lu"
810 ", block offset %lu\n",
811 io_u->file->file_name, io_u->offset, io_u->buflen,
812 (unsigned long) offset);
816 static int verify_header(struct io_u *io_u, struct thread_data *td,
817 struct verify_header *hdr, unsigned int hdr_num,
818 unsigned int hdr_len)
823 if (hdr->magic != FIO_HDR_MAGIC) {
824 log_err("verify: bad magic header %x, wanted %x",
825 hdr->magic, FIO_HDR_MAGIC);
828 if (hdr->len != hdr_len) {
829 log_err("verify: bad header length %u, wanted %u",
833 if (hdr->rand_seed != io_u->rand_seed) {
834 log_err("verify: bad header rand_seed %"PRIu64
836 hdr->rand_seed, io_u->rand_seed);
839 if (hdr->offset != io_u->offset + hdr_num * td->o.verify_interval) {
840 log_err("verify: bad header offset %"PRIu64
842 hdr->offset, io_u->offset);
847 * For read-only workloads, the program cannot be certain of the
848 * last numberio written to a block. Checking of numberio will be
849 * done only for workloads that write data. For verify_only,
850 * numberio will be checked in the last iteration when the correct
851 * state of numberio, that would have been written to each block
852 * in a previous run of fio, has been reached.
854 if (td_write(td) && (td_min_bs(td) == td_max_bs(td)) &&
856 if (!td->o.verify_only || td->o.loops == 0)
857 if (hdr->numberio != io_u->numberio) {
858 log_err("verify: bad header numberio %"PRIu16
860 hdr->numberio, io_u->numberio);
864 crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
865 if (crc != hdr->crc32) {
866 log_err("verify: bad header crc %x, calculated %x",
873 log_err(" at file %s offset %llu, length %u\n",
874 io_u->file->file_name,
875 io_u->offset + hdr_num * hdr_len, hdr_len);
877 if (td->o.verify_dump)
878 dump_buf(p, hdr_len, io_u->offset + hdr_num * hdr_len,
879 "hdr_fail", io_u->file);
884 int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
886 struct verify_header *hdr;
887 struct io_u *io_u = *io_u_ptr;
888 unsigned int header_size, hdr_inc, hdr_num = 0;
892 if (td->o.verify == VERIFY_NULL || io_u->ddir != DDIR_READ)
895 * If the IO engine is faking IO (like null), then just pretend
896 * we verified everything.
898 if (td_ioengine_flagged(td, FIO_FAKEIO))
901 if (io_u->flags & IO_U_F_TRIMMED) {
902 ret = verify_trimmed_io_u(td, io_u);
906 hdr_inc = get_hdr_inc(td, io_u);
909 for (p = io_u->buf; p < io_u->buf + io_u->buflen;
910 p += hdr_inc, hdr_num++) {
916 unsigned int verify_type;
918 if (ret && td->o.verify_fatal)
921 header_size = __hdr_size(td->o.verify);
922 if (td->o.verify_offset)
923 memswp(p, p + td->o.verify_offset, header_size);
927 * Make rand_seed check pass when have verifysort or
930 if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG))
931 io_u->rand_seed = hdr->rand_seed;
933 if (td->o.verify != VERIFY_PATTERN_NO_HDR) {
934 ret = verify_header(io_u, td, hdr, hdr_num, hdr_inc);
939 if (td->o.verify != VERIFY_NONE)
940 verify_type = td->o.verify;
942 verify_type = hdr->verify_type;
944 switch (verify_type) {
945 case VERIFY_HDR_ONLY:
946 /* Header is always verified, check if pattern is left
947 * for verification. */
948 if (td->o.verify_pattern_bytes)
949 ret = verify_io_u_pattern(hdr, &vc);
952 ret = verify_io_u_md5(hdr, &vc);
955 ret = verify_io_u_crc64(hdr, &vc);
958 case VERIFY_CRC32C_INTEL:
959 ret = verify_io_u_crc32c(hdr, &vc);
962 ret = verify_io_u_crc32(hdr, &vc);
965 ret = verify_io_u_crc16(hdr, &vc);
968 ret = verify_io_u_crc7(hdr, &vc);
971 ret = verify_io_u_sha256(hdr, &vc);
974 ret = verify_io_u_sha512(hdr, &vc);
976 case VERIFY_SHA3_224:
977 ret = verify_io_u_sha3_224(hdr, &vc);
979 case VERIFY_SHA3_256:
980 ret = verify_io_u_sha3_256(hdr, &vc);
982 case VERIFY_SHA3_384:
983 ret = verify_io_u_sha3_384(hdr, &vc);
985 case VERIFY_SHA3_512:
986 ret = verify_io_u_sha3_512(hdr, &vc);
989 ret = verify_io_u_xxhash(hdr, &vc);
992 ret = verify_io_u_sha1(hdr, &vc);
995 case VERIFY_PATTERN_NO_HDR:
996 ret = verify_io_u_pattern(hdr, &vc);
999 log_err("Bad verify type %u\n", hdr->verify_type);
1003 if (ret && verify_type != hdr->verify_type)
1004 log_err("fio: verify type mismatch (%u media, %u given)\n",
1005 hdr->verify_type, verify_type);
1009 if (ret && td->o.verify_fatal)
1010 fio_mark_td_terminate(td);
1015 static void fill_xxhash(struct verify_header *hdr, void *p, unsigned int len)
1017 struct vhdr_xxhash *vh = hdr_priv(hdr);
1020 state = XXH32_init(1);
1021 XXH32_update(state, p, len);
1022 vh->hash = XXH32_digest(state);
1025 static void fill_sha3(struct fio_sha3_ctx *sha3_ctx, void *p, unsigned int len)
1027 fio_sha3_update(sha3_ctx, p, len);
1028 fio_sha3_final(sha3_ctx);
1031 static void fill_sha3_224(struct verify_header *hdr, void *p, unsigned int len)
1033 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
1034 struct fio_sha3_ctx sha3_ctx = {
1038 fio_sha3_224_init(&sha3_ctx);
1039 fill_sha3(&sha3_ctx, p, len);
1042 static void fill_sha3_256(struct verify_header *hdr, void *p, unsigned int len)
1044 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
1045 struct fio_sha3_ctx sha3_ctx = {
1049 fio_sha3_256_init(&sha3_ctx);
1050 fill_sha3(&sha3_ctx, p, len);
1053 static void fill_sha3_384(struct verify_header *hdr, void *p, unsigned int len)
1055 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
1056 struct fio_sha3_ctx sha3_ctx = {
1060 fio_sha3_384_init(&sha3_ctx);
1061 fill_sha3(&sha3_ctx, p, len);
1064 static void fill_sha3_512(struct verify_header *hdr, void *p, unsigned int len)
1066 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
1067 struct fio_sha3_ctx sha3_ctx = {
1071 fio_sha3_512_init(&sha3_ctx);
1072 fill_sha3(&sha3_ctx, p, len);
1075 static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
1077 struct vhdr_sha512 *vh = hdr_priv(hdr);
1078 struct fio_sha512_ctx sha512_ctx = {
1082 fio_sha512_init(&sha512_ctx);
1083 fio_sha512_update(&sha512_ctx, p, len);
1086 static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
1088 struct vhdr_sha256 *vh = hdr_priv(hdr);
1089 struct fio_sha256_ctx sha256_ctx = {
1093 fio_sha256_init(&sha256_ctx);
1094 fio_sha256_update(&sha256_ctx, p, len);
1095 fio_sha256_final(&sha256_ctx);
1098 static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
1100 struct vhdr_sha1 *vh = hdr_priv(hdr);
1101 struct fio_sha1_ctx sha1_ctx = {
1105 fio_sha1_init(&sha1_ctx);
1106 fio_sha1_update(&sha1_ctx, p, len);
1107 fio_sha1_final(&sha1_ctx);
1110 static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
1112 struct vhdr_crc7 *vh = hdr_priv(hdr);
1114 vh->crc7 = fio_crc7(p, len);
1117 static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
1119 struct vhdr_crc16 *vh = hdr_priv(hdr);
1121 vh->crc16 = fio_crc16(p, len);
1124 static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
1126 struct vhdr_crc32 *vh = hdr_priv(hdr);
1128 vh->crc32 = fio_crc32(p, len);
1131 static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
1133 struct vhdr_crc32 *vh = hdr_priv(hdr);
1135 vh->crc32 = fio_crc32c(p, len);
1138 static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
1140 struct vhdr_crc64 *vh = hdr_priv(hdr);
1142 vh->crc64 = fio_crc64(p, len);
1145 static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
1147 struct vhdr_md5 *vh = hdr_priv(hdr);
1148 struct fio_md5_ctx md5_ctx = {
1149 .hash = (uint32_t *) vh->md5_digest,
1152 fio_md5_init(&md5_ctx);
1153 fio_md5_update(&md5_ctx, p, len);
1154 fio_md5_final(&md5_ctx);
1157 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
1158 struct verify_header *hdr, unsigned int header_num,
1159 unsigned int header_len, uint64_t rand_seed)
1163 hdr->magic = FIO_HDR_MAGIC;
1164 hdr->verify_type = td->o.verify;
1165 hdr->len = header_len;
1166 hdr->rand_seed = rand_seed;
1167 hdr->offset = io_u->offset + header_num * td->o.verify_interval;
1168 hdr->time_sec = io_u->start_time.tv_sec;
1169 hdr->time_usec = io_u->start_time.tv_usec;
1170 hdr->thread = td->thread_number;
1171 hdr->numberio = io_u->numberio;
1172 hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
1176 static void fill_hdr(struct thread_data *td, struct io_u *io_u,
1177 struct verify_header *hdr, unsigned int header_num,
1178 unsigned int header_len, uint64_t rand_seed)
1181 if (td->o.verify != VERIFY_PATTERN_NO_HDR)
1182 __fill_hdr(td, io_u, hdr, header_num, header_len, rand_seed);
1185 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
1186 struct verify_header *hdr, unsigned int header_num,
1187 unsigned int header_len)
1189 unsigned int data_len;
1194 fill_hdr(td, io_u, hdr, header_num, header_len, io_u->rand_seed);
1196 data_len = header_len - hdr_size(td, hdr);
1198 data = p + hdr_size(td, hdr);
1199 switch (td->o.verify) {
1201 dprint(FD_VERIFY, "fill md5 io_u %p, len %u\n",
1203 fill_md5(hdr, data, data_len);
1206 dprint(FD_VERIFY, "fill crc64 io_u %p, len %u\n",
1208 fill_crc64(hdr, data, data_len);
1211 case VERIFY_CRC32C_INTEL:
1212 dprint(FD_VERIFY, "fill crc32c io_u %p, len %u\n",
1214 fill_crc32c(hdr, data, data_len);
1217 dprint(FD_VERIFY, "fill crc32 io_u %p, len %u\n",
1219 fill_crc32(hdr, data, data_len);
1222 dprint(FD_VERIFY, "fill crc16 io_u %p, len %u\n",
1224 fill_crc16(hdr, data, data_len);
1227 dprint(FD_VERIFY, "fill crc7 io_u %p, len %u\n",
1229 fill_crc7(hdr, data, data_len);
1232 dprint(FD_VERIFY, "fill sha256 io_u %p, len %u\n",
1234 fill_sha256(hdr, data, data_len);
1237 dprint(FD_VERIFY, "fill sha512 io_u %p, len %u\n",
1239 fill_sha512(hdr, data, data_len);
1241 case VERIFY_SHA3_224:
1242 dprint(FD_VERIFY, "fill sha3-224 io_u %p, len %u\n",
1244 fill_sha3_224(hdr, data, data_len);
1246 case VERIFY_SHA3_256:
1247 dprint(FD_VERIFY, "fill sha3-256 io_u %p, len %u\n",
1249 fill_sha3_256(hdr, data, data_len);
1251 case VERIFY_SHA3_384:
1252 dprint(FD_VERIFY, "fill sha3-384 io_u %p, len %u\n",
1254 fill_sha3_384(hdr, data, data_len);
1256 case VERIFY_SHA3_512:
1257 dprint(FD_VERIFY, "fill sha3-512 io_u %p, len %u\n",
1259 fill_sha3_512(hdr, data, data_len);
1262 dprint(FD_VERIFY, "fill xxhash io_u %p, len %u\n",
1264 fill_xxhash(hdr, data, data_len);
1267 dprint(FD_VERIFY, "fill sha1 io_u %p, len %u\n",
1269 fill_sha1(hdr, data, data_len);
1271 case VERIFY_HDR_ONLY:
1272 case VERIFY_PATTERN:
1273 case VERIFY_PATTERN_NO_HDR:
1274 /* nothing to do here */
1277 log_err("fio: bad verify type: %d\n", td->o.verify);
1281 if (td->o.verify_offset && hdr_size(td, hdr))
1282 memswp(p, p + td->o.verify_offset, hdr_size(td, hdr));
1286 * fill body of io_u->buf with random data and add a header with the
1287 * checksum of choice
1289 void populate_verify_io_u(struct thread_data *td, struct io_u *io_u)
1291 if (td->o.verify == VERIFY_NULL)
1294 io_u->numberio = td->io_issues[io_u->ddir];
1296 fill_pattern_headers(td, io_u, 0, 0);
1299 int get_next_verify(struct thread_data *td, struct io_u *io_u)
1301 struct io_piece *ipo = NULL;
1304 * this io_u is from a requeue, we already filled the offsets
1309 if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
1310 struct rb_node *n = rb_first(&td->io_hist_tree);
1312 ipo = rb_entry(n, struct io_piece, rb_node);
1315 * Ensure that the associated IO has completed
1318 if (ipo->flags & IP_F_IN_FLIGHT)
1321 rb_erase(n, &td->io_hist_tree);
1322 assert(ipo->flags & IP_F_ONRB);
1323 ipo->flags &= ~IP_F_ONRB;
1324 } else if (!flist_empty(&td->io_hist_list)) {
1325 ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list);
1328 * Ensure that the associated IO has completed
1331 if (ipo->flags & IP_F_IN_FLIGHT)
1334 flist_del(&ipo->list);
1335 assert(ipo->flags & IP_F_ONLIST);
1336 ipo->flags &= ~IP_F_ONLIST;
1342 io_u->offset = ipo->offset;
1343 io_u->buflen = ipo->len;
1344 io_u->numberio = ipo->numberio;
1345 io_u->file = ipo->file;
1346 io_u_set(td, io_u, IO_U_F_VER_LIST);
1348 if (ipo->flags & IP_F_TRIMMED)
1349 io_u_set(td, io_u, IO_U_F_TRIMMED);
1351 if (!fio_file_open(io_u->file)) {
1352 int r = td_io_open_file(td, io_u->file);
1355 dprint(FD_VERIFY, "failed file %s open\n",
1356 io_u->file->file_name);
1361 get_file(ipo->file);
1362 assert(fio_file_open(io_u->file));
1363 io_u->ddir = DDIR_READ;
1364 io_u->xfer_buf = io_u->buf;
1365 io_u->xfer_buflen = io_u->buflen;
1367 remove_trim_entry(td, ipo);
1369 dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u);
1371 if (!td->o.verify_pattern_bytes) {
1372 io_u->rand_seed = __rand(&td->verify_state);
1373 if (sizeof(int) != sizeof(long *))
1374 io_u->rand_seed *= __rand(&td->verify_state);
1380 dprint(FD_VERIFY, "get_next_verify: empty\n");
1384 void fio_verify_init(struct thread_data *td)
1386 if (td->o.verify == VERIFY_CRC32C_INTEL ||
1387 td->o.verify == VERIFY_CRC32C) {
1388 crc32c_arm64_probe();
1389 crc32c_intel_probe();
1393 static void *verify_async_thread(void *data)
1395 struct thread_data *td = data;
1399 if (fio_option_is_set(&td->o, verify_cpumask) &&
1400 fio_setaffinity(td->pid, td->o.verify_cpumask)) {
1401 log_err("fio: failed setting verify thread affinity\n");
1409 if (td->verify_thread_exit)
1412 pthread_mutex_lock(&td->io_u_lock);
1414 while (flist_empty(&td->verify_list) &&
1415 !td->verify_thread_exit) {
1416 ret = pthread_cond_wait(&td->verify_cond,
1419 pthread_mutex_unlock(&td->io_u_lock);
1424 flist_splice_init(&td->verify_list, &list);
1425 pthread_mutex_unlock(&td->io_u_lock);
1427 if (flist_empty(&list))
1430 while (!flist_empty(&list)) {
1431 io_u = flist_first_entry(&list, struct io_u, verify_list);
1432 flist_del_init(&io_u->verify_list);
1434 io_u_set(td, io_u, IO_U_F_NO_FILE_PUT);
1435 ret = verify_io_u(td, &io_u);
1440 if (td_non_fatal_error(td, ERROR_TYPE_VERIFY_BIT, ret)) {
1441 update_error_count(td, ret);
1449 td_verror(td, ret, "async_verify");
1450 if (td->o.verify_fatal)
1451 fio_mark_td_terminate(td);
1455 pthread_mutex_lock(&td->io_u_lock);
1456 td->nr_verify_threads--;
1457 pthread_mutex_unlock(&td->io_u_lock);
1459 pthread_cond_signal(&td->free_cond);
1463 int verify_async_init(struct thread_data *td)
1466 pthread_attr_t attr;
1468 pthread_attr_init(&attr);
1469 pthread_attr_setstacksize(&attr, 2 * PTHREAD_STACK_MIN);
1471 td->verify_thread_exit = 0;
1473 td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async);
1474 for (i = 0; i < td->o.verify_async; i++) {
1475 ret = pthread_create(&td->verify_threads[i], &attr,
1476 verify_async_thread, td);
1478 log_err("fio: async verify creation failed: %s\n",
1482 ret = pthread_detach(td->verify_threads[i]);
1484 log_err("fio: async verify thread detach failed: %s\n",
1488 td->nr_verify_threads++;
1491 pthread_attr_destroy(&attr);
1493 if (i != td->o.verify_async) {
1494 log_err("fio: only %d verify threads started, exiting\n", i);
1495 td->verify_thread_exit = 1;
1497 pthread_cond_broadcast(&td->verify_cond);
1504 void verify_async_exit(struct thread_data *td)
1506 td->verify_thread_exit = 1;
1508 pthread_cond_broadcast(&td->verify_cond);
1510 pthread_mutex_lock(&td->io_u_lock);
1512 while (td->nr_verify_threads)
1513 pthread_cond_wait(&td->free_cond, &td->io_u_lock);
1515 pthread_mutex_unlock(&td->io_u_lock);
1516 free(td->verify_threads);
1517 td->verify_threads = NULL;
1520 int paste_blockoff(char *buf, unsigned int len, void *priv)
1522 struct io_u *io = priv;
1523 unsigned long long off;
1525 typecheck(typeof(off), io->offset);
1526 off = cpu_to_le64((uint64_t)io->offset);
1527 len = min(len, (unsigned int)sizeof(off));
1528 memcpy(buf, &off, len);
1532 static int __fill_file_completions(struct thread_data *td,
1533 struct thread_io_list *s,
1534 struct fio_file *f, unsigned int *index)
1539 if (!f->last_write_comp)
1542 if (td->io_blocks[DDIR_WRITE] < td->o.iodepth)
1543 comps = td->io_blocks[DDIR_WRITE];
1545 comps = td->o.iodepth;
1547 j = f->last_write_idx - 1;
1548 for (i = 0; i < comps; i++) {
1550 j = td->o.iodepth - 1;
1551 s->comps[*index].fileno = __cpu_to_le64(f->fileno);
1552 s->comps[*index].offset = cpu_to_le64(f->last_write_comp[j]);
1560 static int fill_file_completions(struct thread_data *td,
1561 struct thread_io_list *s, unsigned int *index)
1567 for_each_file(td, f, i)
1568 comps += __fill_file_completions(td, s, f, index);
1573 struct all_io_list *get_all_io_list(int save_mask, size_t *sz)
1575 struct all_io_list *rep;
1576 struct thread_data *td;
1581 compiletime_assert(sizeof(struct all_io_list) == 8, "all_io_list");
1584 * Calculate reply space needed. We need one 'io_state' per thread,
1585 * and the size will vary depending on depth.
1589 for_each_td(td, i) {
1590 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1593 td->flags |= TD_F_VSTATE_SAVED;
1594 depth += (td->o.iodepth * td->o.nr_files);
1602 *sz += nr * sizeof(struct thread_io_list);
1603 *sz += depth * sizeof(struct file_comp);
1605 memset(rep, 0, *sz);
1607 rep->threads = cpu_to_le64((uint64_t) nr);
1609 next = &rep->state[0];
1610 for_each_td(td, i) {
1611 struct thread_io_list *s = next;
1612 unsigned int comps, index = 0;
1614 if (save_mask != IO_LIST_ALL && (i + 1) != save_mask)
1617 comps = fill_file_completions(td, s, &index);
1619 s->no_comps = cpu_to_le64((uint64_t) comps);
1620 s->depth = cpu_to_le64((uint64_t) td->o.iodepth);
1621 s->nofiles = cpu_to_le64((uint64_t) td->o.nr_files);
1622 s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]);
1623 s->index = cpu_to_le64((uint64_t) i);
1624 if (td->random_state.use64) {
1625 s->rand.state64.s[0] = cpu_to_le64(td->random_state.state64.s1);
1626 s->rand.state64.s[1] = cpu_to_le64(td->random_state.state64.s2);
1627 s->rand.state64.s[2] = cpu_to_le64(td->random_state.state64.s3);
1628 s->rand.state64.s[3] = cpu_to_le64(td->random_state.state64.s4);
1629 s->rand.state64.s[4] = cpu_to_le64(td->random_state.state64.s5);
1630 s->rand.state64.s[5] = 0;
1631 s->rand.use64 = cpu_to_le64((uint64_t)1);
1633 s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1);
1634 s->rand.state32.s[1] = cpu_to_le32(td->random_state.state32.s2);
1635 s->rand.state32.s[2] = cpu_to_le32(td->random_state.state32.s3);
1636 s->rand.state32.s[3] = 0;
1639 s->name[sizeof(s->name) - 1] = '\0';
1640 strncpy((char *) s->name, td->o.name, sizeof(s->name) - 1);
1641 next = io_list_next(s);
1647 static int open_state_file(const char *name, const char *prefix, int num,
1655 flags = O_CREAT | O_TRUNC | O_WRONLY | O_SYNC;
1659 verify_state_gen_name(out, sizeof(out), name, prefix, num);
1661 fd = open(out, flags, 0644);
1663 perror("fio: open state file");
1664 log_err("fio: state file: %s (for_write=%d)\n", out, for_write);
1671 static int write_thread_list_state(struct thread_io_list *s,
1674 struct verify_state_hdr hdr;
1679 fd = open_state_file((const char *) s->name, prefix, s->index, 1);
1683 crc = fio_crc32c((void *)s, thread_io_list_sz(s));
1685 hdr.version = cpu_to_le64((uint64_t) VSTATE_HDR_VERSION);
1686 hdr.size = cpu_to_le64((uint64_t) thread_io_list_sz(s));
1687 hdr.crc = cpu_to_le64(crc);
1688 ret = write(fd, &hdr, sizeof(hdr));
1689 if (ret != sizeof(hdr))
1692 ret = write(fd, s, thread_io_list_sz(s));
1693 if (ret != thread_io_list_sz(s)) {
1696 perror("fio: write state file");
1697 log_err("fio: failed to write state file\n");
1706 void __verify_save_state(struct all_io_list *state, const char *prefix)
1708 struct thread_io_list *s = &state->state[0];
1711 for (i = 0; i < le64_to_cpu(state->threads); i++) {
1712 write_thread_list_state(s, prefix);
1713 s = io_list_next(s);
1717 void verify_save_state(int mask)
1719 struct all_io_list *state;
1722 state = get_all_io_list(mask, &sz);
1724 char prefix[PATH_MAX];
1727 sprintf(prefix, "%s%slocal", aux_path, FIO_OS_PATH_SEPARATOR);
1729 strcpy(prefix, "local");
1731 __verify_save_state(state, prefix);
1736 void verify_free_state(struct thread_data *td)
1742 void verify_assign_state(struct thread_data *td, void *p)
1744 struct thread_io_list *s = p;
1747 s->no_comps = le64_to_cpu(s->no_comps);
1748 s->depth = le32_to_cpu(s->depth);
1749 s->nofiles = le32_to_cpu(s->nofiles);
1750 s->numberio = le64_to_cpu(s->numberio);
1751 s->rand.use64 = le64_to_cpu(s->rand.use64);
1753 if (s->rand.use64) {
1754 for (i = 0; i < 6; i++)
1755 s->rand.state64.s[i] = le64_to_cpu(s->rand.state64.s[i]);
1757 for (i = 0; i < 4; i++)
1758 s->rand.state32.s[i] = le32_to_cpu(s->rand.state32.s[i]);
1761 for (i = 0; i < s->no_comps; i++) {
1762 s->comps[i].fileno = le64_to_cpu(s->comps[i].fileno);
1763 s->comps[i].offset = le64_to_cpu(s->comps[i].offset);
1769 int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s)
1773 hdr->version = le64_to_cpu(hdr->version);
1774 hdr->size = le64_to_cpu(hdr->size);
1775 hdr->crc = le64_to_cpu(hdr->crc);
1777 if (hdr->version != VSTATE_HDR_VERSION)
1780 crc = fio_crc32c((void *)s, hdr->size);
1781 if (crc != hdr->crc)
1787 int verify_load_state(struct thread_data *td, const char *prefix)
1789 struct verify_state_hdr hdr;
1795 if (!td->o.verify_state)
1798 fd = open_state_file(td->o.name, prefix, td->thread_number - 1, 0);
1802 ret = read(fd, &hdr, sizeof(hdr));
1803 if (ret != sizeof(hdr)) {
1805 td_verror(td, errno, "read verify state hdr");
1806 log_err("fio: failed reading verify state header\n");
1810 hdr.version = le64_to_cpu(hdr.version);
1811 hdr.size = le64_to_cpu(hdr.size);
1812 hdr.crc = le64_to_cpu(hdr.crc);
1814 if (hdr.version != VSTATE_HDR_VERSION) {
1815 log_err("fio: unsupported (%d) version in verify state header\n",
1816 (unsigned int) hdr.version);
1820 s = malloc(hdr.size);
1821 ret = read(fd, s, hdr.size);
1822 if (ret != hdr.size) {
1824 td_verror(td, errno, "read verify state");
1825 log_err("fio: failed reading verity state\n");
1829 crc = fio_crc32c(s, hdr.size);
1830 if (crc != hdr.crc) {
1831 log_err("fio: verify state is corrupt\n");
1837 verify_assign_state(td, s);
1847 * Use the loaded verify state to know when to stop doing verification
1849 int verify_state_should_stop(struct thread_data *td, struct io_u *io_u)
1851 struct thread_io_list *s = td->vstate;
1852 struct fio_file *f = io_u->file;
1859 * If we're not into the window of issues - depth yet, continue. If
1860 * issue is shorter than depth, do check.
1862 if ((td->io_blocks[DDIR_READ] < s->depth ||
1863 s->numberio - td->io_blocks[DDIR_READ] > s->depth) &&
1864 s->numberio > s->depth)
1868 * We're in the window of having to check if this io was
1869 * completed or not. If the IO was seen as completed, then
1872 for (i = 0; i < s->no_comps; i++) {
1873 if (s->comps[i].fileno != f->fileno)
1875 if (io_u->offset == s->comps[i].offset)
1880 * Not found, we have to stop