From patchwork Mon May 9 15:38:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 94780 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 21DDDB6F3E for ; Tue, 10 May 2011 01:45:40 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150Ab1EIPpj (ORCPT ); Mon, 9 May 2011 11:45:39 -0400 Received: from oproxy8-pub.bluehost.com ([69.89.22.20]:37972 "HELO oproxy8-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752105Ab1EIPpi (ORCPT ); Mon, 9 May 2011 11:45:38 -0400 X-Greylist: delayed 399 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 May 2011 11:45:38 EDT Received: (qmail 22394 invoked by uid 0); 9 May 2011 15:38:58 -0000 Received: from unknown (HELO box585.bluehost.com) (66.147.242.185) by oproxy2.bluehost.com with SMTP; 9 May 2011 15:38:58 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=tao.ma; h=Received:From:To:Subject:Date:Message-Id:X-Mailer:X-Identified-User; b=Uw9eF49LzV59GkNtLXLnOrsRIRNiKfW7QFKT+aS075qNEMUfNdmIdr6bCvJkkaGnlM4yKd6NatEpsAdCyYOdruGZIU2dk4u9L+flGJtIBu9lJpUDuIHjsqi8mlLSJJOw; Received: from [114.251.86.0] (helo=taoma-linux.taobao.ali.com) by box585.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1QJSXx-0004uL-0Q for linux-ext4@vger.kernel.org; Mon, 09 May 2011 09:38:58 -0600 From: Tao Ma To: linux-ext4@vger.kernel.org Subject: [PATCH] mke2fs: Make s_inodes_per_group >= 8 in ext2fs_initialize. Date: Mon, 9 May 2011 23:38:42 +0800 Message-Id: <1304955522-4148-1-git-send-email-tm@tao.ma> X-Mailer: git-send-email 1.7.1 X-Identified-User: {1390:box585.bluehost.com:colyli:tao.ma} {sentby:smtp auth 114.251.86.0 authed with tm@tao.ma} Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Tao Ma current mkfs.ext4 fails if we tried with the following parameters. mkfs.ext4 -m 0 -N 16 -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg -b 1024 /dev/sdb3 It will cause segfault, but it is caused by another issue. See my patch "mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap". And with that patch, the mkfs.ext4 will fail with the error: /dev/sdb3: Memory allocation failed while setting up superblock The reason is that in ext2fs_initialize, we align s_inodes_per_group to 8, but fails to consider the case that s_inodes_per_group < 8. So make at least 8 inodes for s_inodes_per_group. Signed-off-by: Tao Ma --- lib/ext2fs/initialize.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index e1f229b..4706773 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -282,6 +282,8 @@ ipg_retry: * multiple of 8. This is needed to simplify the bitmap * splicing code. */ + if (super->s_inodes_per_group < 8) + super->s_inodes_per_group = 8; super->s_inodes_per_group &= ~7; fs->inode_blocks_per_group = (((super->s_inodes_per_group * EXT2_INODE_SIZE(super)) +