Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3876303pxb; Tue, 17 Nov 2020 06:01:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+XiQFAIEc5WoLfV5bXg72HGr51RfAuN6jwSlDJyMYugA98eM5hfMTW0w6m/MqDYC40ltU X-Received: by 2002:a17:906:1390:: with SMTP id f16mr19498174ejc.504.1605621685107; Tue, 17 Nov 2020 06:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621685; cv=none; d=google.com; s=arc-20160816; b=qswZ3CbkrE2Ssuy53hR7VzBU/uOt9xqfOWr3LPPD8IP02L18c1sHqmlFy3XNoy5/iR LhBTm5G+1//OaLKm0XK67tj4rDKd/9fT/ZYZCx+rsqWkgEmBbnJaCbvJXOZbMGBQT8b7 pZ8ondg+TU8ZJIbFNQ8HWB3m6lmDBgE0oV8IoFMhGsIzO/SMi7EJmXmaqrA5WeCwkwrG eqKAruDeHi/X/Pgqf2zByVbfYw7rCsJZ4XeevHjp4rEyhjipqZfHmgmzOg/2wXZzMSty sFc1Go+at9hWcfOa77pEeNMM5iDNQcdrTr6GLucDQ9Xg/bMuJ8v8PL3eb/pW6bYHOyv9 ErsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ItSJig3H8HR/aLVKwR3fqoQpj/ax0DlJe+0rbs7VfFQ=; b=dt3nmHkfQYbcooxc0ygcUNDnjBdMZFYocvcQMcbntIO+CiZxDVGtx1CrzLPuFk5Bko o+6eHnYkDnmuwAM9inNj9G7bq7I/vwN9a9VlJXjnvdx1Cy9gM4gkcXcZsZzMcxrsLpc6 jiMOM4hXh1X7pAfcehr861/aoFWLf9hzGaqJxBzc2OdUUD2NP1xIGc+JR4w+fBVsCyFu ANOAjBcORG2ngfLQUbP6hkhKq/iEZV0X+GuXtIWuPBSzfjmZOCR0T5X5fDfwB4BbkOSL McPJEAvt4/r7Sm1C7nJJvF1PinB7fSZc04Od8w2HdDoQt5GYY2kNCLzS3Xc5c9LllB5d MMXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ckvgoKjb; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs18si12843542ejb.162.2020.11.17.06.00.59; Tue, 17 Nov 2020 06:01:25 -0800 (PST) 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=ckvgoKjb; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730054AbgKQNTz (ORCPT + 99 others); Tue, 17 Nov 2020 08:19:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:53066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbgKQNTq (ORCPT ); Tue, 17 Nov 2020 08:19:46 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 8D7A22465E; Tue, 17 Nov 2020 13:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619186; bh=CHrSrhxaSDBygUeWx8DikqmEOYsoGcez1vsSOkiG43o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckvgoKjbKmtVkeeTjiRmV/dcsjQLag+f3Bs6YJJWN6irXsS7wcHxIhRySTJBb9GFX MxiLQ4eTLnMRaYGgUg4YM+K8/JW9DQUtMk8xKwAHcxLJiEyzOS30WOzcvjcfgLxHaO aTQRtAkOC40X+Hi5Lxq7kOB2SVcbJA+29gKPBDcU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Christoph Hellwig , Sasha Levin Subject: [PATCH 4.19 057/101] xfs: fix brainos in the refcount scrubbers rmap fragment processor Date: Tue, 17 Nov 2020 14:05:24 +0100 Message-Id: <20201117122115.877021179@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Darrick J. Wong [ Upstream commit 54e9b09e153842ab5adb8a460b891e11b39e9c3d ] Fix some serious WTF in the reference count scrubber's rmap fragment processing. The code comment says that this loop is supposed to move all fragment records starting at or before bno onto the worklist, but there's no obvious reason why nr (the number of items added) should increment starting from 1, and breaking the loop when we've added the target number seems dubious since we could have more rmap fragments that should have been added to the worklist. This seems to manifest in xfs/411 when adding one to the refcount field. Fixes: dbde19da9637 ("xfs: cross-reference the rmapbt data with the refcountbt") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/xfs/scrub/refcount.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/xfs/scrub/refcount.c b/fs/xfs/scrub/refcount.c index e8c82b026083e..76e4f16a9fab2 100644 --- a/fs/xfs/scrub/refcount.c +++ b/fs/xfs/scrub/refcount.c @@ -180,7 +180,6 @@ xchk_refcountbt_process_rmap_fragments( */ INIT_LIST_HEAD(&worklist); rbno = NULLAGBLOCK; - nr = 1; /* Make sure the fragments actually /are/ in agbno order. */ bno = 0; @@ -194,15 +193,14 @@ xchk_refcountbt_process_rmap_fragments( * Find all the rmaps that start at or before the refc extent, * and put them on the worklist. */ + nr = 0; list_for_each_entry_safe(frag, n, &refchk->fragments, list) { - if (frag->rm.rm_startblock > refchk->bno) - goto done; + if (frag->rm.rm_startblock > refchk->bno || nr > target_nr) + break; bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; if (bno < rbno) rbno = bno; list_move_tail(&frag->list, &worklist); - if (nr == target_nr) - break; nr++; } -- 2.27.0