From: Chris Horn Date: Fri, 24 May 2024 17:32:17 +0000 (-0600) Subject: LU-17892 lnet: Fix export with empty nets X-Git-Tag: 2.15.64~56 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F55279%2F3;p=fs%2Flustre-release.git LU-17892 lnet: Fix export with empty nets lnetctl export --backup should not print an error when there haven't been any NIs added. Test-Parameters: trivial Fixes: 8f8f6e2f36 ("LU-10003 lnet: use Netlink to support old and new NI APIs.") Signed-off-by: Chris Horn Change-Id: Id9e916d2d70d5dc01442e24449cb787c5a6a7e1d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55279 Reviewed-by: Frank Sehr Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index bc53e7f..605111a 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -5527,6 +5527,7 @@ static int lnet_net_show_dump(struct sk_buff *msg, int seq = cb->nlh->nlmsg_seq; struct lnet_net *net; void *hdr = NULL; + bool export_backup = cb->nlh->nlmsg_flags & NLM_F_DUMP_FILTERED; #ifdef HAVE_NL_DUMP_WITH_EXT_ACK extack = cb->extack; @@ -5542,8 +5543,7 @@ static int lnet_net_show_dump(struct sk_buff *msg, nlist->lngl_net_id != net->net_id) continue; - if (cb->nlh->nlmsg_flags & NLM_F_DUMP_FILTERED && - LNET_NETTYP(net->net_id) == LOLND) + if (export_backup && LNET_NETTYP(net->net_id) == LOLND) continue; if (gnlh->version && LNET_NETTYP(net->net_id) != LOLND) { @@ -5622,7 +5622,7 @@ static int lnet_net_show_dump(struct sk_buff *msg, ni_attr = nla_nest_start(msg, dev++); found = true; lnet_ni_lock(ni); - if (!(cb->nlh->nlmsg_flags & NLM_F_DUMP_FILTERED)) { + if (!export_backup) { nla_put_string(msg, LNET_NET_LOCAL_NI_ATTR_NID, libcfs_nidstr(&ni->ni_nid)); if (!nid_is_lo0(&ni->ni_nid) && @@ -5658,7 +5658,7 @@ static int lnet_net_show_dump(struct sk_buff *msg, struct nlattr *tun_attr, *ni_tun; int j; - if (cb->nlh->nlmsg_flags & NLM_F_DUMP_FILTERED) { + if (export_backup) { lnet_ni_unlock(ni); goto skip_msg_stats; } @@ -5815,7 +5815,7 @@ skip_msg_stats: nla_nest_end(msg, lnd_tun_attr); } - if (!(cb->nlh->nlmsg_flags & NLM_F_DUMP_FILTERED)) + if (!export_backup) nla_put_s32(msg, LNET_NET_LOCAL_NI_DEV_CPT, ni->ni_dev_cpt); @@ -5858,7 +5858,7 @@ skip_msg_stats: genlmsg_end(msg, hdr); } - if (!found) { + if (!export_backup && !found) { struct nlmsghdr *nlh = nlmsg_hdr(msg); nlmsg_cancel(msg, nlh); diff --git a/lustre/tests/sanity-lnet.sh b/lustre/tests/sanity-lnet.sh index 4bdd617..1672ab0 100755 --- a/lustre/tests/sanity-lnet.sh +++ b/lustre/tests/sanity-lnet.sh @@ -114,7 +114,7 @@ configure_dlc() { GLOBAL_YAML_FILE=$TMP/sanity-lnet-global.yaml define_global_yaml() { - $LNETCTL export --backup >${GLOBAL_YAML_FILE} || + $LNETCTL export --backup &>${GLOBAL_YAML_FILE} || error "Failed to export global yaml $?" }