From 0cf56a1a9926b5e78c6dce246960fda625df744c Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Mon, 22 Feb 2016 17:29:21 -0500 Subject: [PATCH] staging: lustre: avoid race during lnet acceptor thread termination This patch will avoid potential race, around socket sleepers wait list, during acceptor thread termination and using sk_callback_lock RW-Lock protection. Signed-off-by: Bruno Faccini Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6476 Reviewed-on: http://review.whamcloud.com/14503 Reviewed-by: Amir Shehata Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/acceptor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 8f9876bfb692..34684335e30c 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -488,11 +488,17 @@ lnet_acceptor_start(void) void lnet_acceptor_stop(void) { + struct sock *sk; + if (lnet_acceptor_state.pta_shutdown) /* not running */ return; lnet_acceptor_state.pta_shutdown = 1; - wake_up_all(sk_sleep(lnet_acceptor_state.pta_sock->sk)); + + sk = lnet_acceptor_state.pta_sock->sk; + + /* awake any sleepers using safe method */ + sk->sk_state_change(sk); /* block until acceptor signals exit */ wait_for_completion(&lnet_acceptor_state.pta_signal); -- 2.20.1