Skip to content

Commit be4c186

Browse files
Bart Van Asschemartinkpetersen
authored andcommitted
scsi: Introduce scsi_mq_sgl_size()
This patch does not change any functionality but makes the next patch easier to read. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 2dd6fb5 commit be4c186

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,13 @@ static inline int prep_to_mq(int ret)
18591859
}
18601860
}
18611861

1862+
/* Size in bytes of the sg-list stored in the scsi-mq command-private data. */
1863+
static unsigned int scsi_mq_sgl_size(struct Scsi_Host *shost)
1864+
{
1865+
return min_t(unsigned int, shost->sg_tablesize, SG_CHUNK_SIZE) *
1866+
sizeof(struct scatterlist);
1867+
}
1868+
18621869
static int scsi_mq_prep_fn(struct request *req)
18631870
{
18641871
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
@@ -1893,10 +1900,7 @@ static int scsi_mq_prep_fn(struct request *req)
18931900
cmd->sdb.table.sgl = sg;
18941901

18951902
if (scsi_host_get_prot(shost)) {
1896-
cmd->prot_sdb = (void *)sg +
1897-
min_t(unsigned int,
1898-
shost->sg_tablesize, SG_CHUNK_SIZE) *
1899-
sizeof(struct scatterlist);
1903+
cmd->prot_sdb = (void *)sg + scsi_mq_sgl_size(shost);
19001904
memset(cmd->prot_sdb, 0, sizeof(struct scsi_data_buffer));
19011905

19021906
cmd->prot_sdb->table.sgl =
@@ -2202,12 +2206,9 @@ struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev)
22022206

22032207
int scsi_mq_setup_tags(struct Scsi_Host *shost)
22042208
{
2205-
unsigned int cmd_size, sgl_size, tbl_size;
2209+
unsigned int cmd_size, sgl_size;
22062210

2207-
tbl_size = shost->sg_tablesize;
2208-
if (tbl_size > SG_CHUNK_SIZE)
2209-
tbl_size = SG_CHUNK_SIZE;
2210-
sgl_size = tbl_size * sizeof(struct scatterlist);
2211+
sgl_size = scsi_mq_sgl_size(shost);
22112212
cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size + sgl_size;
22122213
if (scsi_host_get_prot(shost))
22132214
cmd_size += sizeof(struct scsi_data_buffer) + sgl_size;

0 commit comments

Comments
 (0)