Skip to contentSkip to conversation

scsi: storvsc: use shost_for_each_device() instead of open coding

PATCH In review Vitaly Kuznetsov 3 participants 4 messages Jul 1, 2015 – Aug 13, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: storvsc: use shost_for_each_device() instead of open coding

Comment in struct Scsi_Host says that drivers are not supposed to access __devices directly. storvsc_host_scan() doesn't happen in irq context so we can just use shost_for_each_device().

---
 drivers/scsi/storvsc_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/scsi/storvsc_drv.c +1 -8
index 3c6584f..9ea912b 100644
@@ -426,7 +426,6 @@ static void storvsc_host_scan(struct work_struct *work)
 	struct storvsc_scan_work *wrk;
 	struct Scsi_Host *host;
 	struct scsi_device *sdev;
-	unsigned long flags;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
 	host = wrk->host;
@@ -443,14 +442,8 @@ static void storvsc_host_scan(struct work_struct *work)
 	 * may have been removed this way.
 	 */
 	mutex_lock(&host->scan_mutex);
-	spin_lock_irqsave(host->host_lock, flags);
-	list_for_each_entry(sdev, &host->__devices, siblings) {
-		spin_unlock_irqrestore(host->host_lock, flags);
+	shost_for_each_device(sdev, host)
 		scsi_test_unit_ready(sdev, 1, 1, NULL);
-		spin_lock_irqsave(host->host_lock, flags);
-		continue;
-	}
-	spin_unlock_irqrestore(host->host_lock, flags);
 	mutex_unlock(&host->scan_mutex);
 	/*
 	 * Now scan the host to discover LUNs that may have been added.
Signature · 1 line
2.4.3
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Wednesday, July 1, 2015 2:31 AM
To: [email protected]
Cc: Long Li; KY Srinivasan; Haiyang Zhang; James E.J. Bottomley; [email protected]; [email protected]
Subject: [PATCH] scsi: storvsc: use shost_for_each_device() instead of open coding

Quoted 5 lines

Comment in struct Scsi_Host says that drivers are not supposed to access __devices directly. storvsc_host_scan() doesn't happen in irq context so we can just use shost_for_each_device().

Quoted 36 lines
---
 drivers/scsi/storvsc_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/scsi/storvsc_drv.c +0 -1
index 3c6584f..9ea912b 100644
@@ -426,7 +426,6 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	struct storvsc_scan_work *wrk;
 	struct Scsi_Host *host;
 	struct scsi_device *sdev;
-	unsigned long flags;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
drivers/scsi/storvsc_drv.c +1 -7
 	host = wrk->host;
@@ -443,14 +442,8 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	 * may have been removed this way.
 	 */
 	mutex_lock(&host->scan_mutex);
-	spin_lock_irqsave(host->host_lock, flags);
-	list_for_each_entry(sdev, &host->__devices, siblings) {
-		spin_unlock_irqrestore(host->host_lock, flags);
+	shost_for_each_device(sdev, host)
 		scsi_test_unit_ready(sdev, 1, 1, NULL);
-		spin_lock_irqsave(host->host_lock, flags);
-		continue;
-	}
-	spin_unlock_irqrestore(host->host_lock, flags);
 	mutex_unlock(&host->scan_mutex);
 	/*

* Now scan the host to discover LUNs that may have been added.
--
2.4.3

Reviewed-by
#2 lore raw
Quoted 22 lines

-----Original Message-----
From: KY Srinivasan
Sent: Friday, July 03, 2015 11:35 AM
To: Vitaly Kuznetsov; [email protected]
Cc: Long Li; Haiyang Zhang; James E.J. Bottomley; [email protected]; [email protected]
Subject: RE: [PATCH] scsi: storvsc: use shost_for_each_device() instead of open coding

Quoted 9 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Wednesday, July 1, 2015 2:31 AM
To: [email protected]
Cc: Long Li; KY Srinivasan; Haiyang Zhang; James E.J. Bottomley; [email protected]; [email protected]
Subject: [PATCH] scsi: storvsc: use shost_for_each_device() instead of open coding

Quoted 7 lines
Quoted 5 lines

Comment in struct Scsi_Host says that drivers are not supposed to access __devices directly. storvsc_host_scan() doesn't happen in irq context so we can just use shost_for_each_device().

Quoted 36 lines
Quoted 36 lines
---
 drivers/scsi/storvsc_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/scsi/storvsc_drv.c +0 -1
index 3c6584f..9ea912b 100644
@@ -426,7 +426,6 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	struct storvsc_scan_work *wrk;
 	struct Scsi_Host *host;
 	struct scsi_device *sdev;
-	unsigned long flags;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
drivers/scsi/storvsc_drv.c +1 -7
 	host = wrk->host;
@@ -443,14 +442,8 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	 * may have been removed this way.
 	 */
 	mutex_lock(&host->scan_mutex);
