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 io_u_mark_submit(td, nd->queued);
50 nd->events = nd->queued;
57 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
59 struct null_data *nd = td->io_ops->data;
61 fio_ro_check(td, io_u);
63 if (td->io_ops->flags & FIO_SYNCIO)
64 return FIO_Q_COMPLETED;
68 nd->io_us[nd->queued++] = io_u;
72 static int fio_null_open(struct thread_data fio_unused *td,
73 struct fio_file fio_unused *f)
78 static void fio_null_cleanup(struct thread_data *td)
80 struct null_data *nd = td->io_ops->data;
86 td->io_ops->data = NULL;
90 static int fio_null_init(struct thread_data *td)
92 struct null_data *nd = malloc(sizeof(*nd));
94 memset(nd, 0, sizeof(*nd));
96 if (td->o.iodepth != 1) {
97 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
98 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
100 td->io_ops->flags |= FIO_SYNCIO;
102 td->io_ops->data = nd;
106 static struct ioengine_ops ioengine = {
108 .version = FIO_IOOPS_VERSION,
109 .queue = fio_null_queue,
110 .commit = fio_null_commit,
111 .getevents = fio_null_getevents,
112 .event = fio_null_event,
113 .init = fio_null_init,
114 .cleanup = fio_null_cleanup,
115 .open_file = fio_null_open,
116 .flags = FIO_DISKLESSIO,
119 static void fio_init fio_null_register(void)
121 register_ioengine(&ioengine);
124 static void fio_exit fio_null_unregister(void)
126 unregister_ioengine(&ioengine);