Skip to content

Commit

Permalink
io_u_queue: convert rings to bool
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Nov 2, 2017
1 parent 52db2da commit 34851ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions io_u_queue.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#include <stdlib.h>
#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)
{
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)) {
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions io_u_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define FIO_IO_U_QUEUE

#include <assert.h>
#include "lib/types.h"

struct io_u;

Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 34851ad

Please sign in to comment.