X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=a1633827fe8eca63017bb8a2d91b731dd9854b73;hp=4310a79f7e6e513b341324c3b2aa3679ffa39219;hb=75e6f36fae06978f29296fce76a7f00ca0df7b56;hpb=13f8e2d2e3e5ec7d8c18b70fb2a2e2a026190020;ds=sidebyside diff --git a/filesetup.c b/filesetup.c index 4310a79f..a1633827 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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; @@ -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);