Skip to contentSkip to conversation

Drivers: scsi: storvsc: Fix miscellaneous issues

PATCH Applied K. Y. Srinivasan 3 participants 13 messages Dec 16, 2014 – Jan 5, 2015

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

cover Drivers: scsi: storvsc: Fix miscellaneous issues

The first two patches in this series are a resend; these were submitted some months ago and as far as I know, there were no outstanding issues.

Win8 and win8 r2 hosts do support SPC-3 features but claim SPC-2 compliance. This issue is fixed here as well.

K. Y. Srinivasan (4):
Drivers: scsi: storvsc: In responce to a scan event, scan the host
Drivers: scsi: storvsc: Force discovery of LUNs that may have been
removed.
Drivers: scsi: storvsc: Fix a bug in storvsc limits
Drivers: scsi: storvsc: Force SPC-3 compliance on win8 and win8 r2
hosts

 drivers/scsi/storvsc_drv.c |   71 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/4 Drivers: scsi: storvsc: In responce to a scan event, scan the host

The virtual HBA that storvsc implements can support multiple channels and targets. So, scan the host when the host notifies that a scan is needed.

---
 drivers/scsi/storvsc_drv.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/scsi/storvsc_drv.c +7 -12
index e3ba251..0a96fef 100644
@@ -426,21 +426,16 @@ done:
 	kfree(wrk);
 }
 
-static void storvsc_bus_scan(struct work_struct *work)
+static void storvsc_host_scan(struct work_struct *work)
 {
 	struct storvsc_scan_work *wrk;
-	int id, order_id;
+	struct Scsi_Host *host;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
-	for (id = 0; id < wrk->host->max_id; ++id) {
-		if (wrk->host->reverse_ordering)
-			order_id = wrk->host->max_id - id - 1;
-		else
-			order_id = id;
-
-		scsi_scan_target(&wrk->host->shost_gendev, 0,
-				order_id, SCAN_WILD_CARD, 1);
-	}
+	host = wrk->host;
+
+	scsi_scan_host(host);
+
 	kfree(wrk);
 }
 
@@ -1198,7 +1193,7 @@ static void storvsc_on_receive(struct hv_device *device,
 		if (!work)
 			return;
 
-		INIT_WORK(&work->work, storvsc_bus_scan);
+		INIT_WORK(&work->work, storvsc_host_scan);
 		work->host = stor_device->host;
 		schedule_work(&work->work);
 		break;
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/4 Drivers: scsi: storvsc: Force discovery of LUNs that may have been removed.

The host asks the guest to scan when a LUN is removed or added. The only way a guest can identify the removed LUN is when an I/O is attempted on a removed LUN - the SRB status code indicates that the LUN is invalid. We currently handle this SRB status and remove the device.

Rather than waiting for an I/O to remove the device, force the discovery of LUNs that may have been removed prior to discovering LUNs that may have been added.

---
 drivers/scsi/storvsc_drv.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
drivers/scsi/storvsc_drv.c +26 -0
index 0a96fef..a7163c6 100644
@@ -430,10 +430,36 @@ 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;
 
+	/*
+	 * Before scanning the host, first check to see if any of the
+	 * currrently known devices have been hot removed. We issue a
+	 * "unit ready" command against all currently known devices.
+	 * This I/O will result in an error for devices that have been
+	 * removed. As part of handling the I/O error, we remove the device.
+	 *
+	 * When a LUN is added or removed, the host sends us a signal to
+	 * scan the host. Thus we are forced to discover the LUNs that
+	 * 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);
+		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.
+	 */
 	scsi_scan_host(host);
 
 	kfree(wrk);
Signature · 1 line
1.7.4.1
Reviewed-by on v1 2/4
#3 lore raw

RE: [PATCH 2/4] Drivers: scsi: storvsc: Force discovery of LUNs that may have been removed.

Quoted 17 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of K. Y. Srinivasan
Sent: Tuesday, December 16, 2014 1:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH 2/4] Drivers: scsi: storvsc: Force discovery of LUNs that may have been removed.

The host asks the guest to scan when a LUN is removed or added. The only way a guest can identify the removed LUN is when an I/O is attempted on a removed LUN - the SRB status code indicates that the LUN is invalid. We currently handle this SRB status and remove the device.

Quoted 5 lines

Rather than waiting for an I/O to remove the device, force the discovery of LUNs that may have been removed prior to discovering LUNs that may have been added.

Quoted 52 lines
---
 drivers/scsi/storvsc_drv.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
