From patchwork Thu Feb 27 21:08:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11409723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B86F14BC for ; Thu, 27 Feb 2020 21:20:15 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2307C246A1 for ; Thu, 27 Feb 2020 21:20:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2307C246A1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id A8F5721FE03; Thu, 27 Feb 2020 13:19:41 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E599D21F982 for ; Thu, 27 Feb 2020 13:18:29 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id BB005E04; Thu, 27 Feb 2020 16:18:13 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id B991646D; Thu, 27 Feb 2020 16:18:13 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:08:36 -0500 Message-Id: <1582838290-17243-49-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 048/622] lustre: ldlm: fix for l_lru usage X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yang Sheng , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Yang Sheng 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. WC-bug-id: https://jira.whamcloud.com/browse/LU-11003 Lustre-commit: 2a77dd3bee76 ("LU-11003 ldlm: fix for l_lru usage") Signed-off-by: Yang Sheng Reviewed-on: https://review.whamcloud.com/32309 Reviewed-by: Fan Yong Reviewed-by: Mikhal Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ldlm/ldlm_inodebits.c | 1 - fs/lustre/ldlm/ldlm_request.c | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/lustre/ldlm/ldlm_inodebits.c b/fs/lustre/ldlm/ldlm_inodebits.c index e74928e..ddbf8d4 100644 --- a/fs/lustre/ldlm/ldlm_inodebits.c +++ b/fs/lustre/ldlm/ldlm_inodebits.c @@ -171,7 +171,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; } diff --git a/fs/lustre/ldlm/ldlm_request.c b/fs/lustre/ldlm/ldlm_request.c index 67c23fc..5833f59 100644 --- a/fs/lustre/ldlm/ldlm_request.c +++ b/fs/lustre/ldlm/ldlm_request.c @@ -881,21 +881,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); @@ -903,7 +907,6 @@ static int lock_convert_interpret(const struct lu_env *env, 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);