Skip to content

Commit f7c4cdc

Browse files
John Garryaxboe
authored andcommitted
scsi: scsi_debug: Support host tagset
When host_max_queue is set (> 0), set the Scsi_Host.host_tagset such that blk-mq will use a hostwide tagset over all SCSI host submission queues. This means that we may expose all submission queues and always use the hwq chosen by blk-mq. And since if sdebug_host_max_queue is set, sdebug_max_queue is fixed to the same value, we can simplify how sdebug_driver_template.can_queue is set. Signed-off-by: John Garry <john.garry@huawei.com> Tested-by: Douglas Gilbert <dgilbert@interlog.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8d98416 commit f7c4cdc

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4696,19 +4696,14 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
46964696
static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd)
46974697
{
46984698
u16 hwq;
4699+
u32 tag = blk_mq_unique_tag(cmnd->request);
46994700

4700-
if (sdebug_host_max_queue) {
4701-
/* Provide a simple method to choose the hwq */
4702-
hwq = smp_processor_id() % submit_queues;
4703-
} else {
4704-
u32 tag = blk_mq_unique_tag(cmnd->request);
4701+
hwq = blk_mq_unique_tag_to_hwq(tag);
47054702

4706-
hwq = blk_mq_unique_tag_to_hwq(tag);
4703+
pr_debug("tag=%#x, hwq=%d\n", tag, hwq);
4704+
if (WARN_ON_ONCE(hwq >= submit_queues))
4705+
hwq = 0;
47074706

4708-
pr_debug("tag=%#x, hwq=%d\n", tag, hwq);
4709-
if (WARN_ON_ONCE(hwq >= submit_queues))
4710-
hwq = 0;
4711-
}
47124707
return sdebug_q_arr + hwq;
47134708
}
47144709

@@ -7347,10 +7342,7 @@ static int sdebug_driver_probe(struct device *dev)
73477342

73487343
sdbg_host = to_sdebug_host(dev);
73497344

7350-
if (sdebug_host_max_queue)
7351-
sdebug_driver_template.can_queue = sdebug_host_max_queue;
7352-
else
7353-
sdebug_driver_template.can_queue = sdebug_max_queue;
7345+
sdebug_driver_template.can_queue = sdebug_max_queue;
73547346
if (!sdebug_clustering)
73557347
sdebug_driver_template.dma_boundary = PAGE_SIZE - 1;
73567348

@@ -7367,11 +7359,11 @@ static int sdebug_driver_probe(struct device *dev)
73677359
}
73687360
/*
73697361
* Decide whether to tell scsi subsystem that we want mq. The
7370-
* following should give the same answer for each host. If the host
7371-
* has a limit of hostwide max commands, then do not set.
7362+
* following should give the same answer for each host.
73727363
*/
7373-
if (!sdebug_host_max_queue)
7374-
hpnt->nr_hw_queues = submit_queues;
7364+
hpnt->nr_hw_queues = submit_queues;
7365+
if (sdebug_host_max_queue)
7366+
hpnt->host_tagset = 1;
73757367

73767368
sdbg_host->shost = hpnt;
73777369
*((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;

0 commit comments

Comments
 (0)