[Ocfs2-tools-commits] smushran commits r1214 - in trunk/debugfs.ocfs2: . include

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Wed Jul 19 12:28:18 CDT 2006


Author: smushran
Signed-off-by: mfasheh
Date: 2006-07-19 12:28:17 -0500 (Wed, 19 Jul 2006)
New Revision: 1214

Modified:
   trunk/debugfs.ocfs2/dump.c
   trunk/debugfs.ocfs2/include/utils.h
   trunk/debugfs.ocfs2/utils.c
Log:
debugfs - shows max contig free bits in group descs
Signed-Off-by: mfasheh

Modified: trunk/debugfs.ocfs2/dump.c
===================================================================
--- trunk/debugfs.ocfs2/dump.c	2006-07-13 17:37:41 UTC (rev 1213)
+++ trunk/debugfs.ocfs2/dump.c	2006-07-19 17:28:17 UTC (rev 1214)
@@ -254,13 +254,13 @@
 		goto bail;
 
 	fprintf(out, "\t##   %-10s   %-10s   %-10s   %s\n",
-		"Total", "Free", "Used", "Block#");
+		"Total", "Used", "Free", "Block#");
 	
 	for (i = 0; i < cl->cl_next_free_rec; ++i) {
 		rec = &(cl->cl_recs[i]);
 		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);
+			i, rec->c_total, (rec->c_total - rec->c_free),
+			rec->c_free, rec->c_blkno);
 	}
 
 bail:
@@ -312,20 +312,25 @@
 void dump_group_descriptor (FILE *out, struct ocfs2_group_desc *grp,
                             int index)
 {
+	int max_contig_free_bits = 0;
+
 	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");
+		fprintf(out, "\t##   %-15s   %-6s   %-6s   %-6s   %-6s   %-6s\n",
+			"Block#", "Total", "Used", "Free", "Contig", "Size");
 	}
 
-	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);
+	find_max_contig_free_bits(grp, &max_contig_free_bits);
 
+	fprintf(out, "\t%-2d   %-15"PRIu64"   %-6u   %-6u   %-6u   %-6u   %-6u\n",
+		index, grp->bg_blkno, grp->bg_bits,
+		(grp->bg_bits - grp->bg_free_bits_count),
+		grp->bg_free_bits_count, max_contig_free_bits, grp->bg_size);
+
 	return ;
 }
 

Modified: trunk/debugfs.ocfs2/include/utils.h
===================================================================
--- trunk/debugfs.ocfs2/include/utils.h	2006-07-13 17:37:41 UTC (rev 1213)
+++ trunk/debugfs.ocfs2/include/utils.h	2006-07-19 17:28:17 UTC (rev 1214)
@@ -51,5 +51,6 @@
 errcode_t rdump_inode(ocfs2_filesys *fs, uint64_t blkno, const char *name,
 		      const char *dumproot, int verbose);
 void crunch_strsplit(char **args);
+void find_max_contig_free_bits(struct ocfs2_group_desc *gd, int *max_contig_free_bits);
 
 #endif		/* __UTILS_H__ */

Modified: trunk/debugfs.ocfs2/utils.c
===================================================================
--- trunk/debugfs.ocfs2/utils.c	2006-07-13 17:37:41 UTC (rev 1213)
+++ trunk/debugfs.ocfs2/utils.c	2006-07-19 17:28:17 UTC (rev 1214)
@@ -24,6 +24,7 @@
  */
 
 #include <main.h>
+#include <bitops.h>
 
 /*
  * get_vote_flag()
@@ -724,3 +725,27 @@
 
 	return ;
 }
+
+/*
+ * find_max_contig_free_bits()
+ *
+ */
+void find_max_contig_free_bits(struct ocfs2_group_desc *gd, int *max_contig_free_bits)
+{
+	int end = 0;
+	int start;
+	int free_bits;
+
+	*max_contig_free_bits = 0;
+
+	while (end < gd->bg_bits) {
+		start = ocfs2_find_next_bit_clear(gd->bg_bitmap, gd->bg_bits, end);
+		if (start >= gd->bg_bits)
+			break;
+
+		end = ocfs2_find_next_bit_set(gd->bg_bitmap, gd->bg_bits, start);
+		free_bits = end - start;
+		if (*max_contig_free_bits < free_bits)
+			*max_contig_free_bits = free_bits;
+	}
+}




More information about the Ocfs2-tools-commits mailing list