Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2261836imm; Mon, 28 May 2018 05:01:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpmdaeZRLJJrq5kGWQq+JH0V+dtZi//QxkwJnFihw3s2MUy7RMkw/ujDNL7eE/c1TI7Yffc X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr13505337plp.333.1527508873720; Mon, 28 May 2018 05:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527508873; cv=none; d=google.com; s=arc-20160816; b=nP0RgojLZcZLYUKE87PbnO0wyj3appM21ki2tRnjIyCHQhx/R4Q38AwIHkd7IZ5qat vtAg07Q1OvXBeSG6ZA3iZYWs1fomtHhOp8Oc3el8CVoNkHUva5/gto77oviUVX+zEAh0 By/ylDqWsPgVrpOuj1AtoElUh/d+aWlgWPoBVvpvxMJebwVoAeK2P6Ncswu6XzhM8V6Y iGf02U3w5W0eegO9rlUGFh0xTSNMcSCuXyvXYJ/CpBOvjDSBNQwru7R0mfZbF2kjZ7bQ d1A4Jfi19uJXXN+W+uShAFMh3pvl1EiAU+MaQdyY+GEeMPKgb6LD7hdK05/ay+T7z6Cy P5Sg== 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=6kDgTk++ZIIYmiwUAX/l8HxkjSLUbGpuwgUEGfoCuVo=; b=dCI+7PrHCASKBdxW88TrGyJMLron4EwlkP8r8tfsdhMICvh8s7dILlv6i1KO7a01IB KxcJKaaQ51kFCOVIktpoAuYh+Sxt1cIgePLtF1VS5g7HBTyqZCFQ3JgohZfglbDjrB4G lZhQFTxas2BW7aHKAne+JfrHa2D2XxObt0UIpZqYLLYp3FsRanMZJKnwYrVe83gfrGjL aEJ00Hbfw/IbpURYxb1uIonmt83R9Eb5qATBCHlZP30IVZL2xmJN+5s6tPM2hXl4jkh2 +4u1FcAAT+8N9oSNqk2wZXJKMLmxIy46D7HYEOZWjLWj6Z189VSAzAg2vMWYEOXLv5Vv hv0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q2tEj2bd; 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 q1-v6si23883833pga.417.2018.05.28.05.00.58; Mon, 28 May 2018 05:01:13 -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=Q2tEj2bd; 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 S1423454AbeE1LHg (ORCPT + 99 others); Mon, 28 May 2018 07:07:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:54176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423414AbeE1LHX (ORCPT ); Mon, 28 May 2018 07:07:23 -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 3761A2086D; Mon, 28 May 2018 11:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505643; bh=msQmGz+jjpDeZChOtY7SZqVMe0a84mG6N3NkbtkGr2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2tEj2bdtZsraFGZvyXV5zwDWZYOU1kUTI2hnMHtg6vg6I4lb4Zsw6xEw09ast1ci 8wLA6/oOx5aPM6RUnrxpWi27U0or7qAukGhMDRe20nU+rsv8W4GJRSZWAlVmQqSb0F DdImdJucRrshqX8JlembavtJjt1i3n/JLy50BWpE= 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.16 075/272] ocfs2/dlm: dont handle migrate lockres if already in shutdown Date: Mon, 28 May 2018 12:01:48 +0200 Message-Id: <20180528100247.277820281@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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 @@ -675,20 +675,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;