[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [dm-devel] [RFC][PATCH 1/2] bio queue functions in dm-bio-list.h



On Saturday 10 January 2004 14:08, Christophe Saout wrote:
> Hi,
>
> I found some bio_list functions in dm-raid1.c and I thought they could
> be made available for other users too. 

> There's probably a better place for this.

Heh...maybe include/linux/bio.h? :)

Now that you've pointed out this stack vs. fifo problem a couple times, I'm 
beginning to wonder why the bi_next field in the bio is a struct bio * 
instead of a struct list_head. It would seem that changing it to a list_head 
would eliminate the need for the bio_list stuff, as well as eliminate the 
original problem of accidentally reordering the bio's.

Of course, it's probably way to late to make this kind of change, since it 
would involve auditing every driver that ever holds a pointer to a bio to see 
if it's treating that pointer as the head of a list.

> --- linux.orig/drivers/md/dm-bio-list.h	1970-01-01 01:00:00.000000000 +0100
> +++ linux/drivers/md/dm-bio-list.h	2004-01-10 20:43:32.442353960 +0100
> @@ -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 <linux/bio.h>
> +
> +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

-- 
Kevin Corry
kevcorry us ibm com
http://evms.sourceforge.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]