From: "Jun'ichi Nomura" bio_alloc_bioset() will return NULL if 'num_vecs' is too large. Use bio_get_nr_vecs() to get estimation of maximum number. Signed-off-by: "Jun'ichi Nomura" Signed-off-by: Alasdair G Kergon --- drivers/md/dm-io.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: linux-2.6.21/drivers/md/dm-io.c =================================================================== --- linux-2.6.21.orig/drivers/md/dm-io.c 2007-05-10 22:49:57.000000000 +0100 +++ linux-2.6.21/drivers/md/dm-io.c 2007-05-14 17:15:24.000000000 +0100 @@ -293,7 +293,9 @@ static void do_region(int rw, unsigned i * bvec for bio_get/set_region() and decrement bi_max_vecs * to hide it from bio_add_page(). */ - num_bvecs = (remaining / (PAGE_SIZE >> SECTOR_SHIFT)) + 2; + num_bvecs = remaining / (PAGE_SIZE >> SECTOR_SHIFT); + num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev), + num_bvecs); bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); bio->bi_sector = where->sector + (where->count - remaining); bio->bi_bdev = where->bdev;