scsi: advansys: use sg helper to iterate over scatterlist [Linux 5.3]

This Linux kernel change "scsi: advansys: use sg helper to iterate over scatterlist" is included in the Linux 5.3 release. This change is authored by Ming Lei <ming.lei [at]> on Tue Jun 18 09:37:43 2019 +0800. The commit for this change in Linux stable tree is c0d0d81 (patch).

scsi: advansys: use sg helper to iterate over scatterlist

Unlike the legacy I/O path, scsi-mq preallocates a large array to hold
the scatterlist for each request. This static allocation can consume
substantial amounts of memory on modern controllers which support a
large number of concurrently outstanding requests.

To facilitate a switch to a smaller static allocation combined with a
dynamic allocation for requests that need it, we need to make sure all
SCSI drivers handle chained scatterlists correctly.

Convert remaining drivers that directly dereference the scatterlist
array to using the iterator functions.

[mkp: clarified commit message]

Reviewed-by: Ewan D. Milne <>
Reviewed-by: Christoph Hellwig <>
Reviewed-by: Bart Van Assche <>
Signed-off-by: Ming Lei <>
Signed-off-by: Martin K. Petersen <>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/scsi/advansys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index d375844..b87de8d 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7714,7 +7714,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
                sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
                return ADV_SUCCESS;
-           slp++;
+           slp = sg_next(slp);
        sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
        prev_sg_block = sg_block;

Leave a Reply

Your email address will not be published. Required fields are marked *