From: Yang Sheng Date: Mon, 7 May 2018 15:59:01 +0000 (+0800) Subject: LU-11003 ldlm: fix for l_lru usage X-Git-Tag: 2.11.53~76 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F32309%2F3;p=fs%2Flustre-release.git LU-11003 ldlm: fix for l_lru usage Fixes for lock convert code to prevent false assertion and busy locks in LRU: - ensure no l_readers and l_writers when add lock to LRU after convert. - don't verify l_lru without ns_lock. Signed-off-by: Yang Sheng Change-Id: I8bcbdef3cb72db241ad03c50f5ce2b968e3ee3e4 Reviewed-on: https://review.whamcloud.com/32309 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_inodebits.c b/lustre/ldlm/ldlm_inodebits.c index 269c49a..626c624 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -412,7 +412,6 @@ int ldlm_cli_dropbits(struct ldlm_lock *lock, __u64 drop_bits) ldlm_set_cbpending(lock); ldlm_set_bl_ast(lock); unlock_res_and_lock(lock); - LASSERT(list_empty(&lock->l_lru)); GOTO(exit, rc); } EXIT; diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 1ab84a5..07520c33 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -1098,21 +1098,25 @@ static int lock_convert_interpret(const struct lu_env *env, } else { ldlm_clear_converting(lock); - /* Concurrent BL AST has arrived, it may cause another convert - * or cancel so just exit here. + /* Concurrent BL AST may arrive and cause another convert + * or cancel so just do nothing here if bl_ast is set, + * finish with convert otherwise. */ if (!ldlm_is_bl_ast(lock)) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); /* Drop cancel_bits since there are no more converts - * and put lock into LRU if it is not there yet. + * and put lock into LRU if it is still not used and + * is not there yet. */ lock->l_policy_data.l_inodebits.cancel_bits = 0; - spin_lock(&ns->ns_lock); - if (!list_empty(&lock->l_lru)) + if (!lock->l_readers && !lock->l_writers) { + spin_lock(&ns->ns_lock); + /* there is check for list_empty() inside */ ldlm_lock_remove_from_lru_nolock(lock); - ldlm_lock_add_to_lru_nolock(lock); - spin_unlock(&ns->ns_lock); + ldlm_lock_add_to_lru_nolock(lock); + spin_unlock(&ns->ns_lock); + } } } unlock_res_and_lock(lock); @@ -1120,7 +1124,6 @@ out: if (rc) { lock_res_and_lock(lock); if (ldlm_is_converting(lock)) { - LASSERT(list_empty(&lock->l_lru)); ldlm_clear_converting(lock); ldlm_set_cbpending(lock); ldlm_set_bl_ast(lock);