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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97C08C5519A for ; Fri, 24 Apr 2020 12:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FDD320767 for ; Fri, 24 Apr 2020 12:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731171; bh=0d+S0c9RGNFepIOls681etkyqAWB3Nn4eFH348tKhX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Nrmr72fc9ZoWBLY6kiYRboCYcwJD+tKC1T4Oo3YzBLEAurftGiNPvqvAkhFrcapzV Yz2SOOc2GMN5YFqOg51nslCw5ChMQSq2oC6L6mEzTaCxlsgNG1aYoeN/ZGs6X59bMj 7ZpbgAWW6ywZqbkpUn2IonzkVCpAWE8QsI3maBwY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728606AbgDXMZB (ORCPT ); Fri, 24 Apr 2020 08:25:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:56010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728603AbgDXMZA (ORCPT ); Fri, 24 Apr 2020 08:25:00 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 981FF20776; Fri, 24 Apr 2020 12:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731100; bh=0d+S0c9RGNFepIOls681etkyqAWB3Nn4eFH348tKhX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kk3fI48nDb2/PqdIHMga0jQ1jqXpDbnW/rxp2LE6j5pRyETnBCqFm/QZAKi6B56i3 FsoopTgYiA+TmLQkuLUuFuMhnd7uNXNrmIOx7xsN4JPpt0NfYmv03i/vgJbyEr4K8q 11tThVyQA0olQ3m2wphJXj98f+p6LMB5JTHEcu9w= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Theodore Ts'o , Sasha Levin , linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 11/13] ext4: convert BUG_ON's to WARN_ON's in mballoc.c Date: Fri, 24 Apr 2020 08:24:44 -0400 Message-Id: <20200424122447.10882-11-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122447.10882-1-sashal@kernel.org> References: <20200424122447.10882-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Theodore Ts'o [ Upstream commit 907ea529fc4c3296701d2bfc8b831dd2a8121a34 ] If the in-core buddy bitmap gets corrupted (or out of sync with the block bitmap), issue a WARN_ON and try to recover. In most cases this involves skipping trying to allocate out of a particular block group. We can end up declaring the file system corrupted, which is fair, since the file system probably should be checked before we proceed any further. Link: https://lore.kernel.org/r/20200414035649.293164-1-tytso@mit.edu Google-Bug-Id: 34811296 Google-Bug-Id: 34639169 Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/mballoc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index c18668e3135e8..ac13de1a7e420 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1944,7 +1944,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, int free; free = e4b->bd_info->bb_free; - BUG_ON(free <= 0); + if (WARN_ON(free <= 0)) + return; i = e4b->bd_info->bb_first_free; @@ -1965,7 +1966,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, } mb_find_extent(e4b, i, ac->ac_g_ex.fe_len, &ex); - BUG_ON(ex.fe_len <= 0); + if (WARN_ON(ex.fe_len <= 0)) + break; if (free < ex.fe_len) { ext4_grp_locked_error(sb, e4b->bd_group, 0, 0, "%d free clusters as per " -- 2.20.1