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, int min_events,
30 int fio_unused max, struct timespec fio_unused *t)
32 struct null_data *nd = td->io_ops->data;
43 static int fio_null_commit(struct thread_data *td)
45 struct null_data *nd = td->io_ops->data;
48 nd->events = nd->queued;
55 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
57 struct null_data *nd = td->io_ops->data;
59 fio_ro_check(td, io_u);
61 if (td->io_ops->flags & FIO_SYNCIO)
62 return FIO_Q_COMPLETED;
66 nd->io_us[nd->queued++] = io_u;
70 static int fio_null_open(struct thread_data fio_unused *td,
71 struct fio_file fio_unused *f)
76 static void fio_null_cleanup(struct thread_data *td)
78 struct null_data *nd = td->io_ops->data;
84 td->io_ops->data = NULL;
88 static int fio_null_init(struct thread_data *td)
90 struct null_data *nd = malloc(sizeof(*nd));
92 memset(nd, 0, sizeof(*nd));
94 if (td->o.iodepth != 1) {
95 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
96 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
98 td->io_ops->flags |= FIO_SYNCIO;
100 td->io_ops->data = nd;
104 static struct ioengine_ops ioengine = {
106 .version = FIO_IOOPS_VERSION,
107 .queue = fio_null_queue,
108 .commit = fio_null_commit,
109 .getevents = fio_null_getevents,
110 .event = fio_null_event,
111 .init = fio_null_init,
112 .cleanup = fio_null_cleanup,
113 .open_file = fio_null_open,
114 .flags = FIO_DISKLESSIO,
117 static void fio_init fio_null_register(void)
119 register_ioengine(&ioengine);
122 static void fio_exit fio_null_unregister(void)
124 unregister_ioengine(&ioengine);