X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Ffio-engine-sync.c;h=43f42ca2ffcace7068656a0ebd4453453af69d7b;hp=1806d4dfda01f9157511f4fba66f430c215e1d7b;hb=cb781c758e5df7ff4c6f655c1e4f9df3043a4be9;hpb=53cdc6864f7471b28cc9b40a5314ab43e5b1cb5e;ds=sidebyside diff --git a/engines/fio-engine-sync.c b/engines/fio-engine-sync.c index 1806d4df..43f42ca2 100644 --- a/engines/fio-engine-sync.c +++ b/engines/fio-engine-sync.c @@ -14,11 +14,6 @@ struct syncio_data { struct io_u *last_io_u; }; -static int fio_syncio_sync(struct thread_data *td, struct fio_file *f) -{ - return fsync(f->fd); -} - static int fio_syncio_getevents(struct thread_data *td, int fio_unused min, int max, struct timespec fio_unused *t) { @@ -47,6 +42,9 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) { struct fio_file *f = io_u->file; + if (io_u->ddir == DDIR_SYNC) + return 0; + if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) { td_verror(td, errno); return 1; @@ -59,14 +57,16 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u) { struct syncio_data *sd = td->io_ops->data; struct fio_file *f = io_u->file; - int ret; + unsigned int ret; if (io_u->ddir == DDIR_READ) ret = read(f->fd, io_u->buf, io_u->buflen); - else + else if (io_u->ddir == DDIR_WRITE) ret = write(f->fd, io_u->buf, io_u->buflen); + else + ret = fsync(f->fd); - if ((unsigned int) ret != io_u->buflen) { + if (ret != io_u->buflen) { if (ret > 0) { io_u->resid = io_u->buflen - ret; io_u->error = EIO; @@ -106,6 +106,5 @@ struct ioengine_ops ioengine = { .getevents = fio_syncio_getevents, .event = fio_syncio_event, .cleanup = fio_syncio_cleanup, - .sync = fio_syncio_sync, .flags = FIO_SYNCIO, };