[Ocfs2-tools-commits] smushran commits r457 - in
trunk/debugfs.ocfs2: . include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Dec 3 18:49:41 CST 2004
Author: smushran
Date: 2004-12-03 18:49:39 -0600 (Fri, 03 Dec 2004)
New Revision: 457
Modified:
trunk/debugfs.ocfs2/commands.c
trunk/debugfs.ocfs2/dump.c
trunk/debugfs.ocfs2/include/dump.h
Log:
redid the chain group dump layout in debugfs
Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c 2004-12-04 00:47:17 UTC (rev 456)
+++ trunk/debugfs.ocfs2/commands.c 2004-12-04 00:49:39 UTC (rev 457)
@@ -242,6 +242,52 @@
} /* traverse_extents */
/*
+ * traverse_chains()
+ *
+ */
+static int traverse_chains (ocfs2_filesys *fs, ocfs2_chain_list *cl, FILE *out)
+{
+ ocfs2_group_desc *grp;
+ ocfs2_chain_rec *rec;
+ errcode_t ret = 0;
+ char *buf = NULL;
+ uint64_t blkno;
+ int i;
+ int index;
+
+ dump_chain_list (out, cl);
+
+ ret = ocfs2_malloc_block(gbls.fs->fs_io, &buf);
+ if (ret) {
+ com_err(gbls.progname, ret, "while allocating a block");
+ goto bail;
+ }
+
+ for (i = 0; i < cl->cl_next_free_rec; ++i) {
+ rec = &(cl->cl_recs[i]);
+ blkno = rec->c_blkno;
+ index = 0;
+ fprintf(out, "\n");
+ while (blkno) {
+ ret = ocfs2_read_group_desc(fs, blkno, buf);
+ if (ret)
+ goto bail;
+
+ grp = (ocfs2_group_desc *)buf;
+ dump_group_descriptor(out, grp, index);
+ blkno = grp->bg_next_group;
+ index++;
+ }
+ }
+
+bail:
+ if (buf)
+ ocfs2_free(&buf);
+ return ret;
+} /* traverse_chains */
+
+
+/*
* do_open()
*
*/
@@ -581,7 +627,7 @@
if ((inode->i_flags & OCFS2_LOCAL_ALLOC_FL))
dump_local_alloc(out, &(inode->id2.i_lab));
else if ((inode->i_flags & OCFS2_CHAIN_FL))
- dump_chain_list(out, &(inode->id2.i_chain));
+ traverse_chains(gbls.fs, &(inode->id2.i_chain), out);
else
traverse_extents(gbls.fs, &(inode->id2.i_list), out);
@@ -737,11 +783,12 @@
*/
static void do_group (char **args)
{
- ocfs2_group_desc *bg;
+ ocfs2_group_desc *grp;
uint64_t blkno;
char *buf = NULL;
FILE *out;
errcode_t ret = 0;
+ int index = 0;
if (!gbls.fs) {
printf ("device not open\n");
@@ -753,19 +800,23 @@
goto bail;
buf = gbls.blockbuf;
- ret = ocfs2_read_group_desc(gbls.fs, blkno, buf);
- if (ret) {
- com_err(gbls.progname, ret,
- "while reading chain group in block %"PRIu64, blkno);
- goto bail;
- }
- bg = (ocfs2_group_desc *)buf;
+ out = open_pager();
+ while (blkno) {
+ ret = ocfs2_read_group_desc(gbls.fs, blkno, buf);
+ if (ret) {
+ com_err(gbls.progname, ret,
+ "while reading chain group in block %"PRIu64, blkno);
+ goto close;
+ }
- out = open_pager();
- dump_group_descriptor(out, bg);
+ grp = (ocfs2_group_desc *)buf;
+ dump_group_descriptor(out, grp, index);
+ blkno = grp->bg_next_group;
+ index++;
+ }
+close:
close_pager (out);
-
bail:
return ;
Modified: trunk/debugfs.ocfs2/dump.c
===================================================================
--- trunk/debugfs.ocfs2/dump.c 2004-12-04 00:47:17 UTC (rev 456)
+++ trunk/debugfs.ocfs2/dump.c 2004-12-04 00:49:39 UTC (rev 457)
@@ -175,7 +175,7 @@
tmp_str, in->i_suballoc_bit);
if (in->i_flags & OCFS2_BITMAP_FL)
- fprintf(out, "\tBitmap Total: %u Used: %u Clear: %u\n",
+ fprintf(out, "\tBitmap Total: %u Used: %u Free: %u\n",
in->id1.bitmap1.i_total, in->id1.bitmap1.i_used,
(in->id1.bitmap1.i_total - in->id1.bitmap1.i_used));
@@ -205,23 +205,23 @@
ocfs2_chain_rec *rec;
int i;
- fprintf(out, "\tClusters Per Group: %u Bits Per Cluster: %u\n",
+ fprintf(out, "\tClusters per Group: %u Bits per Cluster: %u\n",
cl->cl_cpg, cl->cl_bpc);
- fprintf(out, "\tCount: %u Next Free Record: %u\n",
+ fprintf(out, "\tCount: %u Next Free Rec: %u\n",
cl->cl_count, cl->cl_next_free_rec);
if (!cl->cl_next_free_rec)
goto bail;
+ fprintf(out, "\t## %-10s %-10s %-10s %s\n",
+ "Total", "Free", "Used", "Block#");
+
for (i = 0; i < cl->cl_next_free_rec; ++i) {
rec = &(cl->cl_recs[i]);
- fprintf(out, "\t## Bits Total Bits Free Disk Offset\n");
-
- fprintf(out, "\t%-2d %-11u %-12u %"PRIu64"\n", i, rec->c_total,
- rec->c_free, rec->c_blkno);
- traverse_chain(out, rec->c_blkno);
- fprintf(out, "\n");
+ fprintf(out, "\t%-2d %-10u %-10u %-10u %"PRIu64"\n",
+ i, rec->c_total, rec->c_free,
+ (rec->c_total - rec->c_free), rec->c_blkno);
}
bail:
@@ -239,7 +239,7 @@
if (!ext->l_next_free_rec)
goto bail;
- fprintf(out, "\t## File Offset Num Clusters Disk Offset\n");
+ fprintf(out, "\t## %-11s %-12s %-s\n", "Offset", "Clusters", "Block#");
for (i = 0; i < ext->l_next_free_rec; ++i) {
rec = &(ext->l_recs[i]);
@@ -267,66 +267,26 @@
} /* dump_extent_block */
/*
- * traverse_chain()
+ * dump_group_descriptor()
*
*/
-void traverse_chain(FILE *out, __u64 blkno)
+void dump_group_descriptor (FILE *out, ocfs2_group_desc *grp, int index)
{
- ocfs2_group_desc *bg;
- char *buf = NULL;
- errcode_t ret = 0;
-
- ret = ocfs2_malloc_block(gbls.fs->fs_io, &buf);
- if (ret) {
- com_err(gbls.progname, ret, "while allocating a block");
- goto bail;
+ if (!index) {
+ fprintf (out, "\tGroup Chain: %u Parent Inode: %"PRIu64" "
+ "Generation: %u\n",
+ grp->bg_chain,
+ grp->bg_parent_dinode,
+ grp->bg_generation);
+ fprintf(out, "\t## %-15s %-6s %-6s %-6s %-6s\n",
+ "Block#", "Total", "Free", "Used", "Size");
}
- do {
- ret = ocfs2_read_group_desc(gbls.fs, blkno, buf);
- if (ret) {
- com_err(gbls.progname, ret,
- "while reading chain group in block %"PRIu64, blkno);
- goto bail;
- }
+ fprintf(out, "\t%-2d %-15"PRIu64" %-6u %-6u %-6u %-6u\n",
+ index, grp->bg_blkno, grp->bg_bits, grp->bg_free_bits_count,
+ (grp->bg_bits - grp->bg_free_bits_count), grp->bg_size);
- bg = (ocfs2_group_desc *)buf;
-
- dump_group_descriptor(out, bg);
- blkno = bg->bg_next_group;
- } while (blkno);
-
-bail:
- if (buf)
- ocfs2_free(&buf);
-
return ;
-}
-
-/*
- * dump_group_descriptor()
- *
- */
-void dump_group_descriptor (FILE *out, ocfs2_group_desc *blk)
-{
-
- fprintf (out, "\tBlknum: %"PRIu64" Next Group %"PRIu64"\n",
- blk->bg_blkno,
- blk->bg_next_group);
-
- fprintf (out, "\tFree Bits Count: %u Group Bits: %u "
- "Group Size: %u\n",
- blk->bg_free_bits_count,
- blk->bg_bits,
- blk->bg_size);
-
- fprintf (out, "\tParent Chain: %u Parent Dinode: %"PRIu64" "
- "Generation: %u\n",
- blk->bg_chain,
- blk->bg_parent_dinode,
- blk->bg_generation);
-
- return ;
} /* dump_group_descriptor */
/*
Modified: trunk/debugfs.ocfs2/include/dump.h
===================================================================
--- trunk/debugfs.ocfs2/include/dump.h 2004-12-04 00:47:17 UTC (rev 456)
+++ trunk/debugfs.ocfs2/include/dump.h 2004-12-04 00:49:39 UTC (rev 457)
@@ -33,7 +33,7 @@
void dump_extent_list (FILE *out, ocfs2_extent_list *ext);
void dump_chain_list (FILE *out, ocfs2_chain_list *cl);
void dump_extent_block (FILE *out, ocfs2_extent_block *blk);
-void dump_group_descriptor (FILE *out, ocfs2_group_desc *blk);
+void dump_group_descriptor (FILE *out, ocfs2_group_desc *grp, int index);
int dump_dir_entry (struct ocfs2_dir_entry *rec, int offset, int blocksize,
char *buf, void *priv_data);
void dump_config (FILE *out, char *buf);
More information about the Ocfs2-tools-commits
mailing list