Only memcpy last issue time when using iolog replay
[fio.git] / ioengines.c
index 3e17897653f6a8d57a6a18a3b65297bfdd72653c..1688c633db66233fe55caf8284f195d4a7bac8a0 100644 (file)
@@ -195,9 +195,13 @@ int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max,
                if (r < 0)
                        goto out;
        }
+       if (max > td->cur_depth)
+               max = td->cur_depth;
+       if (min > max)
+               max = min;
 
        r = 0;
-       if (td->io_ops->getevents)
+       if (max && td->io_ops->getevents)
                r = td->io_ops->getevents(td, min, max, t);
 out:
        if (r >= 0)
@@ -223,7 +227,12 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
 
        if (td->io_ops->flags & FIO_SYNCIO) {
                fio_gettime(&io_u->issue_time, NULL);
-               memcpy(&td->last_issue, &io_u->issue_time,
+
+               /*
+                * only used for iolog
+                */
+               if (td->o.read_iolog_file)
+                       memcpy(&td->last_issue, &io_u->issue_time,
                                        sizeof(struct timeval));
 
                /*
@@ -268,8 +277,13 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u)
 
        if ((td->io_ops->flags & FIO_SYNCIO) == 0) {
                fio_gettime(&io_u->issue_time, NULL);
-               memcpy(&td->last_issue, &io_u->issue_time,
-                               sizeof(struct timeval));
+
+               /*
+                * only used for iolog
+                */
+               if (td->o.read_iolog_file)
+                       memcpy(&td->last_issue, &io_u->issue_time,
+                                       sizeof(struct timeval));
 
                /*
                 * async engine, set the timeout here
@@ -329,6 +343,13 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
+       fio_file_reset(f);
+       f->flags |= FIO_FILE_OPEN;
+       f->flags &= ~FIO_FILE_CLOSING;
+
+       td->nr_open_files++;
+       get_file(f);
+
        if (f->filetype == FIO_TYPE_PIPE) {
                if (td_random(td)) {
                        log_err("fio: can't seek on pipes (no random io)\n");
@@ -336,10 +357,6 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
                }
        }
 
-       fio_file_reset(f);
-       f->flags |= FIO_FILE_OPEN;
-       f->flags &= ~FIO_FILE_CLOSING;
-
        if (td->io_ops->flags & FIO_DISKLESSIO)
                goto done;
 
@@ -364,10 +381,23 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f)
        if (f->file_map)
                memset(f->file_map, 0, f->num_maps * sizeof(int));
 
+#ifdef FIO_OS_DIRECTIO
+       /*
+        * Some OS's have a distinct call to mark the file non-buffered,
+        * instead of using O_DIRECT (Solaris)
+        */
+       if (td->o.odirect) {
+               int ret = fio_set_odirect(f->fd);
+
+               if (ret) {
+                       td_verror(td, ret, "fio_set_odirect");
+                       goto err;
+               }
+       }
+#endif
+
 done:
        log_file(td, f, FIO_LOG_OPEN_FILE);
-       td->nr_open_files++;
-       get_file(f);
        return 0;
 err:
        if (td->io_ops->close_file)