-static void io_workqueue_fn(struct thread_data *td, struct workqueue_work *work)
-{
- struct io_u *io_u = container_of(work, struct io_u, work);
- const enum fio_ddir ddir = io_u->ddir;
- int ret;
-
- dprint(FD_RATE, "io_u %p queued by %u\n", io_u, gettid());
-
- io_u_set(io_u, IO_U_F_NO_FILE_PUT);
-
- td->cur_depth++;
-
- do {
- ret = td_io_queue(td, io_u);
- if (ret != FIO_Q_BUSY)
- break;
- ret = io_u_queued_complete(td, 1);
- if (ret > 0)
- td->cur_depth -= ret;
- io_u_clear(io_u, IO_U_F_FLIGHT);
- } while (1);
-
- dprint(FD_RATE, "io_u %p ret %d by %u\n", io_u, ret, gettid());
-
- io_queue_event(td, io_u, &ret, ddir, NULL, 0, NULL);
-
- if (ret == FIO_Q_COMPLETED)
- td->cur_depth--;
- else if (ret == FIO_Q_QUEUED) {
- unsigned int min_evts;
-
- if (td->o.iodepth == 1)
- min_evts = 1;
- else
- min_evts = 0;
-
- ret = io_u_queued_complete(td, min_evts);
- if (ret > 0)
- td->cur_depth -= ret;
- } else if (ret == FIO_Q_BUSY) {
- ret = io_u_queued_complete(td, td->cur_depth);
- if (ret > 0)
- td->cur_depth -= ret;
- }
-}
-
-static bool io_workqueue_pre_sleep_flush_fn(struct thread_data *td)
-{
- if (td->io_u_queued || td->cur_depth || td->io_u_in_flight)
- return true;
-
- return false;
-}
-
-static void io_workqueue_pre_sleep_fn(struct thread_data *td)
-{
- int ret;
-
- ret = io_u_quiesce(td);
- if (ret > 0)
- td->cur_depth -= ret;
-}
-
-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,