[PATCH] Basic support for a cpu cycle eater job
[fio.git] / ioengines.c
index b086b60c9d3e156c4c9781b6e3f868577285f37b..01492bcf5645434bac6dee82f3c89a1dcf6d9b06 100644 (file)
@@ -87,7 +87,7 @@ static int fio_libaio_getevents(struct thread_data *td, int min, int max,
                                struct timespec *t)
 {
        struct libaio_data *ld = td->io_data;
                                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);
 
        do {
                r = io_getevents(ld->aio_ctx, min, max, ld->aio_events, t);
@@ -100,14 +100,14 @@ static int fio_libaio_getevents(struct thread_data *td, int min, int max,
                        break;
        } while (1);
 
                        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;
 }
 
 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);
 
        do {
                ret = io_submit(ld->aio_ctx, 1, &iocb);
@@ -121,7 +121,7 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
                        break;
        } while (1);
 
                        break;
        } while (1);
 
-       return ret;
+       return (int) ret;
 
 }
 
 
 }
 
@@ -610,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");
+               log_err("read/write not sector aligned\n");
                return EINVAL;
        }
 
                return EINVAL;
        }
 
@@ -718,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");
+               log_err("ioengine sgio only works on block devices\n");
                return 1;
        }
 
                return 1;
        }
 
@@ -918,3 +918,17 @@ int fio_spliceio_init(struct thread_data *td)
 }
 
 #endif /* FIO_HAVE_SPLICE */
 }
 
 #endif /* FIO_HAVE_SPLICE */
+
+int fio_cpuio_init(struct thread_data *td)
+{
+       if (!td->cpuload) {
+               td_vmsg(td, EINVAL, "cpu thread needs rate");
+               return 1;
+       } else if (td->cpuload > 100)
+               td->cpuload = 100;
+
+       td->read_iolog = td->write_iolog = 0;
+       td->fd = -1;
+
+       return 0;
+}