瀏覽代碼

[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 <lgeek@frontiernet.net>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Bryan Holty 19 年之前
父節點
當前提交
f52359622f
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/scsi/scsi_lib.c

+ 1 - 1
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)
 			   int nsegs, unsigned bufflen, gfp_t gfp)
 {
 {
 	struct request_queue *q = rq->q;
 	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;
 	unsigned int data_len = 0, len, bytes, off;
 	struct page *page;
 	struct page *page;
 	struct bio *bio = NULL;
 	struct bio *bio = NULL;