From: Cyril Bordage Date: Thu, 17 Feb 2022 11:49:16 +0000 (+0100) Subject: LU-14875 import: fix bad CPT read X-Git-Tag: 2.15.51~159 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9ad5c43f4a53f8679cfa1a60f8161b08d3dcfa66;hp=e5cdafa70b5e05e0670797e620e9d3e7e4244037 LU-14875 import: fix bad CPT read When importing, CPT was read from tunables field but in fact, it is in the same level in the YAML file generated during export. Test-parameters: trivial testlist=sanity-lnet Signed-off-by: Cyril Bordage Change-Id: Iea7b6189ad1a25b95ae6416d75ee2cbe4dca2fbf Reviewed-on: https://review.whamcloud.com/46541 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin --- diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index b561f9c..c5ac18a 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -4362,11 +4362,9 @@ failed: static bool yaml_extract_cmn_tunables(struct cYAML *tree, - struct lnet_ioctl_config_lnd_cmn_tunables *tunables, - struct cfs_expr_list **global_cpts) + struct lnet_ioctl_config_lnd_cmn_tunables *tunables) { - struct cYAML *tun, *item, *smp; - int rc; + struct cYAML *tun, *item; tun = cYAML_get_object_item(tree, "tunables"); if (tun != NULL) { @@ -4382,14 +4380,6 @@ yaml_extract_cmn_tunables(struct cYAML *tree, item = cYAML_get_object_item(tun, "credits"); if (item != NULL) tunables->lct_max_tx_credits = item->cy_valueint; - smp = cYAML_get_object_item(tun, "CPT"); - if (smp != NULL) { - rc = cfs_expr_list_parse(smp->cy_valuestring, - strlen(smp->cy_valuestring), - 0, UINT_MAX, global_cpts); - if (rc != 0) - *global_cpts = NULL; - } return true; } @@ -4400,13 +4390,11 @@ yaml_extract_cmn_tunables(struct cYAML *tree, static bool yaml_extract_tunables(struct cYAML *tree, struct lnet_ioctl_config_lnd_tunables *tunables, - struct cfs_expr_list **global_cpts, __u32 net_type) { bool rc; - rc = yaml_extract_cmn_tunables(tree, &tunables->lt_cmn, - global_cpts); + rc = yaml_extract_cmn_tunables(tree, &tunables->lt_cmn); if (!rc) return rc; @@ -4417,6 +4405,23 @@ yaml_extract_tunables(struct cYAML *tree, return rc; } +static void +yaml_extract_cpt(struct cYAML *tree, + struct cfs_expr_list **global_cpts) +{ + int rc; + struct cYAML *smp; + + smp = cYAML_get_object_item(tree, "CPT"); + if (smp != NULL) { + rc = cfs_expr_list_parse(smp->cy_valuestring, + strlen(smp->cy_valuestring), + 0, UINT_MAX, global_cpts); + if (rc != 0) + *global_cpts = NULL; + } +} + /* * net: * - net type: [] @@ -4492,8 +4497,9 @@ static int handle_yaml_config_ni(struct cYAML *tree, struct cYAML **show_rc, } } - found = yaml_extract_tunables(tree, &tunables, &global_cpts, + found = yaml_extract_tunables(tree, &tunables, LNET_NETTYP(nw_descr.nw_id)); + yaml_extract_cpt(tree, &global_cpts); seq_no = cYAML_get_object_item(tree, "seq_no"); rc = lustre_lnet_config_ni(&nw_descr, global_cpts, @@ -4581,8 +4587,9 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree, } } - found = yaml_extract_tunables(tree, &tunables, &global_cpts, + found = yaml_extract_tunables(tree, &tunables, LNET_NETTYP(ip2nets.ip2nets_net.nw_id)); + yaml_extract_cpt(tree, &global_cpts); rc = lustre_lnet_config_ip2nets(&ip2nets, (found) ? &tunables : NULL, @@ -4590,6 +4597,9 @@ static int handle_yaml_config_ip2nets(struct cYAML *tree, (seq_no) ? seq_no->cy_valueint : -1, err_rc); + if (global_cpts != NULL) + cfs_expr_list_free(global_cpts); + /* * don't stop because there was no match. Continue processing the * rest of the rules. If non-match then nothing is configured