linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mke2fs: Make s_inodes_per_group >= 8 in ext2fs_initialize.
@ 2011-05-09 15:38 Tao Ma
  2011-05-15  3:28 ` Ted Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Tao Ma @ 2011-05-09 15:38 UTC (permalink / raw)
  To: linux-ext4

From: Tao Ma <boyu.mt@taobao.com>

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 <boyu.mt@taobao.com>
---
 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)) +
-- 
1.6.3.GIT


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mke2fs: Make s_inodes_per_group >= 8 in ext2fs_initialize.
  2011-05-09 15:38 [PATCH] mke2fs: Make s_inodes_per_group >= 8 in ext2fs_initialize Tao Ma
@ 2011-05-15  3:28 ` Ted Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2011-05-15  3:28 UTC (permalink / raw)
  To: Tao Ma; +Cc: linux-ext4

On Mon, May 09, 2011 at 11:38:42PM +0800, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
> 
> 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 <boyu.mt@taobao.com>

Thanks, I've added this to the "next" branch of e2fsprogs.

	     	   	       	      - Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-15  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 15:38 [PATCH] mke2fs: Make s_inodes_per_group >= 8 in ext2fs_initialize Tao Ma
2011-05-15  3:28 ` Ted Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).