2 * regular read/write sync io engine
14 struct io_u *last_io_u;
17 static int fio_syncio_sync(struct thread_data fio_unused *td,
23 static int fio_syncio_getevents(struct thread_data *td, int fio_unused min,
24 int max, struct timespec fio_unused *t)
29 * we can only have one finished io_u for sync io, since the depth
32 if (list_empty(&td->io_u_busylist))
38 static struct io_u *fio_syncio_event(struct thread_data *td, int event)
40 struct syncio_data *sd = td->io_ops->data;
47 static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
49 struct fio_file *f = io_u->file;
51 if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
59 static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
61 struct syncio_data *sd = td->io_ops->data;
62 struct fio_file *f = io_u->file;
65 if (io_u->ddir == DDIR_READ)
66 ret = read(f->fd, io_u->buf, io_u->buflen);
68 ret = write(f->fd, io_u->buf, io_u->buflen);
70 if ((unsigned int) 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 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,
110 .sync = fio_syncio_sync,