2 * regular read/write sync io engine
14 struct io_u *last_io_u;
17 static int fio_syncio_getevents(struct thread_data *td, int fio_unused min,
18 int max, struct timespec fio_unused *t)
23 * we can only have one finished io_u for sync io, since the depth
26 if (list_empty(&td->io_u_busylist))
32 static struct io_u *fio_syncio_event(struct thread_data *td, int event)
34 struct syncio_data *sd = td->io_ops->data;
41 static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
43 struct fio_file *f = io_u->file;
45 if (io_u->ddir == DDIR_SYNC)
48 if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
56 static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
58 struct syncio_data *sd = td->io_ops->data;
59 struct fio_file *f = io_u->file;
62 if (io_u->ddir == DDIR_READ)
63 ret = read(f->fd, io_u->buf, io_u->buflen);
64 else if (io_u->ddir == DDIR_WRITE)
65 ret = write(f->fd, io_u->buf, io_u->buflen);
69 if (ret != io_u->buflen) {
71 io_u->resid = io_u->buflen - ret;
83 static void fio_syncio_cleanup(struct thread_data *td)
85 if (td->io_ops->data) {
86 free(td->io_ops->data);
87 td->io_ops->data = NULL;
91 static int fio_syncio_init(struct thread_data *td)
93 struct syncio_data *sd = malloc(sizeof(*sd));
96 td->io_ops->data = sd;
100 struct ioengine_ops ioengine = {
102 .version = FIO_IOOPS_VERSION,
103 .init = fio_syncio_init,
104 .prep = fio_syncio_prep,
105 .queue = fio_syncio_queue,
106 .getevents = fio_syncio_getevents,
107 .event = fio_syncio_event,
108 .cleanup = fio_syncio_cleanup,