Whamcloud - gitweb
LU-11475 lnet: transfer routers 39/34539/20
authorAmir Shehata <ashehata@whamcloud.com>
Thu, 28 Mar 2019 02:32:45 +0000 (19:32 -0700)
committerAmir Shehata <ashehata@whamcloud.com>
Fri, 7 Jun 2019 18:17:52 +0000 (18:17 +0000)
When a primary NID of a peer is about to be deleted because
it's being transfered to another peer, if that peer is a gateway
then transfer all gateway properties to the new peer.

Test-Parameters: forbuildonly
Signed-off-by: Amir Shehata <ashehata@whamcloud.com>
Change-Id: Ib475c389ca5630906416a5112b3088f6f5d03950
Reviewed-on: https://review.whamcloud.com/34539
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Tested-by: Jenkins
lnet/include/lnet/lib-lnet.h
lnet/lnet/peer.c
lnet/lnet/router.c

index 494325e..f1dbbff 100644 (file)
@@ -602,6 +602,8 @@ int  lnet_rtrpools_adjust(int tiny, int small, int large);
 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);
index 0ef30b5..73d86d5 100644 (file)
@@ -1362,6 +1362,18 @@ lnet_peer_add_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags)
                }
                /* 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) {
index 9ac6de1..0346cf0 100644 (file)
@@ -141,6 +141,35 @@ rtr_sensitivity_set(const char *val, cfs_kernel_param_arg_t *kp)
        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)
 {