Whamcloud - gitweb
LU-7734 lnet: configuration fixes
authorAmir Shehata <amir.shehata@intel.com>
Fri, 17 Jun 2016 22:55:13 +0000 (15:55 -0700)
committerAmir Shehata <amir.shehata@intel.com>
Wed, 25 Jan 2017 03:10:16 +0000 (19:10 -0800)
Fix cpt configuration from DLC to configure the proper list
of cpts in LNet. Check in LNet that no CPTs are outside the
available CPTs in the system.

Fix peer_rtr_credits name to peer_tx_credits to reflect the
actual value.

Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: Ic4a3985a470ed901be6166df4079205677921817
Reviewed-on: http://review.whamcloud.com/20862
Tested-by: Jenkins
lnet/include/lnet/lib-dlc.h
lnet/lnet/api-ni.c
lnet/lnet/peer.c
lnet/utils/cyaml/cyaml.c
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetctl.c

index 454b962..c006dbc 100644 (file)
@@ -168,6 +168,7 @@ struct lnet_ioctl_config_ni {
        __u32                   lic_tcp_bonding;
        __u32                   lic_idx;
        __s32                   lic_dev_cpt;
        __u32                   lic_tcp_bonding;
        __u32                   lic_idx;
        __s32                   lic_dev_cpt;
+       char                    pad[4];
        char                    lic_bulk[0];
 };
 
        char                    lic_bulk[0];
 };
 
@@ -176,9 +177,10 @@ struct lnet_peer_ni_credit_info {
        __u32 cr_refcount;
        __s32 cr_ni_peer_tx_credits;
        __s32 cr_peer_tx_credits;
        __u32 cr_refcount;
        __s32 cr_ni_peer_tx_credits;
        __s32 cr_peer_tx_credits;
+       __s32 cr_peer_min_tx_credits;
+       __u32 cr_peer_tx_qnob;
        __s32 cr_peer_rtr_credits;
        __s32 cr_peer_min_rtr_credits;
        __s32 cr_peer_rtr_credits;
        __s32 cr_peer_min_rtr_credits;
-       __u32 cr_peer_tx_qnob;
        __u32 cr_ncpt;
 };
 
        __u32 cr_ncpt;
 };
 
index aa752f8..c997c47 100644 (file)
@@ -2356,7 +2356,7 @@ int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf)
        struct lnet_net *net;
        struct lnet_ni *ni;
        struct lnet_ioctl_config_lnd_tunables *tun = NULL;
        struct lnet_net *net;
        struct lnet_ni *ni;
        struct lnet_ioctl_config_lnd_tunables *tun = NULL;
-       int rc;
+       int rc, i;
        __u32 net_id;
 
        /* get the tunables if they are available */
        __u32 net_id;
 
        /* get the tunables if they are available */
@@ -2376,6 +2376,11 @@ int lnet_dyn_add_ni(struct lnet_ioctl_config_ni *conf)
        if (!net)
                return -ENOMEM;
 
        if (!net)
                return -ENOMEM;
 
+       for (i = 0; i < conf->lic_ncpts; i++) {
+               if (conf->lic_cpts[i] >= LNET_CPT_NUMBER)
+                       return -EINVAL;
+       }
+
        ni = lnet_ni_alloc_w_cpt_array(net, conf->lic_cpts, conf->lic_ncpts,
                                       conf->lic_ni_intf[0]);
        if (!ni)
        ni = lnet_ni_alloc_w_cpt_array(net, conf->lic_cpts, conf->lic_ncpts,
                                       conf->lic_ni_intf[0]);
        if (!ni)
@@ -2841,7 +2846,7 @@ LNetCtl(unsigned int cmd, void *arg)
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_ni_peer_tx_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_rtr_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_ni_peer_tx_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_rtr_credits,
-                  &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_min_rtr_credits,
+                  &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_min_tx_credits,
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob);
                mutex_unlock(&the_lnet.ln_api_mutex);
                return rc;
                   &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob);
                mutex_unlock(&the_lnet.ln_api_mutex);
                return rc;
