Lift the bio_list code from dm-raid1.c into dm-bio-list.h [Christophe Saout] --- diff/drivers/md/dm-bio-list.h 1970-01-01 01:00:00.000000000 +0100 +++ source/drivers/md/dm-bio-list.h 2004-01-16 13:56:34.000000000 +0000 @@ -0,0 +1,70 @@ +/* + * bio queue functions + * + * Copyright (C) 2001, 2002 Sistina Software + * + * This file is released under the LGPL. + */ + +#ifndef DM_BIO_LIST_H +#define DM_BIO_LIST_H + +#include + +struct bio_list { + struct bio *head; + struct bio *tail; +}; + +extern inline void bio_list_init(struct bio_list *bl) +{ + bl->head = bl->tail = NULL; +} + +extern inline void bio_list_add(struct bio_list *bl, struct bio *bio) +{ + bio->bi_next = NULL; + + if (bl->tail) + bl->tail->bi_next = bio; + else + bl->head = bio; + + bl->tail = bio; +} + +extern inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2) +{ + if (bl->tail) + bl->tail->bi_next = bl2->head; + else + bl->head = bl2->head; + + bl->tail = bl2->tail; +} + +extern inline struct bio *bio_list_pop(struct bio_list *bl) +{ + struct bio *bio = bl->head; + + if (bio) { + bl->head = bl->head->bi_next; + if (!bl->head) + bl->tail = NULL; + + bio->bi_next = NULL; + } + + return bio; +} + +extern inline struct bio *bio_list_get(struct bio_list *bl) +{ + struct bio *bio = bl->head; + + bl->head = bl->tail = NULL; + + return bio; +} + +#endif