From: Christoph Hellwig Date: Thu, 2 Feb 2012 21:51:24 +0000 (-0500) Subject: iblock: fix handling of large requests X-Git-Tag: v3.3-rc3~2^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c55125f4794f4e77574fc09839cb47b0eb45b06;p=profile%2Fcommon%2Fkernel-common.git iblock: fix handling of large requests Requesting to many bvecs upsets bio_alloc_bioset, so limit the number we ask for to the amount it can handle. Signed-off-by: Christoph Hellwig Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index d43d5eb..8572eae 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -488,6 +488,13 @@ iblock_get_bio(struct se_task *task, sector_t lba, u32 sg_num) struct iblock_req *ib_req = IBLOCK_REQ(task); struct bio *bio; + /* + * Only allocate as many vector entries as the bio code allows us to, + * we'll loop later on until we have handled the whole request. + */ + if (sg_num > BIO_MAX_PAGES) + sg_num = BIO_MAX_PAGES; + bio = bio_alloc_bioset(GFP_NOIO, sg_num, ib_dev->ibd_bio_set); if (!bio) { pr_err("Unable to allocate memory for bio\n");