Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4467382pxb; Tue, 18 Jan 2022 20:51:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIw5IjoQubkMNafr+1muV//78aZ+P3g9oh3odFT5T0ZI8De4M5tGxC/vuxZ+IxS3tjLOcd X-Received: by 2002:a05:6a00:1acb:b0:4c3:afd4:d61d with SMTP id f11-20020a056a001acb00b004c3afd4d61dmr16295163pfv.14.1642567886060; Tue, 18 Jan 2022 20:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642567886; cv=none; d=google.com; s=arc-20160816; b=d0P5Gec3rfsvPY60AmoJj5ay5HmdzUZmR1LUpY5JN9XbvKcAVS56iDisTYmJhi2+at +s78wIRZgfcWJ/7Iao/h/906DD6ML1gtKoYVCzaDd/9yw0SCUXDrMymby2SyA14LOAgN mhYh7EJJ1DlRNwrIy6QIQNfAxP3zxWY36XxrglFMx3F7bbg0rmu4BgoGtbK9PH9fH6mi Wq0d6JRGba7vd47EmwfgEfDu3kjmjbBgC/09pQF3Lc5NRl5/1sLFHSvTwwhEpDb8nRnX Tm24cwKvDqHqfKhfSLduIUwr6JJiVtzeVZiHf0ewIAFCJGtSauU0/m98A9JAXywEhYdb mvzQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5CMhUMee5V2Z5xLX/ztMmhU+G0nkH/un1zKIbBSIRLc=; b=ehZSChEqM1uv4aC4j6ZvegDAuhgLrl9oesxePt1pEUKuJA6EK/pYCCoBE7Pkdn48UF 9qH3R3m151PFObNEfozNtjO/6gf3Qxv5sRceejjs4HDtyPMsPFpOUnAKGWt2Vz2ik7YX d69FVWheyyr/SuKMBoNHzXFExaivJw8MyytCBimWCzaEj4hY2iGBwEO3THn3MkUyyfo8 NtBKPZf4HKqGZiq/v6dYDlJsyl/ZW5UxEyLJoFBjKyCAb9Hfbu9ee0+Jp/27x/RvX/P9 p6WZqfu/MCqG5vkxJS9qARj+/7U34jQp59ME/ndUg58AfkOGQnlBbVsY00Cab/Jwgvxu GtdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lMTKvjnr; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si24453038plf.98.2022.01.18.20.50.04; Tue, 18 Jan 2022 20:51:26 -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=k20201202 header.b=lMTKvjnr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349548AbiARCtr (ORCPT + 99 others); Mon, 17 Jan 2022 21:49:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345577AbiARCbn (ORCPT ); Mon, 17 Jan 2022 21:31:43 -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 53900C061771; Mon, 17 Jan 2022 18:29:51 -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 E9040B8124F; Tue, 18 Jan 2022 02:29:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E44D8C36AEB; Tue, 18 Jan 2022 02:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472989; bh=h1gG3QeHnOPLatdWZB69RHtn1t68ZwkJIf+iuILpzcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lMTKvjnrWk4HKdxX9paYqIbVNQ1atbgpoGLeGykyCA90cxcTB/8FG2qVPIZGBC0/0 02FF0llWXY4j4x/9zvq11TZJ2FifebY32IL2fahKQPt69A/E8dB0IW33veo/4vYgta Rtpb1iqImieTKSSot6mZUtAF6KtumACnTJ+Z6QLKRVdJ4UufanSeVQ0rQIyd5tt//5 o2TmEOv6R+/U1iBRCA1aRpjQHWOoQRQcLNaY83lFK20z9928mH/EiCSegEgdNAW4ax 3l2w7SVbIqPMY5UX6fESoS3/16Ah1rIqTRZrSoDFN32+hz+TsOwiSG+TYHnUBDSqal VdxBBNC4ngdDA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josef Bacik , David Sterba , Sasha Levin , clm@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 193/217] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 17 Jan 2022 21:19:16 -0500 Message-Id: <20220118021940.1942199-193-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 6b4b0f105a572..8b090c40daf77 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1365,10 +1365,18 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, 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