All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 5/7] target: add device vendor_id configfs attribute
@ 2018-11-29  1:01 David Disseldorp
  2018-11-29  1:14 ` Ly, Bryant
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Disseldorp @ 2018-11-29  1:01 UTC (permalink / raw)
  To: target-devel

The vendor_id attribute will allow for the modification of the T10
Vendor Identification string returned in inquiry responses. Its value
can be viewed and modified via the ConfigFS path at:
target/core/$backstore/$name/wwn/vendor_id

"LIO-ORG" remains the default value, which is set when the backstore
device is enabled.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_configfs.c | 48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 9f49b1afd685..fc60c4db718d 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1213,6 +1213,52 @@ static struct t10_wwn *to_t10_wwn(struct config_item *item)
 }
 
 /*
+ * STANDARD and VPD page 0x80 T10 Vendor Identification
+ */
+static ssize_t target_wwn_vendor_id_show(struct config_item *item,
+		char *page)
+{
+	return sprintf(page, "%s\n", &to_t10_wwn(item)->vendor[0]);
+}
+
+static ssize_t target_wwn_vendor_id_store(struct config_item *item,
+		const char *page, size_t count)
+{
+	struct t10_wwn *t10_wwn = to_t10_wwn(item);
+	struct se_device *dev = t10_wwn->t10_dev;
+	unsigned char buf[INQUIRY_VENDOR_LEN + 1];
+
+	if (strlen(page) > INQUIRY_VENDOR_LEN) {
+		pr_err("Emulated T10 Vendor Identification exceeds"
+			" INQUIRY_VENDOR_LEN: " __stringify(INQUIRY_VENDOR_LEN)
+			"\n");
+		return -EOVERFLOW;
+	}
+	strlcpy(buf, page, sizeof(buf));
+	/*
+	 * Check to see if any active exports exist.  If they do exist, fail
+	 * here as changing this information on the fly (underneath the
+	 * initiator side OS dependent multipath code) could cause negative
+	 * effects.
+	 */
+	if (dev->export_count) {
+		pr_err("Unable to set T10 Vendor Identification while"
+			" active %d exports exist\n", dev->export_count);
+		return -EINVAL;
+	}
+
+	/* Assume ASCII encoding. Strip any newline added from userspace. */
+	BUILD_BUG_ON(sizeof(dev->t10_wwn.vendor) != INQUIRY_VENDOR_LEN + 1);
+	strlcpy(dev->t10_wwn.vendor, strstrip(buf),
+		sizeof(dev->t10_wwn.vendor));
+
+	pr_debug("Target_Core_ConfigFS: Set emulated T10 Vendor Identification:"
+		 " %s\n", dev->t10_wwn.vendor);
+
+	return count;
+}
+
+/*
  * VPD page 0x80 Unit serial
  */
 static ssize_t target_wwn_vpd_unit_serial_show(struct config_item *item,
@@ -1358,6 +1404,7 @@ DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10);
 /* VPD page 0x83 Association: SCSI Target Device */
 DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20);
 
+CONFIGFS_ATTR(target_wwn_, vendor_id);
 CONFIGFS_ATTR(target_wwn_, vpd_unit_serial);
 CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier);
 CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit);
@@ -1365,6 +1412,7 @@ CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_target_port);
 CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_scsi_target_device);
 
 static struct configfs_attribute *target_core_dev_wwn_attrs[] = {
+	&target_wwn_attr_vendor_id,
 	&target_wwn_attr_vpd_unit_serial,
 	&target_wwn_attr_vpd_protocol_identifier,
 	&target_wwn_attr_vpd_assoc_logical_unit,
-- 
2.13.7

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

* Re: [PATCH v4 5/7] target: add device vendor_id configfs attribute
  2018-11-29  1:01 [PATCH v4 5/7] target: add device vendor_id configfs attribute David Disseldorp
@ 2018-11-29  1:14 ` Ly, Bryant
  2018-11-29  1:29 ` Lee Duncan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ly, Bryant @ 2018-11-29  1:14 UTC (permalink / raw)
  To: target-devel



> On Nov 28, 2018, at 7:01 PM, David Disseldorp <ddiss@suse.de> wrote:
> 
> The vendor_id attribute will allow for the modification of the T10
> Vendor Identification string returned in inquiry responses. Its value
> can be viewed and modified via the ConfigFS path at:
> target/core/$backstore/$name/wwn/vendor_id
> 
> "LIO-ORG" remains the default value, which is set when the backstore
> device is enabled.
> 
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> ---
> drivers/target/target_core_configfs.c | 48 +++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index 9f49b1afd685..fc60c4db718d 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -1213,6 +1213,52 @@ static struct t10_wwn *to_t10_wwn(struct config_item *item)
> }
> 

Thanks for making it configurable. I know back when I was at IBM we made changes internally
to support LIO-ORG.

Reviewed-by: Bryant G. Ly bly@catalogicsoftware.com

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

* Re: [PATCH v4 5/7] target: add device vendor_id configfs attribute
  2018-11-29  1:01 [PATCH v4 5/7] target: add device vendor_id configfs attribute David Disseldorp
  2018-11-29  1:14 ` Ly, Bryant
