[PATCH] scsi: core: fix race between handling STS_RESOURCE and completion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When queuing IO request to LLD, STS_RESOURCE may be returned because:

- host in recovery or blocked
- target queue throttling or blocked
- LLD rejection

Any one of the above doesn't happen frequently enough.

BLK_STS_DEV_RESOURCE is returned to block layer for avoiding unnecessary
re-run queue, and it is just one small optimization. However, all
in-flight requests originated from this scsi device may be completed
just after reading 'sdev->device_busy', so BLK_STS_DEV_RESOURCE is
returned to block layer. And the current failed IO won't get chance
to be queued any more, since it is invisible at that time for either
scsi_run_queue_async() or blk-mq's RESTART.

Fix the issue by not returning BLK_STS_DEV_RESOURCE in this situation.

Cc: Hannes Reinecke <hare@xxxxxxxx>
Cc: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>
Cc: Kashyap Desai <kashyap.desai@xxxxxxxxxxxx>
Cc: Bart Van Assche <bvanassche@xxxxxxx>
Cc: Ewan Milne <emilne@xxxxxxxxxx>
Cc: Long Li <longli@xxxxxxxxxxxxx>
Tested-by: "chenxiang (M)" <chenxiang66@xxxxxxxxxxxxx>
Reported-by: John Garry <john.garry@xxxxxxxxxx>
Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 60c7a7d74852..03c6d0620bfd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1703,8 +1703,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 		break;
 	case BLK_STS_RESOURCE:
 	case BLK_STS_ZONE_RESOURCE:
-		if (atomic_read(&sdev->device_busy) ||
-		    scsi_device_blocked(sdev))
+		if (scsi_device_blocked(sdev))
 			ret = BLK_STS_DEV_RESOURCE;
 		break;
 	default:
-- 
2.28.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux