Skip to content

Commit 0c028b6

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Abort commands from scsi_debug_device_reset()
Currently scsi_debug_device_reset() does not do much apart from setting the SDEBUG_UA_POR ("Power on, reset, or bus device reset") flag, which is eventually passed back to the SCSI midlayer later for a "unit attention" command. There is a report that blktest scsi/007 test fails due to commit 1107c7b ("scsi: scsi_debug: Dynamically allocate sdebug_queued_cmd"). The problem there is that there are dangling scsi_debug queued commands when we attempt to remove the driver. scsi/007 test triggers SCSI EH and attempts to abort a timed-out command. Function scsi_debug_device_reset() is called as part of the EH, but does not deal with outstanding erroneous command. Prior to the named commit, removing the driver caused all dangling queued commands to be stopped - this should have not been necessary. Fix by aborting outstanding commands on a scsi_device basis from scsi_debug_device_reset(). Fixes: 1107c7b ("scsi: scsi_debug: Dynamically allocate sdebug_queued_cmd") Reported-by: kernel test robot <yujie.liu@intel.com> Link: https://lore.kernel.org/oe-lkp/202304071111.e762fcbd-yujie.liu@intel.com Signed-off-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20230416175654.159163-1-john.g.garry@oracle.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 3c85f08 commit 0c028b6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5291,6 +5291,26 @@ static int scsi_debug_abort(struct scsi_cmnd *SCpnt)
52915291
return SUCCESS;
52925292
}
52935293

5294+
static bool scsi_debug_stop_all_queued_iter(struct request *rq, void *data)
5295+
{
5296+
struct scsi_device *sdp = data;
5297+
struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
5298+
5299+
if (scmd->device == sdp)
5300+
scsi_debug_abort_cmnd(scmd);
5301+
5302+
return true;
5303+
}
5304+
5305+
/* Deletes (stops) timers or work queues of all queued commands per sdev */
5306+
static void scsi_debug_stop_all_queued(struct scsi_device *sdp)
5307+
{
5308+
struct Scsi_Host *shost = sdp->host;
5309+
5310+
blk_mq_tagset_busy_iter(&shost->tag_set,
5311+
scsi_debug_stop_all_queued_iter, sdp);
5312+
}
5313+
52945314
static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
52955315
{
52965316
struct scsi_device *sdp = SCpnt->device;
@@ -5300,6 +5320,8 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
53005320

53015321
if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
53025322
sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
5323+
5324+
scsi_debug_stop_all_queued(sdp);
53035325
if (devip)
53045326
set_bit(SDEBUG_UA_POR, devip->uas_bm);
53055327

0 commit comments

Comments
 (0)