[PATCH] Enable output logging to file instead of stdout
[fio.git] / ioengines.c
index 7b1c1bd3a3360e9feadd4def4eb8c90bd83111aa..c94fcb30c23b87ccea185b88c642081864017111 100644 (file)
 #include <errno.h>
 #include <assert.h>
 #include <time.h>
 #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"
 
 #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
 static int fill_timespec(struct timespec *ts)
 {
 #ifdef _POSIX_TIMERS
@@ -60,6 +52,15 @@ static unsigned long long ts_utime_since_now(struct timespec *t)
        return sec + nsec;
 }
 
        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 libaio_data {
        io_context_t aio_ctx;
        struct io_event *aio_events;
@@ -374,7 +375,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
        if ((unsigned int) ret != io_u->buflen) {
                if (ret > 0) {
                        io_u->resid = io_u->buflen - 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;
        }
                } else
                        io_u->error = errno;
        }
@@ -609,7 +610,7 @@ static int fio_sgio_prep(struct thread_data *td, struct io_u *io_u)
        int nr_blocks, lba;
 
        if (io_u->buflen & (sd->bs - 1)) {
        int nr_blocks, lba;
 
        if (io_u->buflen & (sd->bs - 1)) {
-               fprintf(stderr, "read/write not sector aligned\n");
+               fprintf(f_err, "read/write not sector aligned\n");
                return EINVAL;
        }
 
                return EINVAL;
        }
 
@@ -717,7 +718,7 @@ int fio_sgio_init(struct thread_data *td)
                if (ret)
                        return ret;
        } else {
                if (ret)
                        return ret;
        } else {
-               fprintf(stderr, "ioengine sgio only works on block devices\n");
+               fprintf(f_err, "ioengine sgio only works on block devices\n");
                return 1;
        }
 
                return 1;
        }