Make sure the ->files array is job private
authorJens Axboe <jens.axboe@oracle.com>
Fri, 23 Mar 2007 14:29:45 +0000 (15:29 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 23 Mar 2007 14:29:45 +0000 (15:29 +0100)
Otherwise we introduce differences between threads and processes,
we don't want to do that.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
fio.h
init.c

index 137afacc179dd8ea6744818f97afe90d48fa74b9..d8b7401b35e0230d9f40afe53dcbfcd5e84b83e1 100644 (file)
@@ -539,6 +539,7 @@ void close_files(struct thread_data *td)
        }
 
        td->o.filename = NULL;
        }
 
        td->o.filename = NULL;
+       free(td->files);
        td->files = NULL;
        td->o.nr_files = 0;
 }
        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);
 }
 {
        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 d0629ece3fe6d3f2463a22fbc4dd16628c1ce2ae..8a79289cb77fe9c8d14535276b8181ad41686b5a 100644 (file)
--- 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 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
 
 /*
  * ETA/status stuff
diff --git a/init.c b/init.c
index 1e0eeccfdc6e5dcbf0b95b0fa479e111108826f6..e5d776c22f6a13481508a565c2d76671d2475faf 100644 (file)
--- 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;
 
        td = &threads[thread_number++];
        *td = *parent;
 
+       dup_files(td, parent);
+
        td->thread_number = thread_number;
        return td;
 }
        td->thread_number = thread_number;
        return td;
 }