Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp130745ybc; Mon, 18 Nov 2019 21:50:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzO6fIJGVXYIOFnmpZFYe2cAtVm8Zp2mCwUEU71FORGypiF1T+F9ks3vFvM7077pI5/Vf/z X-Received: by 2002:a17:906:d293:: with SMTP id ay19mr32026532ejb.146.1574142654535; Mon, 18 Nov 2019 21:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574142654; cv=none; d=google.com; s=arc-20160816; b=VAt4whfSZpD5k2RYb2YJ3s4GipJte1Z8S69JkUDkS2Kpf4LgW1yN9CkJc4RUH+cfYd l/OCNcgxs9MxNR2iwCAI6m1q7BzRYxLcGAw3nVcQDhEPOEIpz8AfGuN85Br3fgP2VolN JIHS/F56OiXINHlbUG/Rdi5zgVViwy6ke/aqHkwnqUgksuisdpScZzvrhQrzuozXZzEC T7Fe4MTUkVmwp2SbDU5UehFir6Ko+FITo/+WfZBZHMU8DeaLbN5qxVcbCXC3FclkGKrI 3xIbTsOuKWlmmtCvup22GDgCVeus+/5tgebYJKTRwF4dIrgy3C6fMCLrAqyjU+5R54xd erQw== 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=Txv5Hbk7JWzLaazOK+OoeVdGexBeDDW+oM0kXgAbLpA=; b=LH4+Vi2OHizhtqbZnOkL1zrZrSWJ94aPsWj3bOlhpGzCfeml/LP/yww0ETATqIt6Hb bXc3Mwoeo2j/T3GABVMqB6LsHWfb2ksMdxjrVfdo8MsNkiZLP0d9rFSKZs2BepwO/STl MsXHRYmOFVoEnzpM8nX1WGAOmYVUePMjVynF3PfZM/nvFw8+EQ4Cfc631oIRtk9/Jz9z 4mnupl+/7em65cTOg5ZER8NkIpNN7CnFJgUW4CcbSqClvIS2AjkBl4oGL2rKThmCcpfC 74nMr1Kdp1i+ft1f9WvfxwXT9TjlyyJUQIP8M9RKPxXLJiLoz9rS8089mgl4tloFeFFk 1nYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZnVIvspb; 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 v30si4503222edb.132.2019.11.18.21.50.30; Mon, 18 Nov 2019 21:50:54 -0800 (PST) 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=ZnVIvspb; 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 S1730954AbfKSFre (ORCPT + 99 others); Tue, 19 Nov 2019 00:47:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:43822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731239AbfKSFr1 (ORCPT ); Tue, 19 Nov 2019 00:47:27 -0500 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 18D572071B; Tue, 19 Nov 2019 05:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574142446; bh=66ajkt9iM6MDmOPzzY+y7AnWo/Vg7+hhgie9nPB1eoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnVIvspbC6btfRKlykhoTLf7MOZgtxoqR7rHNqHWgfSli18EdH1+Byr/qlOZgALqP sUosM5E1arvCbc8M7qkevrbPiiV0mozLfOZa4zhJRTGwvc4l7+Vtuk94/Yri5vVIJE mio6nGPpkU7yNvEJ00kYnTEkpcj5qgI5za1jM0Dw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Peterson , Sasha Levin Subject: [PATCH 4.14 044/239] gfs2: Dont set GFS2_RDF_UPTODATE when the lvb is updated Date: Tue, 19 Nov 2019 06:17:24 +0100 Message-Id: <20191119051306.193240094@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051255.850204959@linuxfoundation.org> References: <20191119051255.850204959@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 4f36cb36c9d14340bb200d2ad9117b03ce992cfe ] The GFS2_RDF_UPTODATE flag in the rgrp is used to determine when a rgrp buffer is valid. It's cleared when the glock is invalidated, signifying that the buffer data is now invalid. But before this patch, function update_rgrp_lvb was setting the flag when it determined it had a valid lvb. But that's an invalid assumption: just because you have a valid lvb doesn't mean you have valid buffers. After all, another node may have made the lvb valid, and this node just fetched it from the glock via dlm. Consider this scenario: 1. The file system is mounted with RGRPLVB option. 2. In gfs2_inplace_reserve it locks the rgrp glock EX, but thanks to GL_SKIP, it skips the gfs2_rgrp_bh_get. 3. Since loops == 0 and the allocation target (ap->target) is bigger than the largest known chunk of blocks in the rgrp (rs->rs_rbm.rgd->rd_extfail_pt) it skips that rgrp and bypasses the call to gfs2_rgrp_bh_get there as well. 4. update_rgrp_lvb sees the lvb MAGIC number is valid, so bypasses gfs2_rgrp_bh_get, but it still sets sets GFS2_RDF_UPTODATE due to this invalid assumption. 5. The next time update_rgrp_lvb is called, it sees the bit is set and just returns 0, assuming both the lvb and rgrp are both uptodate. But since this is a smaller allocation, or space has been freed by another node, thus adjusting the lvb values, it decides to use the rgrp for allocations, with invalid rd_free due to the fact it was never updated. This patch changes update_rgrp_lvb so it doesn't set the UPTODATE flag anymore. That way, it has no choice but to fetch the latest values. Signed-off-by: Bob Peterson Signed-off-by: Sasha Levin --- fs/gfs2/rgrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index b0eee90738ff4..0d72baae51509 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1201,7 +1201,7 @@ static int update_rgrp_lvb(struct gfs2_rgrpd *rgd) rl_flags = be32_to_cpu(rgd->rd_rgl->rl_flags); rl_flags &= ~GFS2_RDF_MASK; rgd->rd_flags &= GFS2_RDF_MASK; - rgd->rd_flags |= (rl_flags | GFS2_RDF_UPTODATE | GFS2_RDF_CHECK); + rgd->rd_flags |= (rl_flags | GFS2_RDF_CHECK); if (rgd->rd_rgl->rl_unlinked == 0) rgd->rd_flags &= ~GFS2_RDF_CHECK; rgd->rd_free = be32_to_cpu(rgd->rd_rgl->rl_free); -- 2.20.1