drivers/scsi/storvsc_drv.c index renamed from drivers/scsi/storvsc_drv.c +0 -0

0a96fef..a7163c6 100644

drivers/scsi/storvsc_drv.c +26 -1
@@ -430,10 +430,36 @@ 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;
 
+	/*
+	 * Before scanning the host, first check to see if any of the
+	 * currrently known devices have been hot removed. We issue a
+	 * "unit ready" command against all currently known devices.
+	 * This I/O will result in an error for devices that have been
+	 * removed. As part of handling the I/O error, we remove the device.
+	 *
+	 * When a LUN is added or removed, the host sends us a signal to
+	 * scan the host. Thus we are forced to discover the LUNs that
+	 * 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);
+		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.
+	 */
 	scsi_scan_host(host);
 
 	kfree(wrk);
--

1.7.4.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

#4 lore raw

PATCH 3/4 Drivers: scsi: storvsc: Fix a bug in storvsc limits

In reply to K. Y. Srinivasan

Commit 4cd83ecdac20d30725b4f96e5d7814a1e290bc7e changed the limits to reflect the values on the host. It turns out that WS2008R2 cannot correctly handle these new limits. Fix this bug by setting the limits based on the host.

---
 drivers/scsi/storvsc_drv.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/storvsc_drv.c +12 -3
