Jobs must always open their own files
authorJens Axboe <jens.axboe@oracle.com>
Sat, 1 Mar 2008 17:50:48 +0000 (18:50 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Sat, 1 Mar 2008 17:50:48 +0000 (18:50 +0100)
This is also related to file sharing - we cannot dup() a descriptor,
if the child hasn't inherited it. So make sure the jobs always open
the files again, even after they have been created.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c

diff --git a/fio.c b/fio.c
index c2bc1a6..1046c03 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1153,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);
        }