[Ocfs2-tools-devel] [PATCH 02/22] libocfs2: Change ocfs2_group_bitmap_size.

Tao Ma tao.ma at oracle.com
Wed Mar 31 21:41:06 PDT 2010


Change ocfs2_group_bitmap_size to accept parameters
suballocator and support_discontig_bg, currently all
the callers use 0.
Some of them will be changed later.

Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
 debugfs.ocfs2/find_block_inode.c |    2 +-
 extras/compute_groups.c          |    2 +-
 fsck.ocfs2/pass0.c               |    4 +++-
 fswreck/chain.c                  |    2 +-
 fswreck/group.c                  |    2 +-
 include/ocfs2-kernel/ocfs2_fs.h  |   22 ++++++++++++++++------
 include/ocfs2/ocfs2.h            |    2 +-
 libocfs2/chainalloc.c            |    5 +++--
 mkfs.ocfs2/mkfs.c                |    5 +++--
 9 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/debugfs.ocfs2/find_block_inode.c b/debugfs.ocfs2/find_block_inode.c
index 293ce09..3ed8879 100644
--- a/debugfs.ocfs2/find_block_inode.c
+++ b/debugfs.ocfs2/find_block_inode.c
@@ -294,7 +294,7 @@ static void check_computed_blocks(ocfs2_filesys *fs, uint64_t gb_blkno,
 	if (*found >= count)
 		return;
 
-	cpg = ocfs2_group_bitmap_size(1 << fs->fs_blocksize) * 8;
+	cpg = ocfs2_group_bitmap_size(1 << fs->fs_blocksize, 0, 0) * 8;
 	bpg = ocfs2_clusters_to_blocks(fs, cpg);
 
 	for (i = 0; i < count; ++i) {
diff --git a/extras/compute_groups.c b/extras/compute_groups.c
index dd5b158..3dcfe34 100644
--- a/extras/compute_groups.c
+++ b/extras/compute_groups.c
@@ -62,7 +62,7 @@ int main (int argc, char **argv)
 	       "size %"PRIu64" bytes\n", max_size);
 
 	for (bs = 9; bs < 13; bs++) {
-		cpg = ocfs2_group_bitmap_size(1 << bs) * 8;
+		cpg = ocfs2_group_bitmap_size(1 << bs, 0, 0) * 8;
 		stringyfy((1 << bs), 'b', blkstr);
 		for (cs = 12; cs < 21; cs++) {
 			for (bytoff = 0, clsoff = 0; bytoff < max_size; ) {
diff --git a/fsck.ocfs2/pass0.c b/fsck.ocfs2/pass0.c
index a32bd18..35f5e41 100644
--- a/fsck.ocfs2/pass0.c
+++ b/fsck.ocfs2/pass0.c
@@ -991,7 +991,9 @@ static errcode_t verify_bitmap_descs(o2fsck_state *ost,
 		}
 
 		/* first some easy fields */
-		bg->bg_size = ocfs2_group_bitmap_size(ost->ost_fs->fs_blocksize);
+		bg->bg_size =
+			ocfs2_group_bitmap_size(ost->ost_fs->fs_blocksize,
+						0, 0);
 		bg->bg_bits = bits;
 		bg->bg_parent_dinode = di->i_blkno;
 		bg->bg_blkno = blkno;
diff --git a/fswreck/chain.c b/fswreck/chain.c
index 4a3c793..efe14e9 100644
--- a/fswreck/chain.c
+++ b/fswreck/chain.c
@@ -433,7 +433,7 @@ static void mess_up_superblock_clusters(ocfs2_filesys *fs, int excess)
 
 	di = (struct ocfs2_dinode *)buf;
 
-	cpg= 8 * ocfs2_group_bitmap_size(fs->fs_blocksize);
+	cpg = 8 * ocfs2_group_bitmap_size(fs->fs_blocksize, 0, 0);
 
 	/* make the wrong value to 2.5 times of cluster_per_group. */
 	wrong = cpg * 2 + cpg / 2;
diff --git a/fswreck/group.c b/fswreck/group.c
index aa0298c..6734f49 100644
--- a/fswreck/group.c
+++ b/fswreck/group.c
@@ -268,7 +268,7 @@ void mess_up_cluster_group_desc(ocfs2_filesys *fs, enum fsck_type type,
 		FSWRK_COM_FATAL(progname, ret);
 
 	start_cluster = ocfs2_blocks_to_clusters(fs, start_blk);
-	cpg = ocfs2_group_bitmap_size(fs->fs_blocksize) * 8;
+	cpg = ocfs2_group_bitmap_size(fs->fs_blocksize, 0, 0) * 8;
 	bg_blk = ocfs2_which_cluster_group(fs, cpg, start_cluster);
 
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index bca7e3b..89f9783 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -1266,12 +1266,17 @@ static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
 	return size;
 }
 
-static inline int ocfs2_group_bitmap_size(struct super_block *sb)
+static inline int ocfs2_group_bitmap_size(struct super_block *sb,
+					  int suballocator,
+					  int support_discontig_bg)
 {
 	int size;
 
-	size = sb->s_blocksize -
-		offsetof(struct ocfs2_group_desc, bg_bitmap);
+	if (suballocator && support_discontig_bg)
+		size = OCFS2_MAX_BG_BITMAP_SIZE;
+	else
+		size = sb->s_blocksize -
+			offsetof(struct ocfs2_group_desc, bg_bitmap);
 
 	return size;
 }
@@ -1395,12 +1400,17 @@ static inline int ocfs2_local_alloc_size(int blocksize)
 	return size;
 }
 
-static inline int ocfs2_group_bitmap_size(int blocksize)
+static inline int ocfs2_group_bitmap_size(int blocksize,
+					  int suballocator,
+					  int support_discontig_bg)
 {
 	int size;
 
-	size = blocksize -
-		offsetof(struct ocfs2_group_desc, bg_bitmap);
+	if (suballocator && support_discontig_bg)
+		size = OCFS2_MAX_BG_BITMAP_SIZE;
+	else
+		size = blocksize -
+			offsetof(struct ocfs2_group_desc, bg_bitmap);
 
 	return size;
 }
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index a0983f8..658bb04 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -1113,7 +1113,7 @@ static inline void ocfs2_calc_cluster_groups(uint64_t clusters,
 					     uint64_t blocksize,
 				     struct ocfs2_cluster_group_sizes *cgs)
 {
-	uint16_t max_bits = 8 * ocfs2_group_bitmap_size(blocksize);
+	uint16_t max_bits = 8 * ocfs2_group_bitmap_size(blocksize, 0, 0);
 
 	cgs->cgs_cpg = max_bits;
 	if (max_bits > clusters)
diff --git a/libocfs2/chainalloc.c b/libocfs2/chainalloc.c
index 4287f69..fb2b99e 100644
--- a/libocfs2/chainalloc.c
+++ b/libocfs2/chainalloc.c
@@ -109,7 +109,8 @@ static int chainalloc_process_group(ocfs2_filesys *fs,
 	cr->cr_ag = (struct ocfs2_group_desc *)gd_buf;
 
 	cb->cb_errcode = OCFS2_ET_CORRUPT_GROUP_DESC;
-	if (cr->cr_ag->bg_size != ocfs2_group_bitmap_size(fs->fs_blocksize))
+	if (cr->cr_ag->bg_size != ocfs2_group_bitmap_size(fs->fs_blocksize,
+							  0, 0))
 		goto out_free_cr;
 
 	if (gd_blkno == OCFS2_RAW_SB(fs->fs_super)->s_first_cluster_group)
@@ -487,7 +488,7 @@ void ocfs2_init_group_desc(ocfs2_filesys *fs,
 
 	strcpy((char *)gd->bg_signature, OCFS2_GROUP_DESC_SIGNATURE);
 	gd->bg_generation = generation;
-	gd->bg_size = ocfs2_group_bitmap_size(fs->fs_blocksize);
+	gd->bg_size = ocfs2_group_bitmap_size(fs->fs_blocksize, 0, 0);
 	gd->bg_bits = bits;
 	gd->bg_chain = chain;
 	gd->bg_parent_dinode = parent_inode;
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 5d01e3e..240056e 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -1692,7 +1692,8 @@ initialize_alloc_group(State *s, const char *name,
 
 	strcpy((char *)group->gd->bg_signature, OCFS2_GROUP_DESC_SIGNATURE);
 	group->gd->bg_generation = s->vol_generation;
-	group->gd->bg_size = (uint32_t)ocfs2_group_bitmap_size(s->blocksize);
+	group->gd->bg_size =
+			(uint32_t)ocfs2_group_bitmap_size(s->blocksize, 0, 0);
 	group->gd->bg_bits = cpg * bpc;
 	group->gd->bg_chain = chain;
 	group->gd->bg_parent_dinode = alloc_inode->fe_off >> 
@@ -2338,7 +2339,7 @@ format_file(State *s, SystemFileDiskRecord *rec)
 		di->id2.i_chain.cl_count = 
 			ocfs2_chain_recs_per_inode(s->blocksize);
 		di->id2.i_chain.cl_cpg =
-				 ocfs2_group_bitmap_size(s->blocksize) * 8;
+			 ocfs2_group_bitmap_size(s->blocksize, 0, 0) * 8;
 		di->id2.i_chain.cl_bpc = 1;
 		if (s->nr_cluster_groups > 
 		    ocfs2_chain_recs_per_inode(s->blocksize)) {
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list