Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1667228ybz; Thu, 16 Apr 2020 13:17:27 -0700 (PDT) X-Google-Smtp-Source: APiQypLeahD5iiyc0NIOXQ9saXhP3K7ldnv8OWnYHSjVDfcNTBJBFj+G2A10qmWrlU6K52nqrecv X-Received: by 2002:a17:906:2594:: with SMTP id m20mr10824536ejb.368.1587068247575; Thu, 16 Apr 2020 13:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587068247; cv=none; d=google.com; s=arc-20160816; b=onyIRx69Nb0FH5cWziwA5IPmLtlneUpVIcC0MWCufliOAnu37I3/9aOUTyXJRPEkfS sLXunOpxRUzgBWCdqHXGPRJI/GQU8YCUGW6x+7JbU6bZqlTqhVjEYynFM/CHmMcHMl0k PVBFHbxNUMewG/rEv8CRxuyGm0u7KqcMgVESqDs0C9RGBelzSGh55uL6As34w1gMlzyW xmSGQPDhv1y6fBGcJzPMCcshC04pR/Lg5wCqRvV+txdyrZmBgKFvjky91nL/LAuI1ZMx Ecqe+RI35+uPxVW8/P2nsuM5V1e+cHcoy+dmb2v6uIv9h7je0M8BORWwbXMpTFaI/sQD kAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ArXYlJt7l07TlX3aOGMavRO6leTedT87XYU4bcENXwg=; b=kB/7V3xkfOlTTndcOzxP7RStjTSi6268HG7vOtTJjioKy4tL7C23AvBGp4wu10I3wI VEbPrFQT1m5+F/pnV4q13LHWqFwDzLcNFsoWetMdSd8QCzvnpR67x8/YeTjv5DDrU6Ak vMBw0qJO+SFStwVWIJ5wWU2XYsqr8nIXSGQs7AfrNETeEKnxI+mh01j8C2tVv2nfplYH rfcXCnFIm6InLbR4sz6trXgBSLHY3qLc0a0SDLgSp68o4IGbeIiBWwdHNsYbA8K8CFvl 2gE1Z8uO7pzadzPpvYKBtYZJsY9QAAqvQPWRNYfxN0f02apBxYrnUc1dm5nmRtLsJqGM JALQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bkdf5f3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si8064117ejg.474.2020.04.16.13.17.02; Thu, 16 Apr 2020 13:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bkdf5f3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393285AbgDPOI7 (ORCPT + 99 others); Thu, 16 Apr 2020 10:08:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:59796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2898547AbgDPNqD (ORCPT ); Thu, 16 Apr 2020 09:46:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 F1C2121734; Thu, 16 Apr 2020 13:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044762; bh=5wLauErA2sXj1hwEOBTS/RNcaB9yDT/S+WliV8V9x+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bkdf5f3a61ejWhul7IBtRdPDOtbXRMK7Yz6nuZ7tcckZeDxdYKZlf1tb9m0lpc5+m 9u9LW+7txWC+twzTrOMi2aJlYNhN3pbwJ6e8jtN3z6iVXhHt8CVr4NjbQhDXRyF/Dw ESFKSTpdjFRLN1e5IcRhMRRumDUge+rCGpnQXvGE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Peterson , Andreas Gruenbacher , Sasha Levin Subject: [PATCH 5.4 051/232] gfs2: Dont demote a glock until its revokes are written Date: Thu, 16 Apr 2020 15:22:25 +0200 Message-Id: <20200416131322.069893844@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bob Peterson [ Upstream commit df5db5f9ee112e76b5202fbc331f990a0fc316d6 ] Before this patch, run_queue would demote glocks based on whether there are any more holders. But if the glock has pending revokes that haven't been written to the media, giving up the glock might end in file system corruption if the revokes never get written due to io errors, node crashes and fences, etc. In that case, another node will replay the metadata blocks associated with the glock, but because the revoke was never written, it could replay that block even though the glock had since been granted to another node who might have made changes. This patch changes the logic in run_queue so that it never demotes a glock until its count of pending revokes reaches zero. Signed-off-by: Bob Peterson Reviewed-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- fs/gfs2/glock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 0290a22ebccf5..21820a5b388fd 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -639,6 +639,9 @@ __acquires(&gl->gl_lockref.lock) goto out_unlock; if (nonblock) goto out_sched; + smp_mb(); + if (atomic_read(&gl->gl_revokes) != 0) + goto out_sched; set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags); GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE); gl->gl_target = gl->gl_demote_state; -- 2.20.1