First step at speeding up io_u rand refill
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index a4bf0c08581861076ccd31a8f720dcd861fbfe01..4d3116b7fd4fc0901f4419e8690270c2c18a2d43 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -8,6 +8,7 @@
 #include "fio.h"
 #include "hash.h"
 #include "verify.h"
+#include "lib/rand.h"
 
 struct io_completion_data {
        int nr;                         /* input */
@@ -888,14 +889,6 @@ again:
                io_u->end_io = NULL;
        }
 
-       /*
-        * We ran out, wait for async verify threads to finish and return one
-        */
-       if (!io_u && td->o.verify_async) {
-               pthread_cond_wait(&td->free_cond, &td->io_u_lock);
-               goto again;
-       }
-
        if (io_u) {
                assert(io_u->flags & IO_U_F_FREE);
                io_u->flags &= ~(IO_U_F_FREE | IO_U_F_FREE_DEF);
@@ -905,6 +898,13 @@ again:
                flist_add(&io_u->list, &td->io_u_busylist);
                td->cur_depth++;
                io_u->flags |= IO_U_F_IN_CUR_DEPTH;
+       } else if (td->o.verify_async) {
+               /*
+                * We ran out, wait for async verify threads to finish and
+                * return one
+                */
+               pthread_cond_wait(&td->free_cond, &td->io_u_lock);
+               goto again;
        }
 
        td_io_u_unlock(td);
@@ -1218,7 +1218,7 @@ void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
 
        if (!td->o.zero_buffers) {
                while ((void *) ptr - io_u->buf < max_bs) {
-                       *ptr = rand() * GOLDEN_RATIO_PRIME;
+                       *ptr = __rand(&__fio_rand_state);
                        ptr++;
                }
        } else