From: Bryan Holty Without this change, with 4K io's every sg io that is dma_aligned for direct io, but not page aligned will cause slab corruption and an oops I am able to run a number of tests with sg that cause the boundary to be crossed, and with this fix there is no slab corruption or data corruption. [akpm: use PAGE_ALIGN()] [akpm: needs better changelog] Signed-off-by: Bryan Holty Cc: Mike Christie Cc: James Bottomley Signed-off-by: Andrew Morton --- drivers/scsi/scsi_lib.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -puN drivers/scsi/scsi_lib.c~scsi-properly-count-the-number-of-pages-in-scsi_req_map_sg drivers/scsi/scsi_lib.c --- 25/drivers/scsi/scsi_lib.c~scsi-properly-count-the-number-of-pages-in-scsi_req_map_sg Fri May 26 15:45:49 2006 +++ 25-akpm/drivers/scsi/scsi_lib.c Fri May 26 15:45:49 2006 @@ -367,7 +367,7 @@ static int scsi_req_map_sg(struct reques 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 = PAGE_ALIGN(bufflen + sgl[0].offset); unsigned int data_len = 0, len, bytes, off; struct page *page; struct bio *bio = NULL; _