[Ocfs2-tools-devel] [PATCH 16/22] debugfs.ocfs2: Update group to show discontig block group.
Tao Ma
tao.ma at oracle.com
Wed Mar 31 21:41:20 PDT 2010
Update command 'group' so that it can show discontig
block group for us.
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
debugfs.ocfs2/commands.c | 19 ++++++++++++++-----
debugfs.ocfs2/dump.c | 8 ++++++--
debugfs.ocfs2/include/dump.h | 3 ++-
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index 2c33ab3..c4e1f0c 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -608,7 +608,7 @@ static errcode_t traverse_chains (ocfs2_filesys *fs, struct ocfs2_chain_list *cl
goto bail;
grp = (struct ocfs2_group_desc *)buf;
- dump_group_descriptor(out, grp, index);
+ dump_group_descriptor(out, grp, index, 0);
blkno = grp->bg_next_group;
index++;
}
@@ -847,7 +847,8 @@ static void do_help (char **args)
printf ("findpath <block#>\t\t\tList one pathname of the inode/lockname\n");
printf ("frag <filespec>\t\t\tShow inode extents / clusters ratio\n");
printf ("fs_locks [-f <file>] [-l] [-B]\t\t\tShow live fs locking state\n");
- printf ("group <block#>\t\t\t\tShow chain group\n");
+ printf ("group [-d] <block#>\t\t\t\tShow chain group -d "
+ "for discontig group\n");
printf ("hb\t\t\t\t\tShows the used heartbeat blocks\n");
printf ("help, ?\t\t\t\t\tThis information\n");
printf ("icheck block# ...\t\t\tDo block->inode translation\n");
@@ -1223,14 +1224,22 @@ static void do_group (char **args)
FILE *out;
errcode_t ret = 0;
int index = 0;
+ int ind = 0, discontig = 0;
- if (process_inodestr_args(args, 1, &blkno) != 1)
+ if (args[ind + 1]) {
+ if (!strcmp(args[ind + 1], "-d")) {
+ discontig = 1;
+ ++ind;
+ }
+ }
+
+ if (process_inodestr_args(&args[ind], 1, &blkno) != 1)
return ;
buf = gbls.blockbuf;
out = open_pager(gbls.interactive);
while (blkno) {
- ret = ocfs2_read_group_desc(gbls.fs, blkno, buf, 0);
+ ret = ocfs2_read_group_desc(gbls.fs, blkno, buf, discontig);
if (ret) {
com_err(args[0], ret, "while reading block group "
"descriptor %"PRIu64"", blkno);
@@ -1239,7 +1248,7 @@ static void do_group (char **args)
}
grp = (struct ocfs2_group_desc *)buf;
- dump_group_descriptor(out, grp, index);
+ dump_group_descriptor(out, grp, index, discontig);
blkno = grp->bg_next_group;
index++;
}
diff --git a/debugfs.ocfs2/dump.c b/debugfs.ocfs2/dump.c
index b2a0e55..0fa05d9 100644
--- a/debugfs.ocfs2/dump.c
+++ b/debugfs.ocfs2/dump.c
@@ -437,7 +437,7 @@ void dump_extent_block (FILE *out, struct ocfs2_extent_block *blk)
*
*/
void dump_group_descriptor (FILE *out, struct ocfs2_group_desc *grp,
- int index)
+ int index, int discontig)
{
int max_contig_free_bits = 0;
@@ -460,6 +460,9 @@ void dump_group_descriptor (FILE *out, struct ocfs2_group_desc *grp,
(grp->bg_bits - grp->bg_free_bits_count),
grp->bg_free_bits_count, max_contig_free_bits, grp->bg_size);
+ if (discontig && grp->bg_list.l_next_free_rec)
+ dump_extent_list(out, &grp->bg_list);
+
return ;
}
@@ -722,7 +725,8 @@ void dump_jbd_metadata (FILE *out, enum dump_block_type type, char *buf,
fprintf(out, "Group\n");
ocfs2_swap_group_desc(gbls.fs,
(struct ocfs2_group_desc *)buf, 0, 1);
- dump_group_descriptor (out, (struct ocfs2_group_desc *)buf, 0);
+ dump_group_descriptor(out, (struct ocfs2_group_desc *)buf,
+ 0, 0);
fprintf (out, "\n");
break;
case DUMP_BLOCK_DIR_BLOCK:
diff --git a/debugfs.ocfs2/include/dump.h b/debugfs.ocfs2/include/dump.h
index cb677c9..9e7e1d5 100644
--- a/debugfs.ocfs2/include/dump.h
+++ b/debugfs.ocfs2/include/dump.h
@@ -49,7 +49,8 @@ void dump_inode (FILE *out, struct ocfs2_dinode *in);
void dump_extent_list (FILE *out, struct ocfs2_extent_list *ext);
void dump_chain_list (FILE *out, struct ocfs2_chain_list *cl);
void dump_extent_block (FILE *out, struct ocfs2_extent_block *blk);
-void dump_group_descriptor (FILE *out, struct ocfs2_group_desc *grp, int index);
+void dump_group_descriptor(FILE *out, struct ocfs2_group_desc *grp,
+ int index, int discontig);
int dump_dir_entry (struct ocfs2_dir_entry *rec, int offset, int blocksize,
char *buf, void *priv_data);
void dump_dir_block(FILE *out, char *buf);
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list