]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[PATCH] scsi_lib.c: properly count the number of pages in scsi_req_map_sg()
authorJames Bottomley <jejb@mulgrave.il.steeleye.com>
Thu, 8 Jun 2006 04:03:28 +0000 (00:03 -0400)
committerChris Wright <chrisw@sous-sol.org>
Thu, 22 Jun 2006 19:16:12 +0000 (12:16 -0700)
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>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/scsi_lib.c

index 701a328f7beb55b1bf5bb82cccc4120384805bb8..a0cd6de91afef85e9d53518de062e3fb8fa4e28f 100644 (file)
@@ -368,7 +368,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;