Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2296925imn; Mon, 1 Aug 2022 19:37:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sayVKulbWqCCDcV3x+CRBc+7QA9Ktoxcnq5y4deIIIpqLYQpwzTDOqfDUtMQEEgDZUhI/F X-Received: by 2002:a63:d055:0:b0:41b:539c:7125 with SMTP id s21-20020a63d055000000b0041b539c7125mr15049681pgi.461.1659407864554; Mon, 01 Aug 2022 19:37:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659407864; cv=none; d=google.com; s=arc-20160816; b=PUMisAh7EOLF94ieze5HwQlbdLnqlpxm3Kc4Lea0PVr0XF/0XdE7adeQqqWEG5Vlu3 NFTSOrnjXnidvyQl9sIbOep/nVnh//QyamqSvG5b3DhKRtpz0IUEoHJXRLoVW/rzKAxi HHz5kIb1MxaUNpcfiP+eT3VpdKAXWq0FbNQVR14JSfAnvpQg5URZuqBmPnq6xhDLXIsO 5IjWL/eSvp9Evi6qakmYnIkQAKOHokM7vnVSx/5hDQyVe8A5jxElN4lOFU1BSGSm0tK4 stqyP9EyKk5QH9EffHIFxefva5+vljrJgTeoX7IgRgJe5qgBFX6PC8QR2YaO9YGPGFbq Es2Q== 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 :message-id:date:subject:cc:to:from; bh=iJOb94CyAg88KBj/549ctD8B2YgAHGLzZDIEjEc7QzQ=; b=tgnd/meIs59Z8Eh1DrW8010126N8hSsk+bUUc+DYOW/jaeMttfOZmXSeXzbGLRdxUR u9QqM/XjsQHbnaZhykHbv4osN38B4mmxYsnoSqCRZaaAytO2joZvrPlfG+Hwgc53WSA0 PmVoMzvE5+Urgl7xRY4lwhUckVEpe5+/bcIr5KSL2sJ6jIQhGpSKoxkKTx31/lKVief0 /7ghwCHyE/KKvXUD2yNBHwdrGoWrBFF74rQZKEmL2HS1Ma90SGLb9m8g0jJu3OuFwB/f Meh/AZHukoFqv2FEUe0G60DigMX1VcEMlRmW7cbY/fR/zTuSjVtDHm/abcKZ6DwIq255 Ping== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a63f609000000b0041b022ba97csi13175439pgh.87.2022.08.01.19.37.04; Mon, 01 Aug 2022 19:37:44 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbiHBCLD (ORCPT + 99 others); Mon, 1 Aug 2022 22:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbiHBCLC (ORCPT ); Mon, 1 Aug 2022 22:11:02 -0400 Received: from out29-77.mail.aliyun.com (out29-77.mail.aliyun.com [115.124.29.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCC1B84E; Mon, 1 Aug 2022 19:10:51 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08153923|-1;BR=01201311R701S18rulernew998_84748_2000303;CH=blue;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00132903-2.06163e-05-0.99865;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047212;MF=michael@allwinnertech.com;NM=1;PH=DS;RN=5;RT=5;SR=0;TI=SMTPD_---.Ojh14Qc_1659406238; Received: from SunxiBot.allwinnertech.com(mailfrom:michael@allwinnertech.com fp:SMTPD_---.Ojh14Qc_1659406238) by smtp.aliyun-inc.com; Tue, 02 Aug 2022 10:10:39 +0800 From: Michael Wu To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, allwinner-opensource-support@allwinnertech.com Subject: [PATCH] ext4: fix error when itable blocks is greater than s_itb_per_group Date: Tue, 2 Aug 2022 10:10:29 +0800 Message-Id: <20220802021029.16046-1-michael@allwinnertech.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 following error occurs when mounting the ext4 image made by image making tool: "ext4_init_inode_table:1301:comm ext4lazyinit:Something is wrong with group 0: used itable blocks: 491; itable unused count: 0." Currently all the inodes in block group0 and ext4 image is divided by s_inodes_per_group. That leads to a hazard: we can't ensure all s_inodes_per_group are divisible by s_inodes_per_block. For example, when the s_inodes_per_group (equals to 7851) is divided by s_inodes_per_block (which is 16), because 7851 is undivisible by 16, we get the wrong result 490, while 491 is expected. So, we suggest that s_itb_per_group should equal to DIV_ROUND_UP(s_inodes_per_group, s_inodes_per_block) instead of directly getting the result from s_inodes_per_group/s_inodes_per_block. Signed-off-by: Michael Wu --- fs/ext4/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 845f2f8aee5f..76cbd638ea10 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4796,8 +4796,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sbi->s_inodes_per_group); goto failed_mount; } - sbi->s_itb_per_group = sbi->s_inodes_per_group / - sbi->s_inodes_per_block; + sbi->s_itb_per_group = DIV_ROUND_UP(sbi->s_inodes_per_group, + sbi->s_inodes_per_block); sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb); sbi->s_sbh = bh; sbi->s_mount_state = le16_to_cpu(es->s_state) & ~EXT4_FC_REPLAY; -- 2.29.0