Jobs must always open their own files

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