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 min_events,
28 int fio_unused max, struct timespec fio_unused *t)
30 struct null_data *nd = td->io_ops->data;
41 static int fio_null_commit(struct thread_data *td)
43 struct null_data *nd = td->io_ops->data;
45 nd->events += nd->queued;
50 static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
52 struct null_data *nd = td->io_ops->data;
54 if (td->io_ops->flags & FIO_SYNCIO)
55 return FIO_Q_COMPLETED;
57 nd->io_us[nd->queued++] = io_u;
61 static int fio_null_setup(struct thread_data *td)
66 if (!td->total_file_size) {
67 log_err("fio: need size= set\n");
71 td->io_size = td->total_file_size;
72 td->total_io_size = td->io_size;
74 for_each_file(td, f, i) {
75 f->real_file_size = td->total_io_size / td->nr_files;
76 f->file_size = f->real_file_size;
82 static int fio_null_open(struct thread_data fio_unused *td,
83 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->iodepth != 1) {
108 nd->io_us = malloc(td->iodepth * sizeof(struct io_u *));
109 memset(nd->io_us, 0, td->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);