All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scsi: storvsc: Add support for FC rport.
@ 2017-04-03 11:33 Cathy Avery
  2017-04-03 12:17   ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Cathy Avery @ 2017-04-03 11:33 UTC (permalink / raw)
  To: kys, hch, haiyangz, jejb, martin.petersen
  Cc: stephen, dan.carpenter, devel, linux-kernel, linux-scsi

Included in the current storvsc driver for Hyper-V is the ability
to access luns on an FC fabric via a virtualized fiber channel
adapter exposed by the Hyper-V host. The driver also attaches to
the FC transport to allow host and port names to be published under
/sys/class/fc_host/hostX. Current customer tools running on the VM
require that these names be available in the well known standard
location under fc_host/hostX.

A problem arose when attaching to the FC transport. The scsi_scan
code attempts to call fc_user_scan which has basically become a no-op
due to the fact that the virtualized FC device does not expose rports.
At this point you cannot refresh the scsi bus after mapping or unmapping
luns on the SAN without a reboot of the VM.

This patch stubs in an rport per fc_host in storvsc so that the
requirement of a defined rport is now met within the fc_transport and
echo "- - -" > /sys/class/scsi_host/hostX/scan now works.

Signed-off-by: Cathy Avery <cavery@redhat.com>
---
Changes since v1:
- Fix fc_rport_identifiers init [Stephen Hemminger]
- Better error checking
---
 drivers/scsi/storvsc_drv.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 638e5f4..37646d1 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -478,6 +478,9 @@ struct storvsc_device {
 	 */
 	u64 node_name;
 	u64 port_name;
+#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
+	struct fc_rport *rport;
+#endif
 };
 
 struct hv_host_device {
@@ -1816,19 +1819,27 @@ static int storvsc_probe(struct hv_device *device,
 		target = (device->dev_instance.b[5] << 8 |
 			 device->dev_instance.b[4]);
 		ret = scsi_add_device(host, 0, target, 0);
-		if (ret) {
-			scsi_remove_host(host);
-			goto err_out2;
-		}
+		if (ret)
+			goto err_out3;
 	}
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
 	if (host->transportt == fc_transport_template) {
+		struct fc_rport_identifiers ids = {
+			.roles = FC_PORT_ROLE_FCP_TARGET,
+		};
+
 		fc_host_node_name(host) = stor_device->node_name;
 		fc_host_port_name(host) = stor_device->port_name;
+		stor_device->rport = fc_remote_port_add(host, 0, &ids);
+		if (!stor_device->rport)
+			goto err_out3;
 	}
 #endif
 	return 0;
 
+err_out3:
+	scsi_remove_host(host);
+
 err_out2:
 	/*
 	 * Once we have connected with the host, we would need to
@@ -1854,8 +1865,10 @@ static int storvsc_remove(struct hv_device *dev)
 	struct Scsi_Host *host = stor_device->host;
 
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
-	if (host->transportt == fc_transport_template)
+	if (host->transportt == fc_transport_template) {
+		fc_remote_port_delete(stor_device->rport);
 		fc_remove_host(host);
+	}
 #endif
 	scsi_remove_host(host);
 	storvsc_dev_remove(dev);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add support for FC rport.
  2017-04-03 11:33 [PATCH v2] scsi: storvsc: Add support for FC rport Cathy Avery
@ 2017-04-03 12:17   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2017-04-03 12:17 UTC (permalink / raw)
  To: Cathy Avery
  Cc: kys, hch, haiyangz, jejb, martin.petersen, stephen,
	dan.carpenter, devel, linux-kernel, linux-scsi

>  	if (host->transportt == fc_transport_template) {
> +		struct fc_rport_identifiers ids = {
> +			.roles = FC_PORT_ROLE_FCP_TARGET,
> +		};

I don't think storvsc ever acts as FCP target.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add support for FC rport.
@ 2017-04-03 12:17   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2017-04-03 12:17 UTC (permalink / raw)
  To: Cathy Avery
  Cc: jejb, linux-scsi, martin.petersen, haiyangz, linux-kernel, hch,
	devel, dan.carpenter

>  	if (host->transportt == fc_transport_template) {
> +		struct fc_rport_identifiers ids = {
> +			.roles = FC_PORT_ROLE_FCP_TARGET,
> +		};

I don't think storvsc ever acts as FCP target.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add support for FC rport.
  2017-04-03 12:17   ` Christoph Hellwig
  (?)
@ 2017-04-03 13:14   ` Cathy Avery
  2017-04-04  6:53     ` Christoph Hellwig
  -1 siblings, 1 reply; 8+ messages in thread
From: Cathy Avery @ 2017-04-03 13:14 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: kys, haiyangz, jejb, martin.petersen, stephen, dan.carpenter,
	devel, linux-kernel, linux-scsi

On 04/03/2017 08:17 AM, Christoph Hellwig wrote:
>>   	if (host->transportt == fc_transport_template) {
>> +		struct fc_rport_identifiers ids = {
>> +			.roles = FC_PORT_ROLE_FCP_TARGET,
>> +		};
> I don't think storvsc ever acts as FCP target.

In order to implement the work around so that the scsi scan works 
indicating FC_PORT_ROLE_FCP_TARGET as a role was necessary due to its 
test in fc_scsi_scan_rport. The idea here is to avoid making any changes 
to the fc_transport driver which was of some concern.


Thanks,

Cathy

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] scsi: storvsc: Add support for FC rport.
  2017-04-03 13:14   ` Cathy Avery
@ 2017-04-04  6:53     ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2017-04-04  6:53 UTC (permalink / raw)
  To: Cathy Avery
  Cc: Christoph Hellwig, kys, haiyangz, jejb, martin.petersen, stephen,
	dan.carpenter, devel, linux-kernel, linux-scsi

On Mon, Apr 03, 2017 at 09:14:02AM -0400, Cathy Avery wrote:
> On 04/03/2017 08:17 AM, Christoph Hellwig wrote:
> > >   	if (host->transportt == fc_transport_template) {
> > > +		struct fc_rport_identifiers ids = {
> > > +			.roles = FC_PORT_ROLE_FCP_TARGET,
> > > +		};
> > I don't think storvsc ever acts as FCP target.
> 
> In order to implement the work around so that the scsi scan works indicating
> FC_PORT_ROLE_FCP_TARGET as a role was necessary due to its test in
> fc_scsi_scan_rport. The idea here is to avoid making any changes to the
> fc_transport driver which was of some concern.

Please add a FC_PORT_ROLE_FCP_DUMMY_INITIATOR role instead.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH v2] scsi: storvsc: Add support for FC rport.
  2017-03-17 15:17 ` Cathy Avery
  (?)
@ 2017-03-21 18:10 ` KY Srinivasan
  -1 siblings, 0 replies; 8+ messages in thread
From: KY Srinivasan @ 2017-03-21 18:10 UTC (permalink / raw)
  To: Cathy Avery, hch, Haiyang Zhang, jejb, martin.petersen
  Cc: stephen, dan.carpenter, devel, linux-kernel, linux-scsi



> -----Original Message-----
> From: Cathy Avery [mailto:cavery@redhat.com]
> Sent: Friday, March 17, 2017 8:18 AM
> To: KY Srinivasan <kys@microsoft.com>; hch@infradead.org; Haiyang Zhang
> <haiyangz@microsoft.com>; jejb@linux.vnet.ibm.com;
> martin.petersen@oracle.com
> Cc: stephen@networkplumber.org; dan.carpenter@oracle.com;
> devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; linux-
> scsi@vger.kernel.org
> Subject: [PATCH v2] scsi: storvsc: Add support for FC rport.
> 
> Included in the current storvsc driver for Hyper-V is the ability
> to access luns on an FC fabric via a virtualized fiber channel
> adapter exposed by the Hyper-V host. The driver also attaches to
> the FC transport to allow host and port names to be published under
> /sys/class/fc_host/hostX. Current customer tools running on the VM
> require that these names be available in the well known standard
> location under fc_host/hostX.
> 
> A problem arose when attaching to the FC transport. The scsi_scan
> code attempts to call fc_user_scan which has basically become a no-op
> due to the fact that the virtualized FC device does not expose rports.
> At this point you cannot refresh the scsi bus after mapping or unmapping
> luns on the SAN without a reboot of the VM.
> 
> This patch stubs in an rport per fc_host in storvsc so that the
> requirement of a defined rport is now met within the fc_transport and
> echo "- - -" > /sys/class/scsi_host/hostX/scan now works.
> 
> Signed-off-by: Cathy Avery <cavery@redhat.com>

Acked-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> Changes since v1:
> - Fix fc_rport_identifiers init [Stephen Hemminger]
> - Better error checking
> ---
>  drivers/scsi/storvsc_drv.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 638e5f4..37646d1 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -478,6 +478,9 @@ struct storvsc_device {
>  	 */
>  	u64 node_name;
>  	u64 port_name;
> +#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
> +	struct fc_rport *rport;
> +#endif
>  };
> 
>  struct hv_host_device {
> @@ -1816,19 +1819,27 @@ static int storvsc_probe(struct hv_device
> *device,
>  		target = (device->dev_instance.b[5] << 8 |
>  			 device->dev_instance.b[4]);
>  		ret = scsi_add_device(host, 0, target, 0);
> -		if (ret) {
> -			scsi_remove_host(host);
> -			goto err_out2;
> -		}
> +		if (ret)
> +			goto err_out3;
>  	}
>  #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
>  	if (host->transportt == fc_transport_template) {
> +		struct fc_rport_identifiers ids = {
> +			.roles = FC_PORT_ROLE_FCP_TARGET,
> +		};
> +
>  		fc_host_node_name(host) = stor_device->node_name;
>  		fc_host_port_name(host) = stor_device->port_name;
> +		stor_device->rport = fc_remote_port_add(host, 0, &ids);
> +		if (!stor_device->rport)
> +			goto err_out3;
>  	}
>  #endif
>  	return 0;
> 
> +err_out3:
> +	scsi_remove_host(host);
> +
>  err_out2:
>  	/*
>  	 * Once we have connected with the host, we would need to
> @@ -1854,8 +1865,10 @@ static int storvsc_remove(struct hv_device *dev)
>  	struct Scsi_Host *host = stor_device->host;
> 
>  #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
> -	if (host->transportt == fc_transport_template)
> +	if (host->transportt == fc_transport_template) {
> +		fc_remote_port_delete(stor_device->rport);
>  		fc_remove_host(host);
> +	}
>  #endif
>  	scsi_remove_host(host);
>  	storvsc_dev_remove(dev);
> --
> 2.5.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] scsi: storvsc: Add support for FC rport.
@ 2017-03-17 15:17 ` Cathy Avery
  0 siblings, 0 replies; 8+ messages in thread
From: Cathy Avery @ 2017-03-17 15:17 UTC (permalink / raw)
  To: kys, hch, haiyangz, jejb, martin.petersen
  Cc: stephen, dan.carpenter, devel, linux-kernel, linux-scsi

Included in the current storvsc driver for Hyper-V is the ability
to access luns on an FC fabric via a virtualized fiber channel
adapter exposed by the Hyper-V host. The driver also attaches to
the FC transport to allow host and port names to be published under
/sys/class/fc_host/hostX. Current customer tools running on the VM
require that these names be available in the well known standard
location under fc_host/hostX.

A problem arose when attaching to the FC transport. The scsi_scan
code attempts to call fc_user_scan which has basically become a no-op
due to the fact that the virtualized FC device does not expose rports.
At this point you cannot refresh the scsi bus after mapping or unmapping
luns on the SAN without a reboot of the VM.

This patch stubs in an rport per fc_host in storvsc so that the
requirement of a defined rport is now met within the fc_transport and
echo "- - -" > /sys/class/scsi_host/hostX/scan now works.

Signed-off-by: Cathy Avery <cavery@redhat.com>
---
Changes since v1:
- Fix fc_rport_identifiers init [Stephen Hemminger]
- Better error checking
---
 drivers/scsi/storvsc_drv.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 638e5f4..37646d1 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -478,6 +478,9 @@ struct storvsc_device {
 	 */
 	u64 node_name;
 	u64 port_name;
+#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
+	struct fc_rport *rport;
+#endif
 };
 
 struct hv_host_device {
@@ -1816,19 +1819,27 @@ static int storvsc_probe(struct hv_device *device,
 		target = (device->dev_instance.b[5] << 8 |
 			 device->dev_instance.b[4]);
 		ret = scsi_add_device(host, 0, target, 0);
-		if (ret) {
-			scsi_remove_host(host);
-			goto err_out2;
-		}
+		if (ret)
+			goto err_out3;
 	}
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
 	if (host->transportt == fc_transport_template) {
+		struct fc_rport_identifiers ids = {
+			.roles = FC_PORT_ROLE_FCP_TARGET,
+		};
+
 		fc_host_node_name(host) = stor_device->node_name;
 		fc_host_port_name(host) = stor_device->port_name;
+		stor_device->rport = fc_remote_port_add(host, 0, &ids);
+		if (!stor_device->rport)
+			goto err_out3;
 	}
 #endif
 	return 0;
 
+err_out3:
+	scsi_remove_host(host);
+
 err_out2:
 	/*
 	 * Once we have connected with the host, we would need to
@@ -1854,8 +1865,10 @@ static int storvsc_remove(struct hv_device *dev)
 	struct Scsi_Host *host = stor_device->host;
 
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
-	if (host->transportt == fc_transport_template)
+	if (host->transportt == fc_transport_template) {
+		fc_remote_port_delete(stor_device->rport);
 		fc_remove_host(host);
+	}
 #endif
 	scsi_remove_host(host);
 	storvsc_dev_remove(dev);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] scsi: storvsc: Add support for FC rport.
@ 2017-03-17 15:17 ` Cathy Avery
  0 siblings, 0 replies; 8+ messages in thread
From: Cathy Avery @ 2017-03-17 15:17 UTC (permalink / raw)
  To: kys, hch, haiyangz, jejb, martin.petersen
  Cc: devel, linux-kernel, dan.carpenter, linux-scsi

Included in the current storvsc driver for Hyper-V is the ability
to access luns on an FC fabric via a virtualized fiber channel
adapter exposed by the Hyper-V host. The driver also attaches to
the FC transport to allow host and port names to be published under
/sys/class/fc_host/hostX. Current customer tools running on the VM
require that these names be available in the well known standard
location under fc_host/hostX.

A problem arose when attaching to the FC transport. The scsi_scan
code attempts to call fc_user_scan which has basically become a no-op
due to the fact that the virtualized FC device does not expose rports.
At this point you cannot refresh the scsi bus after mapping or unmapping
luns on the SAN without a reboot of the VM.

This patch stubs in an rport per fc_host in storvsc so that the
requirement of a defined rport is now met within the fc_transport and
echo "- - -" > /sys/class/scsi_host/hostX/scan now works.

Signed-off-by: Cathy Avery <cavery@redhat.com>
---
Changes since v1:
- Fix fc_rport_identifiers init [Stephen Hemminger]
- Better error checking
---
 drivers/scsi/storvsc_drv.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 638e5f4..37646d1 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -478,6 +478,9 @@ struct storvsc_device {
 	 */
 	u64 node_name;
 	u64 port_name;
+#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
+	struct fc_rport *rport;
+#endif
 };
 
 struct hv_host_device {
@@ -1816,19 +1819,27 @@ static int storvsc_probe(struct hv_device *device,
 		target = (device->dev_instance.b[5] << 8 |
 			 device->dev_instance.b[4]);
 		ret = scsi_add_device(host, 0, target, 0);
-		if (ret) {
-			scsi_remove_host(host);
-			goto err_out2;
-		}
+		if (ret)
+			goto err_out3;
 	}
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
 	if (host->transportt == fc_transport_template) {
+		struct fc_rport_identifiers ids = {
+			.roles = FC_PORT_ROLE_FCP_TARGET,
+		};
+
 		fc_host_node_name(host) = stor_device->node_name;
 		fc_host_port_name(host) = stor_device->port_name;
+		stor_device->rport = fc_remote_port_add(host, 0, &ids);
+		if (!stor_device->rport)
+			goto err_out3;
 	}
 #endif
 	return 0;
 
+err_out3:
+	scsi_remove_host(host);
+
 err_out2:
 	/*
 	 * Once we have connected with the host, we would need to
@@ -1854,8 +1865,10 @@ static int storvsc_remove(struct hv_device *dev)
 	struct Scsi_Host *host = stor_device->host;
 
 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
-	if (host->transportt == fc_transport_template)
+	if (host->transportt == fc_transport_template) {
+		fc_remote_port_delete(stor_device->rport);
 		fc_remove_host(host);
+	}
 #endif
 	scsi_remove_host(host);
 	storvsc_dev_remove(dev);
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-04-04  6:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 11:33 [PATCH v2] scsi: storvsc: Add support for FC rport Cathy Avery
2017-04-03 12:17 ` Christoph Hellwig
2017-04-03 12:17   ` Christoph Hellwig
2017-04-03 13:14   ` Cathy Avery
2017-04-04  6:53     ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2017-03-17 15:17 Cathy Avery
2017-03-17 15:17 ` Cathy Avery
2017-03-21 18:10 ` KY Srinivasan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.