2 * regular read/write sync io engine
14 struct io_u *last_io_u;
17 static int fio_syncio_sync(struct thread_data *td)
22 static int fio_syncio_getevents(struct thread_data *td, int fio_unused min,
23 int max, struct timespec fio_unused *t)
28 * we can only have one finished io_u for sync io, since the depth
31 if (list_empty(&td->io_u_busylist))
37 static struct io_u *fio_syncio_event(struct thread_data *td, int event)
39 struct syncio_data *sd = td->io_ops->data;
46 static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
48 if (lseek(td->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;
61 if (io_u->ddir == DDIR_READ)
62 ret = read(td->fd, io_u->buf, io_u->buflen);
64 ret = write(td->fd, io_u->buf, io_u->buflen);
66 if ((unsigned int) ret != io_u->buflen) {
68 io_u->resid = io_u->buflen - ret;
80 static void fio_syncio_cleanup(struct thread_data *td)
82 if (td->io_ops->data) {
83 free(td->io_ops->data);
84 td->io_ops->data = NULL;
88 static int fio_syncio_init(struct thread_data *td)
90 struct syncio_data *sd = malloc(sizeof(*sd));
93 td->io_ops->data = sd;
97 struct ioengine_ops ioengine = {
99 .version = FIO_IOOPS_VERSION,
100 .init = fio_syncio_init,
101 .prep = fio_syncio_prep,
102 .queue = fio_syncio_queue,
103 .getevents = fio_syncio_getevents,
104 .event = fio_syncio_event,
105 .cleanup = fio_syncio_cleanup,
106 .sync = fio_syncio_sync,