Fix segfault with verify_async
[fio.git] / verify.c
index 3eac9cab4ebaa975c7e20f4e57aade6bbc1738f9..5a9428177eef68b58f9fc9d4e6cfa6596d756688 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -36,7 +36,7 @@ void fill_pattern(struct thread_data *td, void *p, unsigned int len, struct io_u
                if (use_seed)
                        __fill_random_buf(p, len, seed);
                else
-                       io_u->rand_seed = fill_random_buf(p, len);
+                       io_u->rand_seed = fill_random_buf(&td->buf_state, p, len);
                break;
        case 1:
                /*
@@ -269,6 +269,9 @@ static void dump_verify_buffers(struct verify_header *hdr, struct vcont *vc)
        struct io_u dummy;
        void *buf;
 
+       if (!td->o.verify_dump)
+               return;
+
        /*
         * Dump the contents we just read off disk
         */
@@ -333,13 +336,13 @@ static int verify_io_u_pattern(struct verify_header *hdr, struct vcont *vc)
        struct thread_data *td = vc->td;
        struct io_u *io_u = vc->io_u;
        char *buf, *pattern;
-       unsigned int hdr_size = __hdr_size(td->o.verify);
+       unsigned int header_size = __hdr_size(td->o.verify);
        unsigned int len, mod, i;
 
        pattern = td->o.verify_pattern;
-       buf = (void *) hdr + hdr_size;
-       len = get_hdr_inc(td, io_u) - hdr_size;
-       mod = hdr_size % td->o.verify_pattern_bytes;
+       buf = (void *) hdr + header_size;
+       len = get_hdr_inc(td, io_u) - header_size;
+       mod = header_size % td->o.verify_pattern_bytes;
 
        for (i = 0; i < len; i++) {
                if (buf[i] != pattern[mod]) {
@@ -599,10 +602,8 @@ int verify_io_u_async(struct thread_data *td, struct io_u *io_u)
        if (io_u->file)
                put_file_log(td, io_u->file);
 
-       io_u->file = NULL;
-
        pthread_mutex_lock(&td->io_u_lock);
-       
+
        if (io_u->flags & IO_U_F_IN_CUR_DEPTH) {
                td->cur_depth--;
                io_u->flags &= ~IO_U_F_IN_CUR_DEPTH;
@@ -653,7 +654,7 @@ static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
 int verify_io_u(struct thread_data *td, struct io_u *io_u)
 {
        struct verify_header *hdr;
-       unsigned int hdr_size, hdr_inc, hdr_num = 0;
+       unsigned int header_size, hdr_inc, hdr_num = 0;
        void *p;
        int ret;
 
@@ -678,9 +679,9 @@ int verify_io_u(struct thread_data *td, struct io_u *io_u)
                if (ret && td->o.verify_fatal)
                        break;
 
-               hdr_size = __hdr_size(td->o.verify);
+               header_size = __hdr_size(td->o.verify);
                if (td->o.verify_offset)
-                       memswp(p, p + td->o.verify_offset, hdr_size);
+                       memswp(p, p + td->o.verify_offset, header_size);
                hdr = p;
 
                if (hdr->fio_magic != FIO_HDR_MAGIC) {