From: Alasdair G Kergon <agk@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org,
"Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
Subject: [2.6.23 PATCH 07/18] dm io: fix panic on large request
Date: Wed, 11 Jul 2007 21:58:46 +0100 [thread overview]
Message-ID: <20070711205846.GY24114@agk.fab.redhat.com> (raw)
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
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" <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
---
drivers/md/dm-io.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
Index: linux/drivers/md/dm-io.c
===================================================================
--- linux.orig/drivers/md/dm-io.c 2007-07-11 21:37:32.000000000 +0100
+++ linux/drivers/md/dm-io.c 2007-07-11 21:37:43.000000000 +0100
@@ -293,7 +293,10 @@ 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 = dm_sector_div_up(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;
next reply other threads:[~2007-07-11 21:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-11 20:58 Alasdair G Kergon [this message]
2007-07-17 13:16 ` Patrick McHardy
2007-07-17 16:39 ` Jun'ichi Nomura
2007-07-17 17:50 ` Patrick McHardy
2007-07-17 22:20 ` Jun'ichi Nomura
2007-07-18 10:08 ` Patrick McHardy
2007-07-18 15:23 ` Chuck Ebbert
2007-07-20 15:07 ` Milan Broz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070711205846.GY24114@agk.fab.redhat.com \
--to=agk@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dm-devel@redhat.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®