4 * IO engine that doesn't do any real IO transfers, it just pretends to.
5 * The main purpose is to test fio itself.
22 static struct io_u *fio_null_event(struct thread_data *td, int event)
24 struct null_data *nd = td->io_ops->data;
26 return nd->io_us[event];
29 static int fio_null_getevents(struct thread_data *td, unsigned int min_events,
30 unsigned int fio_unused max,
31 struct timespec fio_unused *t)
33 struct null_data *nd = td->io_ops->data;
44 static int fio_null_commit(struct thread_data *td)
46 struct null_data *nd = td->io_ops->data;
49 nd->events = nd->queued;
56 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
58 struct null_data *nd = td->io_ops->data;
60 fio_ro_check(td, io_u);
62 if (td->io_ops->flags & FIO_SYNCIO)
63 return FIO_Q_COMPLETED;
67 nd->io_us[nd->queued++] = io_u;
71 static int fio_null_open(struct thread_data fio_unused *td,
72 struct fio_file fio_unused *f)
77 static void fio_null_cleanup(struct thread_data *td)
79 struct null_data *nd = td->io_ops->data;
85 td->io_ops->data = NULL;
89 static int fio_null_init(struct thread_data *td)
91 struct null_data *nd = malloc(sizeof(*nd));
93 memset(nd, 0, sizeof(*nd));
95 if (td->o.iodepth != 1) {
96 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
97 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
99 td->io_ops->flags |= FIO_SYNCIO;
101 td->io_ops->data = nd;
105 static struct ioengine_ops ioengine = {
107 .version = FIO_IOOPS_VERSION,
108 .queue = fio_null_queue,
109 .commit = fio_null_commit,
110 .getevents = fio_null_getevents,
111 .event = fio_null_event,
112 .init = fio_null_init,
113 .cleanup = fio_null_cleanup,
114 .open_file = fio_null_open,
115 .flags = FIO_DISKLESSIO,
118 static void fio_init fio_null_register(void)
120 register_ioengine(&ioengine);
123 static void fio_exit fio_null_unregister(void)
125 unregister_ioengine(&ioengine);