Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp56794lfe; Fri, 15 Apr 2022 19:18:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpYjXROdl6etNtp3hzAiJbKJCQMif8CRZmNRT9PnMHzdUj5NNhAP6ozYc0xYAPbmayK/KM X-Received: by 2002:a05:6a00:1d19:b0:50a:3e40:d89f with SMTP id a25-20020a056a001d1900b0050a3e40d89fmr1649846pfx.61.1650075504034; Fri, 15 Apr 2022 19:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650075504; cv=none; d=google.com; s=arc-20160816; b=HNcfcc5OjT7I2urg9iw2MwuLtZ7TaNbgt1JG1Vkd3b7s7xHGlUsfiw3wZtFg/jCE3n 6wF3GHCIiQVtc21i39eJvAsii3Ce4YsX3ExI5DiAuJYRbrH3uranrwF72hErYxczRgZ9 qC/aAJbecBPsEcYcOVShn2iiKFB+FcitNa5aoTAO1CsHElV+ms00BbzF055RhYazs+vl ANIvIWcXtP10jVCdee1OH4kAxAic4iTJSD+d39yzPoN8t4y1rbcu5e51gtzHGHvL9Y7u Cu3cCQ71ex9t0dWFkMt8Z8Vi98HIMz+DKoe/ZcPmBzYxoPmdpb+J8rd+4dfuUZcjB06+ aUsQ== 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; bh=8vsq8GyBceTs2scj4vA1JVbT08fUaG0niEZ6tpwtric=; b=dtjV/HnfDV8Otq50CsmC80vUjDxATY5SdA1Z0CG48dVluOJ+uosNQM0eADHm2JIj00 cK6z3lTw2WdmAe47qNce97Bgt27rcAaRxrh+GNc1yoZ/fk4O+5RRivZ2s9hXYJsAfLXJ ULwwnMU5W14acUdeVOeLi5m6Ysli6kKIXEhyaFu/i02h+XytTdWPTvTavMarKrLKuYUG q07To8X0aGR5FUIo/P9qkju+zhL9Uk450pUKoErrEbXgly4bb8C+9ANfVO6l1Wf0BaZI R3ZGCDKry7PM6czgOtMx+6vWQNuRt6PptccdBV6bJlUtB2iZc1YAPXIT/NonSXybqxzt dUgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ot5-20020a17090b3b4500b001d0c686af62si3046761pjb.83.2022.04.15.19.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:18:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 28DD4157598; Fri, 15 Apr 2022 18:34:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348839AbiDOC51 (ORCPT + 99 others); Thu, 14 Apr 2022 22:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbiDOC5Z (ORCPT ); Thu, 14 Apr 2022 22:57:25 -0400 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C717533E98 for ; Thu, 14 Apr 2022 19:54:58 -0700 (PDT) Received: from cwcc.thunk.org (pool-108-7-220-252.bstnma.fios.verizon.net [108.7.220.252]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 23F2sjlt023991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 22:54:45 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 10A6015C3EB3; Thu, 14 Apr 2022 22:54:45 -0400 (EDT) From: "Theodore Ts'o" To: Ext4 Developers List Cc: Fariya F , "Theodore Ts'o" , stable@kernel.org Subject: [PATCH 2/3] ext4: force overhead calculation if the s_overhead_cluster makes no sense Date: Thu, 14 Apr 2022 22:54:39 -0400 Message-Id: <20220415025440.2342107-2-tytso@mit.edu> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220415025440.2342107-1-tytso@mit.edu> References: <20220415025440.2342107-1-tytso@mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-ext4@vger.kernel.org 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 --- fs/ext4/super.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 23a9b2c086ed..d08820fdfdee 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5289,9 +5289,18 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) * 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; -- 2.31.0