Skip to contentSkip to conversation

Enable FLEX_BG support

PATCH In review Jose R. Santos 3 participants 11 messages Aug 3, 2007

lore
Share & tools
lore
#0 lore raw

cover Enable FLEX_BG support

The following series of patches add support creating and checking filesystems with the FLEX_BG feature. This feature currently groups meta-data from a series of groups at the beginning of a flex group in order to improve performance during heavy meta-data operations.

Some light testing on meta-data filesystem and fsck times already show some improvements.

This is still very experimental code I meant mostly as a prototype, but comments are welcome.

-JRS

#1 lore raw

PATCH 1/4 Reserve the INCOMPAT feature number for FLEX_BG.

From: Jose R. Santos <[email protected]>

Reserve the INCOMPAT feature number for FLEX_BG.

--

 lib/ext2fs/ext2_fs.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/ext2fs/ext2_fs.h +1 -0
index a316665..2394857 100644
@@ -640,6 +640,7 @@ struct ext2_super_block {
 #define EXT3_FEATURE_INCOMPAT_EXTENTS		0x0040
 #define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
 #define EXT4_FEATURE_INCOMPAT_MMP		0x0100
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
 
 
 #define EXT2_FEATURE_COMPAT_SUPP	0
#2 lore raw

PATCH 2/4 Allow FLEX_BG to be use as a feature option at mke2fs time.

In reply to Jose R. Santos

From: Jose R. Santos <[email protected]>

Allow FLEX_BG to be use as a feature option at mke2fs time.

--

 lib/e2p/feature.c   |    2 ++
 lib/ext2fs/ext2fs.h |    6 ++++--
 misc/mke2fs.c       |    3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)
lib/e2p/feature.c +2 -0
index fe7e65a..4bf5630 100644
@@ -67,6 +67,8 @@ static struct feature feature_list[] = {
 			"extent" },
 	{	E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_64BIT,
 			"64bit" },
+	{       E2P_FEATURE_INCOMPAT, EXT4_FEATURE_INCOMPAT_FLEX_BG,
+                        "flex_bg"},
 	{	0, 0, 0 },
 };
 
lib/ext2fs/ext2fs.h +4 -2
index 20c63c0..d1cda2f 100644
@@ -441,12 +441,14 @@ typedef struct ext2_icount *ext2_icount_t;
 					 EXT2_FEATURE_INCOMPAT_COMPRESSION|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
-					 EXT3_FEATURE_INCOMPAT_RECOVER)
+					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #else
 #define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
 					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
 					 EXT2_FEATURE_INCOMPAT_META_BG|\
-					 EXT3_FEATURE_INCOMPAT_RECOVER)
+					 EXT3_FEATURE_INCOMPAT_RECOVER|\
+					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
 #endif
 #define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE)
misc/mke2fs.c +2 -1
index 0c6d4f3..0af92e2 100644
@@ -873,7 +873,8 @@ static __u32 ok_features[3] = {
 		EXT2_FEATURE_COMPAT_LAZY_BG,	/* Compat */
 	EXT2_FEATURE_INCOMPAT_FILETYPE|		/* Incompat */
 		EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
-		EXT2_FEATURE_INCOMPAT_META_BG,
+		EXT2_FEATURE_INCOMPAT_META_BG|
+		EXT4_FEATURE_INCOMPAT_FLEX_BG,
 	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	/* R/O compat */
 };
 
#3 lore raw

PATCH 3/4 Relax group descriptor checking.

In reply to Jose R. Santos

From: Jose R. Santos <[email protected]>

Relax group descriptor checking.

In order for tools such as dump2efs, e2fsck and debugfs to open a ext4 filesystem with FLEX_BG feature enable, some descriptor checking needs to be relaxed. This patch changes the group desciptor checking so that bitmaps and inode tables can be located anywhere in the partitions block range.

Eventually, a more thorough check would restrict bitmaps and inode tables to be located at the beginning of a flex block group range. Since the super block does not currently know about the number of groups per flex group, this will do for now.

--

 e2fsck/super.c          |   10 ++++++++--
 lib/ext2fs/check_desc.c |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
