2 * Copyright (C) 2004 Red Hat UK Ltd.
4 * This file is released under the GPL.
10 #include <linux/bio.h>
11 #include <linux/prefetch.h>
18 static inline int bio_list_empty(const struct bio_list *bl)
20 return bl->head == NULL;
23 #define BIO_LIST_INIT { .head = NULL, .tail = NULL }
25 #define BIO_LIST(bl) \
26 struct bio_list bl = BIO_LIST_INIT
28 static inline void bio_list_init(struct bio_list *bl)
30 bl->head = bl->tail = NULL;
33 #define bio_list_for_each(bio, bl) \
34 for (bio = (bl)->head; bio && ({ prefetch(bio->bi_next); 1; }); \
37 static inline unsigned bio_list_size(const struct bio_list *bl)
42 bio_list_for_each(bio, bl)
48 static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
53 bl->tail->bi_next = bio;
60 static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
66 bl->tail->bi_next = bl2->head;
73 static inline void bio_list_merge_head(struct bio_list *bl,
80 bl2->tail->bi_next = bl->head;
87 static inline struct bio *bio_list_pop(struct bio_list *bl)
89 struct bio *bio = bl->head;
92 bl->head = bl->head->bi_next;
102 static inline struct bio *bio_list_get(struct bio_list *bl)
104 struct bio *bio = bl->head;
106 bl->head = bl->tail = NULL;