t/run-fio-tests: integrate t/nvmept.py
[fio.git] / engines / null.c
index 47f290548ceafb39763b9bfd5cf08a29aa7f2e06..7236ec94886a47136e450a81c0d366d84f46ec2e 100644 (file)
@@ -6,17 +6,15 @@
  *
  * It also can act as external C++ engine - compiled with:
  *
- * g++ -O2 -g -shared -rdynamic -fPIC -o cpp_null null.c -DFIO_EXTERNAL_ENGINE
+ * g++ -O2 -g -shared -rdynamic -fPIC -o cpp_null null.c \
+ *     -include ../config-host.h -DFIO_EXTERNAL_ENGINE
  *
  * to test it execute:
  *
  * LD_LIBRARY_PATH=./engines ./fio examples/cpp_null.fio
  *
  */
-#include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
 #include <assert.h>
 
 #include "../fio.h"
@@ -46,9 +44,28 @@ static int null_getevents(struct null_data *nd, unsigned int min_events,
        return ret;
 }
 
+static void null_queued(struct thread_data *td, struct null_data *nd)
+{
+       struct timespec now;
+
+       if (!fio_fill_issue_time(td))
+               return;
+
+       fio_gettime(&now, NULL);
+
+       for (int i = 0; i < nd->queued; i++) {
+               struct io_u *io_u = nd->io_us[i];
+
+               memcpy(&io_u->issue_time, &now, sizeof(now));
+               io_u_queued(td, io_u);
+       }
+}
+
 static int null_commit(struct thread_data *td, struct null_data *nd)
 {
        if (!nd->events) {
+               null_queued(td, nd);
+
 #ifndef FIO_EXTERNAL_ENGINE
                io_u_mark_submit(td, nd->queued);
 #endif
@@ -59,8 +76,8 @@ static int null_commit(struct thread_data *td, struct null_data *nd)
        return 0;
 }
 
-static int null_queue(struct thread_data *td, struct null_data *nd,
-                     struct io_u *io_u)
+static enum fio_q_status null_queue(struct thread_data *td,
+                                   struct null_data *nd, struct io_u *io_u)
 {
        fio_ro_check(td, io_u);
 
@@ -89,16 +106,18 @@ static void null_cleanup(struct null_data *nd)
 
 static struct null_data *null_init(struct thread_data *td)
 {
-       struct null_data *nd = (struct null_data *) malloc(sizeof(*nd));
+       struct null_data *nd;
+       nd = malloc(sizeof(*nd));
 
        memset(nd, 0, sizeof(*nd));
 
        if (td->o.iodepth != 1) {
-               nd->io_us = (struct io_u **) malloc(td->o.iodepth * sizeof(struct io_u *));
-               memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
+               nd->io_us = calloc(td->o.iodepth, sizeof(struct io_u *));
+               td->io_ops->flags |= FIO_ASYNCIO_SETS_ISSUE_TIME;
        } else
                td->io_ops->flags |= FIO_SYNCIO;
 
+       td_set_ioengine_flags(td);
        return nd;
 }
 
@@ -106,34 +125,35 @@ static struct null_data *null_init(struct thread_data *td)
 
 static struct io_u *fio_null_event(struct thread_data *td, int event)
 {
-       return null_event((struct null_data *)td->io_ops_data, event);
+       return null_event(td->io_ops_data, event);
 }
 
 static int fio_null_getevents(struct thread_data *td, unsigned int min_events,
                              unsigned int max, const struct timespec *t)
 {
-       struct null_data *nd = (struct null_data *)td->io_ops_data;
+       struct null_data *nd = td->io_ops_data;
        return null_getevents(nd, min_events, max, t);
 }
 
 static int fio_null_commit(struct thread_data *td)
 {
-       return null_commit(td, (struct null_data *)td->io_ops_data);
+       return null_commit(td, td->io_ops_data);
 }
 
-static int fio_null_queue(struct thread_data *td, struct io_u *io_u)
+static enum fio_q_status fio_null_queue(struct thread_data *td,
+                                       struct io_u *io_u)
 {
-       return null_queue(td, (struct null_data *)td->io_ops_data, io_u);
+       return null_queue(td, td->io_ops_data, io_u);
 }
 
 static int fio_null_open(struct thread_data *td, struct fio_file *f)
 {
-       return null_open((struct null_data *)td->io_ops_data, f);
+       return null_open(td->io_ops_data, f);
 }
 
 static void fio_null_cleanup(struct thread_data *td)
 {
-       null_cleanup((struct null_data *)td->io_ops_data);
+       null_cleanup(td->io_ops_data);
 }
 
 static int fio_null_init(struct thread_data *td)
@@ -203,7 +223,7 @@ struct NullData {
                return null_commit(td, impl_);
        }
 
-       int fio_null_queue(struct thread_data *td, struct io_u *io_u)
+       fio_q_status fio_null_queue(struct thread_data *td, struct io_u *io_u)
        {
                return null_queue(td, impl_, io_u);
        }
@@ -213,6 +233,7 @@ struct NullData {
                return null_open(impl_, f);
        }
 
+private:
        struct null_data *impl_;
 };
 
@@ -234,7 +255,7 @@ static int fio_null_commit(struct thread_data *td)
        return NullData::get(td)->fio_null_commit(td);
 }
 
-static int fio_null_queue(struct thread_data *td, struct io_u *io_u)
+static fio_q_status fio_null_queue(struct thread_data *td, struct io_u *io_u)
 {
        return NullData::get(td)->fio_null_queue(td, io_u);
 }