Whamcloud - gitweb
LU-12678 lnet: discard lnd_refcount 29/36829/2
authorMr NeilBrown <neilb@suse.de>
Sun, 24 Nov 2019 23:00:48 +0000 (10:00 +1100)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Dec 2019 06:00:05 +0000 (06:00 +0000)
The lnd_refcount in 'struct lnet_lnd' is never tested (except
in an ASSERT()), so it cannot be needed.  Let's remove it.

Each individual lnd keeps track of how many lnet_ni are
registered for that lnd e.g. ksocklnd has a counter in ksnd_nnets
and o2iblnd has a linked list in kib_devs.
They hold a reference on the module while there are registered
devices, and the lnd is only freed (and the lnd_refcount checked)
when the module is unloaded.  This confirms that lnd_refcount
adds no value.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I0d0c04051bf01a1fa77d888b00fb0a7875b09ccd
Reviewed-on: https://review.whamcloud.com/36829
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-types.h
lnet/lnet/api-ni.c

index 5590503..562dc37 100644 (file)
@@ -250,7 +250,6 @@ struct socket;
 struct lnet_lnd {
        /* fields managed by portals */
        struct list_head        lnd_list;       /* stash in the LND table */
-       int                     lnd_refcount;   /* # active instances */
 
        /* fields initialized by the LND */
        __u32                   lnd_type;
index e3aa9bf..d6e5e3d 100644 (file)
@@ -828,7 +828,6 @@ lnet_register_lnd(struct lnet_lnd *lnd)
        LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == NULL);
 
        list_add_tail(&lnd->lnd_list, &the_lnet.ln_lnds);
-       lnd->lnd_refcount = 0;
 
        CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type));
 
@@ -842,7 +841,6 @@ lnet_unregister_lnd(struct lnet_lnd *lnd)
        mutex_lock(&the_lnet.ln_lnd_mutex);
 
        LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd);
-       LASSERT(lnd->lnd_refcount == 0);
 
        list_del(&lnd->lnd_list);
        CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type));
@@ -2128,15 +2126,6 @@ lnet_shutdown_lndnet(struct lnet_net *net)
        /* Do peer table cleanup for this net */
        lnet_peer_tables_cleanup(net);
 
-       lnet_net_lock(LNET_LOCK_EX);
-       /*
-        * decrement ref count on lnd only when the entire network goes
-        * away
-        */
-       net->net_lnd->lnd_refcount--;
-
-       lnet_net_unlock(LNET_LOCK_EX);
-
        lnet_net_free(net);
 }
 
@@ -2220,9 +2209,6 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_lnd_tunables *tun)
        if (rc != 0) {
                LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n",
                                   rc, libcfs_lnd2str(net->net_lnd->lnd_type));
-               lnet_net_lock(LNET_LOCK_EX);
-               net->net_lnd->lnd_refcount--;
-               lnet_net_unlock(LNET_LOCK_EX);
                goto failed0;
        }
 
@@ -2331,10 +2317,6 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun)
                        }
                }
 
-               lnet_net_lock(LNET_LOCK_EX);
-               lnd->lnd_refcount++;
-               lnet_net_unlock(LNET_LOCK_EX);
-
                net->net_lnd = lnd;
 
                mutex_unlock(&the_lnet.ln_lnd_mutex);