diff options
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r-- | drivers/scsi/scsi_lib.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index aac8a02cbe80..61fdaf02f251 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -295,7 +295,7 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl, | |||
295 | int i, err, nr_vecs = 0; | 295 | int i, err, nr_vecs = 0; |
296 | 296 | ||
297 | for_each_sg(sgl, sg, nsegs, i) { | 297 | for_each_sg(sgl, sg, nsegs, i) { |
298 | page = sg->page; | 298 | page = sg_page(sg); |
299 | off = sg->offset; | 299 | off = sg->offset; |
300 | len = sg->length; | 300 | len = sg->length; |
301 | data_len += len; | 301 | data_len += len; |
@@ -764,7 +764,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
764 | if (unlikely(!sgl)) | 764 | if (unlikely(!sgl)) |
765 | goto enomem; | 765 | goto enomem; |
766 | 766 | ||
767 | memset(sgl, 0, sizeof(*sgl) * sgp->size); | 767 | sg_init_table(sgl, sgp->size); |
768 | 768 | ||
769 | /* | 769 | /* |
770 | * first loop through, set initial index and return value | 770 | * first loop through, set initial index and return value |
@@ -781,6 +781,13 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
781 | sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); | 781 | sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); |
782 | 782 | ||
783 | /* | 783 | /* |
784 | * if we have nothing left, mark the last segment as | ||
785 | * end-of-list | ||
786 | */ | ||
787 | if (!left) | ||
788 | sg_mark_end(sgl, this); | ||
789 | |||
790 | /* | ||
784 | * don't allow subsequent mempool allocs to sleep, it would | 791 | * don't allow subsequent mempool allocs to sleep, it would |
785 | * violate the mempool principle. | 792 | * violate the mempool principle. |
786 | */ | 793 | */ |
@@ -2353,7 +2360,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count, | |||
2353 | *offset = *offset - len_complete + sg->offset; | 2360 | *offset = *offset - len_complete + sg->offset; |
2354 | 2361 | ||
2355 | /* Assumption: contiguous pages can be accessed as "page + i" */ | 2362 | /* Assumption: contiguous pages can be accessed as "page + i" */ |
2356 | page = nth_page(sg->page, (*offset >> PAGE_SHIFT)); | 2363 | page = nth_page(sg_page(sg), (*offset >> PAGE_SHIFT)); |
2357 | *offset &= ~PAGE_MASK; | 2364 | *offset &= ~PAGE_MASK; |
2358 | 2365 | ||
2359 | /* Bytes in this sg-entry from *offset to the end of the page */ | 2366 | /* Bytes in this sg-entry from *offset to the end of the page */ |