X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fsync.c;h=597ee0127a39d1a5d30f0609d366b3fb5d9230e7;hb=53aec0a4d0e0a9b3163c5ca651b9e4636ff7e1ec;hp=6a5b7d391ed206a465f8b2d1cbd7fcf550305c8f;hpb=36167d82e5f49dee91c6d2cd426068edee90e36f;p=fio.git diff --git a/engines/sync.c b/engines/sync.c index 6a5b7d39..597ee012 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -1,5 +1,8 @@ /* - * regular read/write sync io engine + * sync engine + * + * IO engine that does regular read(2)/write(2) with lseek(2) to transfer + * data. * */ #include @@ -9,7 +12,6 @@ #include #include "../fio.h" -#include "../os.h" static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) { @@ -21,7 +23,7 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) return 0; if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) { - td_verror(td, errno); + td_verror(td, errno, "lseek"); return 1; } @@ -33,6 +35,8 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u) struct fio_file *f = io_u->file; int ret; + fio_ro_check(td, io_u); + if (io_u->ddir == DDIR_READ) ret = read(f->fd, io_u->xfer_buf, io_u->xfer_buflen); else if (io_u->ddir == DDIR_WRITE) @@ -41,7 +45,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u) ret = fsync(f->fd); if (ret != (int) io_u->xfer_buflen) { - if (ret > 0) { + if (ret >= 0) { io_u->resid = io_u->xfer_buflen - ret; io_u->error = 0; return FIO_Q_COMPLETED; @@ -50,7 +54,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u) } if (io_u->error) - td_verror(td, io_u->error); + td_verror(td, io_u->error, "xfer"); return FIO_Q_COMPLETED; } @@ -60,6 +64,8 @@ static struct ioengine_ops ioengine = { .version = FIO_IOOPS_VERSION, .prep = fio_syncio_prep, .queue = fio_syncio_queue, + .open_file = generic_open_file, + .close_file = generic_close_file, .flags = FIO_SYNCIO, };