From: Mikulas Patocka <[email-masked]>

dm-io calls bio_get_nr_vecs to get the maximum number of pages to use
for a given device.  It allocates one additional bio_vec to use
internally but failed to respect BIO_MAX_PAGES, so fix this.

This was the likely cause of:
  https://bugzilla.redhat.com/show_bug.cgi?id=173153

Cc: [email-masked]
Signed-off-by: Mikulas Patocka <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>
---
 drivers/md/dm-io.c |    2 ++
 1 files changed, 2 insertions(+)

Index: linux-2.6.29-rc8/drivers/md/dm-io.c
===================================================================
--- linux-2.6.29-rc8.orig/drivers/md/dm-io.c	2009-03-16 13:07:19.000000000 +0000
+++ linux-2.6.29-rc8/drivers/md/dm-io.c	2009-03-16 13:10:01.000000000 +0000
@@ -292,6 +292,8 @@ static void do_region(int rw, unsigned r
 					     (PAGE_SIZE >> SECTOR_SHIFT));
 		num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev),
 				      num_bvecs);
+		if (unlikely(num_bvecs > BIO_MAX_PAGES))
+			num_bvecs = BIO_MAX_PAGES;
 		bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
 		bio->bi_sector = where->sector + (where->count - remaining);
 		bio->bi_bdev = where->bdev;