Fix blktrace replay
authorJens Axboe <jaxboe@fusionio.com>
Tue, 24 Aug 2010 13:01:37 +0000 (15:01 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Tue, 24 Aug 2010 13:01:37 +0000 (15:01 +0200)
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>
blktrace.c
file.h
filesetup.c
log.c

index ef3e18fdfee0f2ff489e9e90852a25a209b26221..68ba964a3a363c6f5e85ac19e5410134e1943238 100644 (file)
@@ -187,7 +187,7 @@ static void trace_add_file(struct thread_data *td, __u32 device)
                int fileno;
 
                dprint(FD_BLKTRACE, "add devices %s\n", dev);
                int fileno;
 
                dprint(FD_BLKTRACE, "add devices %s\n", dev);
-               fileno = add_file(td, dev);
+               fileno = add_file_exclusive(td, dev);
                trace_add_open_event(td, fileno);
        }
 }
                trace_add_open_event(td, fileno);
        }
 }
diff --git a/file.h b/file.h
index 3b4ed0b9acadf206392f3826854d67fac7407f00..63494653bb0d8d582409fb7b34f4ea25bcb353a8 100644 (file)
--- a/file.h
+++ b/file.h
@@ -140,6 +140,7 @@ extern int __must_check generic_close_file(struct thread_data *, struct fio_file
 extern int __must_check generic_get_file_size(struct thread_data *, struct fio_file *);
 extern int __must_check pre_read_files(struct thread_data *);
 extern int add_file(struct thread_data *, const char *);
 extern int __must_check generic_get_file_size(struct thread_data *, struct fio_file *);
 extern int __must_check pre_read_files(struct thread_data *);
 extern int add_file(struct thread_data *, const char *);
+extern int add_file_exclusive(struct thread_data *, const char *);
 extern void get_file(struct fio_file *);
 extern int __must_check put_file(struct thread_data *, struct fio_file *);
 extern void put_file_log(struct thread_data *, struct fio_file *);
 extern void get_file(struct fio_file *);
 extern int __must_check put_file(struct thread_data *, struct fio_file *);
 extern void put_file_log(struct thread_data *, struct fio_file *);
index d2b74d7f6a60fd7a5adece91a8445bb9ad696bde..5a8105a6032e24b2e45a8a9d028c2a0b7e2552fe 100644 (file)
@@ -963,6 +963,19 @@ int add_file(struct thread_data *td, const char *fname)
        return cur_files;
 }
 
        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);
 void get_file(struct fio_file *f)
 {
        dprint(FD_FILE, "get file %s, ref=%d\n", f->file_name, f->references);
diff --git a/log.c b/log.c
index 80d3742f76485ff45130b6a586c6120bcd74de7f..4a64132c82e85569a6c9e52850251efb7364d36a 100644 (file)
--- a/log.c
+++ b/log.c
@@ -131,7 +131,6 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
                        io_u->buflen = ipo->len;
                        io_u->file = td->files[ipo->fileno];
                        get_file(io_u->file);
                        io_u->buflen = ipo->len;
                        io_u->file = td->files[ipo->fileno];
                        get_file(io_u->file);
-
                        dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset,
                                                io_u->buflen, io_u->file->file_name);
                        if (ipo->delay) iolog_delay(td, ipo->delay);
                        dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset,
                                                io_u->buflen, io_u->file->file_name);
                        if (ipo->delay) iolog_delay(td, ipo->delay);