e2fsck/super.c +8 -2
index 00a131c..8e58e5c 100644
@@ -578,8 +578,14 @@ void check_super_block(e2fsck_t ctx)
 	for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) {
 		pctx.group = i;
 
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super,
+			EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;
+		} else {
+			first_block = ext2fs_group_first_block(fs, i);
+			last_block = ext2fs_group_last_block(fs, i);
+		}
 
 		if ((gd->bg_block_bitmap < first_block) ||
 		    (gd->bg_block_bitmap > last_block)) {
lib/ext2fs/check_desc.c +8 -2
index 146f9e5..bb65c06 100644
@@ -38,8 +38,14 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
 	for (i = 0; i < fs->group_desc_count; i++) {
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;
+		}
+		else {
+			first_block = ext2fs_group_first_block(fs, i);
+			last_block = ext2fs_group_last_block(fs, i);
+		}
 
 		/*
 		 * Check to make sure block bitmap for group is
#4 lore raw

Re: [PATCH 3/4][e2fsprogs] Relax group descriptor checking.

Quoted 12 lines · Jose R. Santos

From: Jose R. Santos <[email protected]>

 e2fsck/super.c          |   10 ++++++++--
 lib/ext2fs/check_desc.c |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
e2fsck/super.c +0 -0
index 00a131c..8e58e5c 100644

e2fsck/super.c void check_super_block(e2fsck_t ctx) · line 584

Quoted 9 lines
e2fsck/super.c +4 -2
@@ -578,8 +578,14 @@ void check_super_block(e2fsck_t ctx)
 	for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) {
 		pctx.group = i;
 
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super,
+			EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;

I guess this should be fs->super->s_blocks_count - 1 ;

Quoted 12 lines
e2fsck/super.c +4 -0
+		} else {
+			first_block = ext2fs_group_first_block(fs, i);
+			last_block = ext2fs_group_last_block(fs, i);
+		}
 
 		if ((gd->bg_block_bitmap < first_block) ||
 		    (gd->bg_block_bitmap > last_block)) {
lib/ext2fs/check_desc.c +0 -0
index 146f9e5..bb65c06 100644

lib/ext2fs/check_desc.c errcode_t ext2fs_check_desc(ext2_filsys fs) · line 44

Quoted 9 lines
lib/ext2fs/check_desc.c +4 -2
@@ -38,8 +38,14 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
 	for (i = 0; i < fs->group_desc_count; i++) {
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;
+		

I guess this should be fs->super->s_blocks_count - 1 ;

-aneesh

#5 lore raw

Re: [PATCH 3/4][e2fsprogs] Relax group descriptor checking.

Quoted 16 lines · On Fri, 03 Aug 2007 10:54:04 +0530 "Aneesh Kumar K.V"…
Quoted 15 lines · Jose R. Santos

From: Jose R. Santos <[email protected]>

 e2fsck/super.c          |   10 ++++++++--
 lib/ext2fs/check_desc.c |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
e2fsck/super.c +0 -0
index 00a131c..8e58e5c 100644
@@ -578,8 +578,14 @@ void check_super_block(e2fsck_t ctx)
 	for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) {
 		pctx.group = i;
 
Quoted 9 lines

e2fsck/super.c void check_super_block(e2fsck_t ctx) · line 584

Quoted 6 lines
e2fsck/super.c +4 -2
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super,
+			EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;

I guess this should be fs->super->s_blocks_count - 1 ;

Updated.

Quoted 14 lines
Quoted 14 lines
e2fsck/super.c +4 -0
+		} else {
+			first_block = ext2fs_group_first_block(fs, i);
+			last_block = ext2fs_group_last_block(fs, i);
+		}
 
 		if ((gd->bg_block_bitmap < first_block) ||
 		    (gd->bg_block_bitmap > last_block)) {
lib/ext2fs/check_desc.c +0 -0
index 146f9e5..bb65c06 100644
@@ -38,8 +38,14 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
Quoted 9 lines

lib/ext2fs/check_desc.c errcode_t ext2fs_check_desc(ext2_filsys fs)

Quoted 7 lines
lib/ext2fs/check_desc.c +4 -2
 	for (i = 0; i < fs->group_desc_count; i++) {
-		first_block = ext2fs_group_first_block(fs, i);
-		last_block = ext2fs_group_last_block(fs, i);
+		if (EXT2_HAS_INCOMPAT_FEATURE (fs->super, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+			first_block = fs->super->s_first_data_block;
+			last_block = fs->super->s_blocks_count;
+		

I guess this should be fs->super->s_blocks_count - 1 ;

Updated.

Thanks

Quoted 1 line

-aneesh

-JRS

#6 lore raw

Re: [PATCH 3/4][e2fsprogs] Relax group descriptor checking.

In reply to Jose R. Santos
Quoted 4 lines · Jose R. Santos

Eventually, a more thorough check would restrict bitmaps and inode tables to be located at the beginning of a flex block group range. Since the super block does not currently know about the number of groups per flex group, this will do for now.

As with regular block groups, it would probably be better to limit the bitmaps and inode tables to anywhere inside the flexbg instead of the start. That would allow, for example, INCOMPAT_FLEXBG to be enabled on an existing filesystem and the metadata could be moved together as space becomes available.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

#7 lore raw

Re: [PATCH 3/4][e2fsprogs] Relax group descriptor checking.

Quoted 11 lines · On Fri, 3 Aug 2007 12:22:17 -0600 Andreas Dilger <[email protected]> wrote:
Quoted 4 lines · Jose R. Santos

Eventually, a more thorough check would restrict bitmaps and inode tables to be located at the beginning of a flex block group range. Since the super block does not currently know about the number of groups per flex group, this will do for now.

As with regular block groups, it would probably be better to limit the bitmaps and inode tables to anywhere inside the flexbg instead of the start. That would allow, for example, INCOMPAT_FLEXBG to be enabled on an existing filesystem and the metadata could be moved together as space becomes available.

This is something that would be simple to do if the ratio of block groups per flex group known to the filesystem itself. This implies adding another field to the super block as reliable way to obtain this information. The only thing keeping me from doing so is the uncertainty of backwards compatibility when changing the super block structure.

I agree though that one of the requirements for this feature is more robust checking of the location of the bitmaps and inode tables within the flex group. Checking of the descriptor in flexbg become a little more complicated than in regular block groups because:

1. The block and inode bitmaps should be allocated a one big chunk for each flex group.

2. The block and inode bitmaps should be located in the first block group and the inode tables with in the first few groups of a flex group.

3. If the full range of bitmaps in not allocated contiguously, this means that bad blocks caused us to move a particular bitmap out and thus the bad block list should be checked to ensure that this was the case.

If the above conditions are not met, this could point to possible corruption in the block descriptors.

Quoted 6 lines

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.

-JRS

#8 lore raw

PATCH 4/4 New bitmap and inode table allocation for FLEX_BG

In reply to Jose R. Santos

From: Jose R. Santos <[email protected]>

New bitmap and inode table allocation for FLEX_BG

Change the way we allocate bitmaps and inode tables if the FLEX_BG feature is used at mke2fs time. The block and inode bitmaps are allocated as a one contiguous set for each flex block group. Due to the size of the inode tables, the inode table for each block group is allocate individually but packed close together at the beginning of a flex group. For now, this allow for the inode table to be packed close to the inode bitmaps in cases where we try to allocate a large group of inode tables right after the bitmaps and fail.

--

 lib/ext2fs/alloc_tables.c |  138 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 134 insertions(+), 4 deletions(-)
lib/ext2fs/alloc_tables.c +134 -4
index 4ad2ba9..75252fa 100644
@@ -27,6 +27,130 @@
 #include "ext2_fs.h"
 #include "ext2fs.h"
 
+#define ALLOC_BLOCK_BITMAPS	1
+#define ALLOC_INODE_BITMAPS	2
+#define ALLOC_INODE_TABLES	3
+
+#define GROUPS_PER_FLEXBG	64
+#define FIRST_METADATA_GROUP	3
+
+errcode_t ext2fs_allocate_contiguous(ext2_filsys fs, dgrp_t group,
+				     int type, blk_t start_blk, blk_t last_blk, 
+				     int count, ext2fs_block_bitmap bmap)
+{
+	errcode_t	retval;
+	blk_t		new_blk, blk;
+	int		i, j;
+
+	if (!bmap)
+		bmap = fs->block_map;
+
+	switch (type) {
+	case ALLOC_BLOCK_BITMAPS:
+		retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+						1 * count, bmap, &new_blk);
+		if (retval)
+			return retval;
+		for (i=0, blk=new_blk; i < count; i++, blk++) {
+			ext2fs_mark_block_bitmap(bmap, blk);
+			fs->group_desc[group+i].bg_block_bitmap = blk;
+		}
+		break;
+
+	case ALLOC_INODE_BITMAPS:
+		retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+						1 * count, bmap, &new_blk);
+		if (retval)
+			return retval;
+		for (i=0, blk=new_blk; i < count; i++, blk++) {
+			ext2fs_mark_block_bitmap(bmap, blk);
+			fs->group_desc[group+i].bg_inode_bitmap = blk;
+		}
+		break;
+
+	case ALLOC_INODE_TABLES:
+		for (i=0, blk=new_blk; i < count; i++, blk++) {
+			retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+							fs->inode_blocks_per_group,
+							bmap, &new_blk);
+			if (retval)
+				return retval;
+			for (j=0, blk = new_blk;
+			     j < fs->inode_blocks_per_group; j++, blk++)
+				ext2fs_mark_block_bitmap(bmap, blk);
+			fs->group_desc[group+i].bg_inode_table = new_blk;
+		}
+		break;
+
+	}
+	return 0;
+}
+
+
+
+errcode_t ext2fs_allocate_flex_groups(ext2_filsys fs)
+{
+	errcode_t	retval;
+	blk_t		start, last, j, blocks;
+	dgrp_t		i, k;
+	int		gpm;
+
+	gpm = GROUPS_PER_FLEXBG;
+	blocks = 0;
+
+	for (i = 0; i < fs->group_desc_count; i=i+gpm) {
+		if (i == 0 )
+			start = ext2fs_group_first_block(fs,
+							 FIRST_METADATA_GROUP);
+		else
+			start = ext2fs_group_first_block(fs, i);
+
+		if (i+gpm-1 > fs->group_desc_count) {
+			last = ext2fs_group_last_block(fs, fs->group_desc_count);
+			gpm = fs->group_desc_count - i;
+		}
+		else
+			last = ext2fs_group_last_block(fs, i+gpm-1);
+
+		retval = ext2fs_allocate_contiguous(fs, i, ALLOC_BLOCK_BITMAPS,
+						    start, last, gpm,
+						    fs->block_map);
+		if (retval)
+			return retval;
+		retval = ext2fs_allocate_contiguous(fs, i, ALLOC_INODE_BITMAPS,
+						    start, last, gpm,
+						    fs->block_map);
+		if (retval)
+			return retval;
+		retval = ext2fs_allocate_contiguous(fs, i, ALLOC_INODE_TABLES,
+						    start, last, gpm,
+						    fs->block_map);
+		if (retval)
+			return retval;
+
+		/*
+		 * The content of bg_free_blocks_count is previously
+		 * assigned with out knowledge of the new allocation
+		 * scheme.  Need to update the number of free blocks
+		 * per group descriptor or fsck will complain.
+		 */
+
+		for (k=i; k<i+gpm; k++){
+			if (k > fs->group_desc_count)
+				break;
+			start = ext2fs_group_first_block(fs, k);
+			last = ext2fs_group_last_block(fs, k);
+			for (j=start; j<=last; j++) {
+				if( !ext2fs_fast_test_block_bitmap(fs->block_map, j))
+					blocks++;
+			}
+				fs->group_desc[k].bg_free_blocks_count = blocks;
+			blocks = 0;
+		}
+	}
+	return 0;
+}
+
 errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
 				      ext2fs_block_bitmap bmap)
 {
@@ -107,10 +231,16 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs)
 	errcode_t	retval;
 	dgrp_t		i;
 
