#include <errno.h>
#include <assert.h>
#include <time.h>
+#include <string.h>
#include <sys/mman.h>
#include <sys/poll.h>
#include "fio.h"
#include "os.h"
-#ifdef FIO_HAVE_LIBAIO
-
-#define ev_to_iou(ev) (struct io_u *) ((unsigned long) (ev)->obj)
-
-static int fio_io_sync(struct thread_data *td)
-{
- return fsync(td->fd);
-}
-
static int fill_timespec(struct timespec *ts)
{
#ifdef _POSIX_TIMERS
return sec + nsec;
}
+static int fio_io_sync(struct thread_data *td)
+{
+ return fsync(td->fd);
+}
+
+#ifdef FIO_HAVE_LIBAIO
+
+#define ev_to_iou(ev) (struct io_u *) ((unsigned long) (ev)->obj)
+
struct libaio_data {
io_context_t aio_ctx;
struct io_event *aio_events;
struct timespec *t)
{
struct libaio_data *ld = td->io_data;
- int r;
+ long r;
do {
r = io_getevents(ld->aio_ctx, min, max, ld->aio_events, t);
break;
} while (1);
- return r;
+ return (int) r;
}
static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
{
struct libaio_data *ld = td->io_data;
struct iocb *iocb = &io_u->iocb;
- int ret;
+ long ret;
do {
ret = io_submit(ld->aio_ctx, 1, &iocb);
break;
} while (1);
- return ret;
+ return (int) ret;
}
if ((unsigned int) ret != io_u->buflen) {
if (ret > 0) {
io_u->resid = io_u->buflen - ret;
- io_u->error = ENODATA;
+ io_u->error = EIO;
} else
io_u->error = errno;
}
int nr_blocks, lba;
if (io_u->buflen & (sd->bs - 1)) {
- fprintf(stderr, "read/write not sector aligned\n");
+ log_err("read/write not sector aligned\n");
return EINVAL;
}
if (ret)
return ret;
} else {
- fprintf(stderr, "ioengine sgio only works on block devices\n");
+ log_err("ioengine sgio only works on block devices\n");
return 1;
}