diff options
author | Long Li <longli@microsoft.com> | 2018-01-10 13:21:29 -0700 |
---|---|---|
committer | Sasha Levin <alexander.levin@microsoft.com> | 2018-01-21 09:59:00 -0500 |
commit | 623dfab42becf5c56c9a31b7eaf90cb6eb86459f (patch) | |
tree | d1e75ba7235b5978ab3f4a60584dc71d7f1ec4e6 | |
parent | feedfe2129e348e075b72a5e3e1c7c52d0c769e4 (diff) | |
download | linux-4.1.y-queue.tar.gz |
storvsc: do not assume SG list is continuous when doing bounce bufferslinux-4.1.y-queue
The original patch was made for stable 4.1 and was Acked on 08/22/2017, but for
some reason it never made it to the stable tree.
Change from v1:
Changed comment that this patch is for linux-stable 4.1 and all prior stable
kernels.
storvsc checks the SG list for gaps before passing them to Hyper-v device.
If there are gaps, data is copied to a bounce buffer and a continuous data
buffer is passed to Hyper-V.
The check on gaps assumes SG list is continuous, and not chained. This is
not always true. Failing the check may result in incorrect I/O data
passed to the Hyper-v device.
This code path is not used post Linux 4.1.
[LL: Backport for 4.1]
Signed-off-by: Long Li <longli@microsoft.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-rw-r--r-- | drivers/scsi/storvsc_drv.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index e4b103d5d2896f..98b56a7069d3d1 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -582,17 +582,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; } |