Skip to content

Commit cf48f79

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi into master
Pull SCSI fix from James Bottomley: "Small core patch to fix a corner case bug: we forgot to run the queues to handle starvation in the error exit from the scsi_queue_rq routine, which can lead to hangs on error conditions" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: core: Run queue in case of I/O resource contention failure
2 parents 04300d6 + 3f0dcfb commit cf48f79

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,15 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
547547
scsi_uninit_cmd(cmd);
548548
}
549549

550+
static void scsi_run_queue_async(struct scsi_device *sdev)
551+
{
552+
if (scsi_target(sdev)->single_lun ||
553+
!list_empty(&sdev->host->starved_list))
554+
kblockd_schedule_work(&sdev->requeue_work);
555+
else
556+
blk_mq_run_hw_queues(sdev->request_queue, true);
557+
}
558+
550559
/* Returns false when no more bytes to process, true if there are more */
551560
static bool scsi_end_request(struct request *req, blk_status_t error,
552561
unsigned int bytes)
@@ -591,11 +600,7 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
591600

592601
__blk_mq_end_request(req, error);
593602

594-
if (scsi_target(sdev)->single_lun ||
595-
!list_empty(&sdev->host->starved_list))
596-
kblockd_schedule_work(&sdev->requeue_work);
597-
else
598-
blk_mq_run_hw_queues(q, true);
603+
scsi_run_queue_async(sdev);
599604

600605
percpu_ref_put(&q->q_usage_counter);
601606
return false;
@@ -1702,6 +1707,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
17021707
*/
17031708
if (req->rq_flags & RQF_DONTPREP)
17041709
scsi_mq_uninit_cmd(cmd);
1710+
scsi_run_queue_async(sdev);
17051711
break;
17061712
}
17071713
return ret;

0 commit comments

Comments
 (0)