Avoid opening files until they are used

Fio still opens and creates all files, just to check the size of them. Add
a specialized IO engine op for getting the size of a file and use that
instead.

This also cleans a lot of things up. Note that the IO engine version is now
bumped to 10, meaning that external engines will have to separate the
file open from the size checking.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.c b/fio.c
index b4415fa..f699951 100644
--- a/fio.c
+++ b/fio.c
@@ -897,25 +897,16 @@
 	memcpy(&td->start, &tv, sizeof(tv));
 }
 
-static int clear_io_state(struct thread_data *td)
+static void clear_io_state(struct thread_data *td)
 {
 	struct fio_file *f;
 	unsigned int i;
-	int ret;
 
 	reset_io_counters(td);
 
 	close_files(td);
-
-	ret = 0;
-	for_each_file(td, f, i) {
+	for_each_file(td, f, i)
 		f->flags &= ~FIO_FILE_DONE;
-		ret = td_io_open_file(td, f);
-		if (ret)
-			break;
-	}
-
-	return ret;
 }
 
 /*
@@ -1003,9 +994,6 @@
 	if (td_io_init(td))
 		goto err;
 
-	if (open_files(td))
-		goto err;
-
 	if (init_random_map(td))
 		goto err;
 
@@ -1028,8 +1016,8 @@
 			memcpy(&td->lastrate, &td->ts.stat_sample_time,
 							sizeof(td->lastrate));
 
-		if (clear_state && clear_io_state(td))
-			break;
+		if (clear_state)
+			clear_io_state(td);
 
 		prune_io_piece_log(td);
 
@@ -1064,8 +1052,7 @@
 		    (td->io_ops->flags & FIO_UNIDIR))
 			continue;
 
-		if (clear_io_state(td))
-			break;
+		clear_io_state(td);
 
 		fio_gettime(&td->start, NULL);