index ec26f37..4713fb9 100644 (file)
@@ -1121,7 +1121,8 @@ int lnet_get_peer_info(__u32 idx, lnet_nid_t *primary_nid, lnet_nid_t *nid,
                lpni->lpni_net->net_tunables.lct_peer_tx_credits : 0;
        peer_ni_info->cr_peer_tx_credits = lpni->lpni_txcredits;
        peer_ni_info->cr_peer_rtr_credits = lpni->lpni_rtrcredits;
                lpni->lpni_net->net_tunables.lct_peer_tx_credits : 0;
        peer_ni_info->cr_peer_tx_credits = lpni->lpni_txcredits;
        peer_ni_info->cr_peer_rtr_credits = lpni->lpni_rtrcredits;
-       peer_ni_info->cr_peer_min_rtr_credits = lpni->lpni_mintxcredits;
+       peer_ni_info->cr_peer_min_rtr_credits = lpni->lpni_minrtrcredits;
+       peer_ni_info->cr_peer_min_tx_credits = lpni->lpni_mintxcredits;
        peer_ni_info->cr_peer_tx_qnob = lpni->lpni_txqnob;
 
        peer_ni_stats->send_count = atomic_read(&lpni->lpni_stats.send_count);
        peer_ni_info->cr_peer_tx_qnob = lpni->lpni_txqnob;
 
        peer_ni_stats->send_count = atomic_read(&lpni->lpni_stats.send_count);
index a713566..de8804b 100644 (file)
@@ -687,19 +687,23 @@ static bool find_obj_iter(struct cYAML *node, void *usr_data, void **out)
 
 struct cYAML *cYAML_get_object_item(struct cYAML *parent, const char *name)
 {
 
 struct cYAML *cYAML_get_object_item(struct cYAML *parent, const char *name)
 {
-       struct cYAML *node;
+       struct cYAML *node = parent, *found = NULL;
 
 
-       if (parent == NULL || parent->cy_child == NULL || name == NULL)
+       if (!node || !name)
                return NULL;
 
                return NULL;
 
-       node = parent->cy_child;
-
-       while (node != NULL &&
-               strcmp(node->cy_string, name) != 0) {
-               node = node->cy_next;
+       if (node->cy_string) {
+               if (strcmp(node->cy_string, name) == 0)
+                       return node;
        }
 
        }
 
-       return node;
+       if (node->cy_child)
+               found = cYAML_get_object_item(node->cy_child, name);
+
+       if (!found && node->cy_next)
+               found = cYAML_get_object_item(node->cy_next, name);
+
+       return found;
 }
 
 struct cYAML *cYAML_get_next_seq_item(struct cYAML *seq, struct cYAML **itm)
 }
 
 struct cYAML *cYAML_get_next_seq_item(struct cYAML *seq, struct cYAML **itm)
index a0ade5f..7202e1e 100644 (file)
@@ -1166,7 +1166,7 @@ lustre_lnet_ioctl_config_ni(struct list_head *intf_list,
                conf = (struct lnet_ioctl_config_ni*) data;
                if (i == 0 && tunables != NULL)
                        tun = (struct lnet_ioctl_config_lnd_tunables*)
                conf = (struct lnet_ioctl_config_ni*) data;
                if (i == 0 && tunables != NULL)
                        tun = (struct lnet_ioctl_config_lnd_tunables*)
-                               (data + sizeof(*conf));
+                               conf->lic_bulk;
 
                LIBCFS_IOC_INIT_V2(*conf, lic_cfg_hdr);
                conf->lic_cfg_hdr.ioc_len = len;
 
                LIBCFS_IOC_INIT_V2(*conf, lic_cfg_hdr);
                conf->lic_cfg_hdr.ioc_len = len;
@@ -2106,6 +2106,16 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                            == NULL)
                                goto out;
 
                            == NULL)
                                goto out;
 
+                       if (cYAML_create_number(peer_ni, "min_tx_credits",
+                                               lpni_cri->cr_peer_min_tx_credits)
+                           == NULL)
+                               goto out;
+
+                       if (cYAML_create_number(peer_ni, "tx_q_num_of_buf",
+                                               lpni_cri->cr_peer_tx_qnob)
+                           == NULL)
+                               goto out;
+
                        if (cYAML_create_number(peer_ni, "available_rtr_credits",
                                                lpni_cri->cr_peer_rtr_credits)
                            == NULL)
                        if (cYAML_create_number(peer_ni, "available_rtr_credits",
                                                lpni_cri->cr_peer_rtr_credits)
                            == NULL)
@@ -2116,11 +2126,6 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                            == NULL)
                                goto out;
 
                            == NULL)
                                goto out;
 
