From 60ac3a30921db0ed32f8ec3ae178a01d04f76876 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 7 Oct 2002 21:37:12 -0700 Subject: [PATCH] make bio->bi_max contain max vec entries This changes the way we do pool lookups when freeing a bio. Right now we use bi_max as a handle into bvec_array[], to find the pool where it came from. This used to be just fine, because if you had a private bio, you could specify your own destructor. But now we have bio_add_page() which also needs to know where the bio came from, or more precisely, it needs to know how many entries the bio can hold. So I've changed bi_max to bi_max_vecs, it now contains the number of vec entries in the bio. Privately allocated bio's (or on stack) can now just set bio->bi_max_vecs to reflect the max size. The pool index for the default destructor is stored in the top bits of bi_flags. --- include/linux/bio.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/bio.h b/include/linux/bio.h index d3d75e2904ba..93ac8216aae4 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -81,8 +81,7 @@ struct bio { unsigned short bi_hw_segments; unsigned int bi_size; /* residual I/O count */ - unsigned int bi_max; /* max bvl_vecs we can hold, - used as index into pool */ + unsigned int bi_max_vecs; /* max bvl_vecs we can hold */ struct bio_vec *bi_io_vec; /* the actual vec list */ @@ -104,6 +103,14 @@ struct bio { #define BIO_CLONED 4 /* doesn't own data */ #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) +/* + * top 4 bits of bio flags indicate the pool this bio came from + */ +#define BIO_POOL_BITS (4) +#define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) +#define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) +#define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) + /* * bio bi_rw flags * -- cgit v1.2.3