Linux-2.6.12-rc2
[linux-2.6/kvm.git] / drivers / md / dm-bio-list.h
blobbc021e1fd4d14b6d04a465cc6e91c7491032bfb7
1 /*
2 * Copyright (C) 2004 Red Hat UK Ltd.
4 * This file is released under the GPL.
5 */
7 #ifndef DM_BIO_LIST_H
8 #define DM_BIO_LIST_H
10 #include <linux/bio.h>
12 struct bio_list {
13 struct bio *head;
14 struct bio *tail;
17 static inline void bio_list_init(struct bio_list *bl)
19 bl->head = bl->tail = NULL;
22 static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
24 bio->bi_next = NULL;
26 if (bl->tail)
27 bl->tail->bi_next = bio;
28 else
29 bl->head = bio;
31 bl->tail = bio;
34 static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
36 if (bl->tail)
37 bl->tail->bi_next = bl2->head;
38 else
39 bl->head = bl2->head;
41 bl->tail = bl2->tail;
44 static inline struct bio *bio_list_pop(struct bio_list *bl)
46 struct bio *bio = bl->head;
48 if (bio) {
49 bl->head = bl->head->bi_next;
50 if (!bl->head)
51 bl->tail = NULL;
53 bio->bi_next = NULL;
56 return bio;
59 static inline struct bio *bio_list_get(struct bio_list *bl)
61 struct bio *bio = bl->head;
63 bl->head = bl->tail = NULL;
65 return bio;
68 #endif