]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm io: respect BIO_MAX_PAGES limit
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 16 Mar 2009 17:44:30 +0000 (17:44 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 23 Mar 2009 21:55:26 +0000 (14:55 -0700)
commit d659e6cc98766a1a61d6bdd283f95d149abd7719 upstream.

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

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/md/dm-io.c

index 2fd6d4450637943963d88c948080cf4f0ed73a92..657e1dd2c311a109835c6e222f93806605ceda0c 100644 (file)
@@ -292,6 +292,8 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
                                             (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;