From patchwork Thu Feb 27 21:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EBF3924 for ; Thu, 27 Feb 2020 21:43:09 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 573BC24690 for ; Thu, 27 Feb 2020 21:43:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 573BC24690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2393E34AE16; Thu, 27 Feb 2020 13:34:49 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1C4A821FD1C for ; Thu, 27 Feb 2020 13:20:05 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 621338A90; Thu, 27 Feb 2020 16:18:17 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 60B42468; Thu, 27 Feb 2020 16:18:17 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:13:34 -0500 Message-Id: <1582838290-17243-347-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 346/622] lnet: transfer routers X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amir Shehata , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Amir Shehata When a primary NID of a peer is about to be deleted because it's being transferred to another peer, if that peer is a gateway then transfer all gateway properties to the new peer. WC-bug-id: https://jira.whamcloud.com/browse/LU-11475 Lustre-commit: cab57464e17b ("LU-11475 lnet: transfer routers") Signed-off-by: Amir Shehata Reviewed-on: https://review.whamcloud.com/34539 Reviewed-by: Sebastien Buisson Reviewed-by: Olaf Weber Signed-off-by: James Simmons --- include/linux/lnet/lib-lnet.h | 2 ++ net/lnet/lnet/peer.c | 12 ++++++++++++ net/lnet/lnet/router.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h index 1d06263..5a83e3a 100644 --- a/include/linux/lnet/lib-lnet.h +++ b/include/linux/lnet/lib-lnet.h @@ -534,6 +534,8 @@ int lnet_get_peer_list(u32 *countp, u32 *sizep, int lnet_rtrpools_enable(void); void lnet_rtrpools_disable(void); void lnet_rtrpools_free(int keep_pools); +void lnet_rtr_transfer_to_peer(struct lnet_peer *src, + struct lnet_peer *target); struct lnet_remotenet *lnet_find_rnet_locked(u32 net); int lnet_dyn_add_net(struct lnet_ioctl_config_data *conf); int lnet_dyn_del_net(u32 net); diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index a81fee2..5d13986 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -1355,6 +1355,18 @@ struct lnet_peer_net * } /* If this is the primary NID, destroy the peer. */ if (lnet_peer_ni_is_primary(lpni)) { + struct lnet_peer *rtr_lp = + lpni->lpni_peer_net->lpn_peer; + int rtr_refcount = rtr_lp->lp_rtr_refcount; + + /* if we're trying to delete a router it means + * we're moving this peer NI to a new peer so must + * transfer router properties to the new peer + */ + if (rtr_refcount > 0) { + flags |= LNET_PEER_RTR_NI_FORCE_DEL; + lnet_rtr_transfer_to_peer(rtr_lp, lp); + } lnet_peer_del(lpni->lpni_peer_net->lpn_peer); lpni = lnet_peer_ni_alloc(nid); if (!lpni) { diff --git a/net/lnet/lnet/router.c b/net/lnet/lnet/router.c index 4a061f3..aa8ec8c 100644 --- a/net/lnet/lnet/router.c +++ b/net/lnet/lnet/router.c @@ -136,6 +136,35 @@ static int rtr_sensitivity_set(const char *val, return 0; } +void +lnet_rtr_transfer_to_peer(struct lnet_peer *src, struct lnet_peer *target) +{ + struct lnet_route *route; + + lnet_net_lock(LNET_LOCK_EX); + target->lp_rtr_refcount += src->lp_rtr_refcount; + /* move the list of queued messages to the new peer */ + list_splice_init(&src->lp_rtrq, &target->lp_rtrq); + /* move all the routes that reference the peer */ + list_splice_init(&src->lp_routes, &target->lp_routes); + /* update all the routes to point to the new peer */ + list_for_each_entry(route, &target->lp_routes, lr_gwlist) + route->lr_gateway = target; + /* remove the old peer from the ln_routers list */ + list_del_init(&src->lp_rtr_list); + /* add the new peer to the ln_routers list */ + if (list_empty(&target->lp_rtr_list)) { + lnet_peer_addref_locked(target); + list_add_tail(&target->lp_rtr_list, &the_lnet.ln_routers); + } + /* reset the ref count on the old peer and decrement its ref count */ + src->lp_rtr_refcount = 0; + lnet_peer_decref_locked(src); + /* update the router version */ + the_lnet.ln_routers_version++; + lnet_net_unlock(LNET_LOCK_EX); +} + int lnet_peers_start_down(void) {