[lustre-devel] [PATCH 29/40] lnet: don't delete peer created by Lustre
James Simmons <[email protected]> Sun, 9 Apr 2023 08:13:09 -0400
| Newsgroups | org.lustre.lists.lustre-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Amir Shehata <[email protected]> Peers created by Lustre have their primary NIDs locked. If that peer is deleted, it'll confuse lustre. So when manually deleting a peer using: lnetctl peer del --prim_nid ... We must continue to preserve the primary NID. Therefore we delete all the constituent NIDs, but keep the primary NID. We then flag the peer for rediscovery. WC-bug-id: https://jira.whamcloud.com/browse/LU-14668 Lustre-commit: 7cc5b4329fc2eecbf ("LU-14668 lnet: don't delete peer created by Lustre") Signed-off-by: Amir Shehata <[email protected]> Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/43565 Reviewed-by: Oleg Drokin <[email protected]> Reviewed-by: Serguei Smirnov <[email protected]> Reviewed-by: Cyril Bordage <[email protected]> Signed-off-by: James Simmons <[email protected]> --- net/lnet/lnet/peer.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index fa2ca54..0a5e73a 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -1983,6 +1983,40 @@ int lnet_user_add_peer_ni(struct lnet_nid *prim_nid, struct lnet_nid *nid, bool return lnet_add_peer_ni(prim_nid, nid, mr, LNET_PEER_CONFIGURED); } +static int +lnet_reset_peer(struct lnet_peer *lp) +{ + struct lnet_peer_net *lpn, *lpntmp; + struct lnet_peer_ni *lpni, *lpnitmp; + unsigned int flags; + int rc; + + lnet_peer_cancel_discovery(lp); + + flags = LNET_PEER_CONFIGURED; + if (lp->lp_state & LNET_PEER_MULTI_RAIL) + flags |= LNET_PEER_MULTI_RAIL; + + list_for_each_entry_safe(lpn, lpntmp, &lp->lp_peer_nets, lpn_peer_nets) { + list_for_each_entry_safe(lpni, lpnitmp, &lpn->lpn_peer_nis, + lpni_peer_nis) { + if (nid_same(&lpni->lpni_nid, &lp->lp_primary_nid)) + continue; + + rc = lnet_peer_del_nid(lp, &lpni->lpni_nid, flags); + if (rc) { + CERROR("Failed to delete %s from peer %s\n", + libcfs_nidstr(&lpni->lpni_nid), + libcfs_nidstr(&lp->lp_primary_nid)); + } + } + } + + /* mark it for discovery the next time we use it */ + lp->lp_state &= ~LNET_PEER_NIDS_UPTODATE; + return 0; +} + /* * Implementation of IOC_LIBCFS_DEL_PEER_NI. * @@ -2026,8 +2060,15 @@ int lnet_user_add_peer_ni(struct lnet_nid *prim_nid, struct lnet_nid *nid, bool } lnet_net_unlock(LNET_LOCK_EX); - if (LNET_NID_IS_ANY(nid) || nid_same(nid, &lp->lp_primary_nid)) - return lnet_peer_del(lp); + if (LNET_NID_IS_ANY(nid) || nid_same(nid, &lp->lp_primary_nid)) { + if (lp->lp_state & LNET_PEER_LOCK_PRIMARY) { + CERROR("peer %s created by Lustre. Must preserve primary NID, but will remove other NIDs\n", + libcfs_nidstr(&lp->lp_primary_nid)); + return lnet_reset_peer(lp); + } else { + return lnet_peer_del(lp); + } + } flags = LNET_PEER_CONFIGURED; if (lp->lp_state & LNET_PEER_MULTI_RAIL) -- 1.8.3.1 _______________________________________________ lustre-devel mailing list [email protected] http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org