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 if (td->io_ops->flags & FIO_SYNCIO)
60 return FIO_Q_COMPLETED;
64 nd->io_us[nd->queued++] = io_u;
68 static int fio_null_setup(struct thread_data *td)
73 for_each_file(td, f, i)
74 f->real_file_size = -1ULL;
79 static int fio_null_open(struct thread_data fio_unused *td,
80 struct fio_file fio_unused *f)
86 static void fio_null_cleanup(struct thread_data *td)
88 struct null_data *nd = td->io_ops->data;
94 td->io_ops->data = NULL;
98 static int fio_null_init(struct thread_data *td)
100 struct null_data *nd = malloc(sizeof(*nd));
102 memset(nd, 0, sizeof(*nd));
104 if (td->o.iodepth != 1) {
105 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
106 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
108 td->io_ops->flags |= FIO_SYNCIO;
110 td->io_ops->data = nd;
114 static struct ioengine_ops ioengine = {
116 .version = FIO_IOOPS_VERSION,
117 .setup = fio_null_setup,
118 .queue = fio_null_queue,
119 .commit = fio_null_commit,
120 .getevents = fio_null_getevents,
121 .event = fio_null_event,
122 .init = fio_null_init,
123 .cleanup = fio_null_cleanup,
124 .open_file = fio_null_open,
125 .flags = FIO_DISKLESSIO,
128 static void fio_init fio_null_register(void)
130 register_ioengine(&ioengine);
133 static void fio_exit fio_null_unregister(void)
135 unregister_ioengine(&ioengine);