2 * regular read/write sync io engine
14 static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u)
16 struct fio_file *f = io_u->file;
18 if (io_u->ddir == DDIR_SYNC)
20 if (io_u->offset == f->last_completed_pos)
23 if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
24 td_verror(td, errno, "lseek");
31 static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
33 struct fio_file *f = io_u->file;
36 if (io_u->ddir == DDIR_READ)
37 ret = read(f->fd, io_u->xfer_buf, io_u->xfer_buflen);
38 else if (io_u->ddir == DDIR_WRITE)
39 ret = write(f->fd, io_u->xfer_buf, io_u->xfer_buflen);
43 if (ret != (int) io_u->xfer_buflen) {
45 io_u->resid = io_u->xfer_buflen - ret;
47 return FIO_Q_COMPLETED;
53 td_verror(td, io_u->error, "xfer");
55 return FIO_Q_COMPLETED;
58 static struct ioengine_ops ioengine = {
60 .version = FIO_IOOPS_VERSION,
61 .prep = fio_syncio_prep,
62 .queue = fio_syncio_queue,
66 static void fio_init fio_syncio_register(void)
68 register_ioengine(&ioengine);
71 static void fio_exit fio_syncio_unregister(void)
73 unregister_ioengine(&ioengine);