From: Sonia Sharma Date: Tue, 8 May 2018 04:08:03 +0000 (-0700) Subject: LU-11006 lnet: fix show peer yaml tree with no peer X-Git-Tag: 2.11.55~16 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=40295e5ca3e5ed51c8236a2e641627d687b7d59c LU-11006 lnet: fix show peer yaml tree with no peer When no peer exists then the root created for the peer yaml tree should be deleted. And lnetctl show peer should not display anything. Currently lnetctl peer show shows the root string "peer" even when there is no peer. This create issues when starting lnet using /etc/lnet.conf derived from the existing configuration. Change-Id: Ie310a49e60386b579b48898b032467b1bc112da9 Test-Parameters: trivial Signed-off-by: Sonia Sharma Reviewed-on: https://review.whamcloud.com/32320 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Amir Shehata Reviewed-by: Olaf Weber Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index c2b3667..c9ca32e 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -2886,6 +2886,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, struct lnet_process_id *list = NULL; void *data = NULL; void *lpni_data; + bool exist = false; snprintf(err_str, sizeof(err_str), "\"out of memory\""); @@ -2948,6 +2949,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, l_errno = ENOMEM; goto out; } + for (i = 0; i < count; i++) { for (;;) { memset(&peer_info, 0, sizeof(peer_info)); @@ -2979,6 +2981,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, goto out; } } + exist = true; peer = cYAML_create_seq_item(peer_root); if (peer == NULL) @@ -3150,7 +3153,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, out: free(list); free(data); - if (show_rc == NULL || rc != LUSTRE_CFG_RC_NO_ERR) { + 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;