From a29151e30d8b89d0240c75bfd5f2346cbc57ecec Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Thu, 28 Feb 2019 16:57:30 -0800 Subject: [PATCH] LU-9121 lnet: Apply UDSP on local and remote NIs When a peer net, peer ni, local net or local ni are created apply the UDSPs in the system on these constructs. Test-Parameters: trivial testlist=lnet-selftest,sanity-lnet Signed-off-by: Amir Shehata Change-Id: I0ee427f1bc0d1c8d1ddc17072dcbd9442403fa0f Reviewed-on: https://review.whamcloud.com/34355 Reviewed-by: Chris Horn Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo --- lnet/lnet/api-ni.c | 28 ++++++++++++++++++++++------ lnet/lnet/peer.c | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index d4313ba..8528b83 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -3242,12 +3242,13 @@ int lnet_get_ni_stats(struct lnet_ioctl_element_msg_stats *msg_stats) static int lnet_add_net_common(struct lnet_net *net, struct lnet_ioctl_config_lnd_tunables *tun) { - __u32 net_id; + struct lnet_handle_md ping_mdh; struct lnet_ping_buffer *pbuf; - struct lnet_handle_md ping_mdh; - int rc; struct lnet_remotenet *rnet; - int net_ni_count; + struct lnet_ni *ni; + int net_ni_count; + __u32 net_id; + int rc; lnet_net_lock(LNET_LOCK_EX); rnet = lnet_find_rnet_locked(net->net_id); @@ -3297,10 +3298,25 @@ static int lnet_add_net_common(struct lnet_net *net, lnet_net_lock(LNET_LOCK_EX); net = lnet_get_net_locked(net_id); - lnet_net_unlock(LNET_LOCK_EX); - LASSERT(net); + /* apply the UDSPs */ + rc = lnet_udsp_apply_policies_on_net(net); + if (rc) + CERROR("Failed to apply UDSPs on local net %s\n", + libcfs_net2str(net->net_id)); + + /* At this point we lost track of which NI was just added, so we + * just re-apply the policies on all of the NIs on this net + */ + list_for_each_entry(ni, &net->net_ni_list, ni_netlist) { + rc = lnet_udsp_apply_policies_on_ni(ni); + if (rc) + CERROR("Failed to apply UDSPs on ni %s\n", + libcfs_nid2str(ni->ni_nid)); + } + lnet_net_unlock(LNET_LOCK_EX); + /* * Start the acceptor thread if this is the first network * being added that requires the thread. diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index d2f4cd2..83f52af 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -40,6 +40,7 @@ #endif #include +#include #include #include @@ -1366,6 +1367,8 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, unsigned flags) { struct lnet_peer_table *ptable; + bool new_lpn = false; + int rc; /* Install the new peer_ni */ lnet_net_lock(LNET_LOCK_EX); @@ -1396,6 +1399,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, /* Add peer_net to peer */ if (!lpn->lpn_peer) { + new_lpn = true; lpn->lpn_peer = lp; list_add_tail(&lpn->lpn_peer_nets, &lp->lp_peer_nets); lnet_peer_addref_locked(lp); @@ -1425,6 +1429,18 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, lp->lp_nnis++; + /* apply UDSPs */ + if (new_lpn) { + rc = lnet_udsp_apply_policies_on_lpn(lpn); + if (rc) + CERROR("Failed to apply UDSPs on lpn %s\n", + libcfs_net2str(lpn->lpn_net_id)); + } + rc = lnet_udsp_apply_policies_on_lpni(lpni); + if (rc) + CERROR("Failed to apply UDSPs on lpni %s\n", + libcfs_nid2str(lpni->lpni_nid)); + CDEBUG(D_NET, "peer %s NID %s flags %#x\n", libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(lpni->lpni_nid), flags); -- 1.8.3.1