IO log fixes
[fio.git] / log.c
diff --git a/log.c b/log.c
index 07ba950b9e147a5dfa98c7264fcebf660a5546d0..b5c6f690d4572770557462cad1b80201317fb814 100644 (file)
--- a/log.c
+++ b/log.c
@@ -61,15 +61,11 @@ restart:
        if (!list_empty(&td->io_log_list)) {
                ipo = list_entry(td->io_log_list.next, struct io_piece, list);
                list_del(&ipo->list);
-               io_u->offset = ipo->offset;
-               io_u->buflen = ipo->len;
-               io_u->ddir = ipo->ddir;
-               io_u->file = ipo->file;
 
                /*
                 * invalid ddir, this is a file action
                 */
-               if (io_u->ddir == DDIR_INVAL) {
+               if (ipo->ddir == DDIR_INVAL) {
                        struct fio_file *f = &td->files[ipo->fileno];
 
                        if (ipo->file_action == FIO_LOG_OPEN_FILE) {
@@ -83,14 +79,15 @@ restart:
                        }
                }
 
+               io_u->offset = ipo->offset;
+               io_u->buflen = ipo->len;
+               io_u->ddir = ipo->ddir;
+               io_u->file = &td->files[ipo->fileno];
+               get_file(io_u->file);
+
                if (ipo->delay)
                        iolog_delay(td, ipo->delay);
 
-               /*
-                * work around, this needs a format change to work for > 1 file
-                */
-               if (!io_u->file)
-                       io_u->file = &td->files[0];
                free(ipo);
                return 0;
        }