@ 2018-11-29  1:29 ` Lee Duncan
  2018-11-29 16:32 ` Bart Van Assche
  2018-11-29 21:33 ` David Disseldorp
  3 siblings, 0 replies; 5+ messages in thread
From: Lee Duncan @ 2018-11-29  1:29 UTC (permalink / raw)
  To: target-devel

On 11/28/18 5:01 PM, David Disseldorp wrote:
> The vendor_id attribute will allow for the modification of the T10
> Vendor Identification string returned in inquiry responses. Its value
> can be viewed and modified via the ConfigFS path at:
> target/core/$backstore/$name/wwn/vendor_id
> 
> "LIO-ORG" remains the default value, which is set when the backstore
> device is enabled.
> 
> Signed-off-by: David Disseldorp <ddiss@suse.de>
> ---
>  drivers/target/target_core_configfs.c | 48 +++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index 9f49b1afd685..fc60c4db718d 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -1213,6 +1213,52 @@ static struct t10_wwn *to_t10_wwn(struct config_item *item)
>  }
>  
>  /*
> + * STANDARD and VPD page 0x80 T10 Vendor Identification
> + */
> +static ssize_t target_wwn_vendor_id_show(struct config_item *item,
> +		char *page)
> +{
> +	return sprintf(page, "%s\n", &to_t10_wwn(item)->vendor[0]);
> +}
> +
> +static ssize_t target_wwn_vendor_id_store(struct config_item *item,
> +		const char *page, size_t count)
> +{
> +	struct t10_wwn *t10_wwn = to_t10_wwn(item);
> +	struct se_device *dev = t10_wwn->t10_dev;
> +	unsigned char buf[INQUIRY_VENDOR_LEN + 1];
> +
> +	if (strlen(page) > INQUIRY_VENDOR_LEN) {
> +		pr_err("Emulated T10 Vendor Identification exceeds"
> +			" INQUIRY_VENDOR_LEN: " __stringify(INQUIRY_VENDOR_LEN)
> +			"\n");
> +		return -EOVERFLOW;
> +	}
> +	strlcpy(buf, page, sizeof(buf));
> +	/*
> +	 * Check to see if any active exports exist.  If they do exist, fail
> +	 * here as changing this information on the fly (underneath the
> +	 * initiator side OS dependent multipath code) could cause negative
> +	 * effects.
> +	 */
> +	if (dev->export_count) {
> +		pr_err("Unable to set T10 Vendor Identification while"
> +			" active %d exports exist\n", dev->export_count);
> +		return -EINVAL;
> +	}
> +
> +	/* Assume ASCII encoding. Strip any newline added from userspace. */
> +	BUILD_BUG_ON(sizeof(dev->t10_wwn.vendor) != INQUIRY_VENDOR_LEN + 1);
> +	strlcpy(dev->t10_wwn.vendor, strstrip(buf),
> +		sizeof(dev->t10_wwn.vendor));
> +
> +	pr_debug("Target_Core_ConfigFS: Set emulated T10 Vendor Identification:"
> +		 " %s\n", dev->t10_wwn.vendor);
> +
> +	return count;
> +}
> +
> +/*
>   * VPD page 0x80 Unit serial
>   */
>  static ssize_t target_wwn_vpd_unit_serial_show(struct config_item *item,
> @@ -1358,6 +1404,7 @@ DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10);
>  /* VPD page 0x83 Association: SCSI Target Device */
>  DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20);
>  
> +CONFIGFS_ATTR(target_wwn_, vendor_id);
>  CONFIGFS_ATTR(target_wwn_, vpd_unit_serial);
>  CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier);
>  CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit);
> @@ -1365,6 +1412,7 @@ CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_target_port);
>  CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_scsi_target_device);
>  
>  static struct configfs_attribute *target_core_dev_wwn_attrs[] = {
> +	&target_wwn_attr_vendor_id,
>  	&target_wwn_attr_vpd_unit_serial,
>  	&target_wwn_attr_vpd_protocol_identifier,
>  	&target_wwn_attr_vpd_assoc_logical_unit,
> 


Reviewed-by: Lee Duncan <lduncan@suse.com>

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

* Re: [PATCH v4 5/7] target: add device vendor_id configfs attribute
  2018-11-29  1:01 [PATCH v4 5/7] target: add device vendor_id configfs attribute David Disseldorp
  2018-11-29  1:14 ` Ly, Bryant
  2018-11-29  1:29 ` Lee Duncan
@ 2018-11-29 16:32 ` Bart Van Assche
  2018-11-29 21:33 ` David Disseldorp
  3 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2018-11-29 16:32 UTC (permalink / raw)
  To: target-devel

On Thu, 2018-11-29 at 02:01 +-0100, David Disseldorp wrote:
+AD4 +-static ssize+AF8-t target+AF8-wwn+AF8-vendor+AF8-id+AF8-show(struct config+AF8-item +ACo-item,
+AD4 +-		char +ACo-page)
+AD4 +-+AHs
+AD4 +-	return sprintf(page, +ACIAJQ-s+AFw-n+ACI, +ACY-to+AF8-t10+AF8-wwn(item)-+AD4-vendor+AFs-0+AF0)+ADs
+AD4 +-+AH0

The +ACIAJgAi and +ACIAWw-0+AF0AIg are superfluous in the above sprintf() statement.

+AD4 +-static ssize+AF8-t target+AF8-wwn+AF8-vendor+AF8-id+AF8-store(struct config+AF8-item +ACo-item,
+AD4 +-		const char +ACo-page, size+AF8-t count)
+AD4 +-+AHs
+AD4 +-	struct t10+AF8-wwn +ACo-t10+AF8-wwn +AD0 to+AF8-t10+AF8-wwn(item)+ADs
+AD4 +-	struct se+AF8-device +ACo-dev +AD0 t10+AF8-wwn-+AD4-t10+AF8-dev+ADs
+AD4 +-	unsigned char buf+AFs-INQUIRY+AF8-VENDOR+AF8-LEN +- 1+AF0AOw
+AD4 +-
+AD4 +-	if (strlen(page) +AD4 INQUIRY+AF8-VENDOR+AF8-LEN) +AHs
+AD4 +-		pr+AF8-err(+ACI-Emulated T10 Vendor Identification exceeds+ACI
+AD4 +-			+ACI INQUIRY+AF8-VENDOR+AF8-LEN: +ACI +AF8AXw-stringify(INQUIRY+AF8-VENDOR+AF8-LEN)
+AD4 +-			+ACIAXA-n+ACI)+ADs
+AD4 +-		return -EOVERFLOW+ADs
+AD4 +-	+AH0

Does this force users to use +ACI-echo -n+ACI to configure vendor IDs that are
INQUIRY+AF8-VENDOR+AF8-LEN bytes long?

Bart.

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

* Re: [PATCH v4 5/7] target: add device vendor_id configfs attribute
  2018-11-29  1:01 [PATCH v4 5/7] target: add device vendor_id configfs attribute David Disseldorp
                   ` (2 preceding siblings ...)
  2018-11-29 16:32 ` Bart Van Assche
@ 2018-11-29 21:33 ` David Disseldorp
  3 siblings, 0 replies; 5+ messages in thread
