Abstract out generic sync helper
[fio.git] / engines / sync.c
index 12b85f6a65917c8e2fc197bd35c844bd61684b28..5194f0f8799d68bf659a03d7969e3ed3bfc44769 100644 (file)
@@ -76,7 +76,7 @@ static int fio_psyncio_queue(struct thread_data *td, struct io_u *io_u)
        else if (io_u->ddir == DDIR_WRITE)
                ret = pwrite(f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset);
        else
-               ret = fsync(f->fd);
+               ret = do_io_u_sync(td, io_u);
 
        return fio_io_end(td, io_u, ret);
 }
@@ -93,7 +93,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
        else if (io_u->ddir == DDIR_WRITE)
                ret = write(f->fd, io_u->xfer_buf, io_u->xfer_buflen);
        else
-               ret = fsync(f->fd);
+               ret = do_io_u_sync(td, io_u);
 
        return fio_io_end(td, io_u, ret);
 }
@@ -163,22 +163,12 @@ static int fio_vsyncio_queue(struct thread_data *td, struct io_u *io_u)
                 */
                if (sd->queued)
                        return FIO_Q_BUSY;
-               if (io_u->ddir == DDIR_SYNC) {
-                       int ret = fsync(io_u->file->fd);
+               if (ddir_sync(io_u->ddir)) {
+                       int ret = do_io_u_sync(td, io_u);
 
                        return fio_io_end(td, io_u, ret);
-               } else if (io_u->ddir == DDIR_DATASYNC) {
-                       int ret;
-#ifdef FIO_HAVE_FDATASYNC
-                       ret = fdatasync(io_u->file->fd);
-#else
-                       ret = io_u->xfer_buflen;
-                       io_u->error = EINVAL;
-#endif
-                       return fio_io_end(td, io_u, ret);
-                       
                }
-       
+
                sd->queued = 0;
                sd->queued_bytes = 0;
                fio_vsyncio_set_iov(sd, io_u, 0);