X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Ffio-engine-sync.c;h=5919830edcc6cf0a4fe91e57d20fbabad6e7d4bc;hp=d5be4c8256ecda8415cbe438883d141758acfda7;hb=5f350952eff89948bfbf1eb6ac4d3d08a9109581;hpb=7313b48c3196b4750f4103e8622126039e2231c6 diff --git a/engines/fio-engine-sync.c b/engines/fio-engine-sync.c index d5be4c82..5919830e 100644 --- a/engines/fio-engine-sync.c +++ b/engines/fio-engine-sync.c @@ -7,19 +7,14 @@ #include #include #include -#include "fio.h" -#include "os.h" + +#include "../fio.h" +#include "../os.h" struct syncio_data { struct io_u *last_io_u; }; -static int fio_syncio_sync(struct thread_data fio_unused *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) { @@ -48,6 +43,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; @@ -60,14 +58,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; @@ -98,7 +98,7 @@ static int fio_syncio_init(struct thread_data *td) return 0; } -struct ioengine_ops ioengine = { +static struct ioengine_ops ioengine = { .name = "sync", .version = FIO_IOOPS_VERSION, .init = fio_syncio_init, @@ -107,6 +107,15 @@ struct ioengine_ops ioengine = { .getevents = fio_syncio_getevents, .event = fio_syncio_event, .cleanup = fio_syncio_cleanup, - .sync = fio_syncio_sync, .flags = FIO_SYNCIO, }; + +static void fio_init fio_syncio_register(void) +{ + register_ioengine(&ioengine); +} + +static void fio_exit fio_syncio_unregister(void) +{ + unregister_ioengine(&ioengine); +}