From: David Disseldorp @ 2018-11-29 21:33 UTC (permalink / raw)
  To: target-devel

On Thu, 29 Nov 2018 08:32:47 -0800, Bart Van Assche wrote:

> > +	unsigned char buf[INQUIRY_VENDOR_LEN + 1];
> > +
> > +	if (strlen(page) > INQUIRY_VENDOR_LEN) {
> > +		pr_err("Emulated T10 Vendor Identification exceeds"
> > +			" INQUIRY_VENDOR_LEN: " __stringify(INQUIRY_VENDOR_LEN)
> > +			"\n");
> > +		return -EOVERFLOW;
> > +	}  
> 
> Does this force users to use "echo -n" to configure vendor IDs that are
> INQUIRY_VENDOR_LEN bytes long?

It does. As mentioned in v3, this follows the convention used in
target_wwn_vpd_unit_serial_store(). I don't feel too strongly about it,
but it does make buf allocation a little less error prone IMO.

Cheers, David

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

end of thread, other threads:[~2018-11-29 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-29  1:01 [PATCH v4 5/7] target: add device vendor_id configfs attribute David Disseldorp
2018-11-29  1:14 ` Ly, Bryant
2018-11-29  1:29 ` Lee Duncan
2018-11-29 16:32 ` Bart Van Assche
2018-11-29 21:33 ` David Disseldorp

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.