From f8b46092db20bcd663da4e0976892896b4399148 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 17 Sep 2002 18:59:58 -0700 Subject: [PATCH] bio_add_page() This is bio_add_page(), 100% identical to the version I sent out for comments earlier this week. With the previous queue restriction patch, this guarentees that we can always add a page worth of data to the bio. bio_add_page() returns 0 on success, and 1 on failure. Either the page is added completely, or the attempt is aborted. bio_add_page() uses the normal queue restrictions to determine whether we an add the page or not. if a queue has further restrictions, it can define a q->merge_bvec_fn() to further impose limits. Patch also includes changes to ll_rw_kio(), if for nothing else to demonstrate how to use this piece of instrastructure. --- include/linux/bio.h | 10 +++++++--- include/linux/blkdev.h | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/bio.h b/include/linux/bio.h index 5fdfd8e8936c..8113ca45c3d2 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -37,8 +37,9 @@ #define BIO_BUG_ON #endif -#define BIO_MAX_SECTORS 128 -#define BIO_MAX_SIZE (BIO_MAX_SECTORS << 9) +#define BIO_MAX_PAGES (256) +#define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_CACHE_SHIFT) +#define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9) /* * was unsigned short, but we might as well be ready for > 64kB I/O pages @@ -101,6 +102,7 @@ struct bio { #define BIO_EOF 2 /* out-out-bounds error */ #define BIO_SEG_VALID 3 /* nr_hw_seg valid */ #define BIO_CLONED 4 /* doesn't own data */ +#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) /* * bio bi_rw flags @@ -123,7 +125,7 @@ struct bio { #define bio_offset(bio) bio_iovec((bio))->bv_offset #define bio_sectors(bio) ((bio)->bi_size >> 9) #define bio_data(bio) (page_address(bio_page((bio))) + bio_offset((bio))) -#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_BARRIER)) +#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) /* * will die @@ -203,6 +205,8 @@ extern struct bio *bio_copy(struct bio *, int, int); extern inline void bio_init(struct bio *); +extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); + #ifdef CONFIG_HIGHMEM /* * remember to add offset! and never ever reenable interrupts between a diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 70781c985caa..841295073ffa 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -120,6 +120,9 @@ typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); typedef int (prep_rq_fn) (request_queue_t *, struct request *); typedef void (unplug_fn) (void *q); +struct bio_vec; +typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); + enum blk_queue_state { Queue_down, Queue_up, @@ -163,6 +166,7 @@ struct request_queue make_request_fn *make_request_fn; prep_rq_fn *prep_rq_fn; unplug_fn *unplug_fn; + merge_bvec_fn *merge_bvec_fn; struct backing_dev_info backing_dev_info; -- cgit v1.2.3