Whamcloud - gitweb
LU-12036 ofd: add "no_precreate" mount option
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index be77024..d6e5e3d 100644 (file)
@@ -546,7 +546,7 @@ lnet_init_locks(void)
        spin_lock_init(&the_lnet.ln_eq_wait_lock);
        spin_lock_init(&the_lnet.ln_msg_resend_lock);
        init_waitqueue_head(&the_lnet.ln_eq_waitq);
-       init_waitqueue_head(&the_lnet.ln_mt_waitq);
+       init_completion(&the_lnet.ln_mt_wait_complete);
        mutex_init(&the_lnet.ln_lnd_mutex);
 }
 
@@ -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));
@@ -1100,6 +1098,26 @@ lnet_res_lh_initialize(struct lnet_res_container *rec,
        list_add(&lh->lh_hash_chain, &rec->rec_lh_hash[hash]);
 }
 
+struct list_head **
+lnet_create_array_of_queues(void)
+{
+       struct list_head **qs;
+       struct list_head *q;
+       int i;
+
+       qs = cfs_percpt_alloc(lnet_cpt_table(),
+                             sizeof(struct list_head));
+       if (!qs) {
+               CERROR("Failed to allocate queues\n");
+               return NULL;
+       }
+
+       cfs_percpt_for_each(q, i, qs)
+               INIT_LIST_HEAD(q);
+
+       return qs;
+}
+
 static int lnet_unprepare(void);
 
 static int
@@ -1134,6 +1152,7 @@ lnet_prepare(lnet_pid_t requested_pid)
        INIT_LIST_HEAD(&the_lnet.ln_mt_peerNIRecovq);
        init_waitqueue_head(&the_lnet.ln_dc_waitq);
        LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh);
+       init_completion(&the_lnet.ln_started);
 
        rc = lnet_descriptor_setup();
        if (rc != 0)
@@ -1192,6 +1211,12 @@ lnet_prepare(lnet_pid_t requested_pid)
                goto failed;
        }
 
+       the_lnet.ln_mt_zombie_rstqs = lnet_create_array_of_queues();
+       if (!the_lnet.ln_mt_zombie_rstqs) {
+               rc = -ENOMEM;
+               goto failed;
+       }
+
        return 0;
 
  failed:
@@ -1215,6 +1240,11 @@ lnet_unprepare (void)
        LASSERT(list_empty(&the_lnet.ln_test_peers));
        LASSERT(list_empty(&the_lnet.ln_nets));
 
+       if (the_lnet.ln_mt_zombie_rstqs) {
+               lnet_clean_zombie_rstqs();
+               the_lnet.ln_mt_zombie_rstqs = NULL;
+       }
+
        if (!LNetEQHandleIsInvalid(the_lnet.ln_mt_eqh)) {
                rc = LNetEQFree(the_lnet.ln_mt_eqh);
                LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh);
@@ -1583,7 +1613,6 @@ lnet_swap_pinginfo(struct lnet_ping_buffer *pbuf)
                __swab64s(&stat->ns_nid);
                __swab32s(&stat->ns_status);
        }
-       return;
 }
 
 int
@@ -2082,8 +2111,6 @@ lnet_shutdown_lndnet(struct lnet_net *net)
 
        lnet_net_lock(LNET_LOCK_EX);
 
-       net->net_state = LNET_NET_STATE_DELETING;
-
        list_del_init(&net->net_list);
 
        while (!list_empty(&net->net_ni_list)) {
@@ -2099,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);
 }
 
@@ -2191,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;
        }
 
@@ -2302,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);
@@ -2356,7 +2367,7 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun)
                 * up is actually unique. if it's not fail. */
                if (!lnet_ni_unique_net(&net_l->net_ni_list,
                                        ni->ni_interfaces[0])) {
-                       rc = -EINVAL;
+                       rc = -EEXIST;
                        goto failed1;
                }
 
@@ -2393,7 +2404,6 @@ lnet_startup_lndnet(struct lnet_net *net, struct lnet_lnd_tunables *tun)
                 */
                lnet_net_free(net);
        } else {
-               net->net_state = LNET_NET_STATE_ACTIVE;
                /*
                 * restore tunables after it has been overwitten by the
                 * lnd
@@ -2666,6 +2676,8 @@ LNetNIInit(lnet_pid_t requested_pid)
 
        mutex_unlock(&the_lnet.ln_api_mutex);
 
+       complete_all(&the_lnet.ln_started);
+
        /* wait for all routers to start */
        lnet_wait_router_start();
 
@@ -2710,7 +2722,7 @@ EXPORT_SYMBOL(LNetNIInit);
  * \return always 0 for current implementation.
  */
 int
-LNetNIFini()
+LNetNIFini(void)
 {
        mutex_lock(&the_lnet.ln_api_mutex);