Switch the latter part of the offset generation to __rand() too
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 5a3ca7444946751f4e208a32affdad5fb98051b9..c672993414b480d33e5e4224ab84e727249e81e6 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -168,9 +168,16 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
                goto ffz;
 
        do {
-               r = os_random_long(&td->random_state);
+               if (td->o.use_os_rand) {
+                       r = os_random_long(&td->random_state);
+                       *b = (lastb - 1) * (r / ((unsigned long long) OS_RAND_MAX + 1.0));
+               } else {
+                       r = __rand(&td->__random_state);
+                       *b = (lastb - 1) * (r / ((unsigned long long) FRAND_MAX + 1.0));
+               }
+
                dprint(FD_RANDOM, "off rand %llu\n", r);
-               *b = (lastb - 1) * (r / ((unsigned long long) OS_RAND_MAX + 1.0));
+
 
                /*
                 * if we are not maintaining a random map, we are done.
@@ -203,7 +210,10 @@ static int get_next_rand_offset(struct thread_data *td, struct fio_file *f,
                if (!get_next_free_block(td, f, ddir, b))
                        goto ret;
 
-               r = os_random_long(&td->random_state);
+               if (td->o.use_os_rand)
+                       r = os_random_long(&td->random_state);
+               else
+                       r = __rand(&td->__random_state);
        } while (--loops);
 
        /*