aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm-io.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 352c6fbeac53..f3a772486437 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -293,7 +293,10 @@ static void do_region(int rw, unsigned int region, struct io_region *where,
293 * bvec for bio_get/set_region() and decrement bi_max_vecs 293 * bvec for bio_get/set_region() and decrement bi_max_vecs
294 * to hide it from bio_add_page(). 294 * to hide it from bio_add_page().
295 */ 295 */
296 num_bvecs = (remaining / (PAGE_SIZE >> SECTOR_SHIFT)) + 2; 296 num_bvecs = dm_sector_div_up(remaining,
297 (PAGE_SIZE >> SECTOR_SHIFT));
298 num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev),
299 num_bvecs);
297 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); 300 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
298 bio->bi_sector = where->sector + (where->count - remaining); 301 bio->bi_sector = where->sector + (where->count - remaining);
299 bio->bi_bdev = where->bdev; 302 bio->bi_bdev = where->bdev;