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;
48 nd->events += nd->queued;
53 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
55 struct null_data *nd = td->io_ops->data;
57 if (td->io_ops->flags & FIO_SYNCIO)
58 return FIO_Q_COMPLETED;
60 nd->io_us[nd->queued++] = io_u;
64 static int fio_null_setup(struct thread_data *td)
70 log_err("fio: need size= set\n");
74 td->io_size = td->o.size;
75 td->total_io_size = td->io_size;
77 for_each_file(td, f, i) {
78 f->real_file_size = td->total_io_size / td->o.nr_files;
79 f->file_size = f->real_file_size;
85 static int fio_null_open(struct thread_data fio_unused *td,
86 struct fio_file fio_unused *f)
92 static void fio_null_cleanup(struct thread_data *td)
94 struct null_data *nd = td->io_ops->data;
100 td->io_ops->data = NULL;
104 static int fio_null_init(struct thread_data *td)
106 struct null_data *nd = malloc(sizeof(*nd));
108 memset(nd, 0, sizeof(*nd));
110 if (td->o.iodepth != 1) {
111 nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
112 memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
114 td->io_ops->flags |= FIO_SYNCIO;
116 td->io_ops->data = nd;
120 static struct ioengine_ops ioengine = {
122 .version = FIO_IOOPS_VERSION,
123 .setup = fio_null_setup,
124 .queue = fio_null_queue,
125 .commit = fio_null_commit,
126 .getevents = fio_null_getevents,
127 .event = fio_null_event,
128 .init = fio_null_init,
129 .cleanup = fio_null_cleanup,
130 .open_file = fio_null_open,
131 .flags = FIO_DISKLESSIO,
134 static void fio_init fio_null_register(void)
136 register_ioengine(&ioengine);
139 static void fio_exit fio_null_unregister(void)
141 unregister_ioengine(&ioengine);