Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3891216pxb; Tue, 17 Nov 2020 06:18:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMIHgSTIYRdz8HElM/K7oHBW64OdqTKxmZLHOoQdbMzXGKBNWBSXHDSOfZ03F71ZKNz4J3 X-Received: by 2002:aa7:df04:: with SMTP id c4mr20977961edy.25.1605622734832; Tue, 17 Nov 2020 06:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605622734; cv=none; d=google.com; s=arc-20160816; b=ZCe1ZCimABsNgbvB4v7ll3dOxzR7C63Qt6oiuHvP4jIl/V3YsYZKaZt2BXwMOF5uZD bTFkHRaR7C5DWjK1jQWZQwjygsxj7ZwhPVo+DL9t8II0tV2Xpf78B99Vnr91DTrMffrn r4LZbvp8zyYh06go0kAOQU9Wqu7N73tuaT6QW9oJbNKa8oJ+ksUvdMx7Hrc+4z6vyzq8 nG2e+JkUIU3nx410tX7aYQ9nEHooqxOGWKgzCA08uKVHjzlrhqKtxPd4XKKMyr+gKiCB pq3f80veeObu9weBCwFcVrore+7F+kkKMLog0rLFx+fciUER0DeMsYyK3DMch1VaZW/w MoLw== 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=r6aejsxkH8627cDw64kOwXzUe086D6cNFCTMFW6637w=; b=KVjY5gYS7rHM+HSxlmwoIt0mHtCLXYDvww5CYPyrVSNHxEex57p2SQINx/3jkintdu z4jVOY17VLsJ1MWplfr1EOoQhBNqUOlYSdgwJvw14En/AtdgfuVE8aVab5L5SVSA3T3j nRxvjwRHgPwnD4TAr+J3Y0NDvy2Yw2cJfmHcXu9oRcRIgxIE9cbDegQ7Esw5AL9OAxiI apVl5KhP6gQwN/sOAwXXfjOpGdbgfAtYuqxGBsblPtNDlKzsfO5RF6LsMDvIkH60aqKA uH3cHpLHPISXH/BILLIpHNnWIHyTZdcbQr8Euk1m69oWlq37pq/HmQpjHVU+j8Y0mgoJ QM9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KM0Ggh+z; 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 i25si14199517edy.223.2020.11.17.06.18.31; Tue, 17 Nov 2020 06:18:54 -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=KM0Ggh+z; 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 S1732771AbgKQNjn (ORCPT + 99 others); Tue, 17 Nov 2020 08:39:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:51146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732327AbgKQNjT (ORCPT ); Tue, 17 Nov 2020 08:39:19 -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 B95E5207BC; Tue, 17 Nov 2020 13:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620358; bh=can9amtUp0ur8PA7b9jIWkphGmrsU8d/VsyiRZf9s78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KM0Ggh+zZjQ1iIMNLaHJPv9EnUuyfN6mnqPc0tg1jApZBbMod1rKqNlO5KIFGzsue 0as6owWlyXPuGFv+bgof+Hjg5r8nvbAXIqR7TNGacxcyamoeeV+o2eqyRjHho0HXHq 7PYTPuCLPcqPlo+3WMuwp0ZD3VLk3/SzxRy6xwy0= 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 5.9 161/255] xfs: fix brainos in the refcount scrubbers rmap fragment processor Date: Tue, 17 Nov 2020 14:05:01 +0100 Message-Id: <20201117122146.775521258@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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 beaeb6fa31197..dd672e6bbc75c 100644 --- a/fs/xfs/scrub/refcount.c +++ b/fs/xfs/scrub/refcount.c @@ -170,7 +170,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; @@ -184,15 +183,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