--- /opt/kernel/linux-2.5.1-pre5/fs/bio.c Tue Dec 4 04:42:00 2001 +++ fs/bio.c Tue Dec 4 04:45:56 2001 @@ -35,7 +35,7 @@ #include kmem_cache_t *bio_cachep; -static spinlock_t __cacheline_aligned bio_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t __cacheline_aligned_in_smp bio_lock = SPIN_LOCK_UNLOCKED; static struct bio *bio_pool; static DECLARE_WAIT_QUEUE_HEAD(bio_pool_wait); static DECLARE_WAIT_QUEUE_HEAD(biovec_pool_wait); @@ -74,7 +74,7 @@ struct bio *bio; if ((bio = bio_pool)) { - BUG_ON(bio_pool_free <= 0); + BIO_BUG_ON(bio_pool_free <= 0); bio_pool = bio->bi_next; bio->bi_next = NULL; bio_pool_free--; @@ -90,7 +90,7 @@ spin_lock_irqsave(&bio_lock, flags); bio = __bio_pool_get(); - BUG_ON(!bio && bio_pool_free); + BIO_BUG_ON(!bio && bio_pool_free); spin_unlock_irqrestore(&bio_lock, flags); return bio; @@ -121,8 +121,7 @@ } } -#define BIO_CAN_WAIT(gfp_mask) \ - (((gfp_mask) & (__GFP_WAIT | __GFP_IO)) == (__GFP_WAIT | __GFP_IO)) +#define BIO_CAN_WAIT(gfp_mask) ((gfp_mask) & __GFP_WAIT) static inline struct bio_vec *bvec_alloc(int gfp_mask, int nr, int *idx) { @@ -198,13 +197,15 @@ { struct biovec_pool *bp = &bvec_list[bio->bi_max]; - BUG_ON(bio->bi_max >= BIOVEC_NR_POOLS); + BIO_BUG_ON(bio->bi_max >= BIOVEC_NR_POOLS); /* * cloned bio doesn't own the veclist */ - if (!(bio->bi_flags & (1 << BIO_CLONED))) + if (!(bio->bi_flags & (1 << BIO_CLONED))) { kmem_cache_free(bp->bp_cachep, bio->bi_io_vec); + wake_up_nr(&bp->bp_wait, 1); + } bio_pool_put(bio); } @@ -212,13 +213,13 @@ inline void bio_init(struct bio *bio) { bio->bi_next = NULL; - atomic_set(&bio->bi_cnt, 1); bio->bi_flags = 0; bio->bi_rw = 0; bio->bi_vcnt = 0; bio->bi_idx = 0; bio->bi_size = 0; bio->bi_end_io = NULL; + atomic_set(&bio->bi_cnt, 1); } static inline struct bio *__bio_alloc(int gfp_mask, bio_destructor_t *dest) @@ -314,14 +315,13 @@ **/ void bio_put(struct bio *bio) { - BUG_ON(!atomic_read(&bio->bi_cnt)); + BIO_BUG_ON(!atomic_read(&bio->bi_cnt)); /* * last put frees it */ if (atomic_dec_and_test(&bio->bi_cnt)) { - BUG_ON(bio->bi_next); - + BIO_BUG_ON(bio->bi_next); bio_free(bio); } }