From 3551b2cc2bbb3181bbb2afc8675cb3457215f4f5 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Thu, 5 Jan 2012 11:49:50 -0800 Subject: [PATCH] LU-874 ldlm: Fix ldlm_bl_* thread creation Always create a new ldlm_bl_ thread when all threads are busy, not just after returning from sleep. Change-Id: I2fa99a0f09a42e1333589fc7bc2a6eebef4924b6 Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/1926 Tested-by: Hudson Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Johann Lombardi --- lustre/ldlm/ldlm_lockd.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index da9a6f7..2be5aa9 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2230,33 +2230,31 @@ static int ldlm_bl_thread_main(void *arg) while (1) { struct l_wait_info lwi = { 0 }; struct ldlm_bl_work_item *blwi = NULL; + int busy; blwi = ldlm_bl_get_work(blp); if (blwi == NULL) { - int busy; - cfs_atomic_dec(&blp->blp_busy_threads); l_wait_event_exclusive(blp->blp_waitq, (blwi = ldlm_bl_get_work(blp)) != NULL, &lwi); busy = cfs_atomic_inc_return(&blp->blp_busy_threads); - - if (blwi->blwi_ns == NULL) - /* added by ldlm_cleanup() */ - break; - - /* Not fatal if racy and have a few too many threads */ - if (unlikely(busy < blp->blp_max_threads && - busy >= cfs_atomic_read(&blp->blp_num_threads) && - !blwi->blwi_mem_pressure)) - /* discard the return value, we tried */ - ldlm_bl_thread_start(blp); } else { - if (blwi->blwi_ns == NULL) - /* added by ldlm_cleanup() */ - break; + busy = cfs_atomic_read(&blp->blp_busy_threads); } + + if (blwi->blwi_ns == NULL) + /* added by ldlm_cleanup() */ + break; + + /* Not fatal if racy and have a few too many threads */ + if (unlikely(busy < blp->blp_max_threads && + busy >= cfs_atomic_read(&blp->blp_num_threads) && + !blwi->blwi_mem_pressure)) + /* discard the return value, we tried */ + ldlm_bl_thread_start(blp); + if (blwi->blwi_mem_pressure) cfs_memory_pressure_set(); -- 1.8.3.1