Skip to content

Commit 9c559c9

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Use blk_mq_tagset_busy_iter() in stop_all_queued()
Instead of iterating all deferred commands in the submission queue structures, use blk_mq_tagset_busy_iter(), which is a standard API for this. Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20230327074310.1862889-9-john.g.garry@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 600d9ea commit 9c559c9

1 file changed

Lines changed: 17 additions & 28 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5326,40 +5326,29 @@ static bool scsi_debug_abort_cmnd(struct scsi_cmnd *cmnd)
53265326
return res;
53275327
}
53285328

5329+
/*
5330+
* All we can do is set the cmnd as internally aborted and wait for it to
5331+
* finish. We cannot call scsi_done() as normal completion path may do that.
5332+
*/
5333+
static bool sdebug_stop_cmnd(struct request *rq, void *data)
5334+
{
5335+
scsi_debug_abort_cmnd(blk_mq_rq_to_pdu(rq));
5336+
5337+
return true;
5338+
}
5339+
53295340
/* Deletes (stops) timers or work queues of all queued commands */
53305341
static void stop_all_queued(void)
53315342
{
5332-
unsigned long iflags, flags;
5333-
int j, k;
5334-
struct sdebug_queue *sqp;
5343+
struct sdebug_host_info *sdhp;
53355344

5336-
for (j = 0, sqp = sdebug_q_arr; j < submit_queues; ++j, ++sqp) {
5337-
spin_lock_irqsave(&sqp->qc_lock, iflags);
5338-
for (k = 0; k < SDEBUG_CANQUEUE; ++k) {
5339-
if (test_bit(k, sqp->in_use_bm)) {
5340-
struct sdebug_queued_cmd *sqcp = sqp->qc_arr[k];
5341-
struct sdebug_scsi_cmd *sdsc;
5342-
struct scsi_cmnd *scmd;
5345+
mutex_lock(&sdebug_host_list_mutex);
5346+
list_for_each_entry(sdhp, &sdebug_host_list, host_list) {
5347+
struct Scsi_Host *shost = sdhp->shost;
53435348

5344-
if (!sqcp)
5345-
continue;
5346-
scmd = sqcp->scmd;
5347-
if (!scmd)
5348-
continue;
5349-
sdsc = scsi_cmd_priv(scmd);
5350-
spin_lock_irqsave(&sdsc->lock, flags);
5351-
if (TO_QUEUED_CMD(scmd) != sqcp) {
5352-
spin_unlock_irqrestore(&sdsc->lock, flags);
5353-
continue;
5354-
}
5355-
scsi_debug_stop_cmnd(scmd, NULL);
5356-
spin_unlock_irqrestore(&sdsc->lock, flags);
5357-
sqp->qc_arr[k] = NULL;
5358-
clear_bit(k, sqp->in_use_bm);
5359-
}
5360-
}
5361-
spin_unlock_irqrestore(&sqp->qc_lock, iflags);
5349+
blk_mq_tagset_busy_iter(&shost->tag_set, sdebug_stop_cmnd, NULL);
53625350
}
5351+
mutex_unlock(&sdebug_host_list_mutex);
53635352
}
53645353

53655354
static int scsi_debug_abort(struct scsi_cmnd *SCpnt)

0 commit comments

Comments
 (0)