while (!flist_empty(&du->slaves)) {
struct disk_util *slave;
- slave = flist_entry(du->slaves.next, struct disk_util, slavelist);
+ slave = flist_first_entry(&du->slaves, struct disk_util, slavelist);
flist_del(&slave->slavelist);
slave->users--;
}
while (!flist_empty(&disk_list)) {
struct disk_util *du;
- du = flist_entry(disk_list.next, struct disk_util, list);
+ du = flist_first_entry(&disk_list, struct disk_util, list);
flist_del(&du->list);
disk_util_free(du);
}
__flist_splice(list, head->prev, head);
}
+static inline void flist_splice_tail_init(struct flist_head *list,
+ struct flist_head *head)
+{
+ if (!flist_empty(list)) {
+ __flist_splice(list, head->prev, head);
+ INIT_FLIST_HEAD(list);
+ }
+}
+
static inline void flist_splice_init(struct flist_head *list,
struct flist_head *head)
{
#define flist_entry(ptr, type, member) \
container_of(ptr, type, member)
+#define flist_first_entry(ptr, type, member) \
+ flist_entry((ptr)->next, type, member)
+
/**
* flist_for_each - iterate over a list
* @pos: the &struct flist_head to use as a loop counter.
static void gfio_client_iolog(struct fio_client *client, struct cmd_iolog_pdu *pdu)
{
- printf("got iolog: name=%s, type=%u, entries=%u\n", pdu->name, pdu->log_type, pdu->nr_samples);
+ printf("got iolog: name=%s, type=%u, entries=%lu\n", pdu->name, pdu->log_type, (unsigned long) pdu->nr_samples);
free(pdu);
}
while (!flist_empty(&gc->o_list)) {
struct gfio_client_options *gco;
- gco = flist_entry(gc->o_list.next, struct gfio_client_options, list);
+ gco = flist_first_entry(&gc->o_list, struct gfio_client_options, list);
flist_del(&gco->list);
free(gco);
}
goto done;
while (!flist_empty(&gjv->changed_list)) {
- gopt = flist_entry(gjv->changed_list.next, struct gopt, changed_list);
+ gopt = flist_first_entry(&gjv->changed_list, struct gopt, changed_list);
flist_del_init(&gopt->changed_list);
}
gjv = calloc(1, sizeof(*gjv));
INIT_FLIST_HEAD(&gjv->changed_list);
- gco = flist_entry(gc->o_list.next, struct gfio_client_options, list);
+ gco = flist_first_entry(&gc->o_list, struct gfio_client_options, list);
gjv->o = &gco->o;
gjv->dialog = dialog;
gjv->client = gc;
*/
while (!(v->flags & GV_F_ON_PRIO)) {
assert(!flist_empty(&v->alias));
- v = flist_entry(v->alias.next, struct graph_value, alias);
+ v = flist_first_entry(&v->alias, struct graph_value, alias);
}
prio_tree_remove(&l->prio_tree, &v->node);
while (!flist_empty(&v->alias)) {
struct graph_value *a;
- a = flist_entry(v->alias.next, struct graph_value, alias);
+ a = flist_first_entry(&v->alias, struct graph_value, alias);
flist_del_init(&a->alias);
__graph_value_drop(l, a);
to_drop = 2;
while (to_drop-- && !flist_empty(&i->value_list)) {
- x = flist_entry(i->value_list.next, struct graph_value, list);
+ x = flist_first_entry(&i->value_list, struct graph_value, list);
graph_value_drop(i, x);
/*
struct graph_value *i;
while (!flist_empty(&l->value_list)) {
- i = flist_entry(l->value_list.next, struct graph_value, list);
+ i = flist_first_entry(&l->value_list, struct graph_value, list);
graph_value_drop(l, i);
}
}
struct graph_label *i;
while (!flist_empty(&g->label_list)) {
- i = flist_entry(g->label_list.next, struct graph_label, list);
+ i = flist_first_entry(&g->label_list, struct graph_label, list);
flist_del(&i->list);
graph_free_values(i);
free(i);
}
}
if (!flist_empty(&v->alias))
- v = flist_entry(v->alias.next, struct graph_value, alias);
+ v = flist_first_entry(&v->alias, struct graph_value, alias);
} while (v != rootv);
} while ((n = prio_tree_next(&iter)) != NULL);
if (!flist_empty(&td->next_rand_list)) {
struct rand_off *r;
fetch:
- r = flist_entry(td->next_rand_list.next, struct rand_off, list);
+ r = flist_first_entry(&td->next_rand_list, struct rand_off, list);
flist_del(&r->list);
*b = r->off;
free(r);
while (!flist_empty(&td->io_log_list)) {
int ret;
- ipo = flist_entry(td->io_log_list.next, struct io_piece, list);
+ ipo = flist_first_entry(&td->io_log_list, struct io_piece, list);
flist_del(&ipo->list);
remove_trim_entry(td, ipo);
}
while (!flist_empty(&td->io_hist_list)) {
- ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
+ ipo = flist_entry(&td->io_hist_list, struct io_piece, list);
flist_del(&ipo->list);
remove_trim_entry(td, ipo);
td->io_hist_len--;
static void flush_gz_chunks(struct io_log *log, FILE *f)
{
struct flush_chunk_iter iter = { .chunk_sz = log->log_gz, };
- struct flist_head *node;
z_stream stream;
while (!flist_empty(&log->chunk_list)) {
struct iolog_compress *ic;
- node = log->chunk_list.next;
- ic = flist_entry(node, struct iolog_compress, list);
+ ic = flist_first_entry(&log->chunk_list, struct iolog_compress, list);
flist_del(&ic->list);
if (log->log_gz_store)
if (!tdat->thread_exit && flist_empty(&tdat->work))
pthread_cond_wait(&tdat->cv, &tdat->lock);
- if (!flist_empty(&tdat->work)) {
- flist_splice(&tdat->work, &work_list);
- INIT_FLIST_HEAD(&tdat->work);
- }
+ if (!flist_empty(&tdat->work))
+ flist_splice_tail_init(&tdat->work, &work_list);
pthread_mutex_unlock(&tdat->lock);
return 1;
assert(td->trim_entries);
- ipo = flist_entry(td->trim_list.next, struct io_piece, trim_list);
+ ipo = flist_first_entry(&td->trim_list, struct io_piece, trim_list);
remove_trim_entry(td, ipo);
io_u->offset = ipo->offset;
assert(ipo->flags & IP_F_ONRB);
ipo->flags &= ~IP_F_ONRB;
} else if (!flist_empty(&td->io_hist_list)) {
- ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
+ ipo = flist_first_entry(&td->io_hist_list, struct io_piece, list);
/*
* Ensure that the associated IO has completed
continue;
while (!flist_empty(&list)) {
- io_u = flist_entry(list.next, struct io_u, verify_list);
+ io_u = flist_first_entry(&list, struct io_u, verify_list);
flist_del(&io_u->verify_list);
ret = verify_io_u(td, io_u);