Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3570143pxb; Mon, 24 Jan 2022 12:28:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLuIlDZ7zZfkje7X0c4pMXUMds2mB/JLtmRwTOVGB0W0cnsI5zouo73BQ2k/I4HOd/sknU X-Received: by 2002:a63:710:: with SMTP id 16mr4161073pgh.568.1643056098203; Mon, 24 Jan 2022 12:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056098; cv=none; d=google.com; s=arc-20160816; b=cLn/np1jqbYZNZJztuPWGN65kggORCdqmhrvpCu+Ysqysqg2wiIBleTLpwMnzgrONP NZnA7RY73ekkQAvNFZJ+DW5IK38FL4Mg9NEUUz1psl3fX5WZq31sSUS/QbGFFsErD1HJ xNEV8qHBFADI56b2eV08Fqh3PYdBr2431zCf712+icm+PcB+eKBhMHg8r5YEfoCDY26a UugoXT0xDbHAR8M5ZAW5i48Y2IgnmJPeQUdviVssuC3fbaslRt7LdTHeEnNNe2gBps5B QnzF2gVoCZ71niys51QdalcogMC4JGvN46QG93lKEjDKJzI9SuKxa9YZFfvn09jzmg+J PhGA== 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=3aT+0El/Y6R9XTCnysZY/YN/fSZEv9+E5uOnYhlN3nI=; b=dajcw4YKFGcGbFA8Whh2pU1eyDhiKeto3qYkyOgKJotOCuUQblOfd6+xaJNRcuK1Mv U1ObHdW6yG0Lw12olnJEw3uve4XcXgkSng56A038EuCJW8k267vexALRrwtj6dtSl65g tzIuYJoo305vL+Vx+o83HWiRCJIYG0gfqzQwzVIiRHI6znWq4W8MuAHLVorUZYlJGJ2u usaLyGhJaPgVPnzoPFGdM7pQrnUQgxv8EXcsnEka7zD27+dSUgmj8+JRH7wiyiWYul5Y XQOjy2cmyIjAvdC7dL1ymXtU3VxXZt7dYmgvRPYZ1iSc1J09B+3eKr4vnKR/yXwAGgxD xi6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l26TkjK9; 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 f6si289133pjp.153.2022.01.24.12.28.05; Mon, 24 Jan 2022 12:28:18 -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=l26TkjK9; 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 S1352617AbiAXTar (ORCPT + 99 others); Mon, 24 Jan 2022 14:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347729AbiAXTVk (ORCPT ); Mon, 24 Jan 2022 14:21:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A47C02B85B; Mon, 24 Jan 2022 11:08:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6F0BBB811FC; Mon, 24 Jan 2022 19:08:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68C2CC340E5; Mon, 24 Jan 2022 19:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051315; bh=LqoSMc1RpwTe7F3/upaq0t9gP0hc4FWfCx3wkogjeWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l26TkjK9FocOzRAPOgWE7SiZLKHNHw0vUhqvGzOZaSlAi3Oq/5vVgV5o6GR/MEv++ ojhLyovjXZ4WPjsvKW8cq8ul1ohHCyBlrqi91bXtFfxyE1ncuL/IyD0Pq558oJ21a6 lzVuAsvJ9bIvNQHRKGfgqM9G50r5nAN3DnsFEsIc= 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.14 123/186] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 24 Jan 2022 19:43:18 +0100 Message-Id: <20220124183941.069900901@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 f2c2ac3343bac..58dc96d7ecafa 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1315,10 +1315,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