-                       if (cYAML_create_number(peer_ni, "tx_q_num_of_buf",
-                                               lpni_cri->cr_peer_tx_qnob)
-                           == NULL)
-                               goto out;
-
                        if (cYAML_create_number(peer_ni, "send_count",
                                                lpni_stats->send_count)
                            == NULL)
                        if (cYAML_create_number(peer_ni, "send_count",
                                                lpni_stats->send_count)
                            == NULL)
@@ -2435,10 +2440,10 @@ failed:
 static bool
 yaml_extract_cmn_tunables(struct cYAML *tree,
                          struct lnet_ioctl_config_lnd_cmn_tunables *tunables,
 static bool
 yaml_extract_cmn_tunables(struct cYAML *tree,
                          struct lnet_ioctl_config_lnd_cmn_tunables *tunables,
-                         int *num_global_cpts,
                          struct cfs_expr_list **global_cpts)
 {
        struct cYAML *tun, *item, *smp;
                          struct cfs_expr_list **global_cpts)
 {
        struct cYAML *tun, *item, *smp;
+       int rc;
 
        tun = cYAML_get_object_item(tree, "tunables");
        if (tun != NULL) {
 
        tun = cYAML_get_object_item(tree, "tunables");
        if (tun != NULL) {
@@ -2456,10 +2461,11 @@ yaml_extract_cmn_tunables(struct cYAML *tree,
                        tunables->lct_max_tx_credits = item->cy_valueint;
                smp = cYAML_get_object_item(tun, "CPT");
                if (smp != NULL) {
                        tunables->lct_max_tx_credits = item->cy_valueint;
                smp = cYAML_get_object_item(tun, "CPT");
                if (smp != NULL) {
-                       *num_global_cpts =
-                               cfs_expr_list_parse(smp->cy_valuestring,
+                       rc = cfs_expr_list_parse(smp->cy_valuestring,
                                                 strlen(smp->cy_valuestring),
                                                 0, UINT_MAX, global_cpts);
                                                 strlen(smp->cy_valuestring),
                                                 0, UINT_MAX, global_cpts);
+                       if (rc != 0)
+                               *global_cpts = NULL;
                }
 
                return true;
                }
 
                return true;
@@ -2471,14 +2477,13 @@ yaml_extract_cmn_tunables(struct cYAML *tree,
 static bool
 yaml_extract_tunables(struct cYAML *tree,
                      struct lnet_ioctl_config_lnd_tunables *tunables,
 static bool
 yaml_extract_tunables(struct cYAML *tree,
                      struct lnet_ioctl_config_lnd_tunables *tunables,
-                     int *num_global_cpts,
                      struct cfs_expr_list **global_cpts,
                      __u32 net_type)
 {
        bool rc;
 
        rc = yaml_extract_cmn_tunables(tree, &tunables->lt_cmn,
                      struct cfs_expr_list **global_cpts,
                      __u32 net_type)
 {
        bool rc;
 
        rc = yaml_extract_cmn_tunables(tree, &tunables->lt_cmn,
-                                      num_global_cpts, global_cpts);
+                                      global_cpts);
 
        if (!rc)
                return rc;
 
        if (!rc)
                return rc;
@@ -2519,7 +2524,7 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc,
 {
        struct cYAML *net, *intf, *seq_no, *ip2net = NULL, *local_nis = NULL,
                     *item = NULL;
 {
        struct cYAML *net, *intf, *seq_no, *ip2net = NULL, *local_nis = NULL,
                     *item = NULL;
-       int num_entries = 0, num_global_cpts = 0, rc;
+       int num_entries = 0, rc;
        struct lnet_dlc_network_descr nw_descr;
        struct cfs_expr_list *global_cpts = NULL;
        struct lnet_ioctl_config_lnd_tunables tunables;
        struct lnet_dlc_network_descr nw_descr;
        struct cfs_expr_list *global_cpts = NULL;
        struct lnet_ioctl_config_lnd_tunables tunables;
@@ -2562,13 +2567,12 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc,
                }
        }
 
                }
        }
 
-       found = yaml_extract_tunables(tree, &tunables, &num_global_cpts,
-                                     &global_cpts,
+       found = yaml_extract_tunables(tree, &tunables, &global_cpts,
                                      LNET_NETTYP(nw_descr.nw_id));
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        rc = lustre_lnet_config_ni(&nw_descr,
                                      LNET_NETTYP(nw_descr.nw_id));
        seq_no = cYAML_get_object_item(tree, "seq_no");
 
        rc = lustre_lnet_config_ni(&nw_descr,
-                                  (num_global_cpts > 0) ? global_cpts: NULL,
+                                  global_cpts,
                                   (ip2net) ? ip2net->cy_valuestring : NULL,
                                   (found) ? &tunables: NULL,
                                   (seq_no) ? seq_no->cy_valueint : -1,
                                   (ip2net) ? ip2net->cy_valuestring : NULL,
                                   (found) ? &tunables: NULL,
                                   (seq_no) ? seq_no->cy_valueint : -1,
@@ -2599,7 +2603,7 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree,
        struct lustre_lnet_ip2nets ip2nets;
        struct lustre_lnet_ip_range_descr *ip_range_descr = NULL,
                                          *tmp = NULL;
        struct lustre_lnet_ip2nets ip2nets;
        struct lustre_lnet_ip_range_descr *ip_range_descr = NULL,
                                          *tmp = NULL;
-       int rc = LUSTRE_CFG_RC_NO_ERR, num_global_cpts = 0;
+       int rc = LUSTRE_CFG_RC_NO_ERR;
        struct cfs_expr_list *global_cpts = NULL;
        struct cfs_expr_list *el, *el_tmp;
        struct lnet_ioctl_config_lnd_tunables tunables;
        struct cfs_expr_list *global_cpts = NULL;
        struct cfs_expr_list *el, *el_tmp;
        struct lnet_ioctl_config_lnd_tunables tunables;
@@ -2653,13 +2657,12 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree,
                }
        }
 
                }
        }
 
-       found = yaml_extract_tunables(tree, &tunables, &num_global_cpts,
-                                     &global_cpts,
+       found = yaml_extract_tunables(tree, &tunables, &global_cpts,
                                      LNET_NETTYP(ip2nets.ip2nets_net.nw_id));
 
        rc = lustre_lnet_config_ip2nets(&ip2nets,
                        (found) ? &tunables : NULL,
                                      LNET_NETTYP(ip2nets.ip2nets_net.nw_id));
 
        rc = lustre_lnet_config_ip2nets(&ip2nets,
                        (found) ? &tunables : NULL,
-                       (num_global_cpts > 0) ? global_cpts : NULL,
+                       global_cpts,
                        (seq_no) ? seq_no->cy_valueint : -1,
                        err_rc);
 
                        (seq_no) ? seq_no->cy_valueint : -1,
                        err_rc);
 
index e0aea3a..566a216 100644 (file)
@@ -468,7 +468,7 @@ static int jt_add_ni(int argc, char **argv)
        char *ip2net = NULL;
        long int pto = -1, pc = -1, pbc = -1, cre = -1;
        struct cYAML *err_rc = NULL;
        char *ip2net = NULL;
        long int pto = -1, pc = -1, pbc = -1, cre = -1;
        struct cYAML *err_rc = NULL;
-       int rc, opt, num_global_cpts = 0;
+       int rc, opt, cpt_rc = -1;
        struct lnet_dlc_network_descr nw_descr;
        struct cfs_expr_list *global_cpts = NULL;
        struct lnet_ioctl_config_lnd_tunables tunables;
        struct lnet_dlc_network_descr nw_descr;
        struct cfs_expr_list *global_cpts = NULL;
        struct lnet_ioctl_config_lnd_tunables tunables;
@@ -542,10 +542,9 @@ static int jt_add_ni(int argc, char **argv)
                        }
                        break;
                case 's':
                        }
                        break;
                case 's':
-                       num_global_cpts =
-                               cfs_expr_list_parse(optarg,
-                                                strlen(optarg),
-                                                0, UINT_MAX, &global_cpts);
+                       cpt_rc = cfs_expr_list_parse(optarg,
+                                                    strlen(optarg), 0,
+                                                    UINT_MAX, &global_cpts);
                        break;
                case 'h':
                        print_help(net_cmds, "net", "add");
                        break;
                case 'h':
                        print_help(net_cmds, "net", "add");
@@ -564,7 +563,7 @@ static int jt_add_ni(int argc, char **argv)
        }
 
        rc = lustre_lnet_config_ni(&nw_descr,
        }
 
        rc = lustre_lnet_config_ni(&nw_descr,
-                                  (num_global_cpts > 0) ? global_cpts: NULL,
+                                  (cpt_rc == 0) ? global_cpts: NULL,
                                   ip2net, (found) ? &tunables : NULL,
                                   -1, &err_rc);
 
                                   ip2net, (found) ? &tunables : NULL,
                                   -1, &err_rc);