Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4029877ioa; Tue, 26 Apr 2022 15:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTrIwsaV78Dd3h9Tjl0j13BS+oQrmOQNHvELFSVGA4CzYC2c56CoKBlCcb0uG8BntUfBBy X-Received: by 2002:a17:907:1b19:b0:6f0:1022:1430 with SMTP id mp25-20020a1709071b1900b006f010221430mr23917159ejc.13.1651011459051; Tue, 26 Apr 2022 15:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651011459; cv=none; d=google.com; s=arc-20160816; b=P6L+4GNJYhfkg7aW69YKlJL81fstLxi1m1rubHSbe/5rEwyC0dCkwLdvHh899DZGZX a5qadaPSEscgoKT6s+GQ4ktmHCLMAfwot2Kj8EXceD3jmsjWpQmgs8vAGjhp/01waCgc lb47B+r5TZb1pV3zwz4Id2TcYEgpBMl9nnNkhDY1mU/XPuAlkbJpFBn1Zye8RUEoOBSB IFz04MQe+P2/vNNmEPbS+6+NT1fbJl+dgsBOSXMGHLL2LFwLutK0FXCsOCoRVJmK8thM FeuZqYhx+KS9sg75/kK60N3jCTbmPvsspzuTXl1+B3HQqVdc1dzO+eQfZcgu3nIQRhQE 2oDg== 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=K7bR0pvGLCU64ehUczt6BNpQyJJLE5522Yc5N1/yuKY=; b=aJ+oQzTaxqSKzipBlY37gWrFwMvNbRcBtCjlVPU444cYEJ463Wo7RNZ0Z4Vm0nttP+ +0m6z+aSG/m3dSzjv7KsxCGnJgY7ArEyIhHI2FMovFsbVUkMoovRSmnjs7Zpe3a8TQi8 Lh0/PAFQLmbqE9N/ZNFotZqJL/MEh7BEM8GaT3UlqCcrOYRt86PoOeer7U2SYqGA9BwQ 0MStIjMLzH08h29wXtOvxQJLAnAbMQiv/jCcGXNrXoljiDQr20Q03uEiCIr/s+JekHfu dVFJ+ljt+ZW5+YJTJwMM0mLDo9dqegPv5KU1vFd5ip9pXQhRvfscf/+/aqJ0cxx2ba8l 9QnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="T7r/quVI"; 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 i13-20020a170906444d00b006efe4351406si16530821ejp.135.2022.04.26.15.17.15; Tue, 26 Apr 2022 15:17:39 -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="T7r/quVI"; 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 S1345638AbiDZIqp (ORCPT + 99 others); Tue, 26 Apr 2022 04:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345786AbiDZIjb (ORCPT ); Tue, 26 Apr 2022 04:39:31 -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 CF3124F9C6; Tue, 26 Apr 2022 01:31:06 -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 83724B81A2F; Tue, 26 Apr 2022 08:31:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA3EAC385AC; Tue, 26 Apr 2022 08:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961864; bh=EipAMTZF5YuchwXSMNVNeqbz16e87WfypAJBaEy8V9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T7r/quVIQRGUGAC+Qq7U6cWvhc8/X9B0LKoTwAXJsGaA6tNWzzroBfifb7o5fDYL7 c0tid83QTjRzndNyQrGFpgH6AZOeNBbPQHtth02VZ5vjRxvWuFnbK/h/wrnydtJXjZ mDDNtazYbgskRCqkBeaK4+I9IBy93Io4LgjOUOzM= 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.4 57/62] ext4: force overhead calculation if the s_overhead_cluster makes no sense Date: Tue, 26 Apr 2022 10:21:37 +0200 Message-Id: <20220426081738.856257915@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081737.209637816@linuxfoundation.org> References: <20220426081737.209637816@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 @@ -4514,9 +4514,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;