diff mbox series

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

Message ID 20220630213733.17689-2-bvanassche@acm.org
State New
Headers show
Series Call blk_mq_free_tag_set() earlier | expand

Commit Message

Bart Van Assche June 30, 2022, 9:37 p.m. UTC
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(-)

Comments

Ming Lei July 5, 2022, 2:40 a.m. UTC | #1
On Thu, Jun 30, 2022 at 02:37:31PM -0700, Bart Van Assche wrote:
> 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>
> ---

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming
diff mbox series

Patch

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);
 }