Jobs must always open their own files
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index d345064d392111e50accdb70db9fe2d43f45ab09..1046c03630a7d106241ae33505a3faf634f1b1fd 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -359,7 +359,6 @@ static void do_verify(struct thread_data *td)
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
                                io_u->offset += bytes;
-                               f->last_completed_pos = io_u->offset;
 
                                td->ts.short_io_u[io_u->ddir]++;
 
@@ -485,7 +484,6 @@ static void do_io(struct thread_data *td)
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
                                io_u->offset += bytes;
-                               f->last_completed_pos = io_u->offset;
 
                                td->ts.short_io_u[io_u->ddir]++;
 
@@ -787,8 +785,7 @@ static int clear_io_state(struct thread_data *td)
        if (td->o.time_based || td->o.loops)
                td->nr_done_files = 0;
 
-       for_each_file(td, f, i)
-               td_io_close_file(td, f);
+       close_files(td);
 
        ret = 0;
        for_each_file(td, f, i) {
@@ -966,7 +963,7 @@ static void *thread_main(void *data)
 err:
        if (td->error)
                printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
-       close_files(td);
+       close_and_free_files(td);
        close_ioengine(td);
        cleanup_io_u(td);
 
@@ -1156,7 +1153,18 @@ static void run_threads(void)
                                log_err("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
                        td_set_runstate(td, TD_REAPED);
                        todo--;
-               }
+               } else {
+                       struct fio_file *f;
+                       unsigned int i;
+
+                       /*
+                        * for sharing to work, each job must always open
+                        * its own files. so close them, if we opened them
+                        * for creation
+                        */
+                       for_each_file(td, f, i)
+                               td_io_close_file(td, f);
+               }
 
                init_disk_util(td);
        }