From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 877B9C433EF for ; Tue, 18 Jan 2022 03:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350892AbiARDRg (ORCPT ); Mon, 17 Jan 2022 22:17:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352601AbiARDIm (ORCPT ); Mon, 17 Jan 2022 22:08:42 -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 13288C061748; Mon, 17 Jan 2022 18:51:05 -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 CA313B81255; Tue, 18 Jan 2022 02:51:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C006BC36AF2; Tue, 18 Jan 2022 02:51:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642474262; bh=qwLyaZMfE85g/d4I9bn3G44vYMOvYhH+xIhWBPlvYxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vi63qRGs2yMgEoQk79a7a0x+9cjvEibelkamGz9cgIR1fsj9oC3BXDUn2q3jvbvbj OsogqemTIv2jP5s3f8Gunf3mKJQ/vWnJmVSXsUA1i60PPAE1Pk+m/qQqXiaqfoTmg4 R2u2FaVTYaFnyOlHmW6ZTUHBwe1KYBm5ORMp7J1VtGkDWUVP0I5FNIRI5bLA/DVSnh LtGycdmmIa2sXYPClc2ZiAXGBvnHjgXNhtTj3uHM4T7jV0MGKcA2KXwkekcLkAv24/ RvWRPRXjxElSlmfenDtq/piqVolAlvazPT8PQLgxBtpuLLROPKUcR+gV0l3Eh4bsg2 bRGGHGelA3WOA== 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 4.14 48/56] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 17 Jan 2022 21:49:00 -0500 Message-Id: <20220118024908.1953673-48-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118024908.1953673-1-sashal@kernel.org> References: <20220118024908.1953673-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-btrfs@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 @@ 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