index a7163c6..fdc5164 100644
@@ -1782,6 +1782,9 @@ static int storvsc_probe(struct hv_device *device,
 	bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
 	int target = 0;
 	struct storvsc_device *stor_device;
+	int max_luns_per_target;
+	int max_targets;
+	int max_channels;
 
 	/*
 	 * Based on the windows host we are running on,
@@ -1795,12 +1798,18 @@ static int storvsc_probe(struct hv_device *device,
 		vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
 		vmstor_current_major = VMSTOR_WIN7_MAJOR;
 		vmstor_current_minor = VMSTOR_WIN7_MINOR;
+		max_luns_per_target = STORVSC_IDE_MAX_LUNS_PER_TARGET;
+		max_targets = STORVSC_IDE_MAX_TARGETS;
+		max_channels = STORVSC_IDE_MAX_CHANNELS;
 		break;
 	default:
 		sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
 		vmscsi_size_delta = 0;
 		vmstor_current_major = VMSTOR_WIN8_MAJOR;
 		vmstor_current_minor = VMSTOR_WIN8_MINOR;
+		max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET;
+		max_targets = STORVSC_MAX_TARGETS;
+		max_channels = STORVSC_MAX_CHANNELS;
 		break;
 	}
 
@@ -1848,9 +1857,9 @@ static int storvsc_probe(struct hv_device *device,
 		break;
 
 	case SCSI_GUID:
-		host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-		host->max_id = STORVSC_MAX_TARGETS;
-		host->max_channel = STORVSC_MAX_CHANNELS - 1;
+		host->max_lun = max_luns_per_target;
+		host->max_id = max_targets;
+		host->max_channel = max_channels - 1;
 		break;
 
 	default:
Signature · 1 line
1.7.4.1
Reviewed-by on v1 3/4
#5 lore raw

RE: [PATCH 3/4] Drivers: scsi: storvsc: Fix a bug in storvsc limits

Quoted 11 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of K. Y. Srinivasan
Sent: Tuesday, December 16, 2014 1:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH 3/4] Drivers: scsi: storvsc: Fix a bug in storvsc limits

Quoted 5 lines

Commit 4cd83ecdac20d30725b4f96e5d7814a1e290bc7e changed the limits to reflect the values on the host. It turns out that WS2008R2 cannot correctly handle these new limits. Fix this bug by setting the limits based on the host.

Quoted 59 lines
---
 drivers/scsi/storvsc_drv.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/scsi/storvsc_drv.c index renamed from drivers/scsi/storvsc_drv.c +0 -0

a7163c6..fdc5164 100644

drivers/scsi/storvsc_drv.c +5 -0
@@ -1782,6 +1782,9 @@ static int storvsc_probe(struct hv_device *device,
 	bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
 	int target = 0;
 	struct storvsc_device *stor_device;
+	int max_luns_per_target;
+	int max_targets;
+	int max_channels;
 
 	/*
 	 * Based on the windows host we are running on, @@ -1795,12
+1798,18 @@ static int storvsc_probe(struct hv_device *device,
 		vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
 		vmstor_current_major = VMSTOR_WIN7_MAJOR;
 		vmstor_current_minor = VMSTOR_WIN7_MINOR;
+		max_luns_per_target =

STORVSC_IDE_MAX_LUNS_PER_TARGET;

drivers/scsi/storvsc_drv.c +2 -0
+		max_targets = STORVSC_IDE_MAX_TARGETS;
+		max_channels = STORVSC_IDE_MAX_CHANNELS;
 		break;
 	default:
 		sense_buffer_size =

POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;

drivers/scsi/storvsc_drv.c +6 -4
 		vmscsi_size_delta = 0;
 		vmstor_current_major = VMSTOR_WIN8_MAJOR;
 		vmstor_current_minor = VMSTOR_WIN8_MINOR;
+		max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET;
+		max_targets = STORVSC_MAX_TARGETS;
+		max_channels = STORVSC_MAX_CHANNELS;
 		break;
 	}
@@ -1848,9 +1857,9 @@ static int storvsc_probe(struct hv_device *device,
 		break;
 
 	case SCSI_GUID:
-		host->max_lun = STORVSC_MAX_LUNS_PER_TARGET;
-		host->max_id = STORVSC_MAX_TARGETS;
-		host->max_channel = STORVSC_MAX_CHANNELS - 1;
+		host->max_lun = max_luns_per_target;
+		host->max_id = max_targets;
+		host->max_channel = max_channels - 1;
 		break;
 
 	default:
--

1.7.4.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

#6 lore raw

PATCH 4/4 Drivers: scsi: storvsc: Force SPC-3 compliance on win8 and win8 r2 hosts

In reply to K. Y. Srinivasan

On win8 and win8 r2 hosts force SPC-3 compliance for MSFT virtual disks. Ubuntu has been carrying a similar patch outside the tree for a while now. Starting with win10, the host will support SPC-3 compliance. Based on all the testing that has been done on win8 and win8 r2 hosts, we are comfortable claiming SPC-3 compliance on these hosts as well. This will enable TRIM support on these hosts.

Suggested by: James Bottomley <[email protected]>

---
 drivers/scsi/storvsc_drv.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/scsi/storvsc_drv.c +13 -0
index fdc5164..7487e07 100644
@@ -1468,6 +1468,19 @@ static int storvsc_device_configure(struct scsi_device *sdevice)
 	 */
 	sdevice->sdev_bflags |= msft_blist_flags;
 
+	/*
+	 * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3
+	 * if the device is a MSFT virtual device.
+	 */
+	if (!strncmp(sdevice->vendor, "Msft", 4)) {
+		switch (vmbus_proto_version) {
+		case VERSION_WIN8:
+		case VERSION_WIN8_1:
+			sdevice->scsi_level = SCSI_SPC_3;
+			break;
+		}
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.7.4.1
Reviewed-by on v1 4/4
#7 lore raw

RE: [PATCH 4/4] Drivers: scsi: storvsc: Force SPC-3 compliance on win8 and win8 r2 hosts

Quoted 19 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of K. Y. Srinivasan
Sent: Tuesday, December 16, 2014 1:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH 4/4] Drivers: scsi: storvsc: Force SPC-3 compliance on win8 and win8 r2 hosts

On win8 and win8 r2 hosts force SPC-3 compliance for MSFT virtual disks. Ubuntu has been carrying a similar patch outside the tree for a while now. Starting with win10, the host will support SPC-3 compliance. Based on all the testing that has been done on win8 and win8 r2 hosts, we are comfortable claiming SPC-3 compliance on these hosts as well. This will enable TRIM support on these hosts.

Quoted 3 lines

Suggested by: James Bottomley
<[email protected]>

Quoted 36 lines
---
 drivers/scsi/storvsc_drv.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/scsi/storvsc_drv.c index renamed from drivers/scsi/storvsc_drv.c +0 -0

fdc5164..7487e07 100644

drivers/scsi/storvsc_drv.c +13 -1
@@ -1468,6 +1468,19 @@ static int storvsc_device_configure(struct
 scsi_device *sdevice)
 	 */
 	sdevice->sdev_bflags |= msft_blist_flags;
 
+	/*
+	 * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3
+	 * if the device is a MSFT virtual device.
+	 */
+	if (!strncmp(sdevice->vendor, "Msft", 4)) {
+		switch (vmbus_proto_version) {
+		case VERSION_WIN8:
+		case VERSION_WIN8_1:
+			sdevice->scsi_level = SCSI_SPC_3;
+			break;
+		}
+	}
+
 	return 0;
 }
 
