[PATCH] Remove last remnants of file extending
diff --git a/fio.c b/fio.c
index af16783..5bced24 100644
--- a/fio.c
+++ b/fio.c
@@ -941,18 +941,17 @@
 	return 0;
 }
 
-static int create_file(struct thread_data *td, unsigned long long size,
-		       int extend)
+static int create_file(struct thread_data *td, unsigned long long size)
 {
 	unsigned long long left;
 	unsigned int bs;
-	int r, oflags;
 	char *b;
+	int r;
 
 	/*
 	 * unless specifically asked for overwrite, let normal io extend it
 	 */
-	if (td_write(td) && !td->overwrite) {
+	if (!td->overwrite) {
 		td->real_file_size = size;
 		return 0;
 	}
@@ -964,19 +963,15 @@
 	}
 
 	temp_stall_ts = 1;
+	fprintf(f_out, "%s: Laying out IO file (%LuMiB)\n",td->name,size >> 20);
 
-	if (!extend) {
-		oflags = O_CREAT | O_TRUNC;
-		fprintf(f_out, "%s: Laying out IO file (%LuMiB)\n", td->name, size >> 20);
-	}
-
-	td->fd = open(td->file_name, O_WRONLY | oflags, 0644);
+	td->fd = open(td->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (td->fd < 0) {
 		td_verror(td, errno);
 		goto done_noclose;
 	}
 
-	if (!extend && ftruncate(td->fd, td->file_size) == -1) {
+	if (ftruncate(td->fd, td->file_size) == -1) {
 		td_verror(td, errno);
 		goto done;
 	}
@@ -1177,13 +1172,12 @@
 			td_verror(td, ENOENT);
 			return 1;
 		}
-		if (create_file(td, td->file_size, 0))
+		if (create_file(td, td->file_size))
 			return 1;
-	} else if (td->filetype == FIO_TYPE_FILE) {
-		if (st.st_size < (off_t) td->file_size) {
-			if (create_file(td, td->file_size, 1))
-				return 1;
-		}
+	} else if (td->filetype == FIO_TYPE_FILE &&
+		   st.st_size < (off_t) td->file_size) {
+		if (create_file(td, td->file_size))
+			return 1;
 	}
 
 	if (td->odirect)
diff --git a/init.c b/init.c
index 40fcf1c..32d1e5c 100644
--- a/init.c
+++ b/init.c
@@ -122,6 +122,12 @@
 	if (td->zone_size && !td->sequential)
 		td->zone_size = 0;
 
+	/*
+	 * Reads can do overwrites, we always need to pre-create the file
+	 */
+	if (td_read(td) || td_rw(td))
+		td->overwrite = 1;
+
 	td->filetype = FIO_TYPE_FILE;
 	if (!stat(jobname, &sb)) {
 		if (S_ISBLK(sb.st_mode))