Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2306201imm; Mon, 28 May 2018 05:47:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoReu1G8dwkOL778XElwjL4xSNlQaljEiprd4zpaclvaBEQd/eVwcygrh7XDCIaubh1Jz0D X-Received: by 2002:a63:6e05:: with SMTP id j5-v6mr10590168pgc.150.1527511628763; Mon, 28 May 2018 05:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511628; cv=none; d=google.com; s=arc-20160816; b=UiYdmZBQ0IEDLkmL29cyzrVHkqf/ADdDOMm0GWVtN/wDs8hBJuOp/sjSUT1tOxxdFn Sp8v5v1pIk6iJk8IdNDZyWzvDOROt2hRav5sC8LtMtrG9prkQJooAf+Azqftd0Hsz0yg Z+xtrjPKvn4zsh/v0GBi2vCbmDrauwFnrQJV0D+wCmBbyi5WLg/kMM4z2kGzk7UWK0MD VwdighUFvhYSiBkHSCk8W0JLtIv2DkfswPta/QoNEw+T0l23ptekPrj+4WDGRkRYrQ2c v5xXOFMuw+0AaVI4GQm1blHC5fJCer56xufrlHZN6zaDS3ZdXl+aQaLGJVNrd1CSHL8Y RnaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=mw+t0k/oYLhoQVgckvZALBquMd3VEsBy9KdPh5PN0L4=; b=gC5LkCAi7kncbRjPyODrZRCF1F20xGrR8jtmRNicrrCbH4rqGknyEqedRde8NsMylc +WqOy08zsFj9mBkkNgpRxbV1RqB0eBW7dNzeWeZxGfhsu6FnaUn84FX3U4VwUuN7xfDS 1DdFTdq1NGsWg5gXp65odAAsK/b63f29RBazZtY3UVIrkXU7SaEuqt/UanIO0tFSl7v0 NawhcJIVA77r1fW7z0sPOasEDMGzyzv+96TiFZdC2G04TLhcIHFkjiDoOPt5K+o+yaYo Es2Z/TWRbAn/dOj34pkAZhsJXS/Oz7vkdlRUsrbS4xYulAH7cgk6Euc9nApk8mfOZnk+ RJfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KhZ5VmrE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10-v6si16895677pgs.598.2018.05.28.05.46.53; Mon, 28 May 2018 05:47:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KhZ5VmrE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937832AbeE1K5a (ORCPT + 99 others); Mon, 28 May 2018 06:57:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:45108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164582AbeE1K4u (ORCPT ); Mon, 28 May 2018 06:56:50 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 069B8208A3; Mon, 28 May 2018 10:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505009; bh=U3z4Wq/OWOGw3f6u0WKFB9fM5YrWIF+v7696CAzn7Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhZ5VmrE7vJjuJz0EQBaAIEHca2N/9/oVPG/tOBSRb9xnujTK2r2Nm3b55s2G1cxy I8BtyskbqDIaX/KbYMOeUv6E+b6naiTVI6G4q/aMZZrckCggQEOf5lUOvmJNfjj/bZ 9Hyn845ijZ1ky/k9R3mg4LQhh5guXc+CPm3V3FGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jun Piao , Yiwen Jiang , Joseph Qi , Changwei Ge , Mark Fasheh , Joel Becker , Junxiao Bi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 342/496] ocfs2/dlm: dont handle migrate lockres if already in shutdown Date: Mon, 28 May 2018 12:02:07 +0200 Message-Id: <20180528100334.229104524@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jun Piao [ Upstream commit bb34f24c7d2c98d0c81838a7700e6068325b17a0 ] We should not handle migrate lockres if we are already in 'DLM_CTXT_IN_SHUTDOWN', as that will cause lockres remains after leaving dlm domain. At last other nodes will get stuck into infinite loop when requsting lock from us. The problem is caused by concurrency umount between nodes. Before receiveing N1's DLM_BEGIN_EXIT_DOMAIN_MSG, N2 has picked up N1 as the migrate target. So N2 will continue sending lockres to N1 even though N1 has left domain. N1 N2 (owner) touch file access the file, and get pr lock begin leave domain and pick up N1 as new owner begin leave domain and migrate all lockres done begin migrate lockres to N1 end leave domain, but the lockres left unexpectedly, because migrate task has passed [piaojun@huawei.com: v3] Link: http://lkml.kernel.org/r/5A9CBD19.5020107@huawei.com Link: http://lkml.kernel.org/r/5A99F028.2090902@huawei.com Signed-off-by: Jun Piao Reviewed-by: Yiwen Jiang Reviewed-by: Joseph Qi Reviewed-by: Changwei Ge Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/dlm/dlmdomain.c | 14 -------------- fs/ocfs2/dlm/dlmdomain.h | 25 ++++++++++++++++++++++++- fs/ocfs2/dlm/dlmrecovery.c | 9 +++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -676,20 +676,6 @@ static void dlm_leave_domain(struct dlm_ spin_unlock(&dlm->spinlock); } -int dlm_shutting_down(struct dlm_ctxt *dlm) -{ - int ret = 0; - - spin_lock(&dlm_domain_lock); - - if (dlm->dlm_state == DLM_CTXT_IN_SHUTDOWN) - ret = 1; - - spin_unlock(&dlm_domain_lock); - - return ret; -} - void dlm_unregister_domain(struct dlm_ctxt *dlm) { int leave = 0; --- a/fs/ocfs2/dlm/dlmdomain.h +++ b/fs/ocfs2/dlm/dlmdomain.h @@ -28,7 +28,30 @@ extern spinlock_t dlm_domain_lock; extern struct list_head dlm_domains; -int dlm_shutting_down(struct dlm_ctxt *dlm); +static inline int dlm_joined(struct dlm_ctxt *dlm) +{ + int ret = 0; + + spin_lock(&dlm_domain_lock); + if (dlm->dlm_state == DLM_CTXT_JOINED) + ret = 1; + spin_unlock(&dlm_domain_lock); + + return ret; +} + +static inline int dlm_shutting_down(struct dlm_ctxt *dlm) +{ + int ret = 0; + + spin_lock(&dlm_domain_lock); + if (dlm->dlm_state == DLM_CTXT_IN_SHUTDOWN) + ret = 1; + spin_unlock(&dlm_domain_lock); + + return ret; +} + void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm, int node_num); --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -1378,6 +1378,15 @@ int dlm_mig_lockres_handler(struct o2net if (!dlm_grab(dlm)) return -EINVAL; + if (!dlm_joined(dlm)) { + mlog(ML_ERROR, "Domain %s not joined! " + "lockres %.*s, master %u\n", + dlm->name, mres->lockname_len, + mres->lockname, mres->master); + dlm_put(dlm); + return -EINVAL; + } + BUG_ON(!(mres->flags & (DLM_MRES_RECOVERY|DLM_MRES_MIGRATION))); real_master = mres->master;