--

1.7.4.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reviewed-by on v1 1/4
#8 lore raw

RE: [PATCH 1/4] Drivers: scsi: storvsc: In responce to a scan event, scan the host

In reply to K. Y. Srinivasan
Quoted 12 lines

-----Original Message-----
From: devel [mailto:[email protected]] On Behalf Of K. Y. Srinivasan
Sent: Tuesday, December 16, 2014 1:22 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH 1/4] Drivers: scsi: storvsc: In responce to a scan event, scan the host

Quoted 4 lines

The virtual HBA that storvsc implements can support multiple channels and targets. So, scan the host when the host notifies that a scan is needed.

Quoted 53 lines
---
 drivers/scsi/storvsc_drv.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
drivers/scsi/storvsc_drv.c index renamed from drivers/scsi/storvsc_drv.c +0 -0

e3ba251..0a96fef 100644

drivers/scsi/storvsc_drv.c +7 -12
@@ -426,21 +426,16 @@ done:
 	kfree(wrk);
 }
 
-static void storvsc_bus_scan(struct work_struct *work)
+static void storvsc_host_scan(struct work_struct *work)
 {
 	struct storvsc_scan_work *wrk;
-	int id, order_id;
+	struct Scsi_Host *host;
 
 	wrk = container_of(work, struct storvsc_scan_work, work);
-	for (id = 0; id < wrk->host->max_id; ++id) {
-		if (wrk->host->reverse_ordering)
-			order_id = wrk->host->max_id - id - 1;
-		else
-			order_id = id;
-
-		scsi_scan_target(&wrk->host->shost_gendev, 0,
-				order_id, SCAN_WILD_CARD, 1);
-	}
+	host = wrk->host;
+
+	scsi_scan_host(host);
+
 	kfree(wrk);
 }
 
@@ -1198,7 +1193,7 @@ static void storvsc_on_receive(struct hv_device
 *device,
 		if (!work)
 			return;
 
-		INIT_WORK(&work->work, storvsc_bus_scan);
+		INIT_WORK(&work->work, storvsc_host_scan);
 		work->host = stor_device->host;
 		schedule_work(&work->work);

break;
--
1.7.4.1

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

#9 lore raw
In reply to K. Y. Srinivasan
Quoted 18 lines

-----Original Message-----
From: K. Y. Srinivasan [mailto:[email protected]]
Sent: Tuesday, December 16, 2014 1:21 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: KY Srinivasan
Subject: [PATCH 0/4] Drivers: scsi: storvsc: Fix miscellaneous issues

The first two patches in this series are a resend; these were submitted some months ago and as far as I know, there were no outstanding issues.

Win8 and win8 r2 hosts do support SPC-3 features but claim SPC-2 compliance.
This issue is fixed here as well.

Quoted 7 lines

K. Y. Srinivasan (4):
Drivers: scsi: storvsc: In responce to a scan event, scan the host
Drivers: scsi: storvsc: Force discovery of LUNs that may have been
removed.
Drivers: scsi: storvsc: Fix a bug in storvsc limits
Drivers: scsi: storvsc: Force SPC-3 compliance on win8 and win8 r2
hosts

Christoph,

Should I be resending these patches.

Regards,

K. Y

Quoted 7 lines
 drivers/scsi/storvsc_drv.c |   71
+++++++++++++++++++++++++++++++++++--------
 1 files changed, 57 insertions(+), 14 deletions(-)

--
1.7.4.1

#10 lore raw
Quoted 1 line · KY Srinivasan

Should I be resending these patches.

I don't need a resend, I need a review for the patches. Note that for driver patches I'm also fine with a review from a co worker, as long as it's a real review not just a rubber stamp.

Talking about process: for the next submission please only use "storvsc: " as the subject prefix, I had to remove "Drivers: scsi: " which doesn'd add useful information every time so far.

#11 lore raw
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, December 30, 2014 1:32 AM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/4] Drivers: scsi: storvsc: Fix miscellaneous issues

Quoted 6 lines
Quoted 1 line · KY Srinivasan

Should I be resending these patches.

I don't need a resend, I need a review for the patches. Note that for driver patches I'm also fine with a review from a co worker, as long as it's a real review not just a rubber stamp.

Thanks; will do.

Quoted 4 lines

Talking about process: for the next submission please only use "storvsc: " as the subject prefix, I had to remove "Drivers: scsi: " which doesn'd add useful information every time so far.

Ok.

Regards,

K. Y