Fix blktrace replay

We would add duplicate files, if the open event comes before
the add file event. Make sure we return the current index file
instead of adding a duplicate, this causes bad file lookups.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
diff --git a/filesetup.c b/filesetup.c
index d2b74d7..5a8105a 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -963,6 +963,19 @@
 	return cur_files;
 }
 
+int add_file_exclusive(struct thread_data *td, const char *fname)
+{
+	struct fio_file *f;
+	unsigned int i;
+
+	for_each_file(td, f, i) {
+		if (!strcmp(f->file_name, fname))
+			return i;
+	}
+
+	return add_file(td, fname);
+}
+
 void get_file(struct fio_file *f)
 {
 	dprint(FD_FILE, "get file %s, ref=%d\n", f->file_name, f->references);