From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761275AbbKTXnw (ORCPT ); Fri, 20 Nov 2015 18:43:52 -0500 Received: from smtp2.ccs.ornl.gov ([160.91.199.39]:57245 "EHLO smtp2.ccs.ornl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422682AbbKTXgo (ORCPT ); Fri, 20 Nov 2015 18:36:44 -0500 From: James Simmons To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Oleg Drokin , Andreas Dilger Cc: Linux Kernel Mailing List , lustre-devel@lists.lustre.org, Amir Shehata Subject: [PATCH 20/40] staging: lustre: fix kernel crash when network failed to start Date: Fri, 20 Nov 2015 18:35:56 -0500 Message-Id: <1448062576-23757-21-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amir Shehata When loading Lustre modules without proper network configuration, it always hit the following kernel panic: LNetError: 105-4: Error -100 starting up LNI tcp LNetError: 2145:0:(api-ni.c:823:lnet_unprepare()) ASSERTION( list_empty(&the_lnet.ln_nis) ) failed: NetError: 2145:0:(api-ni.c:823:lnet_unprepare()) LBUG Pid: 2145, comm: modprobe x0aCall Trace: [] libcfs_debug_dumpstack+0x53/0x80 [libcfs] [] lbug_with_loc+0x45/0xc0 [libcfs] [] lnet_unprepare+0x297/0x340 [lnet] [] LNetNIInit+0x25c/0x3e0 [lnet] [] ? put_online_cpus+0x56/0x80 [] ? init_module+0x0/0x1000 [ptlrpc] [] ptlrpc_ni_init+0x2c/0x1a0 [ptlrpc] [] ? init_module+0x0/0x1000 [ptlrpc] [] ptlrpc_init_portals+0x11/0xf0 [ptlrpc] [] ? init_module+0x0/0x1000 [ptlrpc] [] init_module+0x1c4/0x1000 [ptlrpc] [] do_one_initcall+0xe2/0x190 [] load_module+0x129b/0x1a90 [] ? ddebug_dyndbg_module_param_cb+0x0/0x60 [] ? copy_module_from_fd.isra.43+0x53/0x150 [] SyS_finit_module+0xa6/0xd0 [] system_call_fastpath+0x16/0x1b ... This is because in lnet_startup_lndnis(), we may add list items to @the_lnet.ln_nis and @the_lnet.ln_nis_cpt before it failed. But in lnet_startup_lndis() failure path,it did not cleanup list thus causing assertion in lnet_unprepare(). Fix the assertion by cleaning up using lnet_shutdown_lndnis() if the startup fails. In a future enahancement the ni startup API will be modified to cleanup after itself in case of failure. Signed-off-by: Amir Shehata Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5568 Reviewed-on: http://review.whamcloud.com/12512 Reviewed-by: Liang Zhen Reviewed-by: Isaac Huang Reviewed-by: Oleg Drokin --- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 4c4e6d3..bfc1f13 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1246,6 +1246,10 @@ lnet_shutdown_lndni(__u32 net) return 0; } +/* + * Callers of lnet_startup_lndnis need to clean up using + * lnet_shutdown_lndnis if startup fails + */ static int lnet_startup_lndnis(struct list_head *nilist, __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr, __s32 credits, @@ -1554,7 +1558,7 @@ LNetNIInit(lnet_pid_t requested_pid) rc = lnet_startup_lndnis(&net_head, -1, -1, -1, -1, &ni_count); if (rc != 0) - goto failed1; + goto failed2; if (the_lnet.ln_eq_waitni && ni_count > 1) { lnd_type = the_lnet.ln_eq_waitni->ni_lnd->lnd_type; -- 1.7.1