Whamcloud - gitweb
LU-10391 lnet: simplify use of lnet_count_acceptor_nets() 95/37695/8
authorMr NeilBrown <neilb@suse.de>
Fri, 7 Feb 2020 02:05:57 +0000 (13:05 +1100)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Apr 2020 08:09:16 +0000 (08:09 +0000)
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 <neilb@suse.de>
Change-Id: I11ef6c1a226e7b752b540f37651c766e83c5cb52
Reviewed-on: https://review.whamcloud.com/37695
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/acceptor.c
lnet/lnet/api-ni.c

index 1209b18..09d016f 100644 (file)
@@ -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);
 
index 7534a1e..e554429 100644 (file)
@@ -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);