# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.570 -> 1.571 # fs/bio.c 1.27 -> 1.28 # include/linux/bio.h 1.20 -> 1.21 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/09/20 axboe@burns.home.kernel.dk 1.571 # add bio_get_nr_vecs(), returns approximate number of pages that can # be fitted into a bio for this target # -------------------------------------------- # diff -Nru a/fs/bio.c b/fs/bio.c --- a/fs/bio.c Fri Sep 20 09:22:09 2002 +++ b/fs/bio.c Fri Sep 20 09:22:09 2002 @@ -322,6 +322,29 @@ } /** + * bio_get_nr_vecs - return approx number of vecs + * @bdev: I/O target + * + * Return the approximate number of pages we can send to this target. + * There's no guarentee that you will be able to fit this number of pages + * into a bio, it does not account for dynamic restrictions that vary + * on offset. + */ +int bio_get_nr_vecs(struct block_device *bdev) +{ + request_queue_t *q = bdev_get_queue(bdev); + int nr_pages; + + nr_pages = q->max_sectors >> (PAGE_SHIFT - 9); + if (nr_pages > q->max_phys_segments) + nr_pages = q->max_phys_segments; + if (nr_pages > q->max_hw_segments) + nr_pages = q->max_hw_segments; + + return nr_pages; +} + +/** * bio_add_page - attempt to add page to bio * @bio: destination bio * @page: page to add @@ -635,3 +658,4 @@ EXPORT_SYMBOL(bio_phys_segments); EXPORT_SYMBOL(bio_hw_segments); EXPORT_SYMBOL(bio_add_page); +EXPORT_SYMBOL(bio_get_nr_vecs); diff -Nru a/include/linux/bio.h b/include/linux/bio.h --- a/include/linux/bio.h Fri Sep 20 09:22:09 2002 +++ b/include/linux/bio.h Fri Sep 20 09:22:09 2002 @@ -206,6 +206,7 @@ extern inline void bio_init(struct bio *); extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); +extern int bio_get_nr_vecs(struct block_device *); #ifdef CONFIG_HIGHMEM /*