]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] scsi_lib.c: properly count the number of pages in scsi_req_map_sg()
authorBryan Holty <lgeek@frontiernet.net>
Wed, 22 Mar 2006 12:35:39 +0000 (06:35 -0600)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Thu, 1 Jun 2006 14:16:55 +0000 (09:16 -0500)
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 <lgeek@frontiernet.net>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_lib.c

index 764a8b375ead1005ff2a49e130f1f80418748be7..faee4757c03adb712363eb09527c5af357c0bef3 100644 (file)
@@ -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;