[PATCH] Make fio build again on "crippled" platforms
[fio.git] / engines / fio-engine-libaio.c
index 5e394e3e477f0961ad65c8f65a619b1151c30ee6..c0f280b51ed447e1d125f2ee4c2806ffbd10c87b 100644 (file)
@@ -10,6 +10,8 @@
 #include "fio.h"
 #include "os.h"
 
+#ifdef FIO_HAVE_LIBAIO
+
 #define ev_to_iou(ev)  (struct io_u *) ((unsigned long) (ev)->obj)
 
 struct libaio_data {
@@ -57,7 +59,10 @@ static int fio_libaio_getevents(struct thread_data *td, int min, int max,
                        break;
        } while (1);
 
-       return (int) -r;
+       if (r < 0)
+               r = -r;
+
+       return (int) r;
 }
 
 static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
@@ -78,9 +83,13 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
                        break;
        } while (1);
 
-       assert(ret);
+       if (ret <= 0) {
+               io_u->resid = io_u->buflen;
+               io_u->error = -ret;
+               return 1;
+       }
 
-       return (int) -ret;
+       return 0;
 }
 
 static int fio_libaio_cancel(struct thread_data *td, struct io_u *io_u)
@@ -131,3 +140,24 @@ struct ioengine_ops ioengine = {
        .event          = fio_libaio_event,
        .cleanup        = fio_libaio_cleanup,
 };
+
+#else /* FIO_HAVE_LIBAIO */
+
+/*
+ * When we have a proper configure system in place, we simply wont build
+ * and install this io engine. For now install a crippled version that
+ * just complains and fails to load.
+ */
+static int fio_libaio_init(struct thread_data fio_unused *td)
+{
+       fprintf(stderr, "fio: libaio not available\n");
+       return 1;
+}
+
+struct ioengine_ops ioengine = {
+       .name           = "libaio",
+       .version        = FIO_IOOPS_VERSION,
+       .init           = fio_libaio_init,
+};
+
+#endif