Commit be4c186c authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: Introduce scsi_mq_sgl_size()

This patch does not change any functionality but makes the next patch
easier to read.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 2dd6fb59
...@@ -1859,6 +1859,13 @@ static inline int prep_to_mq(int ret) ...@@ -1859,6 +1859,13 @@ static inline int prep_to_mq(int ret)
} }
} }
/* Size in bytes of the sg-list stored in the scsi-mq command-private data. */
static unsigned int scsi_mq_sgl_size(struct Scsi_Host *shost)
{
return min_t(unsigned int, shost->sg_tablesize, SG_CHUNK_SIZE) *
sizeof(struct scatterlist);
}
static int scsi_mq_prep_fn(struct request *req) static int scsi_mq_prep_fn(struct request *req)
{ {
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
...@@ -1893,10 +1900,7 @@ static int scsi_mq_prep_fn(struct request *req) ...@@ -1893,10 +1900,7 @@ static int scsi_mq_prep_fn(struct request *req)
cmd->sdb.table.sgl = sg; cmd->sdb.table.sgl = sg;
if (scsi_host_get_prot(shost)) { if (scsi_host_get_prot(shost)) {
cmd->prot_sdb = (void *)sg + cmd->prot_sdb = (void *)sg + scsi_mq_sgl_size(shost);
min_t(unsigned int,
shost->sg_tablesize, SG_CHUNK_SIZE) *
sizeof(struct scatterlist);
memset(cmd->prot_sdb, 0, sizeof(struct scsi_data_buffer)); memset(cmd->prot_sdb, 0, sizeof(struct scsi_data_buffer));
cmd->prot_sdb->table.sgl = cmd->prot_sdb->table.sgl =
...@@ -2202,12 +2206,9 @@ struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev) ...@@ -2202,12 +2206,9 @@ struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev)
int scsi_mq_setup_tags(struct Scsi_Host *shost) int scsi_mq_setup_tags(struct Scsi_Host *shost)
{ {
unsigned int cmd_size, sgl_size, tbl_size; unsigned int cmd_size, sgl_size;
tbl_size = shost->sg_tablesize; sgl_size = scsi_mq_sgl_size(shost);
if (tbl_size > SG_CHUNK_SIZE)
tbl_size = SG_CHUNK_SIZE;
sgl_size = tbl_size * sizeof(struct scatterlist);
cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size + sgl_size; cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size + sgl_size;
if (scsi_host_get_prot(shost)) if (scsi_host_get_prot(shost))
cmd_size += sizeof(struct scsi_data_buffer) + sgl_size; cmd_size += sizeof(struct scsi_data_buffer) + sgl_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment