Whamcloud - gitweb
LU-6002 lnet: startup acceptor thread dynamically
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index 7a3c8a3..75ff383 100644 (file)
@@ -68,7 +68,6 @@ static int rnet_htable_size = LNET_REMOTE_NETS_HASH_DEFAULT;
 CFS_MODULE_PARM(rnet_htable_size, "i", int, 0444,
                "size of remote network hash table");
 
-static void lnet_ping_target_fini(void);
 static int lnet_ping(lnet_process_id_t id, int timeout_ms,
                     lnet_process_id_t *ids, int n_ids);
 
@@ -1108,7 +1107,7 @@ lnet_ping_info_setup(lnet_ping_info_t **ppinfo, lnet_handle_md_t *md_handle,
 {
        lnet_handle_me_t  me_handle;
        lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY};
-       lnet_md_t         md = {0};
+       lnet_md_t         md = {NULL};
        int               rc, rc2;
 
        if (set_eq) {
@@ -2021,6 +2020,16 @@ lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets,
        if (rc != 0)
                goto failed1;
 
+       if (ni->ni_lnd->lnd_accept != NULL) {
+               rc = lnet_acceptor_start();
+               if (rc < 0) {
+                       /* shutdown the ni that we just started */
+                       CERROR("Failed to start up acceptor thread\n");
+                       lnet_shutdown_lndni(ni);
+                       goto failed1;
+               }
+       }
+
        lnet_ping_target_update(pinfo, md_handle);
        LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
 
@@ -2068,6 +2077,10 @@ lnet_dyn_del_ni(__u32 net)
        lnet_ni_decref_locked(ni, 0);
 
        lnet_shutdown_lndni(ni);
+
+       if (lnet_count_acceptor_nis() == 0)
+               lnet_acceptor_stop();
+
        lnet_ping_target_update(pinfo, md_handle);
        goto out;
 failed:
@@ -2396,7 +2409,7 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids,
        lnet_handle_eq_t     eqh;
        lnet_handle_md_t     mdh;
        lnet_event_t         event;
-       lnet_md_t            md = {0};
+       lnet_md_t            md = { NULL };
        int                  which;
        int                  unlinked = 0;
        int                  replied = 0;