Skip to content

Commit 626b13f

Browse files
committed
scsi: Do not rescan devices with a suspended queue
Commit ff48b37 ("scsi: Do not attempt to rescan suspended devices") modified scsi_rescan_device() to avoid attempting rescanning a suspended device. However, the modification added a check to verify that a SCSI device is in the running state without checking if the device request queue (in the case of block device) is also running, thus allowing the exectuion of internal requests. Without checking the device request queue, commit ff48b37 fix is incomplete and deadlocks on resume can still happen. Use blk_queue_pm_only() to check if the device request queue allows executing commands in addition to checking the SCSI device state. Reported-by: Petr Tesarik <[email protected]> Fixes: ff48b37 ("scsi: Do not attempt to rescan suspended devices") Cc: [email protected] Tested-by: Petr Tesarik <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent 0c1e81d commit 626b13f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/scsi/scsi_scan.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,13 @@ int scsi_rescan_device(struct scsi_device *sdev)
16271627
device_lock(dev);
16281628

16291629
/*
1630-
* Bail out if the device is not running. Otherwise, the rescan may
1631-
* block waiting for commands to be executed, with us holding the
1632-
* device lock. This can result in a potential deadlock in the power
1633-
* management core code when system resume is on-going.
1630+
* Bail out if the device or its queue are not running. Otherwise,
1631+
* the rescan may block waiting for commands to be executed, with us
1632+
* holding the device lock. This can result in a potential deadlock
1633+
* in the power management core code when system resume is on-going.
16341634
*/
1635-
if (sdev->sdev_state != SDEV_RUNNING) {
1635+
if (sdev->sdev_state != SDEV_RUNNING ||
1636+
blk_queue_pm_only(sdev->request_queue)) {
16361637
ret = -EWOULDBLOCK;
16371638
goto unlock;
16381639
}

0 commit comments

Comments
 (0)