[ewg] [PATCH] node description patch
Mike Heinz
michael.heinz at qlogic.com
Tue Jun 1 07:04:16 PDT 2010
This patch fixes a problem with the openibd initialization script. On machines using slower DHCP servers, openibd frequently sets the HCA's node description to HCA-1. This patch modifies openibd to add a "@" instead of the hostname and adds a small hook in the core drivers to replace the "@" sign with the system's utsname().
Because this patch depends on changes to openibd, it cannot be submitted to the upstream kernel, but it still corrects an outstanding issue with OFED 1.5.
Signed-Off-By: Michael Heinz <michael.heinz at qlogic.com>
---
drivers/infiniband/core/mad.c | 18 ++++++++++++++
drivers/infiniband/hw/ipath/ipath_mad.c | 2 -
drivers/infiniband/hw/mlx4/mad.c | 2 -
drivers/infiniband/hw/mthca/mthca_mad.c | 2 -
include/rdma/ib_mad.h | 8 ++++++
ofed_scripts/openibd | 41 ++++++++++++++------------------
6 files changed, 47 insertions(+), 26 deletions(-)
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/core/mad.c
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/drivers/infiniband/core/mad.c
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/core/mad.c
@@ -39,6 +39,7 @@
#include "mad_rmpp.h"
#include "smi.h"
#include "agent.h"
+#include "linux/utsname.h"
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("kernel IB MAD API");
@@ -929,6 +930,23 @@ int ib_get_mad_data_offset(u8 mgmt_class
}
EXPORT_SYMBOL(ib_get_mad_data_offset);
+void ib_build_node_desc(char *dest, char *src)
+{
+ int i;
+ for (i=0; i<64;) {
+ if (*src == '@') {
+ char *name = init_utsname()->nodename;
+ for (; *name && *name != '.' && i<64; ++i)
+ *dest++ = *name++;
+ src++;
+ } else {
+ *dest++ = *src++;
+ i++;
+ }
+ }
+}
+EXPORT_SYMBOL(ib_build_node_desc);
+
int ib_is_mad_class_rmpp(u8 mgmt_class)
{
if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/ipath/ipath_mad.c
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/drivers/infiniband/hw/ipath/ipath_mad.c
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -60,7 +60,7 @@ static int recv_subn_get_nodedescription
if (smp->attr_mod)
smp->status |= IB_SMP_INVALID_FIELD;
- strncpy(smp->data, ibdev->node_desc, sizeof(smp->data));
+ ib_build_node_desc((char*)smp->data, ibdev->node_desc);
return reply(smp);
}
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/mlx4/mad.c
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/drivers/infiniband/hw/mlx4/mad.c
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/mlx4/mad.c
@@ -195,7 +195,7 @@ static void node_desc_override(struct ib
mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
spin_lock(&to_mdev(dev)->sm_lock);
- memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+ ib_build_node_desc((char*)((struct ib_smp *) mad)->data, dev->node_desc);
spin_unlock(&to_mdev(dev)->sm_lock);
}
}
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/mthca/mthca_mad.c
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/drivers/infiniband/hw/mthca/mthca_mad.c
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -153,7 +153,7 @@ static void node_desc_override(struct ib
mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
mutex_lock(&to_mdev(dev)->cap_mask_mutex);
- memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+ ib_build_node_desc((char*)((struct ib_smp *) mad)->data, dev->node_desc);
mutex_unlock(&to_mdev(dev)->cap_mask_mutex);
}
}
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/include/rdma/ib_mad.h
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/include/rdma/ib_mad.h
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/include/rdma/ib_mad.h
@@ -637,6 +637,14 @@ int ib_is_mad_class_rmpp(u8 mgmt_class);
int ib_get_mad_data_offset(u8 mgmt_class);
/**
+ * ib_build_node_desc - copies the node description and replaces
+ * any @ markers with the present system node name.
+ * @dest: destination
+ * @src: source
+ */
+void ib_build_node_desc(char *dest, char *src);
+
+/**
* ib_get_rmpp_segment - returns the data buffer for a given RMPP segment.
* @send_buf: Previously allocated send data buffer.
* @seg_num: number of segment to return
Index: ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/ofed_scripts/openibd
===================================================================
--- ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2.orig/ofed_scripts/openibd
+++ ofa_kernel-1.4.1_QIB-2.6.16_sles10_sp2/ofed_scripts/openibd
@@ -205,6 +205,23 @@ count_ib_ports()
return $cnt
}
+set_node_desc()
+{
+ # Add node description to sysfs
+ sysdir=/sys/class/infiniband
+ declare -i hca_id=1
+ hcas=$(/bin/ls -1 ${sysdir} 2> /dev/null)
+ for hca in $hcas
+ do
+ if [ -e ${sysdir}/${hca}/node_desc ]; then
+ # if old behavior is desired, edit to use $(hostname -s)
+ logger -i "Set node_desc for ${hca}: ${NODE_DESC_HOSTNAME} HCA-\${hca_id}"
+ echo -n "${NODE_DESC_HOSTNAME} HCA-${hca_id}" >> ${sysdir}/${hca}/node_desc
+ fi
+ let hca_id++
+ done
+}
+
# Setting Environment variables
IS_FEDORA=0
if [ -f /etc/redhat-release ]; then
@@ -888,29 +905,7 @@ start()
RC=$[ $RC + $my_rc ]
fi
-cat << EOF >> /tmp/ib_set_node_desc.sh
-#!/bin/bash
-
-# Wait while node's hostname is set
-sleep 10
-# Add node description to sysfs
-IBSYSDIR="/sys/class/infiniband"
-if [ -d \${IBSYSDIR} ]; then
- declare -i hca_id=1
- for hca in \${IBSYSDIR}/*
- do
- if [ -e \${hca}/node_desc ]; then
- logger -i "Set node_desc for \$(basename \$hca): \$(hostname -s) HCA-\${hca_id}"
- echo -n "\$(hostname -s) HCA-\${hca_id}" >> \${hca}/node_desc
- fi
- let hca_id++
- done
-fi
-/bin/rm -f \$0
-EOF
-
- chmod 755 /tmp/ib_set_node_desc.sh
- /tmp/ib_set_node_desc.sh > /dev/null 2>&1 &
+ set_node_desc
${modprobe} ib_umad > /dev/null 2>&1
RC=$[ $RC + $? ]
More information about the ewg
mailing list