[Ocfs2-tools-commits] mfasheh commits r269 - in branches/dlm-changes/debugfs.ocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Sep 27 19:19:42 CDT 2004


Author: mfasheh
Date: 2004-09-27 19:19:40 -0500 (Mon, 27 Sep 2004)
New Revision: 269

Modified:
   branches/dlm-changes/debugfs.ocfs2/commands.c
   branches/dlm-changes/debugfs.ocfs2/dump.c
   branches/dlm-changes/debugfs.ocfs2/include/dump.h
   branches/dlm-changes/debugfs.ocfs2/include/readfs.h
   branches/dlm-changes/debugfs.ocfs2/readfs.c
Log:
* teach debugfs about our new chain allocator stuff.



Modified: branches/dlm-changes/debugfs.ocfs2/commands.c
===================================================================
--- branches/dlm-changes/debugfs.ocfs2/commands.c	2004-09-28 00:07:19 UTC (rev 268)
+++ branches/dlm-changes/debugfs.ocfs2/commands.c	2004-09-28 00:19:40 UTC (rev 269)
@@ -61,6 +61,7 @@
 static void do_publish (char **args);
 static void do_vote (char **args);
 static void do_journal (char **args);
+static void do_group (char **args);
 
 extern gboolean allow_write;
 extern gboolean no_raw_bind;
@@ -118,8 +119,9 @@
   { "publish", do_publish },
   { "vote", do_vote },
 
-  { "logdump", do_journal }
+  { "logdump", do_journal },
 
+  { "group", do_group }
 };
 
 
@@ -526,6 +528,8 @@
 
 	if ((inode->i_flags & OCFS2_LOCAL_ALLOC_FL))
 		dump_local_alloc(out, &(inode->id2.i_lab));
+	else if ((inode->i_flags & OCFS2_SUBALLOC_FL))
+		dump_chain_list(out, &(inode->id2.i_chain));
 	else
 		traverse_extents(gbls.dev_fd, &(inode->id2.i_list), NULL, 1, out);
 
@@ -699,7 +703,54 @@
 	return ;
 }					/* do_journal */
 
+/*
+ * do_group()
+ *
+ */
+static void do_group (char **args)
+{
+	char *opts = args[1];
+	ocfs2_group_desc *bg;
+	__u32 blknum;
+	char *buf = NULL;
+	__u32 buflen;
+	FILE *out;
 
+	if (gbls.dev_fd == -1) {
+		printf ("device not open\n");
+		goto bail;
+	}
+
+	buflen = 1 << gbls.blksz_bits;
+	if (!(buf = memalign(buflen, buflen)))
+		DBGFS_FATAL("%s", strerror(errno));
+
+	if (!opts) {
+		printf("no block number specified\n");
+		goto bail;
+	}
+
+	blknum = atoi(opts);
+	if (blknum > gbls.max_blocks) {
+		printf("block number is too large\n");
+		goto bail;
+	}
+	if ((read_group (gbls.dev_fd, blknum, buf, buflen)) == -1) {
+		printf("Not a group descriptor\n");
+		goto bail;
+	}
+	bg = (ocfs2_group_desc *)buf;
+
+	out = open_pager();
+	dump_group_descriptor(out, bg);
+
+	close_pager (out);
+
+bail:
+	safefree (buf);
+	return ;
+}					/* do_group */
+
 /*
  * handle_signal()
  *

Modified: branches/dlm-changes/debugfs.ocfs2/dump.c
===================================================================
--- branches/dlm-changes/debugfs.ocfs2/dump.c	2004-09-28 00:07:19 UTC (rev 268)
+++ branches/dlm-changes/debugfs.ocfs2/dump.c	2004-09-28 00:19:40 UTC (rev 269)
@@ -135,6 +135,8 @@
 		g_string_append (flags, "journal ");
 	if (in->i_flags & OCFS2_DLM_FL)
 		g_string_append (flags, "dlm ");
+	if (in->i_flags & OCFS2_SUBALLOC_FL)
+		g_string_append (flags, "suballoc ");
 
 	fprintf(out, "\tInode: %llu   Mode: 0%0o   Generation: %u\n",
 	        (unsigned long long)in->i_blkno, mode, in->i_generation);
@@ -215,6 +217,34 @@
  * dump_extent_list()
  *
  */
+void dump_chain_list (FILE *out, ocfs2_chain_list *cl)
+{
+	ocfs2_chain_rec *rec;
+	int i;
+
+	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",
+		cl->cl_count, cl->cl_next_free_rec);
+
+	if (!cl->cl_next_free_rec)
+		goto bail;
+
+	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   %llu\n", i, rec->c_total,
+			rec->c_free, (unsigned long long)rec->c_blkno);
+		traverse_chain(out, rec->c_blkno);
+		fprintf(out, "\n");
+	}
+
+bail:
+	return ;
+}				/* dump_chain_list */
+
 void dump_extent_list (FILE *out, ocfs2_extent_list *ext)
 {
 	ocfs2_extent_rec *rec;
@@ -255,7 +285,58 @@
 	return ;
 }				/* dump_extent_block */
 
