[PATCH v2 1/3] scsi: Simplify scsi_forget_host()

Bart Van Assche
2022-06-30T21:37:46Z

scsi_forget_host() has only one caller, namely scsi_remove_host(). That
function may sleep. Additionally, scsi_forget_host() calls a function
that may sleep (__scsi_remove_device()). Simplify scsi_forget_host() by
removing support for saving and restoring the interrupt state.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_scan.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 91ac901a6682..5c3bb4ceeac3 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1964,17 +1964,18 @@ EXPORT_SYMBOL(scsi_scan_host);
void scsi_forget_host(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
- unsigned long flags;
+
+ might_sleep();

restart:
- spin_lock_irqsave(shost->host_lock, flags);
+ spin_lock_irq(shost->host_lock);
list_for_each_entry(sdev, &shost->__devices, siblings) {
if (sdev->sdev_state == SDEV_DEL)
continue;
- spin_unlock_irqrestore(shost->host_lock, flags);
+ spin_unlock_irq(shost->host_lock);
__scsi_remove_device(sdev);
goto restart;
}
- spin_unlock_irqrestore(shost->host_lock, flags);
+ spin_unlock_irq(shost->host_lock);
}