From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5238C433FE for ; Fri, 10 Sep 2021 01:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE28D610C7 for ; Fri, 10 Sep 2021 01:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234432AbhIJBGz (ORCPT ); Thu, 9 Sep 2021 21:06:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234985AbhIJAZd (ORCPT ); Thu, 9 Sep 2021 20:25:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A2D960FDA; Fri, 10 Sep 2021 00:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631233463; bh=VLC5mYcNKqfZr8/HWLElS6s3L79ATkzMyYnMMDv8/HY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiQOq+DStssw2iSC1cwhQp8tg273o+fS/dxEMlCFpUZQPYNIVIVZ7teaP2Pv+6GVO txaYpJgbCuElpx+eK7FtxTvjhQ4SH3gMlbJMTKJLNtvcXtNfWn5yIRy8sZ/7exyJcj lAUTs3YC85CnjpX94KL/9SeMVs1SeFLeFGj1pUS6WMc8PFyCRe1W4MkZ7Wuhu1WFl6 7eRDk1NMqhsYx6etbsTUHKjxhXJjSyKvuB897iq8gNTZmIYiln4x+EKDWgkyo2gdAc 1F1CRgWC9Pb7msb5aGk1fwTNmwd/fNyxw3M2uMuCubjAVCOuJLTsEiM8Ns1HbdOPaZ Jcj9QQGuP4l7Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gang He , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Andrew Morton , Linus Torvalds , Sasha Levin , ocfs2-devel@oss.oracle.com Subject: [PATCH AUTOSEL 4.4 14/14] ocfs2: ocfs2_downconvert_lock failure results in deadlock Date: Thu, 9 Sep 2021 20:24:03 -0400 Message-Id: <20210910002403.176887-14-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910002403.176887-1-sashal@kernel.org> References: <20210910002403.176887-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gang He [ Upstream commit 9673e0050c39b0534d0e2ca431223f52089f4959 ] Usually, ocfs2_downconvert_lock() function always downconverts dlm lock to the expected level for satisfy dlm bast requests from the other nodes. But there is a rare situation. When dlm lock conversion is being canceled, ocfs2_downconvert_lock() function will return -EBUSY. You need to be aware that ocfs2_cancel_convert() function is asynchronous in fsdlm implementation. If we does not requeue this lockres entry, ocfs2 downconvert thread no longer handles this dlm lock bast request. Then, the other nodes will not get the dlm lock again, the current node's process will be blocked when acquire this dlm lock again. Link: https://lkml.kernel.org/r/20210830044621.12544-1-ghe@suse.com Signed-off-by: Gang He Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/dlmglue.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index faaf8bfd2f52..0e2ba43c398e 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #define MLOG_MASK_PREFIX ML_DLM_GLUE @@ -3682,6 +3683,17 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, spin_unlock_irqrestore(&lockres->l_lock, flags); ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb, gen); + /* The dlm lock convert is being cancelled in background, + * ocfs2_cancel_convert() is asynchronous in fs/dlm, + * requeue it, try again later. + */ + if (ret == -EBUSY) { + ctl->requeue = 1; + mlog(ML_BASTS, "lockres %s, ReQ: Downconvert busy\n", + lockres->l_name); + ret = 0; + msleep(20); + } leave: if (ret) -- 2.30.2