+void traverse_chain(FILE *out, __u64 blknum)
+{
+	ocfs2_group_desc *bg;
+	char *buf = NULL;
+	__u32 buflen;
+
+	buflen = 1 << gbls.blksz_bits;
+	if (!(buf = memalign(buflen, buflen)))
+		DBGFS_FATAL("%s", strerror(errno));
+
+	do {
+		if ((read_group (gbls.dev_fd, blknum, buf, buflen)) == -1) {
+			printf("Not a group descriptor\n");
+			goto bail;
+		}
+		bg = (ocfs2_group_desc *)buf;
+		dump_group_descriptor(out, bg);
+		blknum = bg->bg_next_group;
+	} while (blknum);
+	
+bail:
+	safefree (buf);
+	return ;
+}
+
 /*
+ * dump_group_descriptor()
+ *
+ */
+void dump_group_descriptor (FILE *out, ocfs2_group_desc *blk)
+{
+
+	fprintf (out, "\tParent Chain: %u   Blknum: %llu\n",
+		 blk->bg_chain,
+		 blk->bg_blkno);
+
+	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, "\tNext Group: %llu   Parent Dinode: %llu  "
+		 "Generation: %u\n",
+		 (unsigned long long)blk->bg_next_group,
+		 (unsigned long long)blk->bg_parent_dinode,
+		 blk->bg_generation);
+
+	return ;
+}				/* dump_group_descriptor */
+
+/*
  * dump_dir_entry()
  *
  */

Modified: branches/dlm-changes/debugfs.ocfs2/include/dump.h
===================================================================
--- branches/dlm-changes/debugfs.ocfs2/include/dump.h	2004-09-28 00:07:19 UTC (rev 268)
+++ branches/dlm-changes/debugfs.ocfs2/include/dump.h	2004-09-28 00:19:40 UTC (rev 269)
@@ -31,7 +31,9 @@
 void dump_inode (FILE *out, ocfs2_dinode *in);
 void dump_disk_lock (FILE *out, ocfs2_disk_lock *dl);
 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_dir_entry (FILE *out, GArray *arr);
 void dump_config (FILE *out, char *buf);
 void dump_publish (FILE *out, char *buf);
@@ -41,5 +43,5 @@
 void dump_jbd_block (FILE *out, journal_header_t *header, __u64 blknum);
 void dump_jbd_metadata (FILE *out, int type, char *buf, __u64 blknum);
 void dump_jbd_unknown (FILE *out, __u64 start, __u64 end);
-
+void traverse_chain(FILE *out, __u64 blknum);
 #endif		/* __DUMP_H__ */

Modified: branches/dlm-changes/debugfs.ocfs2/include/readfs.h
===================================================================
--- branches/dlm-changes/debugfs.ocfs2/include/readfs.h	2004-09-28 00:07:19 UTC (rev 268)
+++ branches/dlm-changes/debugfs.ocfs2/include/readfs.h	2004-09-28 00:19:40 UTC (rev 269)
@@ -28,6 +28,7 @@
 
 int read_super_block (int fd, char **buf);
 int read_inode (int fd, __u64 blknum, char *buf, int buflen);
+int read_group (int fd, __u64 blknum, char *buf, int buflen);
 int traverse_extents (int fd, ocfs2_extent_list *ext, GArray *arr, int dump, FILE *out);
 void read_dir_block (struct ocfs2_dir_entry *dir, int len, GArray *arr);
 void read_dir (int fd, ocfs2_extent_list *ext, __u64 size, GArray *dirarr);

Modified: branches/dlm-changes/debugfs.ocfs2/readfs.c
===================================================================
--- branches/dlm-changes/debugfs.ocfs2/readfs.c	2004-09-28 00:07:19 UTC (rev 268)
+++ branches/dlm-changes/debugfs.ocfs2/readfs.c	2004-09-28 00:19:40 UTC (rev 269)
@@ -124,6 +124,30 @@
 }				/* read_inode */
 
 /*
+ * read_group()
+ *
+ */
+int read_group (int fd, __u64 blknum, char *buf, int buflen)
+{
+	uint64_t off;
+	ocfs2_group_desc *bg;
+	int ret = 0;
+
+	off = blknum << gbls.blksz_bits;
+
+	if ((pread64(fd, buf, buflen, off)) == -1)
+		DBGFS_FATAL("%s off=%"PRIu64, strerror(errno), off);
+
+	bg = (ocfs2_group_desc *)buf;
+
+	if (memcmp(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE,
+		   sizeof(OCFS2_GROUP_DESC_SIGNATURE)))
+		ret = -1;
+
+	return ret;
+}				/* read_group */
+
+/*
  * traverse_extents()
  *
  */



More information about the Ocfs2-tools-commits mailing list