summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-03-04 15:27:42 +0100
committerJens Axboe <jens.axboe@oracle.com>2009-03-04 15:27:42 +0100
commitfc99bc0d82371cc704395a7718e78abd0e0d2709 (patch)
tree603af9778d78a98df51d18e5847f2f59e262ef59
parent814452bd47e0f2bb4825b8042b664f32de0aff8d (diff)
downloadfio-fc99bc0d82371cc704395a7718e78abd0e0d2709.tar.gz
fio-fc99bc0d82371cc704395a7718e78abd0e0d2709.tar.bz2
Realloc td->files to full size immediately
For adding many files, we do as many reallocs() as we have files. This is slow, so do full allocs instead. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--filesetup.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/filesetup.c b/filesetup.c
index 088b77c3..461f130c 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -714,10 +714,15 @@ int add_file(struct thread_data *td, const char *fname)
f->fd = -1;
- dprint(FD_FILE, "resize file array to %d files\n", cur_files + 1);
+ if (td->files_size <= td->files_index) {
+ int new_size = td->o.nr_files;
- td->files = realloc(td->files, (cur_files + 1) * sizeof(f));
- td->files[cur_files] = f;
+ dprint(FD_FILE, "resize file array to %d files\n", new_size);
+
+ td->files = realloc(td->files, new_size * sizeof(f));
+ td->files[cur_files] = f;
+ td->files_size = new_size;
+ }
/*
* init function, io engine may not be loaded yet