Skip to content

Commit 09e797c

Browse files
wenchao-haomartinkpetersen
authored andcommitted
scsi: core: Decrease scsi_device's iorequest_cnt if dispatch failed
If scsi_dispatch_cmd() failed, the SCSI command was not sent to the target, scsi_queue_rq() would return BLK_STS_RESOURCE and the related request would be requeued. The timeout of this request would not fire, no one would increase iodone_cnt. The above flow would result the iodone_cnt smaller than iorequest_cnt. So decrease the iorequest_cnt if dispatch failed to workaround the issue. Signed-off-by: Wenchao Hao <haowenchao2@huawei.com> Reported-by: Ming Lei <ming.lei@redhat.com> Closes: https://lore.kernel.org/r/ZF+zB+bB7iqe0wGd@ovpn-8-17.pek2.redhat.com Link: https://lore.kernel.org/r/20230515070156.1790181-3-haowenchao2@huawei.com Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6ca9818 commit 09e797c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
14851485
*/
14861486
SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd,
14871487
"queuecommand : device blocked\n"));
1488+
atomic_dec(&cmd->device->iorequest_cnt);
14881489
return SCSI_MLQUEUE_DEVICE_BUSY;
14891490
}
14901491

@@ -1517,6 +1518,7 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
15171518
trace_scsi_dispatch_cmd_start(cmd);
15181519
rtn = host->hostt->queuecommand(host, cmd);
15191520
if (rtn) {
1521+
atomic_dec(&cmd->device->iorequest_cnt);
15201522
trace_scsi_dispatch_cmd_error(cmd, rtn);
15211523
if (rtn != SCSI_MLQUEUE_DEVICE_BUSY &&
15221524
rtn != SCSI_MLQUEUE_TARGET_BUSY)

0 commit comments

Comments
 (0)