From: Aruna Ramakrishna Date: Tue, 29 Aug 2017 03:23:53 +0000 (-0700) Subject: storvsc: don't assume SG list is contiguous X-Git-Tag: v4.1.12-117.0_27200813_3~136 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8b7ea6a165d99ee6b3b49b4861999acc2055c2e1;p=users%2Fjedix%2Flinux-maple.git storvsc: don't assume SG list is contiguous Scatterlists are contiguous if they're limited to a page; but for large I/Os, it's possible that the scatterlists span pages, in which case the pages will not be physically contiguous - they will be chained together. The MS patch (link below) fixes the wrong assumption in do_bounce_buffer() that scatterlists are always contiguous, so it's a good fix to port, in general. Orabug: 26492697 MS patch: https://github.com/LIS/lis-next/commit/a13bbc4ab81e459f635237a938f89737300ecfa1 Signed-off-by: Aruna Ramakrishna Reviewed-by: Joe Slember Acked-by: Martin K. Petersen --- diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index dbc9d9a1c89d..b08fa4b87f75 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -575,17 +575,18 @@ static int do_bounce_buffer(struct scatterlist *sgl, unsigned int sg_count) for (i = 0; i < sg_count; i++) { if (i == 0) { /* make sure 1st one does not have hole */ - if (sgl[i].offset + sgl[i].length != PAGE_SIZE) + if (sgl->offset + sgl->length != PAGE_SIZE) return i; } else if (i == sg_count - 1) { /* make sure last one does not have hole */ - if (sgl[i].offset != 0) + if (sgl->offset != 0) return i; } else { /* make sure no hole in the middle */ - if (sgl[i].length != PAGE_SIZE || sgl[i].offset != 0) + if (sgl->length != PAGE_SIZE || sgl->offset != 0) return i; } + sgl = sg_next(sgl); } return -1; }