Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3552357ioa; Tue, 26 Apr 2022 06:00:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOoO+9K2hPVHPQ04ktktYJkADszZAYvRvDMmE5KIIciqfAKnAAQqEgENLKShIhpyZBZelV X-Received: by 2002:a05:6402:3587:b0:425:ffd2:8aa0 with SMTP id y7-20020a056402358700b00425ffd28aa0mr1802126edc.403.1650978018773; Tue, 26 Apr 2022 06:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650978018; cv=none; d=google.com; s=arc-20160816; b=dKu/Jw4yHPfgtOhEyuOaRhfPMy7AnOw95gWho1oPBtWn5ANG1taxzkOtvBo7DV3ZTO ipwoyGDbTFOyAM4LNiC2AxYkhMPIau/sas2+RvayYpYFERktgdYdno2M60/ArgcPV8yA vwFFpO1D2ioSbyrVQFewDOpKrcmyykZ5EescmI7qGQHGXEsFxm53W+Im98t51oStjYk9 1qNzjW+VKajHUEA7htAk3ZfWGJZT6WxLSiEPwq+gcGpHuPPZbr3eonMiQZ2fQthGWyxv 6ywX+TaIwm0eQcAIHv07/JM5/OIVynv1cTz9+mVyYYIQkJ5xma66O3Zg0Rp/EHL+dScl gxdw== 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=q5q+wTC5TdKVn038v/iPPMyng07hmT6Sp67W3J6v1VY=; b=xD2b2tLbU49kXAua2W8adte44/fLEYofXT08D60PWs0e7UYLCNlXpZYgIdx65I0o/f mBpEUtjWuM+ENnIab1SfkWaGW0ACReo+zvBQxUyZvYpBMYqygEWk9OReVevvUULniSPL GVGIDSW3+XJsBDB3EchmaKlQ7zhwHWHEOdTOkBFciLkmuDfxpufMiK2W8lGEPv39CE1J FY0oB30Feu3MbwLKrDVoEwluStieFjNcGbTFlFSnUlH5ngSUTev97iiarNkpIn6UpHFb SmUnwZgncMu8OIqvv/T/xieDJbXfrHAMWGjrs5znAO6T1ZVQ3sc1VtuJZ4F9m577qPhP oqbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aKKQ6AnC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a170906701300b006df76385d4bsi15710652ejj.491.2022.04.26.05.59.54; Tue, 26 Apr 2022 06:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aKKQ6AnC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232250AbiDZJUl (ORCPT + 99 others); Tue, 26 Apr 2022 05:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345531AbiDZI5R (ORCPT ); Tue, 26 Apr 2022 04:57:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCE683B36; Tue, 26 Apr 2022 01:41:55 -0700 (PDT) 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 CF8A3B81CF0; Tue, 26 Apr 2022 08:41:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 304DAC385A0; Tue, 26 Apr 2022 08:41:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962512; bh=N0G5hD0cI2nlqMKxZ483v7HcDAb3YSExYsAuoLBhvzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKKQ6AnCB03YvQ+0vv2HcNw3Y1yJ/fUFuUDFw6EFQmNX2UjnVdF6Ly4z6te/0w3Rn zN+2BPJiBXIPA8M4KHi47L99AWvRqbqM6t92cGGeP4e7M+2kBBmlbh8ZNlAq88cJLF S9Q9EQQ5UWc3+bvvAhO7LL0T3+FQeLsc0U1DPvrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 119/124] ext4: force overhead calculation if the s_overhead_cluster makes no sense Date: Tue, 26 Apr 2022 10:22:00 +0200 Message-Id: <20220426081750.672360469@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Theodore Ts'o commit 85d825dbf4899a69407338bae462a59aa9a37326 upstream. If the file system does not use bigalloc, calculating the overhead is cheap, so force the recalculation of the overhead so we don't have to trust the precalculated overhead in the superblock. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4788,9 +4788,18 @@ no_journal: * Get the # of file system overhead blocks from the * superblock if present. */ - if (es->s_overhead_clusters) - sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); - else { + sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); + /* ignore the precalculated value if it is ridiculous */ + if (sbi->s_overhead > ext4_blocks_count(es)) + sbi->s_overhead = 0; + /* + * If the bigalloc feature is not enabled recalculating the + * overhead doesn't take long, so we might as well just redo + * it to make sure we are using the correct value. + */ + if (!ext4_has_feature_bigalloc(sb)) + sbi->s_overhead = 0; + if (sbi->s_overhead == 0) { err = ext4_calculate_overhead(sb); if (err) goto failed_mount_wq;