[PATCH] Fix random_map
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 738f3e20101eee5e3535f1ff52fd344286c45745..3000ea7a96c1c93f11969836b35718d9375c4c7d 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -91,6 +91,8 @@ static int get_next_offset(struct thread_data *td, struct fio_file *f,
                do {
                        r = os_random_long(&td->random_state);
                        b = ((max_blocks - 1) * r / (unsigned long long) (RAND_MAX+1.0));
+                       if (td->norandommap)
+                               break;
                        rb = b + (f->file_offset / td->min_bs);
                        loops--;
                } while (!random_map_free(td, f, rb) && loops);
@@ -119,7 +121,8 @@ static unsigned int get_next_buflen(struct thread_data *td)
        else {
                r = os_random_long(&td->bsrange_state);
                buflen = (1 + (double) (td->max_bs - 1) * r / (RAND_MAX + 1.0));
-               buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
+               if (!td->bs_unaligned)
+                       buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
        }
 
        if (buflen > td->io_size - td->this_io_bytes[td->ddir]) {
@@ -211,7 +214,7 @@ static int fill_io_u(struct thread_data *td, struct fio_file *f,
                        /*
                         * If using a write iolog, store this entry.
                         */
-                       if (td->write_iolog)
+                       if (td->write_iolog_file)
                                write_iolog_put(td, io_u);
 
                        io_u->file = f;
@@ -229,6 +232,7 @@ struct io_u *__get_io_u(struct thread_data *td)
        if (!queue_full(td)) {
                io_u = list_entry(td->io_u_freelist.next, struct io_u, list);
 
+               io_u->buflen = 0;
                io_u->error = 0;
                io_u->resid = 0;
                list_del(&io_u->list);
@@ -276,7 +280,7 @@ struct io_u *get_io_u(struct thread_data *td, struct fio_file *f)
                        return NULL;
                }
 
-               if (!td->read_iolog && !td->sequential)
+               if (!td->read_iolog && !td->sequential && !td->norandommap)
                        mark_random_map(td, f, io_u);
 
                f->last_pos += io_u->buflen;