[PATCH] Fix random_map
[fio.git] / filesetup.c
index 4310a79f7e6e513b341324c3b2aa3679ffa39219..0b9564044d14135d662363219471c674c2670714 100644 (file)
@@ -44,6 +44,11 @@ static int create_file(struct thread_data *td, struct fio_file *f)
                goto err;
        }
 
+       if (posix_fallocate(f->fd, 0, f->file_size) < 0) {
+               td_verror(td, errno);
+               goto err;
+       }
+
        b = malloc(td->max_bs);
        memset(b, 0, td->max_bs);
 
@@ -404,8 +409,11 @@ 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);