From 8b7ea6a165d99ee6b3b49b4861999acc2055c2e1 Mon Sep 17 00:00:00 2001 From: Aruna Ramakrishna Date: Mon, 28 Aug 2017 20:23:53 -0700 Subject: [PATCH] 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 --- drivers/scsi/storvsc_drv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; } -- 2.50.1