Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3557023pxb; Mon, 24 Jan 2022 12:09:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMnIURMIVAVyptkDo+CobB/0REb931OlCaHJ/h8h2jZDBOPv85madH4ch2KtrRY1KT33+L X-Received: by 2002:a17:90a:f30e:: with SMTP id ca14mr3452863pjb.157.1643054964443; Mon, 24 Jan 2022 12:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054964; cv=none; d=google.com; s=arc-20160816; b=rh8Skn2q3njmO0bJIu60oUZQKB5KATmGa36Rchx40pdITY2qcjqwYwBYnRivwEikHe a9ANCSErTQE0EzJupxFyPlRdKVRBCahO2aeATX6atJLwLlqrdpJ/nDlBLvh3Qhml/ddm 3CXahmI/lropKyzzYpy7kN9ClSBRh5LyUJSdX+H4Lro54ZtvsMkCOSowyqnhwWImvAoi i0fOa0E3Pniy6sR+e4ZSrkx2SfGRUHf8XXTNRhkKeCStMSd9P0v/pbQi1ox7JnzrPOSl 4COsbIJ4CRFHDJUpQSifeW2oWG9HQfHsAbxU4gZcbV8kM/29QyBo7HLW5R7WlQiwgPX4 rc6Q== 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=zTcHnLN1SCHhlmUtnsmkDxI+c9Mm6nt5EIhyn9y1CMQ=; b=vBeNtSqO74gCqe3p0ZkUQri84qxUf2e8ARc7Aw8qxU/HpRZmZQbjPzmZ3BmZ6n8dDf TDjWNHgRbOkIFxLM3cK5aeVMkkpYj4+A+VhYfgAinoM7WdjSgxEpc8FZcJdAbEO2BTMR rK8PqQUdAkgC3xPMYWqCmXYRRoXT5Fzdz0UUAqbHTAyfh6TMPFoR9iDvFnTI4enQPvms iII2GrMY0b2pGZrr6E7M9rqb+uUchjjm35vyHtloyEJZVA597roXQRknmhTPBPr+E6Dr 0WzIMxAjcjdjh6QKVikH4khcYCj7cK99s5OL+HzbsLwVIjXC2VqWE1Z2P2YkjmRTSt3K IftA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k0nQjD9z; 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=pass (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 k62si6172629pgd.675.2022.01.24.12.09.07; Mon, 24 Jan 2022 12:09:24 -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=@linuxfoundation.org header.s=korg header.b=k0nQjD9z; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347116AbiAXTJn (ORCPT + 99 others); Mon, 24 Jan 2022 14:09:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344246AbiAXTDN (ORCPT ); Mon, 24 Jan 2022 14:03:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1045AC061753; Mon, 24 Jan 2022 10:59:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A17E86020F; Mon, 24 Jan 2022 18:59:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7257EC340E7; Mon, 24 Jan 2022 18:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050743; bh=1LsIV7lL5lJ40dfUxO8pKqDVJSLOtPvkZEuXKWupjx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k0nQjD9z2HTYmojl9TbYPZWt96gPnaPgE6OsqV44iyClLzRf0HpDxd+5pLRb3P9Lo 9tT8gXVK/zDXV8n+DsBzLhPhfzlarpLG2tSMk8MGPXvIAnrYli/kvWXyTEitCjIZgZ pXG+dBIxDlvXmSgJV78chz1t+5G8A5IpKdj4bMso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 4.9 098/157] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 24 Jan 2022 19:43:08 +0100 Message-Id: <20220124183935.878229190@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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: Josef Bacik [ Upstream commit 9f05c09d6baef789726346397438cca4ec43c3ee ] If we're looking for leafs that point to a data extent we want to record the extent items that point at our bytenr. At this point we have the reference and we know for a fact that this leaf should have a reference to our bytenr. However if there's some sort of corruption we may not find any references to our leaf, and thus could end up with eie == NULL. Replace this BUG_ON() with an ASSERT() and then return -EUCLEAN for the mortals. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/backref.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 29a19bc2abe18..16169b35ab6e5 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1437,10 +1437,18 @@ again: goto out; if (!ret && extent_item_pos) { /* - * we've recorded that parent, so we must extend - * its inode list here + * We've recorded that parent, so we must extend + * its inode list here. + * + * However if there was corruption we may not + * have found an eie, return an error in this + * case. */ - BUG_ON(!eie); + ASSERT(eie); + if (!eie) { + ret = -EUCLEAN; + goto out; + } while (eie->next) eie = eie->next; eie->next = ref->inode_list; -- 2.34.1