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) {
75 f->real_file_size = td->o.size / td->o.nr_files;
77 f->real_file_size = -1ULL;
83 static int fio_null_open(struct thread_data fio_unused *td,
84 struct fio_file fio_unused *f)
89 static void fio_null_cleanup(struct thread_data *td)
91 struct null_data *nd = td->io_ops->data;
97 td->io_ops->data = NULL;
101 static int fio_null_init(struct thread_data *td)
103 struct null_data *nd = malloc(sizeof(*nd));
105 memset(nd, 0, sizeof(*nd));
107 if (td->o.iodepth != 1) {
108 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
109 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
111 td->io_ops->flags |= FIO_SYNCIO;
113 td->io_ops->data = nd;
117 static struct ioengine_ops ioengine = {
119 .version = FIO_IOOPS_VERSION,
120 .setup = fio_null_setup,
121 .queue = fio_null_queue,
122 .commit = fio_null_commit,
123 .getevents = fio_null_getevents,
124 .event = fio_null_event,
125 .init = fio_null_init,
126 .cleanup = fio_null_cleanup,
127 .open_file = fio_null_open,
128 .flags = FIO_DISKLESSIO,
131 static void fio_init fio_null_register(void)
133 register_ioengine(&ioengine);
136 static void fio_exit fio_null_unregister(void)
138 unregister_ioengine(&ioengine);