From 918c378fb4fb0a46b71ebf1cf5e1cec56538d93a Mon Sep 17 00:00:00 2001 From: Sonia Sharma Date: Mon, 7 May 2018 20:27:14 -0700 Subject: [PATCH] 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. Lustre-change: https://review.whamcloud.com/32320 Lustre-commit: 40295e5ca3e5ed51c8236a2e641627d687b7d59c Change-Id: I58a337233c4dcea80e78c9dfd6eaabab33766f04 Test-Parameters: trivial Signed-off-by: Sonia Sharma Reviewed-on: https://review.whamcloud.com/32318 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Amir Shehata Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/liblnetconfig.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index 5883e8c..57d8c56 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -2232,6 +2232,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, int data_size = sizeof(*lpni_cri) + sizeof(*lpni_stats); char *data = malloc(data_size); bool new_peer = true; + bool exist = false; snprintf(err_str, sizeof(err_str), "\"out of memory\""); @@ -2275,6 +2276,8 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, lpni_cri = peer_info.prcfg_bulk; lpni_stats = peer_info.prcfg_bulk + sizeof(*lpni_cri); + exist = true; + peer = cYAML_create_seq_item(peer_root); if (peer == NULL) goto out; @@ -2392,7 +2395,7 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no, rc = LUSTRE_CFG_RC_NO_ERR; out: - 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; -- 1.8.3.1