From: Amir Shehata Date: Tue, 13 Jan 2015 01:14:33 +0000 (-0800) Subject: LU-6002 lnet: startup acceptor thread dynamically X-Git-Tag: 2.6.93~42 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=91df044a6bc06cf41f876843302c536cb18d39ca LU-6002 lnet: startup acceptor thread dynamically With DLC it's possible to start up a system with no NIs that require the acceptor thread, and thus it won't start. Later on the user can add an NI that requires the acceptor thread to start, it is then necessary to start it up. If the user removes a NI and as a result there are no more NIs that require the acceptor thread then it should be stopped. This patch adds logic in the dynamically adding and removing NIs code to ensure the above logic is implemented. Signed-off-by: Amir Shehata Change-Id: Iecada597d417dcb8991e9fb98f6844382295246a Reviewed-on: http://review.whamcloud.com/13010 Tested-by: Jenkins Reviewed-by: Isaac Huang Reviewed-by: Doug Oucharek Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lnet/lnet/acceptor.c b/lnet/lnet/acceptor.c index 405c065..6bb9f85 100644 --- a/lnet/lnet/acceptor.c +++ b/lnet/lnet/acceptor.c @@ -47,7 +47,9 @@ static struct { int pta_shutdown; cfs_socket_t *pta_sock; struct completion pta_signal; -} lnet_acceptor_state; +} lnet_acceptor_state = { + .pta_shutdown = 1 +}; int lnet_acceptor_port(void) @@ -508,6 +510,10 @@ lnet_acceptor_start(void) long rc2; long secure; + /* if acceptor is already running return immediately */ + if (!lnet_acceptor_state.pta_shutdown) + return 0; + LASSERT (lnet_acceptor_state.pta_sock == NULL); rc = lnet_acceptor_get_tunables(); @@ -558,7 +564,7 @@ lnet_acceptor_start(void) void lnet_acceptor_stop(void) { - if (lnet_acceptor_state.pta_sock == NULL) /* not running */ + if (lnet_acceptor_state.pta_shutdown) /* not running */ return; lnet_acceptor_state.pta_shutdown = 1; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 2333899..75ff383 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -2020,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); @@ -2067,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: