From cade3ef44669c5c962d7ed18ca0e361116ee44ad Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 23 Mar 2007 15:29:45 +0100 Subject: [PATCH] Make sure the ->files array is job private Otherwise we introduce differences between threads and processes, we don't want to do that. Signed-off-by: Jens Axboe --- filesetup.c | 20 ++++++++++++++++++++ fio.h | 1 + init.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/filesetup.c b/filesetup.c index 137afacc..d8b7401b 100644 --- a/filesetup.c +++ b/filesetup.c @@ -539,6 +539,7 @@ void close_files(struct thread_data *td) } td->o.filename = NULL; + free(td->files); td->files = NULL; td->o.nr_files = 0; } @@ -661,3 +662,22 @@ int add_dir_files(struct thread_data *td, const char *path) { return recurse_dir(td, path); } + +void dup_files(struct thread_data *td, struct thread_data *org) +{ + struct fio_file *f; + unsigned int i; + size_t bytes; + + if (!org->files) + return; + + bytes = org->files_index * sizeof(*f); + td->files = malloc(bytes); + memcpy(td->files, org->files, bytes); + + for_each_file(td, f, i) { + if (f->file_name) + f->file_name = strdup(f->file_name); + } +} diff --git a/fio.h b/fio.h index d0629ece..8a79289c 100644 --- a/fio.h +++ b/fio.h @@ -708,6 +708,7 @@ extern void get_file(struct fio_file *); extern void put_file(struct thread_data *, struct fio_file *); extern int add_dir_files(struct thread_data *, const char *); extern int init_random_map(struct thread_data *); +extern void dup_files(struct thread_data *, struct thread_data *); /* * ETA/status stuff diff --git a/init.c b/init.c index 1e0eeccf..e5d776c2 100644 --- a/init.c +++ b/init.c @@ -115,6 +115,8 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent) td = &threads[thread_number++]; *td = *parent; + dup_files(td, parent); + td->thread_number = thread_number; return td; } -- 2.25.1