rate-submit: clean up init/exit helpers
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 19:36:27 +0000 (12:36 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 19:36:27 +0000 (12:36 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
rate-submit.c
rate-submit.h

index d39968519fe3680a8ab0fe87716087eb61ad1d6e..ae2612036124b700c7959251090389fd84d618ed 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1555,8 +1555,7 @@ static void *thread_main(void *data)
 
        fio_verify_init(td);
 
-       if ((o->io_submit_mode == IO_MODE_OFFLOAD) &&
-           workqueue_init(td, &td->io_wq, &rated_wq_ops, td->o.iodepth))
+       if (rate_submit_init(td))
                goto err;
 
        fio_gettime(&td->epoch, NULL);
@@ -1654,10 +1653,8 @@ static void *thread_main(void *data)
 
        fio_writeout_logs(td);
 
-       if (o->io_submit_mode == IO_MODE_OFFLOAD)
-               workqueue_exit(&td->io_wq);
-
        iolog_compress_exit(td);
+       rate_submit_exit(td);
 
        if (o->exec_postrun)
                exec_string(o, o->exec_postrun, (const char *)"postrun");
index 3d35815212f5e1ca67b1b79990d78abf90579241..39b552d47927a40f4d910f249dabe5265bdd29fc 100644 (file)
@@ -224,7 +224,7 @@ static void io_workqueue_update_acct_fn(struct submit_worker *sw)
 
 }
 
-struct workqueue_ops rated_wq_ops = {
+static struct workqueue_ops rated_wq_ops = {
        .fn                     = io_workqueue_fn,
        .pre_sleep_flush_fn     = io_workqueue_pre_sleep_flush_fn,
        .pre_sleep_fn           = io_workqueue_pre_sleep_fn,
@@ -234,3 +234,19 @@ struct workqueue_ops rated_wq_ops = {
        .init_worker_fn         = io_workqueue_init_worker_fn,
        .exit_worker_fn         = io_workqueue_exit_worker_fn,
 };
+
+int rate_submit_init(struct thread_data *td)
+{
+       if (td->o.io_submit_mode != IO_MODE_OFFLOAD)
+               return 0;
+
+       return workqueue_init(td, &td->io_wq, &rated_wq_ops, td->o.iodepth);
+}
+
+void rate_submit_exit(struct thread_data *td)
+{
+       if (td->o.io_submit_mode != IO_MODE_OFFLOAD)
+               return;
+
+       workqueue_exit(&td->io_wq);
+}
index 33bb9d77797c802b2151ebf8852723e638261a60..b4ca1292137124094e5f83840302ec3975f9ea15 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef FIO_RATE_SUBMIT
 #define FIO_RATE_SUBMIT
 
-#include "workqueue.h"
-
-extern struct workqueue_ops rated_wq_ops;
+int rate_submit_init(struct thread_data *);
+void rate_submit_exit(struct thread_data *);
 
 #endif