From 1477027d073be1efb6ffbb368ed68b97a65c72f1 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 7 Feb 2020 13:05:57 +1100 Subject: [PATCH] LU-10391 lnet: simplify use of lnet_count_acceptor_nets() Instead of calling this in various places before either lnet_acceptor_start() or lnet_acceptor_stop(), only call it in those functions. It is already called in lnet_acceptor_start(). At shutdown, lnet_acceptor_stop() must succeed unconditionally, so include a test on the_lnet.ln_refcount. Signed-off-by: Mr NeilBrown Change-Id: I11ef6c1a226e7b752b540f37651c766e83c5cb52 Reviewed-on: https://review.whamcloud.com/37695 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- lnet/lnet/acceptor.c | 4 ++++ lnet/lnet/api-ni.c | 20 ++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lnet/lnet/acceptor.c b/lnet/lnet/acceptor.c index 1209b18..09d016f 100644 --- a/lnet/lnet/acceptor.c +++ b/lnet/lnet/acceptor.c @@ -527,6 +527,10 @@ lnet_acceptor_stop(void) if (lnet_acceptor_state.pta_shutdown) /* not running */ return; + /* If still required, return immediately */ + if (the_lnet.ln_refcount && lnet_count_acceptor_nets() > 0) + return; + lnet_acceptor_state.pta_shutdown = 1; wake_up(&lnet_acceptor_state.pta_waitq); diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 7534a1e..e554429 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -3123,7 +3123,6 @@ static int lnet_add_net_common(struct lnet_net *net, int rc; struct lnet_remotenet *rnet; int net_ni_count; - int num_acceptor_nets; lnet_net_lock(LNET_LOCK_EX); rnet = lnet_find_rnet_locked(net->net_id); @@ -3164,14 +3163,6 @@ static int lnet_add_net_common(struct lnet_net *net, else memset(&net->net_tunables, -1, sizeof(net->net_tunables)); - /* - * before starting this network get a count of the current TCP - * networks which require the acceptor thread running. If that - * count is == 0 before we start up this network, then we'd want to - * start up the acceptor thread after starting up this network - */ - num_acceptor_nets = lnet_count_acceptor_nets(); - net_id = net->net_id; rc = lnet_startup_lndnet(net, @@ -3189,7 +3180,7 @@ static int lnet_add_net_common(struct lnet_net *net, * Start the acceptor thread if this is the first network * being added that requires the thread. */ - if (net->net_lnd->lnd_accept && num_acceptor_nets == 0) { + if (net->net_lnd->lnd_accept) { rc = lnet_acceptor_start(); if (rc < 0) { /* shutdown the net that we just started */ @@ -3342,8 +3333,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf) lnet_shutdown_lndnet(net); - if (lnet_count_acceptor_nets() == 0) - lnet_acceptor_stop(); + lnet_acceptor_stop(); lnet_ping_target_update(pbuf, ping_mdh); @@ -3370,8 +3360,7 @@ int lnet_dyn_del_ni(struct lnet_ioctl_config_ni *conf) lnet_shutdown_lndni(ni); - if (lnet_count_acceptor_nets() == 0) - lnet_acceptor_stop(); + lnet_acceptor_stop(); lnet_ping_target_update(pbuf, ping_mdh); @@ -3481,8 +3470,7 @@ lnet_dyn_del_net(__u32 net_id) lnet_shutdown_lndnet(net); - if (lnet_count_acceptor_nets() == 0) - lnet_acceptor_stop(); + lnet_acceptor_stop(); lnet_ping_target_update(pbuf, ping_mdh); -- 1.8.3.1