[PATCH Various fixes

- Multiple files fixes
- Fix for unaligned io issued for raw io

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index adfe940..e1afeb9 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -12,9 +12,21 @@
 {
 	unsigned long long left;
 	unsigned int bs;
+	struct stat st;
 	char *b;
 	int r;
 
+	if (td->filetype != FIO_TYPE_FILE)
+		return 0;
+
+	if (stat(f->file_name, &st) == -1) {
+		if (!td->create_file) {
+			td_verror(td, ENOENT);
+			return 1;
+		}
+	} else if (st.st_size >= (off_t) f->file_size)
+		return 0;
+
 	f->fd = open(f->file_name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 	if (f->fd < 0) {
 		td_verror(td, errno);
@@ -95,6 +107,7 @@
 	for_each_file(td, f, i) {
 		f->file_size = td->total_file_size / td->nr_files;
 		err = create_file(td, f);
+		if (err)
 			break;
 
 		td->io_size += f->file_size;
@@ -267,26 +280,8 @@
 
 static int setup_file(struct thread_data *td, struct fio_file *f)
 {
-	struct stat st;
 	int flags = 0;
 
-	if (stat(f->file_name, &st) == -1) {
-		if (errno != ENOENT) {
-			td_verror(td, errno);
-			return 1;
-		}
-		if (!td->create_file) {
-			td_verror(td, ENOENT);
-			return 1;
-		}
-		if (create_file(td, f))
-			return 1;
-	} else if (td->filetype == FIO_TYPE_FILE &&
-		   st.st_size < (off_t) f->file_size) {
-		if (create_file(td, f))
-			return 1;
-	}
-
 	if (td->odirect)
 		flags |= OS_O_DIRECT;