[Ocfs2-tools-devel] [PATCH 17/22] debugfs.ocfs2: Make chain iteration notice suballoc file.

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


Add a new paramter named gb_blkno in dbgfs_gbls which shows
the blkno for the global bitmap. With this, we can tell
ocfs2_read_group_desc whether it will read a suballocator
or not.

Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
 debugfs.ocfs2/commands.c         |   21 +++++++++++++++++----
 debugfs.ocfs2/find_block_inode.c |    6 +++++-
 debugfs.ocfs2/include/main.h     |    1 +
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index c4e1f0c..781a1ed 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -581,7 +581,10 @@ bail:
  * traverse_chains()
  *
  */
-static errcode_t traverse_chains (ocfs2_filesys *fs, struct ocfs2_chain_list *cl, FILE *out)
+static errcode_t traverse_chains(ocfs2_filesys *fs,
+				 struct ocfs2_chain_list *cl,
+				 FILE *out,
+				 int suballocator)
 {
 	struct ocfs2_group_desc *grp;
 	struct ocfs2_chain_rec *rec;
@@ -603,12 +606,13 @@ static errcode_t traverse_chains (ocfs2_filesys *fs, struct ocfs2_chain_list *cl
 		index = 0;
 		fprintf(out, "\n");
 		while (blkno) {
-			ret = ocfs2_read_group_desc(fs, blkno, buf, 0);
+			ret = ocfs2_read_group_desc(fs, blkno, buf,
+						    suballocator);
 			if (ret)
 				goto bail;
 
 			grp = (struct ocfs2_group_desc *)buf;
-			dump_group_descriptor(out, grp, index, 0);
+			dump_group_descriptor(out, grp, index, suballocator);
 			blkno = grp->bg_next_group;
 			index++;
 		}
@@ -704,6 +708,14 @@ static void do_open (char **args)
 			gbls.jrnl_blkno[i] = 0;
 	}
 
+	/* lookup global_bitmap file */
+	snprintf(sysfile, sizeof(sysfile),
+		 ocfs2_system_inodes[GLOBAL_BITMAP_SYSTEM_INODE].si_name);
+	ret = ocfs2_lookup(gbls.fs, gbls.sysdir_blkno, sysfile,
+			   strlen(sysfile), NULL, &gbls.gb_blkno);
+	if (ret)
+		gbls.gb_blkno = 0;
+
 	return ;
 	
 }
@@ -1049,7 +1061,8 @@ static void do_stat (char **args)
 	if ((inode->i_flags & OCFS2_LOCAL_ALLOC_FL))
 		dump_local_alloc(out, &(inode->id2.i_lab));
 	else if ((inode->i_flags & OCFS2_CHAIN_FL))
-		ret = traverse_chains(gbls.fs, &(inode->id2.i_chain), out);
+		ret = traverse_chains(gbls.fs, &(inode->id2.i_chain), out,
+				      inode->i_blkno != gbls.gb_blkno);
 	else if (S_ISLNK(inode->i_mode) && !inode->i_clusters)
 		dump_fast_symlink(out, (char *)inode->id2.i_symlink);
 	else if (inode->i_flags & OCFS2_DEALLOC_FL)
diff --git a/debugfs.ocfs2/find_block_inode.c b/debugfs.ocfs2/find_block_inode.c
index a90488c..514841b 100644
--- a/debugfs.ocfs2/find_block_inode.c
+++ b/debugfs.ocfs2/find_block_inode.c
@@ -129,6 +129,7 @@ struct walk_it {
 	uint64_t inode;
 	int count;
 	int found;
+	int suballocator;
 };
 
 static int walk_chain_func(ocfs2_filesys *fs, uint64_t blkno, int chain,
@@ -139,7 +140,7 @@ static int walk_chain_func(ocfs2_filesys *fs, uint64_t blkno, int chain,
 	int i;
 	errcode_t ret;
 
-	ret = ocfs2_read_group_desc(fs, blkno, wi->buf, 0);
+	ret = ocfs2_read_group_desc(fs, blkno, wi->buf, wi->suballocator);
 	if (ret) {
 		com_err(gbls.cmd, ret, "while reading group %"PRIu64, blkno);
 		return ret;
@@ -176,6 +177,9 @@ static errcode_t lookup_chain(ocfs2_filesys *fs, struct ocfs2_dinode *di,
 	wi.inode = di->i_blkno;
 	wi.count = count;
 	wi.found = *found;
+	/* This function is only called for every suballocator,
+	 * see the caller. */
+	wi.suballocator = 1;
 
 	ret = ocfs2_malloc_block(fs->fs_io, &wi.buf);
 	if (ret) {
diff --git a/debugfs.ocfs2/include/main.h b/debugfs.ocfs2/include/main.h
index 3df01d4..7dd6b93 100644
--- a/debugfs.ocfs2/include/main.h
+++ b/debugfs.ocfs2/include/main.h
@@ -83,6 +83,7 @@ typedef struct _dbgfs_glbs {
 	uint64_t sysdir_blkno;
 	uint64_t hb_blkno;
 	uint64_t slotmap_blkno;
+	uint64_t gb_blkno;
 	uint64_t jrnl_blkno[256];
 } dbgfs_gbls;
 
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list