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

scsi: scsi_debug: Simplify request tag decoding

Since commit 64d513ac ("scsi: use host wide tags by default") all
SCSI requests have a tag, whether or not scsi-mq is enabled.

Additionally, it is safe to use blk_mq_unique_tag() and
blk_mq_unique_tag_to_hwq() for legacy SCSI queues. Since this means that
the sdebug_mq_active variable is superfluous, remove it.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 34e81f7a
...@@ -649,7 +649,6 @@ static bool sdebug_any_injecting_opt; ...@@ -649,7 +649,6 @@ static bool sdebug_any_injecting_opt;
static bool sdebug_verbose; static bool sdebug_verbose;
static bool have_dif_prot; static bool have_dif_prot;
static bool sdebug_statistics = DEF_STATISTICS; static bool sdebug_statistics = DEF_STATISTICS;
static bool sdebug_mq_active;
static unsigned int sdebug_store_sectors; static unsigned int sdebug_store_sectors;
static sector_t sdebug_capacity; /* in sectors */ static sector_t sdebug_capacity; /* in sectors */
...@@ -3727,20 +3726,13 @@ static int resp_xdwriteread_10(struct scsi_cmnd *scp, ...@@ -3727,20 +3726,13 @@ static int resp_xdwriteread_10(struct scsi_cmnd *scp,
static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd) static struct sdebug_queue *get_queue(struct scsi_cmnd *cmnd)
{ {
struct sdebug_queue *sqp = sdebug_q_arr; u32 tag = blk_mq_unique_tag(cmnd->request);
u16 hwq = blk_mq_unique_tag_to_hwq(tag);
if (sdebug_mq_active) { pr_debug("tag=%#x, hwq=%d\n", tag, hwq);
u32 tag = blk_mq_unique_tag(cmnd->request); if (WARN_ON_ONCE(hwq >= submit_queues))
u16 hwq = blk_mq_unique_tag_to_hwq(tag); hwq = 0;
return sdebug_q_arr + hwq;
if (unlikely(hwq >= submit_queues)) {
pr_warn("Unexpected hwq=%d, apply modulo\n", hwq);
hwq %= submit_queues;
}
pr_debug("tag=%u, hwq=%d\n", tag, hwq);
return sqp + hwq;
} else
return sqp;
} }
/* Queued (deferred) command completions converge here. */ /* Queued (deferred) command completions converge here. */
...@@ -4587,9 +4579,8 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host) ...@@ -4587,9 +4579,8 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
num_host_resets); num_host_resets);
seq_printf(m, "dix_reads=%d, dix_writes=%d, dif_errors=%d\n", seq_printf(m, "dix_reads=%d, dix_writes=%d, dif_errors=%d\n",
dix_reads, dix_writes, dif_errors); dix_reads, dix_writes, dif_errors);
seq_printf(m, "usec_in_jiffy=%lu, %s=%d, mq_active=%d\n", seq_printf(m, "usec_in_jiffy=%lu, statistics=%d\n", TICK_NSEC / 1000,
TICK_NSEC / 1000, "statistics", sdebug_statistics, sdebug_statistics);
sdebug_mq_active);
seq_printf(m, "cmnd_count=%d, completions=%d, %s=%d, a_tsf=%d\n", seq_printf(m, "cmnd_count=%d, completions=%d, %s=%d, a_tsf=%d\n",
atomic_read(&sdebug_cmnd_count), atomic_read(&sdebug_cmnd_count),
atomic_read(&sdebug_completions), atomic_read(&sdebug_completions),
...@@ -5612,13 +5603,8 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost, ...@@ -5612,13 +5603,8 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost,
n += scnprintf(b + n, sb - n, "%02x ", n += scnprintf(b + n, sb - n, "%02x ",
(u32)cmd[k]); (u32)cmd[k]);
} }
if (sdebug_mq_active) sdev_printk(KERN_INFO, sdp, "%s: tag=%#x, cmd %s\n", my_name,
sdev_printk(KERN_INFO, sdp, "%s: tag=%u, cmd %s\n", blk_mq_unique_tag(scp->request), b);
my_name, blk_mq_unique_tag(scp->request),
b);
else
sdev_printk(KERN_INFO, sdp, "%s: cmd %s\n", my_name,
b);
} }
if (fake_host_busy(scp)) if (fake_host_busy(scp))
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
...@@ -5782,8 +5768,7 @@ static int sdebug_driver_probe(struct device * dev) ...@@ -5782,8 +5768,7 @@ static int sdebug_driver_probe(struct device * dev)
} }
/* Decide whether to tell scsi subsystem that we want mq */ /* Decide whether to tell scsi subsystem that we want mq */
/* Following should give the same answer for each host */ /* Following should give the same answer for each host */
sdebug_mq_active = shost_use_blk_mq(hpnt) && (submit_queues > 1); if (shost_use_blk_mq(hpnt))
if (sdebug_mq_active)
hpnt->nr_hw_queues = submit_queues; hpnt->nr_hw_queues = submit_queues;
sdbg_host->shost = hpnt; sdbg_host->shost = hpnt;
......
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