[PATCH] Must use ->real_file_size
[fio.git] / filesetup.c
index 21854a9739747bb1f5bd16d95e034116d5b7c170..a14cd9503a68dbab9a656b78a3fd92726d46b07c 100644 (file)
@@ -117,14 +117,19 @@ static int create_files(struct thread_data *td)
        }
 
        temp_stall_ts = 1;
-       fprintf(f_out, "%s: Laying out IO file(s) (%d x %LuMiB == %LuMiB)\n",
+       fprintf(f_out, "%s: Laying out IO file(s) (%u x %LuMiB == %LuMiB)\n",
                                td->name, td->nr_uniq_files,
                                (td->total_file_size >> 20) / td->nr_uniq_files,
                                td->total_file_size >> 20);
 
        err = 0;
        for_each_file(td, f, i) {
+               /*
+                * Only unlink files that we created.
+                */
+               f->unlink = 0;
                if (file_ok(td, f)) {
+                       f->unlink = td->unlink;
                        err = create_file(td, f);
                        if (err)
                                break;
@@ -151,7 +156,7 @@ static int file_size(struct thread_data *td, struct fio_file *f)
                        f->file_size = f->real_file_size;
        }
 
-       f->file_size -= f->file_offset;
+       f->file_size = f->real_file_size - f->file_offset;
        return 0;
 }
 
@@ -434,7 +439,7 @@ void close_files(struct thread_data *td)
        int i;
 
        for_each_file(td, f, i) {
-               if (!td->filename && td->unlink &&
+               if (!td->filename && f->unlink &&
                    td->filetype == FIO_TYPE_FILE) {
                        unlink(f->file_name);
                        free(f->file_name);