Skip to content

Commit 840e1b5

Browse files
Ye Binmartinkpetersen
authored andcommitted
scsi: core: Refactor scsi_mq_setup_tags function
shost->tag_set is used too many times, introduce temporary parameter tag_set instead of &shost->tag_set. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Ye Bin <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4dea170 commit 840e1b5

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,7 @@ struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev)
18491849
int scsi_mq_setup_tags(struct Scsi_Host *shost)
18501850
{
18511851
unsigned int cmd_size, sgl_size;
1852+
struct blk_mq_tag_set *tag_set = &shost->tag_set;
18521853

18531854
sgl_size = max_t(unsigned int, sizeof(struct scatterlist),
18541855
scsi_mq_inline_sgl_size(shost));
@@ -1857,21 +1858,21 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
18571858
cmd_size += sizeof(struct scsi_data_buffer) +
18581859
sizeof(struct scatterlist) * SCSI_INLINE_PROT_SG_CNT;
18591860

1860-
memset(&shost->tag_set, 0, sizeof(shost->tag_set));
1861+
memset(tag_set, 0, sizeof(*tag_set));
18611862
if (shost->hostt->commit_rqs)
1862-
shost->tag_set.ops = &scsi_mq_ops;
1863+
tag_set->ops = &scsi_mq_ops;
18631864
else
1864-
shost->tag_set.ops = &scsi_mq_ops_no_commit;
1865-
shost->tag_set.nr_hw_queues = shost->nr_hw_queues ? : 1;
1866-
shost->tag_set.queue_depth = shost->can_queue;
1867-
shost->tag_set.cmd_size = cmd_size;
1868-
shost->tag_set.numa_node = NUMA_NO_NODE;
1869-
shost->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
1870-
shost->tag_set.flags |=
1865+
tag_set->ops = &scsi_mq_ops_no_commit;
1866+
tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1;
1867+
tag_set->queue_depth = shost->can_queue;
1868+
tag_set->cmd_size = cmd_size;
1869+
tag_set->numa_node = NUMA_NO_NODE;
1870+
tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
1871+
tag_set->flags |=
18711872
BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
1872-
shost->tag_set.driver_data = shost;
1873+
tag_set->driver_data = shost;
18731874

1874-
return blk_mq_alloc_tag_set(&shost->tag_set);
1875+
return blk_mq_alloc_tag_set(tag_set);
18751876
}
18761877

18771878
void scsi_mq_destroy_tags(struct Scsi_Host *shost)

0 commit comments

Comments
 (0)