public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Bohé" <frederic.bohe@bull.net>
To: linux-ext4 <linux-ext4@vger.kernel.org>
Subject: [PATCH][e2fsprogs] Fix inode table allocation with flexbg
Date: Thu, 17 Jul 2008 13:34:41 +0200	[thread overview]
Message-ID: <1216294481.3136.18.camel@localhost> (raw)
In-Reply-To: 20080701084357.819339274@bull.net

From: Frederic Bohe <frederic.bohe@bull.net>

Disordered inode tables may appear when inode_blocks_per_group is lesser
or equal to the number of groups in a flex group.

Signed-off-by: Frederic Bohe <frederic.bohe@bull.net>
---
This bug can be reproduced with:
 mkfs.ext4 -t ext4dev -G512 70G

In that case, you can see with dump2fs that inode tables for groups 510
and 511 are placed just after group 51's inode table instead of being 
placed after group 509's inode table.

 alloc_tables.c |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Index: e2fsprogs/lib/ext2fs/alloc_tables.c
===================================================================
--- e2fsprogs.orig/lib/ext2fs/alloc_tables.c	2008-07-17 10:33:56.000000000 +0200
+++ e2fsprogs/lib/ext2fs/alloc_tables.c	2008-07-17 10:46:49.000000000 +0200
@@ -34,9 +34,10 @@
  * tables can be allocated continously and in order.
  */
 static blk_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk_t start_blk,
-			   ext2fs_block_bitmap bmap, int offset, int size)
+			   ext2fs_block_bitmap bmap, int offset, int size,
+			   int elem_size)
 {
-	int		flexbg, flexbg_size, elem_size;
+	int		flexbg, flexbg_size;
 	blk_t		last_blk, first_free = 0;
 	dgrp_t	       	last_grp;
 
@@ -54,10 +55,6 @@ static blk_t flexbg_offset(ext2_filsys f
 	 * search is still valid.
 	 */
 	if (start_blk && group % flexbg_size) {
-		if (size > flexbg_size)
-			elem_size = fs->inode_blocks_per_group;
-		else
-			elem_size = 1;
 		if (ext2fs_test_block_bitmap_range(bmap, start_blk + elem_size,
 						   size))
 			return start_blk + elem_size;
@@ -126,7 +123,7 @@ errcode_t ext2fs_allocate_group_table(ex
 		if (group && fs->group_desc[group-1].bg_block_bitmap)
 			prev_block = fs->group_desc[group-1].bg_block_bitmap;
 		start_blk = flexbg_offset(fs, group, prev_block, bmap,
-						 0, rem_grps);
+						 0, rem_grps, 1);
 		last_blk = ext2fs_group_last_block(fs, last_grp);
 	}
 
@@ -154,7 +151,7 @@ errcode_t ext2fs_allocate_group_table(ex
 		if (group && fs->group_desc[group-1].bg_inode_bitmap)
 			prev_block = fs->group_desc[group-1].bg_inode_bitmap;
 		start_blk = flexbg_offset(fs, group, prev_block, bmap,
-						 flexbg_size, rem_grps);
+						 flexbg_size, rem_grps, 1);
 		last_blk = ext2fs_group_last_block(fs, last_grp);
 	}
 
@@ -187,7 +184,8 @@ errcode_t ext2fs_allocate_group_table(ex
 		group_blk = flexbg_offset(fs, group, prev_block, bmap,
 						 flexbg_size * 2,
 						 fs->inode_blocks_per_group *
-						 rem_grps);
+						 rem_grps,
+						 fs->inode_blocks_per_group);
 		last_blk = ext2fs_group_last_block(fs, last_grp);
 	}

-- 


  parent reply	other threads:[~2008-07-17  9:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080701084357.819339274@bull.net>
2008-07-01  9:17 ` [PATCH v2] ext4: fix online resize with mballoc Frédéric Bohé
2008-07-17 11:34 ` Frédéric Bohé [this message]
2008-07-17 13:47   ` [PATCH][e2fsprogs] Fix inode table allocation with flexbg Jose R. Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1216294481.3136.18.camel@localhost \
    --to=frederic.bohe@bull.net \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox