From 34851ad5ffacf9f4f8a7f23ee2edb17281b917a0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 2 Nov 2017 12:26:39 -0600 Subject: [PATCH] io_u_queue: convert rings to bool Signed-off-by: Jens Axboe --- backend.c | 6 +++--- io_u_queue.c | 12 ++++++------ io_u_queue.h | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/backend.c b/backend.c index d3e9bf8160..7cf9b38270 100644 --- a/backend.c +++ b/backend.c @@ -1203,9 +1203,9 @@ static int init_io_u(struct thread_data *td) data_xfer = 0; err = 0; - err += io_u_rinit(&td->io_u_requeues, td->o.iodepth); - err += io_u_qinit(&td->io_u_freelist, td->o.iodepth); - err += io_u_qinit(&td->io_u_all, td->o.iodepth); + err += !io_u_rinit(&td->io_u_requeues, td->o.iodepth); + err += !io_u_qinit(&td->io_u_freelist, td->o.iodepth); + err += !io_u_qinit(&td->io_u_all, td->o.iodepth); if (err) { log_err("fio: failed setting up IO queues\n"); diff --git a/io_u_queue.c b/io_u_queue.c index 9994c7879a..8cf4c8c3d7 100644 --- a/io_u_queue.c +++ b/io_u_queue.c @@ -1,15 +1,15 @@ #include #include "io_u_queue.h" -int io_u_qinit(struct io_u_queue *q, unsigned int nr) +bool io_u_qinit(struct io_u_queue *q, unsigned int nr) { q->io_us = calloc(nr, sizeof(struct io_u *)); if (!q->io_us) - return 1; + return false; q->nr = 0; q->max = nr; - return 0; + return true; } void io_u_qexit(struct io_u_queue *q) @@ -17,7 +17,7 @@ void io_u_qexit(struct io_u_queue *q) free(q->io_us); } -int io_u_rinit(struct io_u_ring *ring, unsigned int nr) +bool io_u_rinit(struct io_u_ring *ring, unsigned int nr) { ring->max = nr + 1; if (ring->max & (ring->max - 1)) { @@ -32,10 +32,10 @@ int io_u_rinit(struct io_u_ring *ring, unsigned int nr) ring->ring = calloc(ring->max, sizeof(struct io_u *)); if (!ring->ring) - return 1; + return false; ring->head = ring->tail = 0; - return 0; + return true; } void io_u_rexit(struct io_u_ring *ring) diff --git a/io_u_queue.h b/io_u_queue.h index 118e59342b..b5b8d2faf3 100644 --- a/io_u_queue.h +++ b/io_u_queue.h @@ -2,6 +2,7 @@ #define FIO_IO_U_QUEUE #include +#include "lib/types.h" struct io_u; @@ -42,7 +43,7 @@ static inline int io_u_qempty(const struct io_u_queue *q) #define io_u_qiter(q, io_u, i) \ for (i = 0; i < (q)->nr && (io_u = (q)->io_us[i]); i++) -int io_u_qinit(struct io_u_queue *q, unsigned int nr); +bool io_u_qinit(struct io_u_queue *q, unsigned int nr); void io_u_qexit(struct io_u_queue *q); struct io_u_ring { @@ -52,7 +53,7 @@ struct io_u_ring { struct io_u **ring; }; -int io_u_rinit(struct io_u_ring *ring, unsigned int nr); +bool io_u_rinit(struct io_u_ring *ring, unsigned int nr); void io_u_rexit(struct io_u_ring *ring); static inline void io_u_rpush(struct io_u_ring *r, struct io_u *io_u)