workqueue: move private exit code to caller
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:32:46 +0000 (08:32 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:32:46 +0000 (08:32 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
workqueue.c
workqueue.h

index b40a3ce..c127498 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1492,6 +1492,17 @@ err:
 
 }
 
+static void io_workqueue_exit_worker_fn(struct submit_worker *sw)
+{
+       struct thread_data *td = sw->private;
+
+       fio_options_free(td);
+       close_and_free_files(td);
+       if (td->io_ops)
+               close_ioengine(td);
+       td_set_runstate(td, TD_EXITED);
+}
+
 struct workqueue_ops rated_wq_ops = {
        .fn                     = io_workqueue_fn,
        .pre_sleep_flush_fn     = io_workqueue_pre_sleep_flush_fn,
@@ -1499,6 +1510,7 @@ struct workqueue_ops rated_wq_ops = {
        .alloc_worker_fn        = io_workqueue_alloc_fn,
        .free_worker_fn         = io_workqueue_free_fn,
        .init_worker_fn         = io_workqueue_init_worker_fn,
+       .exit_worker_fn         = io_workqueue_exit_worker_fn,
 };
 
 /*
index 818baf8..f26d9d7 100644 (file)
@@ -270,14 +270,9 @@ done:
 
 static void free_worker(struct submit_worker *sw)
 {
-       struct thread_data *td = sw->private;
        struct workqueue *wq = sw->wq;
 
-       fio_options_free(td);
-       close_and_free_files(td);
-       if (td->io_ops)
-               close_ioengine(td);
-       td_set_runstate(td, TD_EXITED);
+       workqueue_exit_worker(sw);
 
        pthread_cond_destroy(&sw->cond);
        pthread_mutex_destroy(&sw->lock);
index f724f90..d36f421 100644 (file)
@@ -25,14 +25,18 @@ typedef void (workqueue_pre_sleep_fn)(struct submit_worker *);
 typedef int (workqueue_alloc_worker_fn)(struct submit_worker *);
 typedef void (workqueue_free_worker_fn)(struct submit_worker *);
 typedef int (workqueue_init_worker_fn)(struct submit_worker *);
+typedef void (workqueue_exit_worker_fn)(struct submit_worker *);
 
 struct workqueue_ops {
        workqueue_work_fn *fn;
        workqueue_pre_sleep_flush_fn *pre_sleep_flush_fn;
        workqueue_pre_sleep_fn *pre_sleep_fn;
+
        workqueue_alloc_worker_fn *alloc_worker_fn;
        workqueue_free_worker_fn *free_worker_fn;
+
        workqueue_init_worker_fn *init_worker_fn;
+       workqueue_exit_worker_fn *exit_worker_fn;
 };
 
 struct workqueue {
@@ -85,4 +89,13 @@ static inline int workqueue_init_worker(struct submit_worker *sw)
        return wq->ops.init_worker_fn(sw);
 }
 
+static inline void workqueue_exit_worker(struct submit_worker *sw)
+{
+       struct workqueue *wq = sw->wq;
+
+       if (!wq->ops.exit_worker_fn)
+               return;
+
+       wq->ops.exit_worker_fn(sw);
+}
 #endif