Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3390921pxb; Mon, 17 Jan 2022 19:25:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxk3Z+vv9ctOufVc+vTKEumf1cgS7UeXxtmpF0H9e1OHkSdjXsDBy3aVrY0f7LUBMik4yNm X-Received: by 2002:a63:864a:: with SMTP id x71mr12245855pgd.448.1642476248561; Mon, 17 Jan 2022 19:24:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642476248; cv=none; d=google.com; s=arc-20160816; b=Qt4WAIsIqRh9R7lBB1erYS1ui+g9DO9CQZhKiphBJ9wUxv4F7xBz1NpubVnsHDgiYL KS6MHM0SAxvh9g9CbxZ1k97nqPMmNh+P1w5wCUQY0Aj/+a08n7vTcUTuGp+I3V1AbLaV KWC8WFJl/cVAWEgdUJcm4aYcYjH5pIeV0QY5Xr/cm4xaHa0IOadldn0Ftww7fhelx/YT 0oDLJnQmGtzm5FrPIETLXbu7dQMXQH3op/DXz8FxaYTiztUHeKEy60c5kXwpiLDCsT8u pBFCwHrzJwYz8as4axJhr+hfONQY4MCN2tA81T+jg3L3wT0qEB8wO0DMVjg4mOoAyzjH MPQw== 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=G9tu6nnX2YvYrSNeYYzG/0QqSC7TCmW/g1yAAXh32aY=; b=clvQSC1BTVZONO+YjHsD9dSHikxoB9TOcKtFQXp4yqxttPFnlAdK6U3OL9coAlJRsh 59J7d+hm7wfEFNoTtSbJ5loJTTEebv2CqAtvd14kWxNLjTV2QM06f6KNRuEtM1Xf9qxJ p4B0+4GnT49XHY/ViAU8POe4LdtrCOIbV52dzFSwVda03cp20Dd3HBz3HFC089DGDqfj W2D4m/uUxFPDFkYEtTwM1IrerkhL1HRtDakLc3PTtWIrdH3VDZa5oiJyxWr/BBLZOyOh nN9ZboIof9sOjPVUG3wn7Ky8oq/F4EIveaSanWODqxTXT6b0JT0m4pei8oh6OcpVn5SI oKdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AVYb2OjG; 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 l184si16084393pgd.199.2022.01.17.19.23.56; Mon, 17 Jan 2022 19:24:08 -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=AVYb2OjG; 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 S1343960AbiARCd6 (ORCPT + 99 others); Mon, 17 Jan 2022 21:33:58 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:42462 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344375AbiARC3v (ORCPT ); Mon, 17 Jan 2022 21:29:51 -0500 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 98BCFB8124E; Tue, 18 Jan 2022 02:29:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B98E6C36AF2; Tue, 18 Jan 2022 02:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472988; bh=zI6GycII7ZqdcccMhnvZf7pbAzNxjeMsL9gidccGsHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AVYb2OjGxexQQI+93dqsjY2XIKdb2fVyHXuqYxRCL/Cpt2BMGbtXLNgO8mee3H0rX J4CeqAVxxZbc4ik2ZPSrtBQIAHc5jbnetpEA1P9demhAXHGw/MZ7rSMDWUZCYTTKvx VMWAUZrOhFlzSbDNGdAtiuckG8RVUA9PVZudiGHj7A2JJHiG18/Q/KUVs1YT4PeYqW 6ImHDY6rhk4gl8ntNVrMrPS5oAVdj8IAqHc6m5bhsjKzB3mAgD7Uf3NHx3BaqLy5yo 4PuTNoFhztAkkzL2T1imgo9bnDxW3VOKa1laEfuyWlV2ffpM2acRHdjw5LE2C9vKr/ 9Iq05+2ysMcwg== 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 192/217] btrfs: remove BUG_ON() in find_parent_nodes() Date: Mon, 17 Jan 2022 21:19:15 -0500 Message-Id: <20220118021940.1942199-192-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 fcba0120edf88328524a4878d1d6f4ad39f2ec81 ] We search for an extent entry with .offset = -1, which shouldn't be a thing, but corruption happens. Add an ASSERT() for the developers, return -EUCLEAN for mortals. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/backref.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index f735b8798ba12..6b4b0f105a572 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1214,7 +1214,12 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0); if (ret < 0) goto out; - BUG_ON(ret == 0); + if (ret == 0) { + /* This shouldn't happen, indicates a bug or fs corruption. */ + ASSERT(ret != 0); + ret = -EUCLEAN; + goto out; + } #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS if (trans && likely(trans->type != __TRANS_DUMMY) && -- 2.34.1