X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=verify.c;h=93731228f1b68661e0edd3293bc491ccb650774d;hp=371b650a50a327f383672fb41bb332adaa3e7bde;hb=002fe73409d1e;hpb=621677626f2551bedfdc4a5fc3b3e5f8492b94fa diff --git a/verify.c b/verify.c index 371b650a..93731228 100644 --- a/verify.c +++ b/verify.c @@ -72,10 +72,10 @@ void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, if (use_seed) __fill_random_buf(p, len, seed); else - io_u->rand_seed = fill_random_buf(&td->buf_state, p, len); + io_u->rand_seed = fill_random_buf(&td->__verify_state, p, len); return; } - + if (io_u->buf_filled_len >= len) { dprint(FD_VERIFY, "using already filled verify pattern b=%d len=%u\n", td->o.verify_pattern_bytes, len); @@ -671,18 +671,17 @@ static int verify_header(struct io_u *io_u, struct verify_header *hdr) uint32_t crc; if (hdr->magic != FIO_HDR_MAGIC) - return 0; - if (hdr->len > io_u->buflen) { - log_err("fio: verify header exceeds buffer length (%u > %lu)\n", hdr->len, io_u->buflen); - return 0; - } + return 1; + if (hdr->len > io_u->buflen) + return 2; + if (hdr->rand_seed != io_u->rand_seed) + return 3; crc = fio_crc32c(p, offsetof(struct verify_header, crc32)); if (crc == hdr->crc32) - return 1; - + return 0; log_err("fio: verify header crc %x, calculated %x\n", hdr->crc32, crc); - return 0; + return 4; } int verify_io_u(struct thread_data *td, struct io_u *io_u) @@ -719,13 +718,48 @@ int verify_io_u(struct thread_data *td, struct io_u *io_u) memswp(p, p + td->o.verify_offset, header_size); hdr = p; - if (!verify_header(io_u, hdr)) { + /* + * Make rand_seed check pass when have verifysort or + * verify_backlog. + */ + if (td->o.verifysort || (td->flags & TD_F_VER_BACKLOG)) + io_u->rand_seed = hdr->rand_seed; + + ret = verify_header(io_u, hdr); + switch (ret) { + case 0: + break; + case 1: log_err("verify: bad magic header %x, wanted %x at " "file %s offset %llu, length %u\n", hdr->magic, FIO_HDR_MAGIC, io_u->file->file_name, io_u->offset + hdr_num * hdr->len, hdr->len); return EILSEQ; + break; + case 2: + log_err("fio: verify header exceeds buffer length (%u " + "> %lu)\n", hdr->len, io_u->buflen); + return EILSEQ; + break; + case 3: + log_err("verify: bad header rand_seed %"PRIu64 + ", wanted %"PRIu64" at file %s offset %llu, " + "length %u\n", + hdr->rand_seed, io_u->rand_seed, + io_u->file->file_name, + io_u->offset + hdr_num * hdr->len, hdr->len); + return EILSEQ; + break; + case 4: + return EILSEQ; + break; + default: + log_err("verify: unknown header error at file %s " + "offset %llu, length %u\n", + io_u->file->file_name, + io_u->offset + hdr_num * hdr->len, hdr->len); + return EILSEQ; } if (td->o.verify != VERIFY_NONE) @@ -988,11 +1022,27 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u) struct rb_node *n = rb_first(&td->io_hist_tree); ipo = rb_entry(n, struct io_piece, rb_node); + + /* + * Ensure that the associated IO has completed + */ + read_barrier(); + if (ipo->flags & IP_F_IN_FLIGHT) + goto nothing; + rb_erase(n, &td->io_hist_tree); assert(ipo->flags & IP_F_ONRB); ipo->flags &= ~IP_F_ONRB; } else if (!flist_empty(&td->io_hist_list)) { ipo = flist_entry(td->io_hist_list.next, struct io_piece, list); + + /* + * Ensure that the associated IO has completed + */ + read_barrier(); + if (ipo->flags & IP_F_IN_FLIGHT) + goto nothing; + flist_del(&ipo->list); assert(ipo->flags & IP_F_ONLIST); ipo->flags &= ~IP_F_ONLIST; @@ -1029,9 +1079,16 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u) remove_trim_entry(td, ipo); free(ipo); dprint(FD_VERIFY, "get_next_verify: ret io_u %p\n", io_u); + + if (!td->o.verify_pattern_bytes) { + io_u->rand_seed = __rand(&td->__verify_state); + if (sizeof(int) != sizeof(long *)) + io_u->rand_seed *= __rand(&td->__verify_state); + } return 0; } +nothing: dprint(FD_VERIFY, "get_next_verify: empty\n"); return 1; }