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;
}
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;
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;
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;
if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
td->cur_depth--;
- io_u->flags &= ~IO_U_F_IN_CUR_DEPTH;
+ io_u_clear(io_u, IO_U_F_IN_CUR_DEPTH);
}
flist_add_tail(&io_u->verify_list, &td->verify_list);
*io_u_ptr = NULL;
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)
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)
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,
io_u->buflen = ipo->len;
io_u->numberio = ipo->numberio;
io_u->file = ipo->file;
- io_u->flags |= IO_U_F_VER_LIST;
+ io_u_set(io_u, IO_U_F_VER_LIST);
if (ipo->flags & IP_F_TRIMMED)
- io_u->flags |= IO_U_F_TRIMMED;
+ io_u_set(io_u, IO_U_F_TRIMMED);
if (!fio_file_open(io_u->file)) {
int r = td_io_open_file(td, io_u->file);
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;
io_u = flist_first_entry(&list, struct io_u, verify_list);
flist_del_init(&io_u->verify_list);
- io_u->flags |= IO_U_F_NO_FILE_PUT;
+ io_u_set(io_u, IO_U_F_NO_FILE_PUT);
ret = verify_io_u(td, &io_u);
put_io_u(td, io_u);
s->depth = cpu_to_le64((uint64_t) td->o.iodepth);
s->numberio = cpu_to_le64((uint64_t) td->io_issues[DDIR_WRITE]);
s->index = cpu_to_le64((uint64_t) i);
- s->rand.s[0] = cpu_to_le32(td->random_state.s1);
- 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));
+ if (td->random_state.use64) {
+ s->rand.state64.s[0] = cpu_to_le64(td->random_state.state64.s1);
+ s->rand.state64.s[1] = cpu_to_le64(td->random_state.state64.s2);
+ s->rand.state64.s[2] = cpu_to_le64(td->random_state.state64.s3);
+ s->rand.state64.s[3] = cpu_to_le64(td->random_state.state64.s4);
+ s->rand.state64.s[4] = cpu_to_le64(td->random_state.state64.s5);
+ s->rand.state64.s[5] = 0;
+ s->rand.use64 = cpu_to_le64((uint64_t)1);
+ } else {
+ s->rand.state32.s[0] = cpu_to_le32(td->random_state.state32.s1);
+ s->rand.state32.s[1] = cpu_to_le32(td->random_state.state32.s2);
+ s->rand.state32.s[2] = cpu_to_le32(td->random_state.state32.s3);
+ s->rand.state32.s[3] = 0;
+ s->rand.use64 = 0;
+ }
+ s->name[sizeof(s->name) - 1] = '\0';
+ strncpy((char *) s->name, td->o.name, sizeof(s->name) - 1);
next = io_list_next(s);
}
free(td->vstate);
}
-void verify_convert_assign_state(struct thread_data *td,
- struct thread_io_list *s)
+static struct thread_io_list *convert_v1_list(struct thread_io_list_v1 *s)
{
+ struct thread_io_list *til;
int i;
- s->no_comps = le64_to_cpu(s->no_comps);
- s->depth = le64_to_cpu(s->depth);
- s->numberio = le64_to_cpu(s->numberio);
+ til = malloc(__thread_io_list_sz(s->no_comps));
+ til->no_comps = s->no_comps;
+ til->depth = s->depth;
+ til->numberio = s->numberio;
+ til->index = s->index;
+ memcpy(til->name, s->name, sizeof(til->name));
+
+ til->rand.use64 = 0;
for (i = 0; i < 4; i++)
- s->rand.s[i] = le32_to_cpu(s->rand.s[i]);
+ til->rand.state32.s[i] = s->rand.s[i];
+
for (i = 0; i < s->no_comps; i++)
- s->offsets[i] = le64_to_cpu(s->offsets[i]);
+ til->offsets[i] = s->offsets[i];
+
+ return til;
+}
+
+void verify_convert_assign_state(struct thread_data *td, void *p, int version)
+{
+ struct thread_io_list *til;
+ int i;
+
+ if (version == 1) {
+ struct thread_io_list_v1 *s = p;
+
+ s->no_comps = le64_to_cpu(s->no_comps);
+ s->depth = le64_to_cpu(s->depth);
+ s->numberio = le64_to_cpu(s->numberio);
+ for (i = 0; i < 4; i++)
+ s->rand.s[i] = le32_to_cpu(s->rand.s[i]);
+ for (i = 0; i < s->no_comps; i++)
+ s->offsets[i] = le64_to_cpu(s->offsets[i]);
+
+ til = convert_v1_list(s);
+ free(s);
+ } else {
+ struct thread_io_list *s = p;
+
+ s->no_comps = le64_to_cpu(s->no_comps);
+ s->depth = le64_to_cpu(s->depth);
+ s->numberio = le64_to_cpu(s->numberio);
+ s->rand.use64 = le64_to_cpu(s->rand.use64);
+
+ if (s->rand.use64) {
+ for (i = 0; i < 6; i++)
+ s->rand.state64.s[i] = le64_to_cpu(s->rand.state64.s[i]);
+ } else {
+ for (i = 0; i < 4; i++)
+ s->rand.state32.s[i] = le32_to_cpu(s->rand.state32.s[i]);
+ }
+ for (i = 0; i < s->no_comps; i++)
+ s->offsets[i] = le64_to_cpu(s->offsets[i]);
+
+ til = p;
+ }
- td->vstate = s;
+ td->vstate = til;
}
-int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s)
+int verify_state_hdr(struct verify_state_hdr *hdr, struct thread_io_list *s,
+ int *version)
{
uint64_t crc;
hdr->size = le64_to_cpu(hdr->size);
hdr->crc = le64_to_cpu(hdr->crc);
- if (hdr->version != VSTATE_HDR_VERSION)
+ if (hdr->version != VSTATE_HDR_VERSION ||
+ hdr->version != VSTATE_HDR_VERSION_V1)
return 1;
crc = fio_crc32c((void *)s, hdr->size);
if (crc != hdr->crc)
return 1;
+ *version = hdr->version;
return 0;
}
int verify_load_state(struct thread_data *td, const char *prefix)
{
- struct thread_io_list *s = NULL;
struct verify_state_hdr hdr;
+ void *s = NULL;
uint64_t crc;
ssize_t ret;
int fd;
hdr.size = le64_to_cpu(hdr.size);
hdr.crc = le64_to_cpu(hdr.crc);
- if (hdr.version != VSTATE_HDR_VERSION) {
+ if (hdr.version != VSTATE_HDR_VERSION &&
+ hdr.version != VSTATE_HDR_VERSION_V1) {
log_err("fio: bad version in verify state header\n");
goto err;
}
goto err;
}
- crc = fio_crc32c((void *)s, hdr.size);
+ crc = fio_crc32c(s, hdr.size);
if (crc != hdr.crc) {
log_err("fio: verify state is corrupt\n");
goto err;
close(fd);
- verify_convert_assign_state(td, s);
+ verify_convert_assign_state(td, s, hdr.version);
return 0;
err:
if (s)
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;
/*