Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3424818ioa; Tue, 26 Apr 2022 03:30:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvBkhibItAJEXAktGUt5NWKjU3ZQM345t5c8QvizK5kYOfyrhea4Lmaq1xMB4tAnaawLgI X-Received: by 2002:a17:907:3f91:b0:6d7:16c0:ae1b with SMTP id hr17-20020a1709073f9100b006d716c0ae1bmr20508150ejc.74.1650969013707; Tue, 26 Apr 2022 03:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650969013; cv=none; d=google.com; s=arc-20160816; b=v9/x21WU8LCK+rTln8qGVX3p+AUOQrRema006YxWf0HHth25ulgVu/QH4ggtItiuw2 rKpcve7R4sIhHY4+f0tHzYIRHa6L6x1PihYDqA4ZSvpS7wbX06dfiycefXHssDpAw2C9 NeLp77cwVi+iCizOgD4m8isbt2JlA+RlqGWlcV3KEPoD5Zw67yh/FK20JnLLYnOBMnw6 mHft+WOZ28W8fhwlrSl+zKQvAL7+WEdG7oCZ1OCYPyPJ90ynGhROdjPICHDV1Bl4w/XI Nb7WyNRhT1mZyyYXzNZ1XmJvr3qg9rxBZgNN4lrfp6XpOneTxR9tNHtsmaEmhZ1CP/zm AkGA== 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=EWDgUSh/TVSNKhOr+reITHbK6qxDUnb18orMxwfjEVY=; b=wjt2KVODatmMDHC/ah3RB3Hl8H2rQDb6yPO15zSo3neCVnel7oDFly2ns+RqQwIRc+ vNM9Cs0i7sJJsIqFmJm6mdN1upjomizY/4WoE5l47M2pDMv1dogi1BwupE/SUOp7q3vE e8eAka9jLUNEUtJSZnCmPR1uXYIvcW0lm5SRg8WqNMSa2QivCiaUWcI5q7+vkyVqlw1V aP+RN2lru82Uf83wmCRHiwWLiFSjwnmapVX46oblfxu9HM1i10HWi3DIhZVM8ahMyXob P6Hyux47BGmeTQ7rbMdst6TnUhJPOjAUXYR2CH31M45HuNfnBoD80T/NSVxpDmb9TCQi Ohtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xIri91Se; 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 hc11-20020a170907168b00b006e89d0c88d9si18749960ejc.633.2022.04.26.03.29.49; Tue, 26 Apr 2022 03:30:13 -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=xIri91Se; 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 S244081AbiDZJUz (ORCPT + 99 others); Tue, 26 Apr 2022 05:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345571AbiDZI5Q (ORCPT ); Tue, 26 Apr 2022 04:57:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE0583B23; Tue, 26 Apr 2022 01:41:50 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 25077604F5; Tue, 26 Apr 2022 08:41:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C1B0C385A0; Tue, 26 Apr 2022 08:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962509; bh=GTArJCbJt/PH4MavpqXS9m5Og/sdJEC9E8m9WgSVba4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xIri91SeQpF9slsLak5nzixTbGRDQq57AK3o13MuGZK3ENaVYAXzSaehXHh14zZlm C39wRDE4b16/nQSYF/Ly67VrRb4jxkhFXIVnVAuCL7+LnlRGUj5Ajy7oZsfH8Q/c97 Jmqepx4E0yYQNSh3LSIB4NedeR72s8vXB6GbfRXU= 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 118/124] ext4: fix overhead calculation to account for the reserved gdt blocks Date: Tue, 26 Apr 2022 10:21:59 +0200 Message-Id: <20220426081750.644197809@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 10b01ee92df52c8d7200afead4d5e5f55a5c58b1 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3697,9 +3697,11 @@ static int count_overhead(struct super_b 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) +