Make sure the ->files array is job private
[fio.git] / filesetup.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);
+       }
+}