Skip to contentSkip to conversation

flexbg metadata offset

PATCH Celine Bourde 1 participant 1 message Apr 23, 2008

lore
Share & tools
lore
#0 lore raw

There is a problem on offset metadata. In all flexbg groups the block between the last block bitmap and the first inode bitmap is not used, which introduces a hole.

This patch changes this. It corrects the offset of flexbg metadata, specifically at the end of the disk, if the number of groups isn't a multiple of the -G option argument.

Céline Bourde.

lib/ext2fs/alloc_tables.c +9 -4
diff -r -u a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
@@ -84,7 +84,7 @@
 	errcode_t	retval;
 	blk_t		group_blk, start_blk, last_blk, new_blk, blk;
 	dgrp_t		last_grp;
-	int		j, rem_grps, flexbg_size = 0;
+	int		j, rem_grps, flexbg_size = 0, last_flexbg_size = 0;
 
 	group_blk = ext2fs_group_first_block(fs, group);
 	last_blk = ext2fs_group_last_block(fs, group);
@@ -96,10 +96,14 @@
 				      EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
 	    fs->super->s_log_groups_per_flex) {
 		flexbg_size = 1 << fs->super->s_log_groups_per_flex;
+		last_flexbg_size = fs->group_desc_count -
+				((group / flexbg_size) * flexbg_size);
 		last_grp = group | (flexbg_size - 1);
-		rem_grps = last_grp - group;
 		if (last_grp > fs->group_desc_count)
 			last_grp = fs->group_desc_count;
+		if (last_flexbg_size > flexbg_size)
+			last_flexbg_size = flexbg_size;
+		rem_grps = last_grp - group;
 	}
 	
 	/*
@@ -151,7 +155,8 @@
 		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);
+						 last_flexbg_size - 1,
+						 rem_grps);
 		last_blk = ext2fs_group_last_block(fs, last_grp);
 	}
 
@@ -182,7 +187,7 @@
 		if (group && fs->group_desc[group-1].bg_inode_table)
 			prev_block = fs->group_desc[group-1].bg_inode_table;
 		group_blk = flexbg_offset(fs, group, prev_block, bmap,
-						 flexbg_size * 2,
+						 last_flexbg_size * 2 - 1,
 						 fs->inode_blocks_per_group *
 						 rem_grps);
 		last_blk = ext2fs_group_last_block(fs, last_grp);

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html