Replace redundant TD_F_NOIO flag with td->io_ops_init
authorTomohiro Kusumi <tkusumi@tuxera.com>
Mon, 20 Mar 2017 21:28:41 +0000 (23:28 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 21 Mar 2017 13:16:11 +0000 (07:16 -0600)
The only reason TD_F_NOIO exists in addition to FIO_NOIO is because
fio_running_or_pending_io_threads() needs to know whether td has
successfully initialized ioengine, whereas FIO_NOIO is statically
set regardless of ioengines's ->init() result.

This commit adds a new td field ->io_ops_init to inidicate ->init()
result, so that td needs no extra bit field for each ioengine like
TD_F_NOIO. It was rather odd that td was unable to tell ->init()
result afterward when ->init() failure (returning non zero) doesn't
mean aborting fio itself. This commit also changes TD_F_NOIO to
TD_F_RESERVED as it's no longer used.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
fio.h
init.c
ioengines.c
libfio.c

diff --git a/fio.h b/fio.h
index b573ac587d3361e3b1f5919a391e3e3ceab7f649..581512fd0ad77d1b748b285bf6df5b2e216edbbf 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -74,7 +74,7 @@ enum {
        TD_F_VER_NONE           = 1U << 5,
        TD_F_PROFILE_OPS        = 1U << 6,
        TD_F_COMPRESS           = 1U << 7,
-       TD_F_NOIO               = 1U << 8,
+       TD_F_RESERVED           = 1U << 8, /* not used */
        TD_F_COMPRESS_LOG       = 1U << 9,
        TD_F_VSTATE_SAVED       = 1U << 10,
        TD_F_NEED_LOCK          = 1U << 11,
@@ -231,6 +231,7 @@ struct thread_data {
         * to any of the available IO engines.
         */
        struct ioengine_ops *io_ops;
+       int io_ops_init;
 
        /*
         * IO engine private data and dlhandle.
diff --git a/init.c b/init.c
index b4b09743f1c94225f48a5566462be84ddb27c810..4a722555fda9ae612540b96c7d32023ed3a7bed9 100644 (file)
--- a/init.c
+++ b/init.c
@@ -459,6 +459,7 @@ static struct thread_data *get_new_job(bool global, struct thread_data *parent,
                copy_opt_list(td, parent);
 
        td->io_ops = NULL;
+       td->io_ops_init = 0;
        if (!preserve_eo)
                td->eo = NULL;
 
index 95013d1daaaa07d9bd26ed2899a81d7fd1b45244..c773f2ed3464a08fa6a51464d33d68a0231fc553 100644 (file)
@@ -368,17 +368,17 @@ int td_io_init(struct thread_data *td)
 
        if (td->io_ops->init) {
                ret = td->io_ops->init(td);
-               if (ret && td->o.iodepth > 1) {
-                       log_err("fio: io engine init failed. Perhaps try"
-                               " reducing io depth?\n");
-               }
+               if (ret)
+                       log_err("fio: io engine %s init failed.%s\n",
+                               td->io_ops->name,
+                               td->o.iodepth > 1 ?
+                               " Perhaps try reducing io depth?" : "");
+               else
+                       td->io_ops_init = 1;
                if (!td->error)
                        td->error = ret;
        }
 
-       if (!ret && td_ioengine_flagged(td, FIO_NOIO))
-               td->flags |= TD_F_NOIO;
-
        return ret;
 }
 
index 4b53c92a8756efbe945173d850acedd956608770..83107084a4239c096298c3bddd702b7c8166cef0 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -276,7 +276,7 @@ int fio_running_or_pending_io_threads(void)
        int nr_io_threads = 0;
 
        for_each_td(td, i) {
-               if (td->flags & TD_F_NOIO)
+               if (td->io_ops_init && td_ioengine_flagged(td, FIO_NOIO))
                        continue;
                nr_io_threads++;
                if (td->runstate < TD_EXITED)