Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3595981pxb; Mon, 24 Jan 2022 13:07:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz95BF95xUsKm9lpyCVI4pCRQD/pyPO083lhlIxy9RTFc3OpfvJip+gAFQVA/38oRgrk8LQ X-Received: by 2002:a17:90a:cb0d:: with SMTP id z13mr186808pjt.192.1643058440553; Mon, 24 Jan 2022 13:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058440; cv=none; d=google.com; s=arc-20160816; b=VeB8tCxjay43Ak9bz4nSQFi2mfDvW8efdCN3Z3C6yLc54TckTrY08zibRR9ae6LbcE glnYnGXCTYwX6jNFyJkSAdbLnoDP15GkVaEkpr+VUd3XB9a74lC5Kp3V/7ZXoKg4e6gp l4zoffR+FKfRv7dk2NcRwnURPwRoiPcaHiwsUdKXyE+lqxAVPQWRD+rzbPpnYekBKAP/ MVXnKMEmpGLvK8m/35ZlRzSk8NF7mpOot5VrbdqglzUvVgtCvSTmKzTVmawBCYzRkphT HsZfrOI5ESfLgH1Y0hUTdjbiTFV6iil2H3UMusllDMR3IEUzz/FdFddReVLFjr+tqD5M cMtQ== 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=j1mlnS9BvmHNpbNAhqlKGVPmBtfdA9M4gtwODDoW5GI=; b=hbAQ/w7uhQRkrkvSIHvBJ0mdpAPV9/siSj7HlynbjqMHV+p0cv6Mcoo+zxW+CDvTXi eCjg504JI8EIFnY6+7y6PcBfjnXgofqa3Wat9Jl3KOkSp+bUDSN6k88IbeB3hC8hT3Oq fvv3PRA4jUaS+dOvbV1pBLdhPoZRUVCFqU7t15/qHYsVO3v0++BanLU6fEHbnrGTKM4f JXHpHrHUKk2mXW+mT10darFftYJzVc2i3gO3y22BAgQRhw6N3LqeHnXAwoRkSjpyuj4o Cm3amX+fRXf9nE/twvD55YgXuNU9zw5tfWK/vnD7x4AYCS9miAl392EifdiDGdWmiFeD asww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DpiRk5Fc; 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 ob7si464105pjb.143.2022.01.24.13.07.03; Mon, 24 Jan 2022 13:07:20 -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=DpiRk5Fc; 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 S1356634AbiAXUcT (ORCPT + 99 others); Mon, 24 Jan 2022 15:32:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355389AbiAXUNh (ORCPT ); Mon, 24 Jan 2022 15:13:37 -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 F26ABC06175B; Mon, 24 Jan 2022 11:35: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 9B1ABB8122C; Mon, 24 Jan 2022 19:35:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4694C340E5; Mon, 24 Jan 2022 19:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052904; bh=YMTmdgspCZHdunm2O2C28dMwUyvgjGcIM5w9bO9muWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpiRk5FcO17xLe1ezQXBLK3xGzLsukQMYIktdhhGYSbeGsm5ItZcRYcUnoTbj7LhE Lt89OWZ4yaIWhGUjuHlkBOEjoX+YOQVb3n6fvRGAbYeQQAKLIERgyPK4l3K7dCrxz5 FbRB8aECi0W83QIm8ZjyzLD9mELdFRSCbPC39r8s= 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 5.4 212/320] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 24 Jan 2022 19:43:16 +0100 Message-Id: <20220124184000.839504289@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 9044e7282d0b2..c701a19fac533 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1361,10 +1361,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