From: Bryan Holty Date: Wed, 22 Mar 2006 12:35:39 +0000 (-0600) Subject: [SCSI] scsi_lib.c: properly count the number of pages in scsi_req_map_sg() X-Git-Tag: MMI-PSA29.97-13-9~49579^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f52359622fa25783cf1a08c0772048d2ed1a7434;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [SCSI] scsi_lib.c: properly count the number of pages in scsi_req_map_sg() The calculation of nr_pages in scsi_req_map_sg() doesn't account for the fact that the first page could have an offset that pushes the end of the buffer onto a new page. Signed-off-by: Bryan Holty Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 764a8b375ead..faee4757c03a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -367,7 +367,7 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl, int nsegs, unsigned bufflen, gfp_t gfp) { struct request_queue *q = rq->q; - int nr_pages = (bufflen + PAGE_SIZE - 1) >> PAGE_SHIFT; + int nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) >> PAGE_SHIFT; unsigned int data_len = 0, len, bytes, off; struct page *page; struct bio *bio = NULL;