[PATCH] Time and seek optimizations
[fio.git] / engines / fio-engine-sync.c
index 8bc990d72bcd3de7457169e9b27b1f1389719bd9..c7ddd4c52956125bd408e4c6f2a0d86f95908041 100644 (file)
@@ -7,8 +7,9 @@
 #include <unistd.h>
 #include <errno.h>
 #include <assert.h>
-#include "fio.h"
-#include "os.h"
+
+#include "../fio.h"
+#include "../os.h"
 
 struct syncio_data {
        struct io_u *last_io_u;
@@ -44,6 +45,8 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
 
        if (io_u->ddir == DDIR_SYNC)
                return 0;
+       if (io_u->offset == f->last_completed_pos)
+               return 0;
 
        if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
                td_verror(td, errno);
@@ -57,7 +60,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
 {
        struct syncio_data *sd = td->io_ops->data;
        struct fio_file *f = io_u->file;
-       int ret;
+       unsigned int ret;
 
        if (io_u->ddir == DDIR_READ)
                ret = read(f->fd, io_u->buf, io_u->buflen);
@@ -66,7 +69,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
        else
                ret = fsync(f->fd);
 
-       if ((unsigned int) ret != io_u->buflen) {
+       if (ret != io_u->buflen) {
                if (ret > 0) {
                        io_u->resid = io_u->buflen - ret;
                        io_u->error = EIO;
@@ -97,7 +100,7 @@ static int fio_syncio_init(struct thread_data *td)
        return 0;
 }
 
-struct ioengine_ops ioengine = {
+static struct ioengine_ops ioengine = {
        .name           = "sync",
        .version        = FIO_IOOPS_VERSION,
        .init           = fio_syncio_init,
@@ -108,3 +111,13 @@ struct ioengine_ops ioengine = {
        .cleanup        = fio_syncio_cleanup,
        .flags          = FIO_SYNCIO,
 };
+
+static void fio_init fio_syncio_register(void)
+{
+       register_ioengine(&ioengine);
+}
+
+static void fio_exit fio_syncio_unregister(void)
+{
+       unregister_ioengine(&ioengine);
+}