]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
target: add inquiry_product module param to override LIO default
authorKyle Fortin <kyle.fortin@oracle.com>
Tue, 13 Mar 2018 17:57:50 +0000 (13:57 -0400)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 22 Mar 2018 23:18:20 +0000 (16:18 -0700)
Orabug: 27679431

OL6 iscsi target used IET which presented VIRTUAL-DISK for inquiry product.
OL7 uses the LIO iscsi target instead, which presented LIO iblock name.

Exadata targets upgrading from OL6 to OL7 need to present the same
product ID to existing iscsi initiator multipath mappings.

Add target_core_mod parameter inquiry_product for target inquiry vendor
string override.  It defaults to LIO iblock name.

The user will also need to do one of the following in targetcli:
set global export_backstore_name_as_model=false
or for each backstore:
/backstores/<type>/<name> set attribute emulate_model_alias=0

(cherry picked from commit faf91b95fd22dbf0a1a7fd5b18ab71a929385927)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_device.c
drivers/target/target_core_internal.h
drivers/target/target_core_spc.c

index 44382647668cf8e7a099eca802c3d1d7c339aaf0..193d95d35dbbb5969ddca3f5eadee1f3912cae9b 100644 (file)
@@ -63,6 +63,12 @@ module_param_string(inquiry_vendor, g_inquiry_vendor,
                sizeof(g_inquiry_vendor), S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(inquiry_vendor, "inquiry vendor string override");
 
+/* SCSI inquiry product string is 16 chars space padded + NULL. */
+char g_inquiry_product[17] = "";
+module_param_string(inquiry_product, g_inquiry_product,
+               sizeof(g_inquiry_product), S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(inquiry_product, "inquiry product string override");
+
 sense_reason_t
 transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun)
 {
@@ -757,8 +763,15 @@ int se_dev_set_emulate_model_alias(struct se_device *dev, int flag)
        if (flag) {
                dev_set_t10_wwn_model_alias(dev);
        } else {
-               strncpy(&dev->t10_wwn.model[0],
-                       dev->transport->inquiry_prod, 16);
+               /*
+                * If module_parm inquiry_product was set, use that.
+                */
+               if (g_inquiry_product[0] != '\0')
+                       strncpy(&dev->t10_wwn.model[0],
+                               g_inquiry_product, 16);
+               else
+                       strncpy(&dev->t10_wwn.model[0],
+                               dev->transport->inquiry_prod, 16);
        }
        dev->dev_attrib.emulate_model_alias = flag;
 
@@ -1614,8 +1627,15 @@ int target_configure_device(struct se_device *dev)
         */
        if (!(dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)) {
                strncpy(&dev->t10_wwn.vendor[0], g_inquiry_vendor, 8);
-               strncpy(&dev->t10_wwn.model[0],
-                       dev->transport->inquiry_prod, 16);
+               /*
+                * If module_parm inquiry_product was set, use that.
+                */
+               if (g_inquiry_product[0] != '\0')
+                       strncpy(&dev->t10_wwn.model[0],
+                               g_inquiry_product, 16);
+               else
+                       strncpy(&dev->t10_wwn.model[0],
+                               dev->transport->inquiry_prod, 16);
                strncpy(&dev->t10_wwn.revision[0],
                        dev->transport->inquiry_rev, 4);
        }
index 9e19d9099df5010a57b13d90c525cde0a1ffa26b..9d273e68e5a2e005f99a3acaec7a6670636cb1e5 100644 (file)
@@ -21,6 +21,7 @@ extern struct t10_alua_lu_gp *default_lu_gp;
 extern struct mutex g_device_mutex;
 extern struct list_head g_device_list;
 extern char g_inquiry_vendor[];
+extern char g_inquiry_product[];
 
 struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
 int    core_free_device_list_for_node(struct se_node_acl *,
index d75bdd9dbe2a5680c16a7a1fdb5d507856ebceaa..87f6084951ec331464ff5e15aeaaf46f200865f3 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/string.h>
 #include <asm/unaligned.h>
 
 #include <scsi/scsi.h>
@@ -117,9 +118,9 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
        memcpy(&buf[8], g_inquiry_vendor, 8);
        memset(&buf[16], 0x20, 16);
        memcpy(&buf[16], dev->t10_wwn.model,
-              min_t(size_t, strlen(dev->t10_wwn.model), 16));
+              min_t(size_t, strnlen(dev->t10_wwn.model, 16), 16));
        memcpy(&buf[32], dev->t10_wwn.revision,
-              min_t(size_t, strlen(dev->t10_wwn.revision), 4));
+              min_t(size_t, strnlen(dev->t10_wwn.revision, 4), 4));
        buf[4] = 31; /* Set additional length to 31 */
 
        return 0;
@@ -134,7 +135,8 @@ spc_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf)
        u16 len;
 
        if (dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL) {
-               len = sprintf(&buf[4], "%s", dev->t10_wwn.unit_serial);
+               len = snprintf(&buf[4], INQUIRY_VPD_SERIAL_LEN, "%s",
+                               dev->t10_wwn.unit_serial);
                len++; /* Extra Byte for NULL Terminator */
                buf[3] = len;
        }
@@ -187,7 +189,7 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
        struct t10_alua_tg_pt_gp *tg_pt_gp;
        struct t10_alua_tg_pt_gp_member *tg_pt_gp_mem;
        unsigned char *prod = &dev->t10_wwn.model[0];
-       u32 prod_len;
+       u32 prod_len, model_len;
        u32 unit_serial_len, off = 0;
        u16 len = 0, id_len;
 
@@ -246,15 +248,22 @@ check_t10_vend_desc:
        id_len = 8; /* For Vendor field */
        prod_len = 4; /* For VPD Header */
        prod_len += 8; /* For Vendor field */
-       prod_len += strlen(prod);
+       model_len = strnlen(prod, 16);
+       prod_len += model_len;
        prod_len++; /* For : */
 
        if (dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL) {
-               unit_serial_len = strlen(&dev->t10_wwn.unit_serial[0]);
-               unit_serial_len++; /* For NULL Terminator */
-
-               id_len += sprintf(&buf[off+12], "%s:%s", prod,
-                               &dev->t10_wwn.unit_serial[0]);
+               unit_serial_len = strnlen(&dev->t10_wwn.unit_serial[0],
+                                       INQUIRY_VPD_SERIAL_LEN);
+               if (model_len && unit_serial_len) {
+                       id_len += snprintf(&buf[off+12],
+                                       model_len, "%s", prod);
+                       id_len += snprintf(&buf[off+12+model_len],
+                                       unit_serial_len + 1, ":%s",
+                                       &dev->t10_wwn.unit_serial[0]);
+                       /* Extra Byte for NULL Terminator */
+                       id_len++;
+               }
        }
        buf[off] = 0x2; /* ASCII */
        buf[off+1] = 0x1; /* T10 Vendor ID */