From e48f5a556f05e8dd6f2ffc57ad7c1220c24c9be1 Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Thu, 26 Nov 2015 19:30:01 -0800 Subject: [PATCH] LU-7475 lnet: ensure buffer config symmetry When showing the configuration, make sure to add a buffers block in the YAML output, if routing is configured, in order to allow the same YAML block to be fed back for configuration to LNet. Signed-off-by: Amir Shehata Change-Id: I3b269edf5b3688b500bbb3656c367bc82fff6b68 Reviewed-on: http://review.whamcloud.com/17370 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Doug Oucharek Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/liblnetconfig.c | 38 +++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 625e5fa..da7fe62 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -828,7 +828,7 @@ int lustre_lnet_config_buffers(int tiny, int small, int large, int seq_no, } out: - cYAML_build_error(rc, seq_no, DEL_CMD, "buf", err_str, err_rc); + cYAML_build_error(rc, seq_no, ADD_CMD, "buf", err_str, err_rc); return rc; } @@ -842,9 +842,10 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc, int l_errno = 0; char *buf; char *pools[LNET_NRBPOOLS] = {"tiny", "small", "large"}; + int buf_count[LNET_NRBPOOLS] = {0}; struct cYAML *root = NULL, *pools_node = NULL, *type_node = NULL, *item = NULL, *cpt = NULL, - *first_seq = NULL; + *first_seq = NULL, *buffers = NULL; int i, j; char err_str[LNET_MAX_STR_LEN]; char node_name[LNET_MAX_STR_LEN]; @@ -915,6 +916,9 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc, pool_cfg->pl_pools[j]. pl_mincredits) == NULL) goto out; + /* keep track of the total count for each of the + * tiny, small and large buffers */ + buf_count[j] += pool_cfg->pl_pools[j].pl_nbuffers; } } @@ -928,6 +932,18 @@ int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc, goto out; } + /* create a buffers entry in the show. This is necessary so that + * if the YAML output is used to configure a node, the buffer + * configuration takes hold */ + buffers = cYAML_create_object(root, "buffers"); + if (buffers == NULL) + goto out; + + for (i = 0; i < LNET_NRBPOOLS; i++) { + if (cYAML_create_number(buffers, pools[i], buf_count[i]) == NULL) + goto out; + } + if (show_rc == NULL) cYAML_print_tree(root); @@ -949,18 +965,14 @@ out: if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR || !exist) { cYAML_free_tree(root); } else if (show_rc != NULL && *show_rc != NULL) { - struct cYAML *show_node; - /* find the routing node, if one doesn't exist then - * insert one. Otherwise add to the one there - */ - show_node = cYAML_get_object_item(*show_rc, "routing"); - if (show_node != NULL && cYAML_is_sequence(show_node)) { - cYAML_insert_child(show_node, first_seq); - free(pools_node); - free(root); - } else if (show_node == NULL) { + struct cYAML *routing_node; + /* there should exist only one routing block and one + * buffers block. If there already exists a previous one + * then don't add another */ + routing_node = cYAML_get_object_item(*show_rc, "routing"); + if (routing_node == NULL) { cYAML_insert_sibling((*show_rc)->cy_child, - pools_node); + root->cy_child); free(root); } else { cYAML_free_tree(root); -- 1.8.3.1