Add support for 'bssplit' option, fine grained block size contrl
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 1a68ad1171c2a175950f6ac20ac5bcdf1f1803c9..7890a87099c26f7d5802f9a0479e8ddc6d768bad 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -186,7 +186,21 @@ static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
                buflen = td->o.min_bs[ddir];
        else {
                r = os_random_long(&td->bsrange_state);
-               buflen = (unsigned int) (1 + (double) (td->o.max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
+               if (!td->o.bssplit_nr)
+                       buflen = (unsigned int) (1 + (double) (td->o.max_bs[ddir] - 1) * r / (RAND_MAX + 1.0));
+               else {
+                       long perc = 0;
+                       unsigned int i;
+
+                       for (i = 0; i < td->o.bssplit_nr; i++) {
+                               struct bssplit *bsp = &td->o.bssplit[i];
+
+                               buflen = bsp->bs;
+                               perc += bsp->perc;
+                               if (r <= ((LONG_MAX / 100L) * perc))
+                                       break;
+                       }
+               }
                if (!td->o.bs_unaligned)
                        buflen = (buflen + td->o.min_bs[ddir] - 1) & ~(td->o.min_bs[ddir] - 1);
        }
@@ -313,6 +327,9 @@ void requeue_io_u(struct thread_data *td, struct io_u **io_u)
 
 static int fill_io_u(struct thread_data *td, struct io_u *io_u)
 {
+       if (td->io_ops->flags & FIO_NOIO)
+               goto out;
+
        /*
         * see if it's time to sync
         */
@@ -760,6 +777,7 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
                io_u_mark_latency(td, usec);
 
                if (td_write(td) && idx == DDIR_WRITE &&
+                   td->o.do_verify &&
                    td->o.verify != VERIFY_NONE)
                        log_io_piece(td, io_u);
 
@@ -770,8 +788,6 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
                        if (ret && !icd->error)
                                icd->error = ret;
                }
-               if (io_u->unmap)
-                       io_u->unmap(td, io_u);
        } else {
                icd->error = io_u->error;
                io_u_log_error(td, io_u);