[PATCH] Random map fix
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index da6fe8f3af0a55f2f0a26680f257b78f6996d0de..31f75cd6794ed09ecc5a2b2e193ce5f2714f2cf4 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -27,13 +27,13 @@ static int random_map_free(struct thread_data *td, struct fio_file *f,
 static void mark_random_map(struct thread_data *td, struct fio_file *f,
                            struct io_u *io_u)
 {
-       unsigned int min_bs = td->min_bs[io_u->ddir];
+       unsigned int min_bs = td->rw_min_bs;
        unsigned long long block;
        unsigned int blocks;
 
        block = io_u->offset / (unsigned long long) min_bs;
        blocks = 0;
-       while (blocks < (io_u->buflen / min_bs)) {
+       while (blocks < ((io_u->buflen + min_bs - 1) / min_bs)) {
                unsigned int idx, bit;
 
                if (!random_map_free(td, f, block))
@@ -322,8 +322,12 @@ struct io_u *get_io_u(struct thread_data *td, struct fio_file *f)
                return NULL;
        }
 
+       /*
+        * Set io data pointers.
+        */
        io_u->xfer_buf = io_u->buf;
        io_u->xfer_buflen = io_u->buflen;
+
        fio_gettime(&io_u->start_time, NULL);
        return io_u;
 }
@@ -381,5 +385,3 @@ void ios_completed(struct thread_data *td, struct io_completion_data *icd)
                put_io_u(td, io_u);
        }
 }
-
-