2 * regular read/write sync io engine
15 struct io_u *last_io_u;
18 static int fio_syncio_getevents(struct thread_data *td, int fio_unused min,
19 int max, struct timespec fio_unused *t)
24 * we can only have one finished io_u for sync io, since the depth
27 if (list_empty(&td->io_u_busylist))
33 static struct io_u *fio_syncio_event(struct thread_data *td, int event)
35 struct syncio_data *sd = td->io_ops->data;
42 static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
44 struct fio_file *f = io_u->file;
46 if (io_u->ddir == DDIR_SYNC)
49 if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
57 static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
59 struct syncio_data *sd = td->io_ops->data;
60 struct fio_file *f = io_u->file;
63 if (io_u->ddir == DDIR_READ)
64 ret = read(f->fd, io_u->buf, io_u->buflen);
65 else if (io_u->ddir == DDIR_WRITE)
66 ret = write(f->fd, io_u->buf, io_u->buflen);
70 if (ret != io_u->buflen) {
72 io_u->resid = io_u->buflen - ret;
84 static void fio_syncio_cleanup(struct thread_data *td)
86 if (td->io_ops->data) {
87 free(td->io_ops->data);
88 td->io_ops->data = NULL;
92 static int fio_syncio_init(struct thread_data *td)
94 struct syncio_data *sd = malloc(sizeof(*sd));
97 td->io_ops->data = sd;
101 static struct ioengine_ops ioengine = {
103 .version = FIO_IOOPS_VERSION,
104 .init = fio_syncio_init,
105 .prep = fio_syncio_prep,
106 .queue = fio_syncio_queue,
107 .getevents = fio_syncio_getevents,
108 .event = fio_syncio_event,
109 .cleanup = fio_syncio_cleanup,
113 static void fio_init fio_syncio_register(void)
115 register_ioengine(&ioengine);
118 static void fio_exit fio_syncio_unregister(void)
120 unregister_ioengine(&ioengine);