4 * IO engine that doesn't do any real IO transfers, it just pretends to.
5 * The main purpose is to test fio itself.
23 static struct io_u *fio_null_event(struct thread_data *td, int event)
25 struct null_data *nd = td->io_ops->data;
27 return nd->io_us[event];
30 static int fio_null_getevents(struct thread_data *td, int min_events,
31 int fio_unused max, 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 if (td->io_ops->flags & FIO_SYNCIO)
61 return FIO_Q_COMPLETED;
65 nd->io_us[nd->queued++] = io_u;
69 static int fio_null_setup(struct thread_data *td)
74 for_each_file(td, f, i)
75 f->real_file_size = -1ULL;
80 static int fio_null_open(struct thread_data fio_unused *td,
81 struct fio_file fio_unused *f)
87 static void fio_null_cleanup(struct thread_data *td)
89 struct null_data *nd = td->io_ops->data;
95 td->io_ops->data = NULL;
99 static int fio_null_init(struct thread_data *td)
101 struct null_data *nd = malloc(sizeof(*nd));
103 memset(nd, 0, sizeof(*nd));
105 if (td->o.iodepth != 1) {
106 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
107 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
109 td->io_ops->flags |= FIO_SYNCIO;
111 td->io_ops->data = nd;
115 static struct ioengine_ops ioengine = {
117 .version = FIO_IOOPS_VERSION,
118 .setup = fio_null_setup,
119 .queue = fio_null_queue,
120 .commit = fio_null_commit,
121 .getevents = fio_null_getevents,
122 .event = fio_null_event,
123 .init = fio_null_init,
124 .cleanup = fio_null_cleanup,
125 .open_file = fio_null_open,
126 .flags = FIO_DISKLESSIO,
129 static void fio_init fio_null_register(void)
131 register_ioengine(&ioengine);
134 static void fio_exit fio_null_unregister(void)
136 unregister_ioengine(&ioengine);