X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=0b9564044d14135d662363219471c674c2670714;hp=2e81a1d10c88320e4396d625e99be1e9d9a04a9f;hb=b6e25da4225ca990f6997d2d60fe96a7b51d4661;hpb=b4a6a59a939f0e6554632de311e7d1d1b7633ccf diff --git a/filesetup.c b/filesetup.c index 2e81a1d1..0b956404 100644 --- a/filesetup.c +++ b/filesetup.c @@ -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); @@ -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,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);