Merge branch 'master' of https://github.com/celestinechen/fio
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 09e5f15a8b1ffe785adcd546da1e8232c9f47399..a499ff076b188c5cf6530892a4c1c7e1ce73d43b 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -360,6 +360,17 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
                loop_cache_invalidate(td, f);
        }
 
+       /*
+        * If we reach the end for a rw-io-size based run, reset us back to 0
+        * and invalidate the cache, if we need to.
+        */
+       if (td_rw(td) && o->io_size > o->size) {
+               if (f->last_pos[ddir] >= f->io_size + get_start_offset(td, f)) {
+                       f->last_pos[ddir] = f->file_offset;
+                       loop_cache_invalidate(td, f);
+               }
+        }
+
        if (f->last_pos[ddir] < f->real_file_size) {
                uint64_t pos;
 
@@ -2102,7 +2113,6 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr,
        if (ddir_sync(ddir)) {
                if (io_u->error)
                        goto error;
-               td->last_was_sync = true;
                if (f) {
                        f->first_write = -1ULL;
                        f->last_write = -1ULL;
@@ -2112,7 +2122,6 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr,
                return;
        }
 
-       td->last_was_sync = false;
        td->last_ddir = ddir;
 
        if (!io_u->error && ddir_rw(ddir)) {