From patchwork Thu Feb 27 21:12:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410131 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 34ED3138D for ; Thu, 27 Feb 2020 21:31:03 +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 1D97620801 for ; Thu, 27 Feb 2020 21:31:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D97620801 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 4091B349752; Thu, 27 Feb 2020 13:26:22 -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 957F221FC82 for ; Thu, 27 Feb 2020 13:19:46 -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 B138A8A33; Thu, 27 Feb 2020 16:18:16 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id B00B346C; Thu, 27 Feb 2020 16:18:16 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:12:35 -0500 Message-Id: <1582838290-17243-288-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 287/622] lustre: statahead: sa_handle_callback get lli_sa_lock earlier 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: Ann Koehler , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Ann Koehler sa_handle_callback() must acquire the lli_sa_lock before calling sa_has_callback(), which checks whether the sai_interim_entries list is empty. Acquiring the lock avoids a race between an rpc handler executing ll_statahead_interpret and the separate ll_statahead_thread. When a client receives a stat request response, ll_statahead_interpret increments sai_replied and if needed adds the request to the sai_interim_entries list for instantiating by the ll_statahead_thread. ll_statahead_interpret() holds the lli_sa_lock while doing this work. On process termination, ll_statahead_thread() waits for sai_sent to equal sai_replied and then removes any entries in the sai_interim_entries list. It does not get the lli_sa_lock until it determines that there are sai_interim_entries to process. A bug occurs on weak memory model processors that do not guarantee that both ll_statahead_interpret updates done under the lock are visible to other processors at the same time. For example, on ARM nodes, an ll_statahead_thread can read the updated value of sai_replied and a non-updated value of sai_interim_lists. ll_statahead_thread then thinks all replies have been received (true) and all sai_interim_entries have been processed false). Later, the update to sai_interim_entries becomes visible leaving the ll_statahead_info struct in an unexpected state. The bad state eventually triggers the LBUG: statahead.c:477:ll_sai_put()) ASSERTION( !sa_has_callback(sai) ) Cray-bug-id: LUS-6243 WC-bug-id: https://jira.whamcloud.com/browse/LU-12221 Lustre-commit: 31ef093c2197 ("LU-12221 statahead: sa_handle_callback get lli_sa_lock earlier") Signed-off-by: Ann Koehler Reviewed-on: https://review.whamcloud.com/34760 Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/statahead.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/lustre/llite/statahead.c b/fs/lustre/llite/statahead.c index 7dfb045..497aba3 100644 --- a/fs/lustre/llite/statahead.c +++ b/fs/lustre/llite/statahead.c @@ -688,21 +688,19 @@ static void sa_handle_callback(struct ll_statahead_info *sai) lli = ll_i2info(sai->sai_dentry->d_inode); + spin_lock(&lli->lli_sa_lock); while (sa_has_callback(sai)) { struct sa_entry *entry; - spin_lock(&lli->lli_sa_lock); - if (unlikely(!sa_has_callback(sai))) { - spin_unlock(&lli->lli_sa_lock); - break; - } entry = list_first_entry(&sai->sai_interim_entries, struct sa_entry, se_list); list_del_init(&entry->se_list); spin_unlock(&lli->lli_sa_lock); sa_instantiate(sai, entry); + spin_lock(&lli->lli_sa_lock); } + spin_unlock(&lli->lli_sa_lock); } /*