Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp309339pxb; Thu, 14 Apr 2022 23:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvJBAb53/twnqKCYp87Z7Aagd/eSnSkDIbINZubFIWt5It5mbTBkg5cGIivjBgx+uTI2mQ X-Received: by 2002:a50:d4d9:0:b0:41d:6ee0:80d with SMTP id e25-20020a50d4d9000000b0041d6ee0080dmr6651269edj.254.1650004103513; Thu, 14 Apr 2022 23:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650004103; cv=none; d=google.com; s=arc-20160816; b=chD5BzT/ZwCADC7xvOL7l1gVZsy+Qg7LK8BkmN3BBXLQcruQBLcNq/FKfhBFTRw/NH xqzkP5as0DPRk39NJxIgivC149rFeSwW4+bCEfJb1uDdht/gBOldQppp1AVA0gdzNeCJ FGthRSlSxY89Txhep4/qLTV6V+Ujn2HCtUgDo5ahPlCiEqXWdRJqHEqz6vc2Yd+i8wqM q8He1sKGnzdPffKNDm7PrrXQIKkRgGmEhStQM/TNtaAAL9VVlBugCCq7LrFt+i0zH/jY bnVFO09OdlPXXfwAQaR4zyHm+KihZQ4pfhjpWsRfDWI2y8cyHjLHhjD3o2IEmw8l/tJh W/CA== 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=mng/R8fF19cKjOhRyNTMG/rJm56Ahj/hqweiwGV7bd8=; b=jYAFty5Bho+sW95qYXJI3NJGsQQ3/ruOZcyJS8KZCwCuGQ1lVDny1ZcRpPM5Hfhmbl 36Ozr6F0Xbv4hruxQPxsCQEnZ3+Us/mpIMjcnNVq9SWJyq+RubmfjYizbZLGVESRT+Ky 9AIztGlAjwDv2f1VKFFoBDlP7HWSrP2/X0FFFLOhqX/gk6nMp6H3V/nehFwRx6Aalr89 0bhrNTi+0b85u+jguck+AAtcbQpilaZx4LLgVGF1MhqAr39kdEH6qtwauM874QhAgGpT W5fOeWe4eg6V53hdfjsBbDnR8S24f3x5gQBVEaKmt5CZ/I68Q+Kn9lJeNMLdc4pZUQYu a7QA== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a170906385300b006e7f865ec9csi442211ejc.850.2022.04.14.23.27.55; Thu, 14 Apr 2022 23:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348846AbiDOC50 (ORCPT + 99 others); Thu, 14 Apr 2022 22:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348183AbiDOC5Z (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 F24BF33EA9 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 23F2sjl2023989 (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 0F34715C3EAF; 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 1/3] ext4: fix overhead calculation to account for the reserved gdt blocks Date: Thu, 14 Apr 2022 22:54:38 -0400 Message-Id: <20220415025440.2342107-1-tytso@mit.edu> X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org The kernel calculation was underestimating the overhead by not taking into account the reserved gdt blocks. With this change, the overhead calculated by the kernel matches the overhead calculation in mke2fs. Signed-off-by: Theodore Ts'o Cc: stable@kernel.org --- fs/ext4/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index f2a5e78f93a9..23a9b2c086ed 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4177,9 +4177,11 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp, ext4_fsblk_t first_block, last_block, b; ext4_group_t i, ngroups = ext4_get_groups_count(sb); int s, j, count = 0; + int has_super = ext4_bg_has_super(sb, grp); if (!ext4_has_feature_bigalloc(sb)) - return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) + + return (has_super + ext4_bg_num_gdb(sb, grp) + + (has_super ? le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0) + sbi->s_itb_per_group + 2); first_block = le32_to_cpu(sbi->s_es->s_first_data_block) + -- 2.31.0