-	for (i = 0; i < fs->group_desc_count; i++) {
-		retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
-		if (retval)
-			return retval;
+	if (EXT2_HAS_INCOMPAT_FEATURE (fs->super, 
+				       EXT4_FEATURE_INCOMPAT_FLEX_BG)) 
+		ext2fs_allocate_flex_groups(fs);
+	
+	else {
+		for (i = 0; i < fs->group_desc_count; i++) {
+			retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
+			if (retval)
+				return retval;
+		}
 	}
 	return 0;
 }
#9 lore raw

Re: [PATCH 4/4][e2fsprogs] New bitmap and inode table allocation for FLEX_BG

lib/ext2fs/alloc_tables.c line 72

Quoted 5 lines · Jose R. Santos

From: Jose R. Santos <[email protected]>

Ne

lib/ext2fs/alloc_tables.c +2 -0
+	case ALLOC_INODE_TABLES:
+		for (i=0, blk=new_blk; i < count; i++, blk++) {

I guess you can drop the blk update in the for() loop above.

Quoted 26 lines
lib/ext2fs/alloc_tables.c +26 -0
+			retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+							fs->inode_blocks_per_group,
+							bmap, &new_blk);
+			if (retval)
+				return retval;
+			for (j=0, blk = new_blk;
+			     j < fs->inode_blocks_per_group; j++, blk++)
+				ext2fs_mark_block_bitmap(bmap, blk);
+			fs->group_desc[group+i].bg_inode_table = new_blk;
+		}
+		break;
+
+	}
+	return 0;
+}
+
+
+
+errcode_t ext2fs_allocate_flex_groups(ext2_filsys fs)
+{
+	errcode_t	retval;
+	blk_t		start, last, j, blocks;
+	dgrp_t		i, k;
+	int		gpm;
+
+	gpm = GROUPS_PER_FLEXBG;

lib/ext2fs/alloc_tables.c line 108

Quoted 10 lines
lib/ext2fs/alloc_tables.c +10 -0
+	blocks = 0;
+
+	for (i = 0; i < fs->group_desc_count; i=i+gpm) {
+		if (i == 0 )
+			start = ext2fs_group_first_block(fs,
+							 FIRST_METADATA_GROUP);
+		else
+			start = ext2fs_group_first_block(fs, i);
+
+		if (i+gpm-1 > fs->group_desc_count) {
		if (i+gpm >= fs->group_desc_count) 

lib/ext2fs/alloc_tables.c line 111

Quoted 3 lines
lib/ext2fs/alloc_tables.c +3 -0
+			last = ext2fs_group_last_block(fs, fs->group_desc_count);
+			gpm = fs->group_desc_count - i;
+		}

-aneesh

#10 lore raw

Re: [PATCH 4/4][e2fsprogs] New bitmap and inode table allocation for FLEX_BG

Quoted 10 lines · On Fri, 03 Aug 2007 12:01:20 +0530 "Aneesh Kumar K.V"…

lib/ext2fs/alloc_tables.c line 72

Quoted 5 lines · Jose R. Santos

From: Jose R. Santos <[email protected]>

Ne

lib/ext2fs/alloc_tables.c +2 -0
+	case ALLOC_INODE_TABLES:
+		for (i=0, blk=new_blk; i < count; i++, blk++) {

I guess you can drop the blk update in the for() loop above.

This was from the remains of the very first attempt at inode table allocation. Thanks for catching.

Quoted 32 lines
Quoted 32 lines
lib/ext2fs/alloc_tables.c +31 -0
+			retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+							fs->inode_blocks_per_group,
+							bmap, &new_blk);
+			if (retval)
+				return retval;
+			for (j=0, blk = new_blk;
+			     j < fs->inode_blocks_per_group; j++, blk++)
+				ext2fs_mark_block_bitmap(bmap, blk);
+			fs->group_desc[group+i].bg_inode_table = new_blk;
+		}
+		break;
+
+	}
+	return 0;
+}
+
+
+
+errcode_t ext2fs_allocate_flex_groups(ext2_filsys fs)
+{
+	errcode_t	retval;
+	blk_t		start, last, j, blocks;
+	dgrp_t		i, k;
+	int		gpm;
+
+	gpm = GROUPS_PER_FLEXBG;
+	blocks = 0;
+
+	for (i = 0; i < fs->group_desc_count; i=i+gpm) {
+		if (i == 0 )
+			start = ext2fs_group_first_block(fs,
Quoted 8 lines

lib/ext2fs/alloc_tables.c line 108

Quoted 5 lines
lib/ext2fs/alloc_tables.c +5 -0
+							 FIRST_METADATA_GROUP);
+		else
+			start = ext2fs_group_first_block(fs, i);
+
+		if (i+gpm-1 > fs->group_desc_count) {
		if (i+gpm >= fs->group_desc_count) 

Update.

Quoted 7 lines

lib/ext2fs/alloc_tables.c line 111

Quoted 4 lines
lib/ext2fs/alloc_tables.c +3 -0
+			last = ext2fs_group_last_block(fs, fs->group_desc_count);
+			gpm = fs->group_desc_count - i;
+		}

-aneesh

Thanks

-JRS