X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=verify.c;h=b6793d7da76a7f98d68df2847de727ee359cd3dc;hp=f05e85dfb0475c837f5f826adbd0283af63c3d49;hb=85629b7f714d9ec410acd40657abfd909287d441;hpb=e499aedc141da35cf778116d0abcb9cfcd53470c diff --git a/verify.c b/verify.c index f05e85df..b6793d7d 100644 --- a/verify.c +++ b/verify.c @@ -29,62 +29,47 @@ static void populate_hdr(struct thread_data *td, struct io_u *io_u, struct verify_header *hdr, unsigned int header_num, unsigned int header_len); -static void fill_pattern(struct thread_data *td, void *p, unsigned int len, - char *pattern, unsigned int pattern_bytes) +void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len) { - switch (pattern_bytes) { - case 0: - assert(0); - break; - case 1: - dprint(FD_VERIFY, "fill verify pattern b=0 len=%u\n", len); - memset(p, pattern[0], len); - break; - default: { - unsigned int i = 0, size = 0; - unsigned char *b = p; - - dprint(FD_VERIFY, "fill verify pattern b=%d len=%u\n", - pattern_bytes, len); - - while (i < len) { - size = pattern_bytes; - if (size > (len - i)) - size = len - i; - memcpy(b+i, pattern, size); - i += size; - } - break; - } - } + fill_pattern(p, len, td->o.buffer_pattern, td->o.buffer_pattern_bytes); } -void fill_buffer_pattern(struct thread_data *td, void *p, unsigned int len) +void __fill_buffer(struct thread_options *o, unsigned long seed, void *p, + unsigned int len) { - fill_pattern(td, p, len, td->o.buffer_pattern, td->o.buffer_pattern_bytes); + __fill_random_buf_percentage(seed, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes); +} + +unsigned long fill_buffer(struct thread_data *td, void *p, unsigned int len) +{ + struct frand_state *fs = &td->verify_state; + struct thread_options *o = &td->o; + + return fill_random_buf_percentage(fs, p, o->compress_percentage, len, len, o->buffer_pattern, o->buffer_pattern_bytes); } void fill_verify_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u *io_u, unsigned long seed, int use_seed) { - if (!td->o.verify_pattern_bytes) { + struct thread_options *o = &td->o; + + if (!o->verify_pattern_bytes) { dprint(FD_VERIFY, "fill random bytes len=%u\n", len); if (use_seed) - __fill_random_buf(p, len, seed); + __fill_buffer(o, seed, p, len); else - io_u->rand_seed = fill_random_buf(&td->verify_state, p, len); + io_u->rand_seed = fill_buffer(td, 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); + o->verify_pattern_bytes, len); return; } - fill_pattern(td, p, len, td->o.verify_pattern, td->o.verify_pattern_bytes); - + fill_pattern(p, len, o->verify_pattern, o->verify_pattern_bytes); io_u->buf_filled_len = len; } @@ -487,6 +472,7 @@ static int verify_io_u_sha256(struct verify_header *hdr, struct vcont *vc) fio_sha256_init(&sha256_ctx); fio_sha256_update(&sha256_ctx, p, hdr->len - hdr_size(hdr)); + fio_sha256_final(&sha256_ctx); if (!memcmp(vh->sha256, sha256_ctx.buf, sizeof(sha256))) return 0; @@ -512,6 +498,7 @@ static int verify_io_u_sha1(struct verify_header *hdr, struct vcont *vc) fio_sha1_init(&sha1_ctx); fio_sha1_update(&sha1_ctx, p, hdr->len - hdr_size(hdr)); + fio_sha1_final(&sha1_ctx); if (!memcmp(vh->sha1, sha1_ctx.H, sizeof(sha1))) return 0; @@ -642,6 +629,7 @@ static int verify_io_u_md5(struct verify_header *hdr, struct vcont *vc) fio_md5_init(&md5_ctx); fio_md5_update(&md5_ctx, p, hdr->len - hdr_size(hdr)); + fio_md5_final(&md5_ctx); if (!memcmp(vh->md5_digest, md5_ctx.hash, sizeof(hash))) return 0; @@ -908,6 +896,7 @@ static void fill_sha256(struct verify_header *hdr, void *p, unsigned int len) fio_sha256_init(&sha256_ctx); fio_sha256_update(&sha256_ctx, p, len); + fio_sha256_final(&sha256_ctx); } static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len) @@ -919,6 +908,7 @@ static void fill_sha1(struct verify_header *hdr, void *p, unsigned int len) fio_sha1_init(&sha1_ctx); fio_sha1_update(&sha1_ctx, p, len); + fio_sha1_final(&sha1_ctx); } static void fill_crc7(struct verify_header *hdr, void *p, unsigned int len) @@ -965,6 +955,7 @@ static void fill_md5(struct verify_header *hdr, void *p, unsigned int len) fio_md5_init(&md5_ctx); fio_md5_update(&md5_ctx, p, len); + fio_md5_final(&md5_ctx); } static void populate_hdr(struct thread_data *td, struct io_u *io_u, @@ -1166,7 +1157,7 @@ static void *verify_async_thread(void *data) struct io_u *io_u; int ret = 0; - if (td->o.verify_cpumask_set && + if (fio_option_is_set(&td->o, verify_cpumask) && fio_setaffinity(td->pid, td->o.verify_cpumask)) { log_err("fio: failed setting verify thread affinity\n"); goto done; @@ -1356,7 +1347,8 @@ struct all_io_list *get_all_io_list(int save_mask, size_t *sz) s->rand.s[1] = cpu_to_le32(td->random_state.s2); s->rand.s[2] = cpu_to_le32(td->random_state.s3); s->rand.s[3] = 0; - strncpy((char *) s->name, td->o.name, sizeof(s->name)); + s->name[sizeof(s->name) - 1] = '\0'; + strncpy((char *) s->name, td->o.name, sizeof(s->name) - 1); next = io_list_next(s); } @@ -1554,10 +1546,12 @@ int verify_state_should_stop(struct thread_data *td, struct io_u *io_u) return 0; /* - * If we're not into the window of issues - depth yet, continue + * If we're not into the window of issues - depth yet, continue. If + * issue is shorter than depth, do check. */ - if (td->io_blocks[DDIR_READ] < s->depth || - s->numberio - td->io_blocks[DDIR_READ] > s->depth) + if ((td->io_blocks[DDIR_READ] < s->depth || + s->numberio - td->io_blocks[DDIR_READ] > s->depth) && + s->numberio > s->depth) return 0; /*