[PATCH] Fix int vs long problems in parsing some options
[fio.git] / filesetup.c
index d6df4f9fccb7b699c7e5dcfe292bbd4b6d65d8ac..a1633827fe8eca63017bb8a2d91b731dd9854b73 100644 (file)
@@ -44,12 +44,17 @@ static int create_file(struct thread_data *td, struct fio_file *f)
                goto err;
        }
 
-       b = malloc(td->max_bs);
-       memset(b, 0, td->max_bs);
+       if (posix_fallocate(f->fd, 0, f->file_size) < 0) {
+               td_verror(td, errno);
+               goto err;
+       }
+
+       b = malloc(td->max_bs[DDIR_WRITE]);
+       memset(b, 0, td->max_bs[DDIR_WRITE]);
 
        left = f->file_size;
        while (left && !td->terminate) {
-               bs = td->max_bs;
+               bs = td->max_bs[DDIR_WRITE];
                if (bs > left)
                        bs = left;
 
@@ -114,8 +119,8 @@ 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",
-                               td->name, td->nr_files,
-                               (td->total_file_size >> 20) / td->nr_files,
+                               td->name, td->nr_uniq_files,
+                               (td->total_file_size >> 20) / td->nr_uniq_files,
                                td->total_file_size >> 20);
 
        err = 0;
@@ -404,8 +409,13 @@ void close_files(struct thread_data *td)
 
        for_each_file(td, f, i) {
                if (f->fd != -1) {
-                       if (td->unlink && td->filetype == FIO_TYPE_FILE)
+                       if (td->unlink && td->filetype == FIO_TYPE_FILE &&
+                           td->filename) {
                                unlink(f->file_name);
+                               td->filename = NULL;
+                       }
+                       free(f->file_name);
+                       f->file_name = NULL;
                        close(f->fd);
                        f->fd = -1;
                }
@@ -414,4 +424,8 @@ void close_files(struct thread_data *td)
                        f->mmap = NULL;
                }
        }
+
+       free(td->files);
+       td->files = NULL;
+       td->nr_files = 0;
 }