-	spin_lock_irqsave(host->host_lock, flags);
-	list_for_each_entry(sdev, &host->__devices, siblings) {
-		spin_unlock_irqrestore(host->host_lock, flags);
+	shost_for_each_device(sdev, host)
 		scsi_test_unit_ready(sdev, 1, 1, NULL);
-		spin_lock_irqsave(host->host_lock, flags);
-		continue;
-	}
-	spin_unlock_irqrestore(host->host_lock, flags);
 	mutex_unlock(&host->scan_mutex);
 	/*

* Now scan the host to discover LUNs that may have been added.
--
2.4.3

#3 lore raw
Quoted 20 lines · Long Li
Quoted 20 lines

-----Original Message-----
From: KY Srinivasan
Sent: Friday, July 03, 2015 11:35 AM
To: Vitaly Kuznetsov; [email protected]
Cc: Long Li; Haiyang Zhang; James E.J. Bottomley; [email protected]; [email protected]
Subject: RE: [PATCH] scsi: storvsc: use shost_for_each_device() instead of open coding

Quoted 9 lines

-----Original Message-----
From: Vitaly Kuznetsov [mailto:[email protected]]
Sent: Wednesday, July 1, 2015 2:31 AM
To: [email protected]
Cc: Long Li; KY Srinivasan; Haiyang Zhang; James E.J. Bottomley; [email protected]; [email protected]
Subject: [PATCH] scsi: storvsc: use shost_for_each_device() instead of open coding

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

Comment in struct Scsi_Host says that drivers are not supposed to access __devices directly. storvsc_host_scan() doesn't happen in irq context so we can just use shost_for_each_device().

Sorry for the ping but it seems the fix never made it to scsi tree...

Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
---
 drivers/scsi/storvsc_drv.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/scsi/storvsc_drv.c +0 -1
index 3c6584f..9ea912b 100644
@@ -426,7 +426,6 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	struct storvsc_scan_work *wrk;
 	struct Scsi_Host *host;
 	struct scsi_device *sdev;
-	unsigned long flags;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
drivers/scsi/storvsc_drv.c +1 -7
 	host = wrk->host;
@@ -443,14 +442,8 @@ static void storvsc_host_scan(struct work_struct
 *work)
 	 * may have been removed this way.
 	 */
 	mutex_lock(&host->scan_mutex);
-	spin_lock_irqsave(host->host_lock, flags);
-	list_for_each_entry(sdev, &host->__devices, siblings) {
-		spin_unlock_irqrestore(host->host_lock, flags);
+	shost_for_each_device(sdev, host)
 		scsi_test_unit_ready(sdev, 1, 1, NULL);
-		spin_lock_irqsave(host->host_lock, flags);
-		continue;
-	}
-	spin_unlock_irqrestore(host->host_lock, flags);
 	mutex_unlock(&host->scan_mutex);
 	/*

* Now scan the host to discover LUNs that may have been added.
--
2.4.3

Signature · 1 line
  Vitaly