Skip to content

Commit 673235f

Browse files
Ming Leimartinkpetersen
authored andcommitted
scsi: core: Fix race between handling STS_RESOURCE and completion
When queuing I/O request to LLD, STS_RESOURCE may be returned because: - Host is in recovery or blocked - Target queue throttling or target is blocked - LLD rejection In these scenarios BLK_STS_DEV_RESOURCE is returned to the block layer to avoid an unnecessary re-run of the queue. However, all of the requests queued to this SCSI device may complete immediately after reading 'sdev->device_busy' and BLK_STS_DEV_RESOURCE is returned to block layer. In that case the current I/O won't get a chance to get queued since it is invisible at that time for both scsi_run_queue_async() and blk-mq's RESTART. Fix the issue by not returning BLK_STS_DEV_RESOURCE in this situation. Link: https://lore.kernel.org/r/[email protected] Fixes: 86ff7c2 ("blk-mq: introduce BLK_STS_DEV_RESOURCE") Cc: Hannes Reinecke <[email protected]> Cc: Sumit Saxena <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Ewan Milne <[email protected]> Cc: Long Li <[email protected]> Reported-by: John Garry <[email protected]> Tested-by: "chenxiang (M)" <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent eeaf06a commit 673235f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,8 +1703,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
17031703
break;
17041704
case BLK_STS_RESOURCE:
17051705
case BLK_STS_ZONE_RESOURCE:
1706-
if (atomic_read(&sdev->device_busy) ||
1707-
scsi_device_blocked(sdev))
1706+
if (scsi_device_blocked(sdev))
17081707
ret = BLK_STS_DEV_RESOURCE;
17091708
break;
17101709
default:

0 commit comments

Comments
 (0)