From 353d1f1928adf9546f2345126f2843aedc559450 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 27 May 2016 01:02:11 +0000 Subject: [PATCH 1/7] scst: update README how to configure SCST, so VMware start using EXTENDED COPY between datastores Based on information from Artur Piechocki Tested-By: Isaac Goldbaum git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6892 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 28 ++++++++++++++++++++++++++++ scst/README_in-tree | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/scst/README b/scst/README index c15c718f2..9f4aac4ac 100644 --- a/scst/README +++ b/scst/README @@ -1827,6 +1827,34 @@ benefit from SCST VAAI implementation. Those actions described in the implementation notes below. For vdisk and fileio_tgt handlers they have already been implemented. +IMPORTANT: To use EXTENDED COPY command between LUNs (datastores) they all +========= MUST have the same PRODUCT IDENTIFICATION INQUIRY field. By + default, to simplify remote devices identification, SCST uses + vdisk names as PRODUCT IDENTIFICATION, so SCST devices look + differently from the initiators. However, for some reasons, + VMware does not use EXTENDED COPY between LUNs with different + PRODUCT IDENTIFICATION. Thus, to be able to use full VAAI in + your VMware setups you must manually set PRODUCT + IDENTIFICATION for all your VMware LUNs to the same value, + for instance, "SCST", via using "prod_id" attribute. It could + be done either by adding "prod_id" attribute to scstadmin + scst.conf, or by directly writing to SCST sysfs attribute. + For example: + + HANDLER vdisk_blockio { + DEVICE blockio1 { + filename /dev/sda5 + prod_id SCST + } + + or + + echo SCST >/sys/kernel/scst_tgt/devices/blockio1/prod_id + correspondingly. + + Note, this prod_id modification must be done on all + datastores BEFORE VMware connects to them. + Implementation notes .................... diff --git a/scst/README_in-tree b/scst/README_in-tree index 0bdc68618..78e94401d 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -1680,6 +1680,34 @@ benefit from SCST VAAI implementation. Those actions described in the implementation notes below. For vdisk and fileio_tgt handlers they have already been implemented. +IMPORTANT: To use EXTENDED COPY command between LUNs (datastores) they all +========= MUST have the same PRODUCT IDENTIFICATION INQUIRY field. By + default, to simplify remote devices identification, SCST uses + vdisk names as PRODUCT IDENTIFICATION, so SCST devices look + differently from the initiators. However, for some reasons, + VMware does not use EXTENDED COPY between LUNs with different + PRODUCT IDENTIFICATION. Thus, to be able to use full VAAI in + your VMware setups you must manually set PRODUCT + IDENTIFICATION for all your VMware LUNs to the same value, + for instance, "SCST", via using "prod_id" attribute. It could + be done either by adding "prod_id" attribute to scstadmin + scst.conf, or by directly writing to SCST sysfs attribute. + For example: + + HANDLER vdisk_blockio { + DEVICE blockio1 { + filename /dev/sda5 + prod_id SCST + } + + or + + echo SCST >/sys/kernel/scst_tgt/devices/blockio1/prod_id + correspondingly. + + Note, this prod_id modification must be done on all + datastores BEFORE VMware connects to them. + Implementation notes .................... From 0556c29fdd17b09db85d5079d5a194c06873aeb1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 8 Jun 2016 21:19:24 +0000 Subject: [PATCH 2/7] ib_srpt: Port to Linux kernel v4.7 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6896 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index f4f0f698a..1715dbbb0 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -419,7 +419,11 @@ static void srpt_get_class_port_info(struct ib_dm_mad *mad) memset(cif, 0, sizeof(*cif)); cif->base_version = 1; cif->class_version = 1; +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0) cif->resp_time_value = 20; +#else + ib_set_cpi_resp_time(cif, 20); +#endif mad->mad_hdr.status = 0; } From 1b8ba2f3cba396d33844cb329e37c9805615b6b9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jun 2016 21:03:34 +0000 Subject: [PATCH 3/7] ib_srpt: Add link_layer and port_id sysfs attributes git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6897 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 99 +++++++++++++++++++++++++++++++++++++++++++++- srpt/src/ib_srpt.h | 2 + 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 1715dbbb0..fa91ebe7b 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -90,7 +90,7 @@ #define SRPT_PROC_TRACE_LEVEL_NAME "trace_level" #endif -#define SRPT_ID_STRING "SCST SRP target" +#define DEFAULT_SRPT_ID_STRING "SCST SRP target" MODULE_AUTHOR("Vu Pham and Bart Van Assche"); MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol target " @@ -484,7 +484,7 @@ static void srpt_get_ioc(struct srpt_port *sport, u32 slot, send_queue_depth = min(SRPT_RQ_SIZE, sdev->dev_attr.max_qp_wr); memset(iocp, 0, sizeof(*iocp)); - strcpy(iocp->id_string, SRPT_ID_STRING); + strcpy(iocp->id_string, DEFAULT_SRPT_ID_STRING); iocp->guid = cpu_to_be64(srpt_service_guid); iocp->vendor_id = cpu_to_be32(sdev->dev_attr.vendor_id); iocp->device_id = cpu_to_be32(sdev->dev_attr.vendor_part_id); @@ -4039,6 +4039,99 @@ out: static struct kobj_attribute srpt_device_attr = __ATTR(device, S_IRUGO, srpt_show_device, NULL); +/* + * The link layer names in this function match those used by the IB core. + * See also link_layer_show() in drivers/infiniband/core/sysfs.c + */ +static ssize_t srpt_show_link_layer(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct scst_tgt *scst_tgt = container_of(kobj, struct scst_tgt, + tgt_kobj); + struct srpt_port *sport = scst_tgt_get_tgt_priv(scst_tgt); + const char *lln = "Unknown"; + int res = -E_TGT_PRIV_NOT_YET_SET; + + if (!sport) + goto out; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) /* commit a3f5adaf4 */ + switch (rdma_port_get_link_layer(sport->sdev->device, sport->port)) { + case IB_LINK_LAYER_INFINIBAND: + lln = "InfiniBand"; + break; + case IB_LINK_LAYER_ETHERNET: + lln = "Ethernet"; + break; + case IB_LINK_LAYER_UNSPECIFIED: + default: + break; + } +#endif + res = sprintf(buf, "%s\n", lln); + +out: + return res; +} + +static struct kobj_attribute srpt_link_layer_attr = + __ATTR(link_layer, S_IRUGO, srpt_show_link_layer, NULL); + +static ssize_t show_port_id(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct scst_tgt *scst_tgt = container_of(kobj, struct scst_tgt, + tgt_kobj); + struct srpt_port *sport = scst_tgt_get_tgt_priv(scst_tgt); + int res = -E_TGT_PRIV_NOT_YET_SET; + + if (!sport) + goto out; + + mutex_lock(&sport->mutex); + snprintf(buf, PAGE_SIZE, "%s\n%s", sport->port_id, + strcmp(sport->port_id, DEFAULT_SRPT_ID_STRING) ? + SCST_SYSFS_KEY_MARK "\n" : ""); + mutex_unlock(&sport->mutex); + + res = strlen(buf); + +out: + return res; +} + +static ssize_t store_port_id(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct scst_tgt *scst_tgt = container_of(kobj, struct scst_tgt, + tgt_kobj); + struct srpt_port *sport = scst_tgt_get_tgt_priv(scst_tgt); + const char *end; + int res = -E_TGT_PRIV_NOT_YET_SET; + + if (!sport) + goto out; + + end = buf + count; + while (end > buf && isspace(((unsigned char *)end)[-1])) + --end; + res = -E2BIG; + if (end - buf >= sizeof(sport->port_id)) + goto out; + + mutex_lock(&sport->mutex); + sprintf(sport->port_id, "%.*s", (int)(end - buf), buf); + mutex_unlock(&sport->mutex); + + res = count; + +out: + return res; +} + +static struct kobj_attribute srpt_port_id_attr = + __ATTR(port_id, S_IRUGO | S_IWUSR, show_port_id, store_port_id); + static ssize_t show_login_info(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -4075,6 +4168,8 @@ static struct kobj_attribute srpt_show_login_info_attr = static const struct attribute *srpt_tgt_attrs[] = { &srpt_show_comp_v_mask_attr.attr, &srpt_device_attr.attr, + &srpt_link_layer_attr.attr, + &srpt_port_id_attr.attr, &srpt_show_login_info_attr.attr, NULL }; diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index c4c14b2f3..24bc0f273 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -419,6 +419,7 @@ struct srpt_nexus { * @comp_v_mask: Bitmask with one bit per allowed completion vector. * @comp_vector: Completion vector from where searching will start. * @enabled: Whether or not this SCST target is enabled. + * @port_id: ID String reported in IOControllerProfile replies. */ struct srpt_port { struct srpt_device *sdev; @@ -435,6 +436,7 @@ struct srpt_port { cpumask_t comp_v_mask; u8 comp_vector; bool enabled; + u8 port_id[64]; }; /** From a6f0551eef39dc2dfa5b52e18274b97ae61b88b9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jun 2016 21:14:29 +0000 Subject: [PATCH 4/7] ib_srpt: Introduce srpt_init_sport() git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6898 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index fa91ebe7b..f265d9af9 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -484,7 +484,7 @@ static void srpt_get_ioc(struct srpt_port *sport, u32 slot, send_queue_depth = min(SRPT_RQ_SIZE, sdev->dev_attr.max_qp_wr); memset(iocp, 0, sizeof(*iocp)); - strcpy(iocp->id_string, DEFAULT_SRPT_ID_STRING); + strcpy(iocp->id_string, sport->port_id); iocp->guid = cpu_to_be64(srpt_service_guid); iocp->vendor_id = cpu_to_be32(sdev->dev_attr.vendor_id); iocp->device_id = cpu_to_be32(sdev->dev_attr.vendor_part_id); @@ -4293,6 +4293,21 @@ static struct scst_proc_data srpt_log_proc_data = { #endif /* CONFIG_SCST_PROC */ +/* Note: the caller must have zero-initialized *@sport. */ +static void srpt_init_sport(struct srpt_port *sport, struct ib_device *ib_dev) +{ + int i; + + INIT_LIST_HEAD(&sport->nexus_list); + init_waitqueue_head(&sport->ch_releaseQ); + mutex_init(&sport->mutex); + sport->comp_vector = -1; + strlcpy(sport->port_id, DEFAULT_SRPT_ID_STRING, + sizeof(sport->port_id)); + for (i = 0; i < ib_dev->num_comp_vectors; i++) + cpumask_set_cpu(i, &sport->comp_v_mask); +} + /** * srpt_add_one() - Infiniband device addition callback function. */ @@ -4302,7 +4317,7 @@ static void srpt_add_one(struct ib_device *device) struct srpt_device *sdev; struct srpt_port *sport; struct ib_srq_init_attr srq_attr; - int i, j, ret; + int i, ret; pr_debug("device = %p, device->dma_ops = %p\n", device, device->dma_ops); @@ -4424,12 +4439,7 @@ static void srpt_add_one(struct ib_device *device) sport = &sdev->port[i - 1]; sport->sdev = sdev; sport->port = i; - INIT_LIST_HEAD(&sport->nexus_list); - init_waitqueue_head(&sport->ch_releaseQ); - mutex_init(&sport->mutex); - sport->comp_vector = -1; - for (j = 0; j < sdev->device->num_comp_vectors; j++) - cpumask_set_cpu(j, &sport->comp_v_mask); + srpt_init_sport(sport, sdev->device); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) && !defined(BACKPORT_LINUX_WORKQUEUE_TO_2_6_19) /* * A vanilla 2.6.19 or older kernel without backported OFED From 0d3c65105aa12ed1c9c91c20166f5830af6775d8 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jun 2016 21:39:15 +0000 Subject: [PATCH 5/7] ib_srpt: Remove a duplicate comment git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6899 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 24bc0f273..71f6319b8 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -343,7 +343,6 @@ enum rdma_ch_state { * @pkey: P_Key of the IB partition for this SRP channel. * @comp_vector: Completion vector assigned to the QP. * @using_rdma_cm: Whether to use the RDMA/CM or the IB/CM. - * @processing_wait_list: Whether the I/O context wait list is being processed. * @sess_name: SCST session name. * @sess: SCST session information associated with this SRP channel. */ From da83a4a9a44a338f7f0c02451fc372c150e560c7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jun 2016 21:39:45 +0000 Subject: [PATCH 6/7] ib_srpt: Serialize sport->port_id accesses git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6900 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index f265d9af9..410c392eb 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -484,7 +484,9 @@ static void srpt_get_ioc(struct srpt_port *sport, u32 slot, send_queue_depth = min(SRPT_RQ_SIZE, sdev->dev_attr.max_qp_wr); memset(iocp, 0, sizeof(*iocp)); - strcpy(iocp->id_string, sport->port_id); + mutex_lock(&sport->mutex); + strlcpy(iocp->id_string, sport->port_id, sizeof(iocp->id_string)); + mutex_unlock(&sport->mutex); iocp->guid = cpu_to_be64(srpt_service_guid); iocp->vendor_id = cpu_to_be32(sdev->dev_attr.vendor_id); iocp->device_id = cpu_to_be32(sdev->dev_attr.vendor_part_id); From e7603fc7a719aeed6d327235ca2cadc25094d078 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 9 Jun 2016 22:18:10 +0000 Subject: [PATCH 7/7] ib_srpt: Start with comp_vector 0 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6901 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 410c392eb..ebe5a2901 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -4303,7 +4303,6 @@ static void srpt_init_sport(struct srpt_port *sport, struct ib_device *ib_dev) INIT_LIST_HEAD(&sport->nexus_list); init_waitqueue_head(&sport->ch_releaseQ); mutex_init(&sport->mutex); - sport->comp_vector = -1; strlcpy(sport->port_id, DEFAULT_SRPT_ID_STRING, sizeof(sport->port_id)); for (i = 0; i < ib_dev->num_comp_vectors; i++)