Fix sum_stat() bug in group_reporting
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 6a53bdaab074fcf9660c6e25e08c19408bd0dca2..a87c58e32791e35cfbb770c705a2c34c9b41ee17 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -249,8 +249,12 @@ static int get_next_seq_block(struct thread_data *td, struct fio_file *f,
        assert(ddir_rw(ddir));
 
        if (f->last_pos < f->real_file_size) {
-               unsigned long long pos = f->last_pos - f->file_offset;
+               unsigned long long pos;
 
+               if (f->last_pos == f->file_offset && td->o.ddir_seq_add < 0)
+                       f->last_pos = f->real_file_size;
+
+               pos = f->last_pos - f->file_offset;
                if (pos)
                        pos += td->o.ddir_seq_add;
 
@@ -486,6 +490,16 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir)
        } else
                usec = td->rate_pending_usleep[ddir];
 
+       /*
+        * We are going to sleep, ensure that we flush anything pending as
+        * not to skew our latency numbers
+        */
+       if (td->cur_depth) {
+               int fio_unused ret;
+
+               ret = io_u_queued_complete(td, td->cur_depth, NULL);
+       }
+
        fio_gettime(&t, NULL);
        usec_sleep(td, usec);
        usec = utime_since_now(&t);
@@ -1436,7 +1450,7 @@ void io_u_fill_buffer(struct thread_data *td, struct io_u *io_u,
        io_u->buf_filled_len = 0;
 
        if (!td->o.zero_buffers)
-               fill_random_buf(io_u->buf, max_bs);
+               fill_random_buf(&td->buf_state, io_u->buf, max_bs);
        else
                memset(io_u->buf, 0, max_bs);
 }