From patchwork Fri May 1 13:23:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226549 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, 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 EAF95C47254 for ; Fri, 1 May 2020 13:52:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBAD4205C9 for ; Fri, 1 May 2020 13:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588341161; bh=wOuKPrjxBqIWiZszReIQZcoXpdptGYDNhKxL4TUtiEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CPU5wUNNkFX0SOwzNIB4VO4Gimbr9F8Ws1hkkqDatTbbSQylMHeSESYtLrj3WmC19 W9peJmFWDgEiP6Sfo+8nKDC6jJWwELl6OtJT6n2iUsqZNmxIAfFw9+sVhqRnXdn7mU fb2K/rOTZUk0+WYROdcedMwlXVHFmHdPW6d7kJSo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729705AbgEANwh (ORCPT ); Fri, 1 May 2020 09:52:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:36656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730277AbgEANhc (ORCPT ); Fri, 1 May 2020 09:37:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC2A0208DB; Fri, 1 May 2020 13:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340252; bh=wOuKPrjxBqIWiZszReIQZcoXpdptGYDNhKxL4TUtiEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+yC9n6HN0in8lOfLBE/XAbpnaowjdEmtKW5w5CvJjXWWKcn0XpyPuG7ciX5Ni5XB ObPzuKYTAZ+WFYPoRYxhn5ubHo07KFrnR/rXYTG6VmzeYCbI6JhcZqyV4tx120fC7Y nRz6tO9l7P5QUEIU4WzQTbs98c26PaDlTccweKZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Sasha Levin Subject: [PATCH 4.19 42/46] ext4: convert BUG_ONs to WARN_ONs in mballoc.c Date: Fri, 1 May 2020 15:23:07 +0200 Message-Id: <20200501131513.390465961@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131457.023036302@linuxfoundation.org> References: <20200501131457.023036302@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 71121fcf9e8cc..8dd54a8a03610 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1936,7 +1936,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; @@ -1959,7 +1960,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 "