2 * IO verification helpers
11 #include "arch/arch.h"
16 #include "lib/hweight.h"
17 #include "lib/pattern.h"
18 #include "oslib/asprintf.h"
21 #include "crc/crc64.h"
22 #include "crc/crc32.h"
23 #include "crc/crc32c.h"
24 #include "crc/crc16.h"
26 #include "crc/sha256.h"
27 #include "crc/sha512.h"
29 #include "crc/xxhash.h"
32 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
33 struct verify_header *hdr, unsigned int header_num,
34 unsigned int header_len);
35 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
36 struct verify_header *hdr, unsigned int header_num,
37 unsigned int header_len, uint64_t rand_seed);
39 void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len)
41 (void)cpy_pattern(td->o.buffer_pattern, td->o.buffer_pattern_bytes, p, len);
44 static void __fill_buffer(struct thread_options *o, uint64_t seed, void *p,
47 __fill_random_buf_percentage(seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes);
50 void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len,
51 struct io_u *io_u, uint64_t seed, int use_seed)
53 struct thread_options *o = &td->o;
55 if (!o->verify_pattern_bytes) {
56 dprint(FD_VERIFY, "fill random bytes len=%u\n", len);
59 seed = __rand(&td->verify_state);
60 if (sizeof(int) != sizeof(long *))
61 seed *= (unsigned long)__rand(&td->verify_state);
63 io_u->rand_seed = seed;
64 __fill_buffer(o, seed, p, len);
68 /* Skip if we were here and we do not need to patch pattern
70 if (!td->o.verify_fmt_sz && io_u->buf_filled_len >= len) {
71 dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n",
72 o->verify_pattern_bytes, len);
76 (void)paste_format(td->o.verify_pattern, td->o.verify_pattern_bytes,
77 td->o.verify_fmt, td->o.verify_fmt_sz,
79 io_u->buf_filled_len = len;
82 static unsigned int get_hdr_inc(struct thread_data *td, struct io_u *io_u)
87 * If we use bs_unaligned, buflen can be larger than the verify
88 * interval (which just defaults to the smallest blocksize possible).
90 hdr_inc = io_u->buflen;
91 if (td->o.verify_interval && td->o.verify_interval <= io_u->buflen &&
93 hdr_inc = td->o.verify_interval;
98 static void fill_pattern_headers(struct thread_data *td, struct io_u *io_u,
99 uint64_t seed, int use_seed)
101 unsigned int hdr_inc, header_num;
102 struct verify_header *hdr;
105 fill_verify_pattern(td, p, io_u->buflen, io_u, seed, use_seed);
107 hdr_inc = get_hdr_inc(td, io_u);
109 for (; p < io_u->buf + io_u->buflen; p += hdr_inc) {
111 populate_hdr(td, io_u, hdr, header_num, hdr_inc);
116 static void memswp(void *buf1, void *buf2, unsigned int len)
120 assert(len <= sizeof(swap));
122 memcpy(&swap, buf1, len);
123 memcpy(buf1, buf2, len);
124 memcpy(buf2, &swap, len);
127 static void hexdump(void *buffer, int len)
129 unsigned char *p = buffer;
132 for (i = 0; i < len; i++)
133 log_err("%02x", p[i]);
138 * Prepare for separation of verify_header and checksum header
140 static inline unsigned int __hdr_size(int verify_type)
142 unsigned int len = 0;
144 switch (verify_type) {
146 case VERIFY_HDR_ONLY:
152 len = sizeof(struct vhdr_md5);
155 len = sizeof(struct vhdr_crc64);
159 case VERIFY_CRC32C_INTEL:
160 len = sizeof(struct vhdr_crc32);
163 len = sizeof(struct vhdr_crc16);
166 len = sizeof(struct vhdr_crc7);
169 len = sizeof(struct vhdr_sha256);
172 len = sizeof(struct vhdr_sha512);
174 case VERIFY_SHA3_224:
175 len = sizeof(struct vhdr_sha3_224);
177 case VERIFY_SHA3_256:
178 len = sizeof(struct vhdr_sha3_256);
180 case VERIFY_SHA3_384:
181 len = sizeof(struct vhdr_sha3_384);
183 case VERIFY_SHA3_512:
184 len = sizeof(struct vhdr_sha3_512);
187 len = sizeof(struct vhdr_xxhash);
190 len = sizeof(struct vhdr_sha1);
192 case VERIFY_PATTERN_NO_HDR:
195 log_err("fio: unknown verify header!\n");
199 return len + sizeof(struct verify_header);
202 static inline unsigned int hdr_size(struct thread_data *td,
203 struct verify_header *hdr)
205 if (td->o.verify == VERIFY_PATTERN_NO_HDR)
208 return __hdr_size(hdr->verify_type);
211 static void *hdr_priv(struct verify_header *hdr)
215 return priv + sizeof(struct verify_header);
219 * Verify container, pass info to verify handlers and allow them to
220 * pass info back in case of error
227 unsigned int hdr_num;
228 struct thread_data *td;
231 * Output, only valid in case of error
236 unsigned int crc_len;
239 #define DUMP_BUF_SZ 255
241 static void dump_buf(char *buf, unsigned int len, unsigned long long offset,
242 const char *type, struct fio_file *f)
245 char sep[2] = { FIO_OS_PATH_SEPARATOR, 0 };
248 ptr = strdup(f->file_name);
250 if (asprintf(&fname, "%s%s%s.%llu.%s", aux_path ? : "",
251 aux_path ? sep : "", basename(ptr), offset, type) < 0) {
252 if (!fio_did_warn(FIO_WARN_VERIFY_BUF))
253 log_err("fio: not enough memory for dump buffer filename\n");
257 fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644);
259 perror("open verify buf file");
264 ret = write(fd, buf, len);
268 perror("write verify buf file");
276 log_err(" %s data dumped as %s\n", type, fname);
286 * Dump the contents of the read block and re-generate the correct data
289 static void __dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
291 struct thread_data *td = vc->td;
292 struct io_u *io_u = vc->io_u;
293 unsigned long hdr_offset;
297 if (!td->o.verify_dump)
301 * Dump the contents we just read off disk
303 hdr_offset = vc->hdr_num * hdr->len;
305 dump_buf(io_u->buf + hdr_offset, hdr->len, io_u->verify_offset + hdr_offset,
306 "received", vc->io_u->file);
309 * Allocate a new buf and re-generate the original data
311 buf = malloc(io_u->buflen);
314 dummy.rand_seed = hdr->rand_seed;
315 dummy.buf_filled_len = 0;
316 dummy.buflen = io_u->buflen;
318 fill_pattern_headers(td, &dummy, hdr->rand_seed, 1);
320 dump_buf(buf + hdr_offset, hdr->len, io_u->verify_offset + hdr_offset,
321 "expected", vc->io_u->file);
325 static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
327 struct thread_data *td = vc->td;
328 struct verify_header shdr;
330 if (td->o.verify == VERIFY_PATTERN_NO_HDR) {
331 __fill_hdr(td, vc->io_u, &shdr, 0, vc->io_u->buflen, 0);
335 __dump_verify_buffers(hdr, vc);
338 static void log_verify_failure(struct verify_header *hdr, struct vcont *vc)
340 unsigned long long offset;
342 offset = vc->io_u->verify_offset;
343 offset += vc->hdr_num * hdr->len;
344 log_err("%.8s: verify failed at file %s offset %llu, length %u"
345 " (requested block: offset=%llu, length=%llu, flags=%x)\n",
346 vc->name, vc->io_u->file->file_name, offset, hdr->len,
347 vc->io_u->verify_offset, vc->io_u->buflen, vc->io_u->flags);
349 if (vc->good_crc && vc->bad_crc) {
350 log_err(" Expected CRC: ");
351 hexdump(vc->good_crc, vc->crc_len);
352 log_err(" Received CRC: ");
353 hexdump(vc->bad_crc, vc->crc_len);
356 dump_verify_buffers(hdr, vc);
360 * Return data area 'header_num'
362 static inline void *io_u_verify_off(struct verify_header *hdr, struct vcont *vc)
364 return vc->io_u->buf + vc->hdr_num * hdr->len + hdr_size(vc->td, hdr);
367 static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
369 struct thread_data *td = vc->td;
370 struct io_u *io_u = vc->io_u;
372 unsigned int header_size = __hdr_size(td->o.verify);
373 unsigned int len, mod, i, pattern_size;
376 pattern = td->o.verify_pattern;
377 pattern_size = td->o.verify_pattern_bytes;
378 assert(pattern_size != 0);
380 (void)paste_format_inplace(pattern, pattern_size,
381 td->o.verify_fmt, td->o.verify_fmt_sz, io_u);
383 buf = (char *) hdr + header_size;
384 len = get_hdr_inc(td, io_u) - header_size;
385 mod = (get_hdr_inc(td, io_u) * vc->hdr_num + header_size) % pattern_size;
387 rc = cmp_pattern(pattern, pattern_size, mod, buf, len);
391 /* Slow path, compare each byte */
392 for (i = 0; i < len; i++) {
393 if (buf[i] != pattern[mod]) {
396 bits = hweight8(buf[i] ^ pattern[mod]);
397 log_err("fio: got pattern '%02x', wanted '%02x'. Bad bits %d\n",
398 (unsigned char)buf[i],
399 (unsigned char)pattern[mod],
401 log_err("fio: bad pattern block offset %u\n", i);
402 vc->name = "pattern";
403 log_verify_failure(hdr, vc);
407 if (mod == td->o.verify_pattern_bytes)
411 /* Unreachable line */
416 static int verify_io_u_xxhash(struct verify_header *hdr, struct vcont *vc)
418 void *p = io_u_verify_off(hdr, vc);
419 struct vhdr_xxhash *vh = hdr_priv(hdr);
423 dprint(FD_VERIFY, "xxhash verify io_u %p, len %u\n", vc->io_u, hdr->len);
425 state = XXH32_init(1);
426 XXH32_update(state, p, hdr->len - hdr_size(vc->td, hdr));
427 hash = XXH32_digest(state);
429 if (vh->hash == hash)
433 vc->good_crc = &vh->hash;
435 vc->crc_len = sizeof(hash);
436 log_verify_failure(hdr, vc);
440 static int verify_io_u_sha3(struct verify_header *hdr, struct vcont *vc,
441 struct fio_sha3_ctx *sha3_ctx, uint8_t *sha,
442 unsigned int sha_size, const char *name)
444 void *p = io_u_verify_off(hdr, vc);
446 dprint(FD_VERIFY, "%s verify io_u %p, len %u\n", name, vc->io_u, hdr->len);
448 fio_sha3_update(sha3_ctx, p, hdr->len - hdr_size(vc->td, hdr));
449 fio_sha3_final(sha3_ctx);
451 if (!memcmp(sha, sha3_ctx->sha, sha_size))
456 vc->bad_crc = sha3_ctx->sha;
457 vc->crc_len = sha_size;
458 log_verify_failure(hdr, vc);
462 static int verify_io_u_sha3_224(struct verify_header *hdr, struct vcont *vc)
464 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
465 uint8_t sha[SHA3_224_DIGEST_SIZE];
466 struct fio_sha3_ctx sha3_ctx = {
470 fio_sha3_224_init(&sha3_ctx);
472 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
473 SHA3_224_DIGEST_SIZE, "sha3-224");
476 static int verify_io_u_sha3_256(struct verify_header *hdr, struct vcont *vc)
478 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
479 uint8_t sha[SHA3_256_DIGEST_SIZE];
480 struct fio_sha3_ctx sha3_ctx = {
484 fio_sha3_256_init(&sha3_ctx);
486 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
487 SHA3_256_DIGEST_SIZE, "sha3-256");
490 static int verify_io_u_sha3_384(struct verify_header *hdr, struct vcont *vc)
492 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
493 uint8_t sha[SHA3_384_DIGEST_SIZE];
494 struct fio_sha3_ctx sha3_ctx = {
498 fio_sha3_384_init(&sha3_ctx);
500 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
501 SHA3_384_DIGEST_SIZE, "sha3-384");
504 static int verify_io_u_sha3_512(struct verify_header *hdr, struct vcont *vc)
506 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
507 uint8_t sha[SHA3_512_DIGEST_SIZE];
508 struct fio_sha3_ctx sha3_ctx = {
512 fio_sha3_512_init(&sha3_ctx);
514 return verify_io_u_sha3(hdr, vc, &sha3_ctx, vh->sha,
515 SHA3_512_DIGEST_SIZE, "sha3-512");
518 static int verify_io_u_sha512(struct verify_header *hdr, struct vcont *vc)
520 void *p = io_u_verify_off(hdr, vc);
521 struct vhdr_sha512 *vh = hdr_priv(hdr);
523 struct fio_sha512_ctx sha512_ctx = {
527 dprint(FD_VERIFY, "sha512 verify io_u %p, len %u\n", vc->io_u, hdr->len);
529 fio_sha512_init(&sha512_ctx);
530 fio_sha512_update(&sha512_ctx, p, hdr->len - hdr_size(vc->td, hdr));
532 if (!memcmp(vh->sha512, sha512_ctx.buf, sizeof(sha512)))
536 vc->good_crc = vh->sha512;
537 vc->bad_crc = sha512_ctx.buf;
538 vc->crc_len = sizeof(vh->sha512);
539 log_verify_failure(hdr, vc);
543 static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc)
545 void *p = io_u_verify_off(hdr, vc);
546 struct vhdr_sha256 *vh = hdr_priv(hdr);
548 struct fio_sha256_ctx sha256_ctx = {
552 dprint(FD_VERIFY, "sha256 verify io_u %p, len %u\n", vc->io_u, hdr->len);
554 fio_sha256_init(&sha256_ctx);
555 fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(vc->td, hdr));
556 fio_sha256_final(&sha256_ctx);
558 if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256)))
562 vc->good_crc = vh->sha256;
563 vc->bad_crc = sha256_ctx.buf;
564 vc->crc_len = sizeof(vh->sha256);
565 log_verify_failure(hdr, vc);
569 static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc)
571 void *p = io_u_verify_off(hdr, vc);
572 struct vhdr_sha1 *vh = hdr_priv(hdr);
574 struct fio_sha1_ctx sha1_ctx = {
578 dprint(FD_VERIFY, "sha1 verify io_u %p, len %u\n", vc->io_u, hdr->len);
580 fio_sha1_init(&sha1_ctx);
581 fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(vc->td, hdr));
582 fio_sha1_final(&sha1_ctx);
584 if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1)))
588 vc->good_crc = vh->sha1;
589 vc->bad_crc = sha1_ctx.H;
590 vc->crc_len = sizeof(vh->sha1);
591 log_verify_failure(hdr, vc);
595 static int verify_io_u_crc7(struct verify_header *hdr, struct vcont *vc)
597 void *p = io_u_verify_off(hdr, vc);
598 struct vhdr_crc7 *vh = hdr_priv(hdr);
601 dprint(FD_VERIFY, "crc7 verify io_u %p, len %u\n", vc->io_u, hdr->len);
603 c = fio_crc7(p, hdr->len - hdr_size(vc->td, hdr));
609 vc->good_crc = &vh->crc7;
612 log_verify_failure(hdr, vc);
616 static int verify_io_u_crc16(struct verify_header *hdr, struct vcont *vc)
618 void *p = io_u_verify_off(hdr, vc);
619 struct vhdr_crc16 *vh = hdr_priv(hdr);
622 dprint(FD_VERIFY, "crc16 verify io_u %p, len %u\n", vc->io_u, hdr->len);
624 c = fio_crc16(p, hdr->len - hdr_size(vc->td, hdr));
630 vc->good_crc = &vh->crc16;
633 log_verify_failure(hdr, vc);
637 static int verify_io_u_crc64(struct verify_header *hdr, struct vcont *vc)
639 void *p = io_u_verify_off(hdr, vc);
640 struct vhdr_crc64 *vh = hdr_priv(hdr);
641 unsigned long long c;
643 dprint(FD_VERIFY, "crc64 verify io_u %p, len %u\n", vc->io_u, hdr->len);
645 c = fio_crc64(p, hdr->len - hdr_size(vc->td, hdr));
651 vc->good_crc = &vh->crc64;
654 log_verify_failure(hdr, vc);
658 static int verify_io_u_crc32(struct verify_header *hdr, struct vcont *vc)
660 void *p = io_u_verify_off(hdr, vc);
661 struct vhdr_crc32 *vh = hdr_priv(hdr);
664 dprint(FD_VERIFY, "crc32 verify io_u %p, len %u\n", vc->io_u, hdr->len);
666 c = fio_crc32(p, hdr->len - hdr_size(vc->td, hdr));
672 vc->good_crc = &vh->crc32;
675 log_verify_failure(hdr, vc);
679 static int verify_io_u_crc32c(struct verify_header *hdr, struct vcont *vc)
681 void *p = io_u_verify_off(hdr, vc);
682 struct vhdr_crc32 *vh = hdr_priv(hdr);
685 dprint(FD_VERIFY, "crc32c verify io_u %p, len %u\n", vc->io_u, hdr->len);
687 c = fio_crc32c(p, hdr->len - hdr_size(vc->td, hdr));
693 vc->good_crc = &vh->crc32;
696 log_verify_failure(hdr, vc);
700 static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc)
702 void *p = io_u_verify_off(hdr, vc);
703 struct vhdr_md5 *vh = hdr_priv(hdr);
704 uint32_t hash[MD5_HASH_WORDS];
705 struct fio_md5_ctx md5_ctx = {
709 dprint(FD_VERIFY, "md5 verify io_u %p, len %u\n", vc->io_u, hdr->len);
711 fio_md5_init(&md5_ctx);
712 fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(vc->td, hdr));
713 fio_md5_final(&md5_ctx);
715 if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash)))
719 vc->good_crc = vh->md5_digest;
720 vc->bad_crc = md5_ctx.hash;
721 vc->crc_len = sizeof(hash);
722 log_verify_failure(hdr, vc);
727 * Push IO verification to a separate thread
729 int verify_io_u_async(struct thread_data *td, struct io_u **io_u_ptr)
731 struct io_u *io_u = *io_u_ptr;
733 pthread_mutex_lock(&td->io_u_lock);
736 put_file_log(td, io_u->file);
738 if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
740 io_u_clear(td, io_u, IO_U_F_IN_CUR_DEPTH);
742 flist_add_tail(&io_u->verify_list, &td->verify_list);
745 pthread_cond_signal(&td->verify_cond);
746 pthread_mutex_unlock(&td->io_u_lock);
751 * Thanks Rusty, for spending the time so I don't have to.
753 * http://rusty.ozlabs.org/?p=560
755 static int mem_is_zero(const void *data, size_t length)
757 const unsigned char *p = data;
760 /* Check first 16 bytes manually */
761 for (len = 0; len < 16; len++) {
770 /* Now we know that's zero, memcmp with self. */
771 return memcmp(data, p, length) == 0;
774 static int mem_is_zero_slow(const void *data, size_t length, size_t *offset)
776 const unsigned char *p = data;
790 static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
794 if (!td->o.trim_zero)
797 if (mem_is_zero(io_u->buf, io_u->buflen))
800 mem_is_zero_slow(io_u->buf, io_u->buflen, &offset);
802 log_err("trim: verify failed at file %s offset %llu, length %llu"
803 ", block offset %lu\n",
804 io_u->file->file_name, io_u->verify_offset, io_u->buflen,
805 (unsigned long) offset);
809 static int verify_header(struct io_u *io_u, struct thread_data *td,
810 struct verify_header *hdr, unsigned int hdr_num,
811 unsigned int hdr_len)
816 if (hdr->magic != FIO_HDR_MAGIC) {
817 log_err("verify: bad magic header %x, wanted %x",
818 hdr->magic, FIO_HDR_MAGIC);
821 if (hdr->len != hdr_len) {
822 log_err("verify: bad header length %u, wanted %u",
826 if (hdr->rand_seed != io_u->rand_seed) {
827 log_err("verify: bad header rand_seed %"PRIu64
829 hdr->rand_seed, io_u->rand_seed);
832 if (hdr->offset != io_u->verify_offset + hdr_num * td->o.verify_interval) {
833 log_err("verify: bad header offset %"PRIu64
835 hdr->offset, io_u->verify_offset);
840 * For read-only workloads, the program cannot be certain of the
841 * last numberio written to a block. Checking of numberio will be
842 * done only for workloads that write data. For verify_only,
843 * numberio check is skipped.
845 if (td_write(td) && (td_min_bs(td) == td_max_bs(td)) &&
847 if (!td->o.verify_only)
848 if (hdr->numberio != io_u->numberio) {
849 log_err("verify: bad header numberio %"PRIu16
851 hdr->numberio, io_u->numberio);
855 crc = fio_crc32c(p, offsetof(struct verify_header, crc32));
856 if (crc != hdr->crc32) {
857 log_err("verify: bad header crc %x, calculated %x",
864 log_err(" at file %s offset %llu, length %u"
865 " (requested block: offset=%llu, length=%llu)\n",
866 io_u->file->file_name,
867 io_u->verify_offset + hdr_num * hdr_len, hdr_len,
868 io_u->verify_offset, io_u->buflen);
870 if (td->o.verify_dump)
871 dump_buf(p, hdr_len, io_u->verify_offset + hdr_num * hdr_len,
872 "hdr_fail", io_u->file);
877 int verify_io_u(struct thread_data *td, struct io_u **io_u_ptr)
879 struct verify_header *hdr;
880 struct io_u *io_u = *io_u_ptr;
881 unsigned int header_size, hdr_inc, hdr_num = 0;
885 if (td->o.verify == VERIFY_NULL || io_u->ddir != DDIR_READ)
888 * If the IO engine is faking IO (like null), then just pretend
889 * we verified everything.
891 if (td_ioengine_flagged(td, FIO_FAKEIO))
894 if (io_u->flags & IO_U_F_TRIMMED) {
895 ret = verify_trimmed_io_u(td, io_u);
899 hdr_inc = get_hdr_inc(td, io_u);
902 for (p = io_u->buf; p < io_u->buf + io_u->buflen;
903 p += hdr_inc, hdr_num++) {
909 unsigned int verify_type;
911 if (ret && td->o.verify_fatal)
914 header_size = __hdr_size(td->o.verify);
915 if (td->o.verify_offset)
916 memswp(p, p + td->o.verify_offset, header_size);
920 * Make rand_seed check pass when have verify_backlog or
921 * zone reset frequency for zonemode=zbd.
923 if (!td_rw(td) || (td->flags & TD_F_VER_BACKLOG) ||
925 io_u->rand_seed = hdr->rand_seed;
927 if (td->o.verify != VERIFY_PATTERN_NO_HDR) {
928 ret = verify_header(io_u, td, hdr, hdr_num, hdr_inc);
933 if (td->o.verify != VERIFY_NONE)
934 verify_type = td->o.verify;
936 verify_type = hdr->verify_type;
938 switch (verify_type) {
939 case VERIFY_HDR_ONLY:
940 /* Header is always verified, check if pattern is left
941 * for verification. */
942 if (td->o.verify_pattern_bytes)
943 ret = verify_io_u_pattern(hdr, &vc);
946 ret = verify_io_u_md5(hdr, &vc);
949 ret = verify_io_u_crc64(hdr, &vc);
952 case VERIFY_CRC32C_INTEL:
953 ret = verify_io_u_crc32c(hdr, &vc);
956 ret = verify_io_u_crc32(hdr, &vc);
959 ret = verify_io_u_crc16(hdr, &vc);
962 ret = verify_io_u_crc7(hdr, &vc);
965 ret = verify_io_u_sha256(hdr, &vc);
968 ret = verify_io_u_sha512(hdr, &vc);
970 case VERIFY_SHA3_224:
971 ret = verify_io_u_sha3_224(hdr, &vc);
973 case VERIFY_SHA3_256:
974 ret = verify_io_u_sha3_256(hdr, &vc);
976 case VERIFY_SHA3_384:
977 ret = verify_io_u_sha3_384(hdr, &vc);
979 case VERIFY_SHA3_512:
980 ret = verify_io_u_sha3_512(hdr, &vc);
983 ret = verify_io_u_xxhash(hdr, &vc);
986 ret = verify_io_u_sha1(hdr, &vc);
989 case VERIFY_PATTERN_NO_HDR:
990 ret = verify_io_u_pattern(hdr, &vc);
993 log_err("Bad verify type %u\n", hdr->verify_type);
997 if (ret && verify_type != hdr->verify_type)
998 log_err("fio: verify type mismatch (%u media, %u given)\n",
999 hdr->verify_type, verify_type);
1003 if (ret && td->o.verify_fatal)
1004 fio_mark_td_terminate(td);
1009 static void fill_xxhash(struct verify_header *hdr, void *p, unsigned int len)
1011 struct vhdr_xxhash *vh = hdr_priv(hdr);
1014 state = XXH32_init(1);
1015 XXH32_update(state, p, len);
1016 vh->hash = XXH32_digest(state);
1019 static void fill_sha3(struct fio_sha3_ctx *sha3_ctx, void *p, unsigned int len)
1021 fio_sha3_update(sha3_ctx, p, len);
1022 fio_sha3_final(sha3_ctx);
1025 static void fill_sha3_224(struct verify_header *hdr, void *p, unsigned int len)
1027 struct vhdr_sha3_224 *vh = hdr_priv(hdr);
1028 struct fio_sha3_ctx sha3_ctx = {
1032 fio_sha3_224_init(&sha3_ctx);
1033 fill_sha3(&sha3_ctx, p, len);
1036 static void fill_sha3_256(struct verify_header *hdr, void *p, unsigned int len)
1038 struct vhdr_sha3_256 *vh = hdr_priv(hdr);
1039 struct fio_sha3_ctx sha3_ctx = {
1043 fio_sha3_256_init(&sha3_ctx);
1044 fill_sha3(&sha3_ctx, p, len);
1047 static void fill_sha3_384(struct verify_header *hdr, void *p, unsigned int len)
1049 struct vhdr_sha3_384 *vh = hdr_priv(hdr);
1050 struct fio_sha3_ctx sha3_ctx = {
1054 fio_sha3_384_init(&sha3_ctx);
1055 fill_sha3(&sha3_ctx, p, len);
1058 static void fill_sha3_512(struct verify_header *hdr, void *p, unsigned int len)
1060 struct vhdr_sha3_512 *vh = hdr_priv(hdr);
1061 struct fio_sha3_ctx sha3_ctx = {
1065 fio_sha3_512_init(&sha3_ctx);
1066 fill_sha3(&sha3_ctx, p, len);
1069 static void fill_sha512(struct verify_header *hdr, void *p, unsigned int len)
1071 struct vhdr_sha512 *vh = hdr_priv(hdr);
1072 struct fio_sha512_ctx sha512_ctx = {
1076 fio_sha512_init(&sha512_ctx);
1077 fio_sha512_update(&sha512_ctx, p, len);
1080 static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len)
1082 struct vhdr_sha256 *vh = hdr_priv(hdr);
1083 struct fio_sha256_ctx sha256_ctx = {
1087 fio_sha256_init(&sha256_ctx);
1088 fio_sha256_update(&sha256_ctx, p, len);
1089 fio_sha256_final(&sha256_ctx);
1092 static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len)
1094 struct vhdr_sha1 *vh = hdr_priv(hdr);
1095 struct fio_sha1_ctx sha1_ctx = {
1099 fio_sha1_init(&sha1_ctx);
1100 fio_sha1_update(&sha1_ctx, p, len);
1101 fio_sha1_final(&sha1_ctx);
1104 static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len)
1106 struct vhdr_crc7 *vh = hdr_priv(hdr);
1108 vh->crc7 = fio_crc7(p, len);
1111 static void fill_crc16(struct verify_header *hdr, void *p, unsigned int len)
1113 struct vhdr_crc16 *vh = hdr_priv(hdr);
1115 vh->crc16 = fio_crc16(p, len);
1118 static void fill_crc32(struct verify_header *hdr, void *p, unsigned int len)
1120 struct vhdr_crc32 *vh = hdr_priv(hdr);
1122 vh->crc32 = fio_crc32(p, len);
1125 static void fill_crc32c(struct verify_header *hdr, void *p, unsigned int len)
1127 struct vhdr_crc32 *vh = hdr_priv(hdr);
1129 vh->crc32 = fio_crc32c(p, len);
1132 static void fill_crc64(struct verify_header *hdr, void *p, unsigned int len)
1134 struct vhdr_crc64 *vh = hdr_priv(hdr);
1136 vh->crc64 = fio_crc64(p, len);
1139 static void fill_md5(struct verify_header *hdr, void *p, unsigned int len)
1141 struct vhdr_md5 *vh = hdr_priv(hdr);
1142 struct fio_md5_ctx md5_ctx = {
1143 .hash = (uint32_t *) vh->md5_digest,
1146 fio_md5_init(&md5_ctx);
1147 fio_md5_update(&md5_ctx, p, len);
1148 fio_md5_final(&md5_ctx);
1151 static void __fill_hdr(struct thread_data *td, struct io_u *io_u,
1152 struct verify_header *hdr, unsigned int header_num,
1153 unsigned int header_len, uint64_t rand_seed)
1157 hdr->magic = FIO_HDR_MAGIC;
1158 hdr->verify_type = td->o.verify;
1159 hdr->len = header_len;
1160 hdr->rand_seed = rand_seed;
1161 hdr->offset = io_u->verify_offset + header_num * td->o.verify_interval;
1162 hdr->time_sec = io_u->start_time.tv_sec;
1163 hdr->time_nsec = io_u->start_time.tv_nsec;
1164 hdr->thread = td->thread_number;
1165 hdr->numberio = io_u->numberio;
1166 hdr->crc32 = fio_crc32c(p, offsetof(struct verify_header, crc32));
1170 static void fill_hdr(struct thread_data *td, struct io_u *io_u,
1171 struct verify_header *hdr, unsigned int header_num,
1172 unsigned int header_len, uint64_t rand_seed)
1174 if (td->o.verify != VERIFY_PATTERN_NO_HDR)
1175 __fill_hdr(td, io_u, hdr, header_num, header_len, rand_seed);
1178 static void populate_hdr(struct thread_data *td, struct io_u *io_u,
1179 struct verify_header *hdr, unsigned int header_num,
1180 unsigned int header_len)
1182 unsigned int data_len;
1188 fill_hdr(td, io_u, hdr, header_num, header_len, io_u->rand_seed);
1190 if (header_len <= hdr_size(td, hdr)) {
1191 td_verror(td, EINVAL, "Blocksize too small");
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 fill_pattern_headers(td, io_u, 0, 0);
1295 int get_next_verify(struct thread_data *td, struct io_u *io_u)
1297 struct io_piece *ipo = NULL;
1300 * this io_u is from a requeue, we already filled the offsets
1305 if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
1306 struct fio_rb_node *n = rb_first(&td->io_hist_tree);
1308 ipo = rb_entry(n, struct io_piece, rb_node);
1311 * Ensure that the associated IO has completed
1313 if (atomic_load_acquire(&ipo->flags) & IP_F_IN_FLIGHT)
1316 rb_erase(n, &td->io_hist_tree);
1317 assert(ipo->flags & IP_F_ONRB);
1318 ipo->flags &= ~IP_F_ONRB;
1319 } else if (!flist_empty(&td->io_hist_list)) {
1320 ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list);
1323 * Ensure that the associated IO has completed
1325 if (atomic_load_acquire(&ipo->flags) & IP_F_IN_FLIGHT)
1328 flist_del(&ipo->list);
1329 assert(ipo->flags & IP_F_ONLIST);
1330 ipo->flags &= ~IP_F_ONLIST;
1336 io_u->offset = ipo->offset;
1337 io_u->verify_offset = ipo->offset;
1338 io_u->buflen = ipo->len;
1339 io_u->numberio = ipo->numberio;
1340 io_u->file = ipo->file;
1341 io_u_set(td, io_u, IO_U_F_VER_LIST);
1343 if (ipo->flags & IP_F_TRIMMED)
1344 io_u_set(td, io_u, IO_U_F_TRIMMED);
1346 if (!fio_file_open(io_u->file)) {
1347 int r = td_io_open_file(td, io_u->file);
1350 dprint(FD_VERIFY, "failed file %s open\n",
1351 io_u->file->file_name);
1356 get_file(ipo->file);
1357 assert(fio_file_open(io_u->file));
1358 io_u->ddir = DDIR_READ;
1359 io_u->xfer_buf = io_u->buf;
1360 io_u->xfer_buflen = io_u->buflen;
1362 remove_trim_entry(td, ipo);
1364 dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u);
1366 if (!td->o.verify_pattern_bytes) {
1367 io_u->rand_seed = __rand(&td->verify_state);
1368 if (sizeof(int) != sizeof(long *))
1369 io_u->rand_seed *= __rand(&td->verify_state);
1375 dprint(FD_VERIFY, "get_next_verify: empty\n");
1379 void fio_verify_init(struct thread_data *td)
1381 if (td->o.verify == VERIFY_CRC32C_INTEL ||
1382 td->o.verify == VERIFY_CRC32C) {
1383 crc32c_arm64_probe();
1384 crc32c_intel_probe();
1388 static void *verify_async_thread(void *data)
1390 struct thread_data *td = data;
1394 if (fio_option_is_set(&td->o, verify_cpumask) &&
1395 fio_setaffinity(td->pid, td->o.verify_cpumask)) {
1396 log_err("fio: failed setting verify thread affinity\n");
1404 if (td->verify_thread_exit)
1407 pthread_mutex_lock(&td->io_u_lock);
1409 while (flist_empty(&td->verify_list) &&
1410 !td->verify_thread_exit) {
1411 ret = pthread_cond_wait(&td->verify_cond,
1418 flist_splice_init(&td->verify_list, &list);
1419 pthread_mutex_unlock(&td->io_u_lock);
1421 if (flist_empty(&list))
1424 while (!flist_empty(&list)) {
1425 io_u = flist_first_entry(&list, struct io_u, verify_list);
1426 flist_del_init(&io_u->verify_list);
1428 io_u_set(td, io_u, IO_U_F_NO_FILE_PUT);
1429 ret = verify_io_u(td, &io_u);
1434 if (td_non_fatal_error(td, ERROR_TYPE_VERIFY_BIT, ret)) {
1435 update_error_count(td, ret);
1443 td_verror(td, ret, "async_verify");
1444 if (td->o.verify_fatal)
1445 fio_mark_td_terminate(td);
1449 pthread_mutex_lock(&td->io_u_lock);
1450 td->nr_verify_threads--;
1451 pthread_cond_signal(&td->free_cond);
1452 pthread_mutex_unlock(&td->io_u_lock);
1457 int verify_async_init(struct thread_data *td)
1460 pthread_attr_t attr;
1462 pthread_attr_init(&attr);
1463 pthread_attr_setstacksize(&attr, 2 * PTHREAD_STACK_MIN);
1465 td->verify_thread_exit = 0;
1467 td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async);
1468 for (i = 0; i < td->o.verify_async; i++) {
1469 ret = pthread_create(&td->verify_threads[i], &attr,
1470 verify_async_thread, td);
1472 log_err("fio: async verify creation failed: %s\n",
1476 ret = pthread_detach(td->verify_threads[i]);
1478 log_err("fio: async verify thread detach failed: %s\n",
1482 td->nr_verify_threads++;
1485 pthread_attr_destroy(&attr);
1487 if (i != td->o.verify_async) {
1488 log_err("fio: only %d verify threads started, exiting\n", i);
1490 pthread_mutex_lock(&td->io_u_lock);
1491 td->verify_thread_exit = 1;
1492 pthread_cond_broadcast(&td->verify_cond);
1493 pthread_mutex_unlock(&td->io_u_lock);
1501 void verify_async_exit(struct thread_data *td)
1503 pthread_mutex_lock(&td->io_u_lock);
1504 td->verify_thread_exit = 1;
1505 pthread_cond_broadcast(&td->verify_cond);
1507 while (td->nr_verify_threads)
1508 pthread_cond_wait(&td->free_cond, &td->io_u_lock);
1510 pthread_mutex_unlock(&td->io_u_lock);
1511 free(td->verify_threads);
1512 td->verify_threads = NULL;
1515 int paste_blockoff(char *buf, unsigned int len, void *priv)
1517 struct io_u *io = priv;
1518 unsigned long long off;
1520 typecheck(__typeof__(off), io->offset);
1521 off = cpu_to_le64((uint64_t)io->offset);
1522 len = min(len, (unsigned int)sizeof(off));
1523 memcpy(buf, &off, len);
1527 static int __fill_file_completions(struct thread_data *td,
1528 struct thread_io_list *s,
1529 struct fio_file *f, unsigned int *index)
1534 if (!f->last_write_comp)
1537 if (td->io_blocks[DDIR_WRITE] < td->o.iodepth)
1538 comps = td->io_blocks[DDIR_WRITE];
1540 comps = td->o.iodepth;
1542 j = f->last_write_idx - 1;
1543 for (i = 0; i < comps; i++) {
1545 j = td->o.iodepth - 1;
1546 s->comps[*index].fileno = __cpu_to_le64(f->fileno);
1547 s->comps[*index].offset = cpu_to_le64(f->last_write_comp[j]);
1555 static int fill_file_completions(struct thread_data *td,
1556 struct thread_io_list *s, unsigned int *index)
1562 for_each_file(td, f, i)
1563 comps += __fill_file_completions(td, s, f, index);
1568 struct all_io_list *get_all_io_list(int save_mask, size_t *sz)
1570 struct all_io_list *rep;
1575 compiletime_assert(sizeof(struct all_io_list) == 8, "all_io_list");
1578 * Calculate reply space needed. We need one 'io_state' per thread,
1579 * and the size will vary depending on depth.
1584 if (save_mask != IO_LIST_ALL && (__td_index + 1) != save_mask)
1587 td->flags |= TD_F_VSTATE_SAVED;
1588 depth += (td->o.iodepth * td->o.nr_files);
1596 *sz += nr * sizeof(struct thread_io_list);
1597 *sz += depth * sizeof(struct file_comp);
1598 rep = calloc(1, *sz);
1600 rep->threads = cpu_to_le64((uint64_t) nr);
1602 next = &rep->state[0];
1604 struct thread_io_list *s = next;
1605 unsigned int comps, index = 0;
1607 if (save_mask != IO_LIST_ALL && (__td_index + 1) != save_mask)
1610 comps = fill_file_completions(td, s, &index);
1612 s->no_comps = cpu_to_le64((uint64_t) comps);
1613 s->depth = cpu_to_le64((uint64_t) td->o.iodepth);
1614 s->nofiles = cpu_to_le64((uint64_t) td->o.nr_files);
1615 s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]);
1616 s->index = cpu_to_le64((uint64_t) __td_index);
1617 if (td->random_state.use64) {
1618 s->rand.state64.s[0] = cpu_to_le64(td->random_state.state64.s1);
1619 s->rand.state64.s[1] = cpu_to_le64(td->random_state.state64.s2);
1620 s->rand.state64.s[2] = cpu_to_le64(td->random_state.state64.s3);
1621 s->rand.state64.s[3] = cpu_to_le64(td->random_state.state64.s4);
1622 s->rand.state64.s[4] = cpu_to_le64(td->random_state.state64.s5);
1623 s->rand.state64.s[5] = 0;
1624 s->rand.use64 = cpu_to_le64((uint64_t)1);
1626 s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1);
1627 s->rand.state32.s[1] = cpu_to_le32(td->random_state.state32.s2);
1628 s->rand.state32.s[2] = cpu_to_le32(td->random_state.state32.s3);
1629 s->rand.state32.s[3] = 0;
1632 snprintf((char *) s->name, sizeof(s->name), "%s", td->o.name);
1633 next = io_list_next(s);
1639 static int open_state_file(const char *name, const char *prefix, int num,
1647 flags = O_CREAT | O_TRUNC | O_WRONLY | O_SYNC;
1651 verify_state_gen_name(out, sizeof(out), name, prefix, num);
1653 fd = open(out, flags, 0644);
1655 perror("fio: open state file");
1656 log_err("fio: state file: %s (for_write=%d)\n", out, for_write);
1663 static int write_thread_list_state(struct thread_io_list *s,
1666 struct verify_state_hdr hdr;
1671 fd = open_state_file((const char *) s->name, prefix, s->index, 1);
1675 crc = fio_crc32c((void *)s, thread_io_list_sz(s));
1677 hdr.version = cpu_to_le64((uint64_t) VSTATE_HDR_VERSION);
1678 hdr.size = cpu_to_le64((uint64_t) thread_io_list_sz(s));
1679 hdr.crc = cpu_to_le64(crc);
1680 ret = write(fd, &hdr, sizeof(hdr));
1681 if (ret != sizeof(hdr))
1684 ret = write(fd, s, thread_io_list_sz(s));
1685 if (ret != thread_io_list_sz(s)) {
1688 perror("fio: write state file");
1689 log_err("fio: failed to write state file\n");
1698 void __verify_save_state(struct all_io_list *state, const char *prefix)
1700 struct thread_io_list *s = &state->state[0];
1703 for (i = 0; i < le64_to_cpu(state->threads); i++) {
1704 write_thread_list_state(s, prefix);
1705 s = io_list_next(s);
1709 void verify_save_state(int mask)
1711 struct all_io_list *state;
1714 state = get_all_io_list(mask, &sz);
1716 char prefix[PATH_MAX];
1719 sprintf(prefix, "%s%clocal", aux_path, FIO_OS_PATH_SEPARATOR);
1721 strcpy(prefix, "local");
1723 __verify_save_state(state, prefix);
1728 void verify_free_state(struct thread_data *td)
1734 void verify_assign_state(struct thread_data *td, void *p)
1736 struct thread_io_list *s = p;
1739 s->no_comps = le64_to_cpu(s->no_comps);
1740 s->depth = le32_to_cpu(s->depth);
1741 s->nofiles = le32_to_cpu(s->nofiles);
1742 s->numberio = le64_to_cpu(s->numberio);
1743 s->rand.use64 = le64_to_cpu(s->rand.use64);
1745 if (s->rand.use64) {
1746 for (i = 0; i < 6; i++)
1747 s->rand.state64.s[i] = le64_to_cpu(s->rand.state64.s[i]);
1749 for (i = 0; i < 4; i++)
1750 s->rand.state32.s[i] = le32_to_cpu(s->rand.state32.s[i]);
1753 for (i = 0; i < s->no_comps; i++) {
1754 s->comps[i].fileno = le64_to_cpu(s->comps[i].fileno);
1755 s->comps[i].offset = le64_to_cpu(s->comps[i].offset);
1761 int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s)
1765 hdr->version = le64_to_cpu(hdr->version);
1766 hdr->size = le64_to_cpu(hdr->size);
1767 hdr->crc = le64_to_cpu(hdr->crc);
1769 if (hdr->version != VSTATE_HDR_VERSION)
1772 crc = fio_crc32c((void *)s, hdr->size);
1773 if (crc != hdr->crc)
1779 int verify_load_state(struct thread_data *td, const char *prefix)
1781 struct verify_state_hdr hdr;
1787 if (!td->o.verify_state)
1790 fd = open_state_file(td->o.name, prefix, td->thread_number - 1, 0);
1794 ret = read(fd, &hdr, sizeof(hdr));
1795 if (ret != sizeof(hdr)) {
1797 td_verror(td, errno, "read verify state hdr");
1798 log_err("fio: failed reading verify state header\n");
1802 hdr.version = le64_to_cpu(hdr.version);
1803 hdr.size = le64_to_cpu(hdr.size);
1804 hdr.crc = le64_to_cpu(hdr.crc);
1806 if (hdr.version != VSTATE_HDR_VERSION) {
1807 log_err("fio: unsupported (%d) version in verify state header\n",
1808 (unsigned int) hdr.version);
1812 s = malloc(hdr.size);
1813 ret = read(fd, s, hdr.size);
1814 if (ret != hdr.size) {
1816 td_verror(td, errno, "read verify state");
1817 log_err("fio: failed reading verity state\n");
1821 crc = fio_crc32c(s, hdr.size);
1822 if (crc != hdr.crc) {
1823 log_err("fio: verify state is corrupt\n");
1829 verify_assign_state(td, s);
1839 * Use the loaded verify state to know when to stop doing verification
1841 int verify_state_should_stop(struct thread_data *td, struct io_u *io_u)
1843 struct thread_io_list *s = td->vstate;
1844 struct fio_file *f = io_u->file;
1851 * If we're not into the window of issues - depth yet, continue. If
1852 * issue is shorter than depth, do check.
1854 if ((td->io_blocks[DDIR_READ] < s->depth ||
1855 s->numberio - td->io_blocks[DDIR_READ] > s->depth) &&
1856 s->numberio > s->depth)
1860 * We're in the window of having to check if this io was
1861 * completed or not. If the IO was seen as completed, then
1864 for (i = 0; i < s->no_comps; i++) {
1865 if (s->comps[i].fileno != f->fileno)
1867 if (io_u->verify_offset == s->comps[i].offset)
1872 * Not found, we have to stop