Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4455544ioa; Wed, 27 Apr 2022 04:22:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4Xp+h7lD5aIbR15NySSLngeIbxD1wNizX2VkFuFtrOx3hRzz6OLrbita6Ev7SUVtQBJbX X-Received: by 2002:a17:90a:58f:b0:1ca:7a28:273f with SMTP id i15-20020a17090a058f00b001ca7a28273fmr32357523pji.62.1651058576592; Wed, 27 Apr 2022 04:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651058576; cv=none; d=google.com; s=arc-20160816; b=XIxjcHNI/1VXdRWmxj8X8z2sJmnWyzQtKuLqldGi5ZLb3ak7xfjM8nc3o2ODZY8IO4 IDcEK1rPhZ9VhUO6YXyGFpVARLwgklmJ8s+UZ/3gBvdZtW83n6B1GjZ4UKB/lJATIbZQ vZLPX0x1O35kULTc/MX1UGBdrJerrFyd66VvkDzVCj4p+214OKPYp5rSxbzKffHdRXd5 vlwpoXvvH0+7TJn64vsId/LKgWvqOoY9AqCvrLsU3iy8LHCIO/OlXWgtP/BtWQrxtKP4 NKULmqt05TRc+WOEusJd6hGTKRI5S+/7KmbjZNpPaQ4zaYWHpkXxoHMY4FgSGpiJKzZ7 r5wQ== 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=9AsCcbomYTcxNAQOZPZ9OYAkQeHpr/hMngBABBSBrfs=; b=IA9mp+pvna3Tn1eyVi3uAu7UsY30LOuNg7a8xnNGjQTEnX4FqEkG/AXrF+9N2NXNTN eDGzvkoZFYuQLefqaEVU4yQY79dL+bw+irAJfGFQ7gwpL3QiDv+wtYdbaklK2LnzOhX0 0MI6IFAiIhBnVjiG9hEvF+nfcd6vtTf8FxO7D6tUBDOTmSXmADKw1t+OeMQ6l/pYyw7K VhA6rEQ3XspO5a97TWa+R21m4HobmfWjTDgY9SdK787BQahE6w89yNpDraabte6Fa+PJ 0i/mEHJmk2hLMz3ZsKAflijdIMQDx2XhUbDcIbem72rn/jp4OdiMYTwKRBt5CxBM0wcX 6QTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nrS9RghN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d2-20020a633602000000b003ab97181f95si1133503pga.845.2022.04.27.04.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nrS9RghN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9215B33C5D0; Wed, 27 Apr 2022 03:16:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345591AbiDZImf (ORCPT + 99 others); Tue, 26 Apr 2022 04:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345539AbiDZIen (ORCPT ); Tue, 26 Apr 2022 04:34:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC3D78FE9; Tue, 26 Apr 2022 01:27:38 -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 167CC617AE; Tue, 26 Apr 2022 08:27:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CA9AC385A4; Tue, 26 Apr 2022 08:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961657; bh=rXwXAidvJq3nMv+8q5ENQBIe/PH5KIoFhtL2h7Zp24k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrS9RghNiCzeqdSiD3mZOwVeJgb+kSRzSoFYLUdqOrEzJm8YS3u1mNl1uhqBC/qEs Pfe2tdLfRsN12sSTrPhFifbfqbgLk1thM9GIut+sDgVjy6QdQoIXEK9O3NWt3FLi2Y ROfBeoB5O8X5272acS3i9SEtuAUfxnD3s9PJZWgY= 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 4.19 41/53] ext4: fix overhead calculation to account for the reserved gdt blocks Date: Tue, 26 Apr 2022 10:21:21 +0200 Message-Id: <20220426081736.852399741@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081735.651926456@linuxfoundation.org> References: <20220426081735.651926456@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=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 @@ -3440,9 +3440,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) +