2 * null engine - doesn't do any transfers. Used to test fio.
20 static struct io_u *fio_null_event(struct thread_data *td, int event)
22 struct null_data *nd = td->io_ops->data;
24 return nd->io_us[event];
27 static int fio_null_getevents(struct thread_data *td, int fio_unused min,
28 int fio_unused max, struct timespec fio_unused *t)
30 struct null_data *nd = td->io_ops->data;
38 static int fio_null_commit(struct thread_data *td)
40 struct null_data *nd = td->io_ops->data;
42 nd->events = nd->queued;
47 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
49 struct null_data *nd = td->io_ops->data;
51 if (td->io_ops->flags & FIO_SYNCIO)
52 return FIO_Q_COMPLETED;
54 nd->io_us[nd->queued++] = io_u;
58 static int fio_null_setup(struct thread_data *td)
63 if (!td->total_file_size) {
64 log_err("fio: need size= set\n");
68 td->io_size = td->total_file_size;
69 td->total_io_size = td->io_size;
71 for_each_file(td, f, i) {
72 f->real_file_size = td->total_io_size / td->nr_files;
73 f->file_size = f->real_file_size;
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->iodepth != 1) {
105 nd->io_us = malloc(td->iodepth * sizeof(struct io_u *));
106 memset(nd->io_us, 0, td->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);