io_u: we don't need to set power_2 to false
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index f1a3916f5096ea7cc07be1c488b42f32307fc83d..5f01c1b674ebecd8612c9681411dc9773dd5a493 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -62,6 +62,7 @@ static uint64_t last_block(struct thread_data *td, struct fio_file *f,
 
        /*
         * Hmm, should we make sure that ->io_size <= ->real_file_size?
+        * -> not for now since there is code assuming it could go either.
         */
        max_size = f->io_size;
        if (max_size > f->real_file_size)
@@ -532,6 +533,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
        unsigned int buflen = 0;
        unsigned int minbs, maxbs;
        uint64_t frand_max, r;
+       bool power_2;
 
        assert(ddir_rw(ddir));
 
@@ -576,9 +578,11 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u,
                        }
                }
 
-               if (!td->o.bs_unaligned && is_power_of_2(minbs))
+               power_2 = is_power_of_2(minbs);
+               if (!td->o.bs_unaligned && power_2)
                        buflen &= ~(minbs - 1);
-
+               else if (!td->o.bs_unaligned && !power_2) 
+                       buflen -= buflen % minbs; 
        } while (!io_u_fits(td, io_u, buflen));
 
        return buflen;
@@ -642,7 +646,7 @@ int io_u_quiesce(struct thread_data *td)
        }
 
        while (td->io_u_in_flight) {
-               int fio_unused ret;
+               int ret;
 
                ret = io_u_queued_complete(td, 1);
                if (ret > 0)
@@ -758,8 +762,10 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td)
                ddir = DDIR_READ;
        else if (td_write(td))
                ddir = DDIR_WRITE;
-       else
+       else if (td_trim(td))
                ddir = DDIR_TRIM;
+       else
+               ddir = DDIR_INVAL;
 
        td->rwmix_ddir = rate_ddir(td, ddir);
        return td->rwmix_ddir;
@@ -1731,6 +1737,9 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
        if (td->parent)
                td = td->parent;
 
+       if (!td->o.stats)
+               return;
+
        if (no_reduce)
                lusec = utime_since(&io_u->issue_time, &icd->time);
 
@@ -1957,7 +1966,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts)
        int ret, ddir;
        struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, };
 
-       dprint(FD_IO, "io_u_queued_completed: min=%d\n", min_evts);
+       dprint(FD_IO, "io_u_queued_complete: min=%d\n", min_evts);
 
        if (!min_evts)
                tvp = &ts;
@@ -1991,7 +2000,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts)
  */
 void io_u_queued(struct thread_data *td, struct io_u *io_u)
 {
-       if (!td->o.disable_slat) {
+       if (!td->o.disable_slat && ramp_time_over(td) && td->o.stats) {
                unsigned long slat_time;
 
                slat_time = utime_since(&io_u->start_time, &io_u->issue_time);