[Ocfs-tools-commits] smushran commits r153 - in trunk/ocfs2/debugfs.ocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Jul 9 19:17:07 CDT 2004


Author: smushran
Date: 2004-07-09 18:17:05 -0500 (Fri, 09 Jul 2004)
New Revision: 153

Modified:
   trunk/ocfs2/debugfs.ocfs2/dump.c
   trunk/ocfs2/debugfs.ocfs2/include/journal.h
   trunk/ocfs2/debugfs.ocfs2/journal.c
Log:
logdump expands inodes and extents

Modified: trunk/ocfs2/debugfs.ocfs2/dump.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/dump.c	2004-07-09 03:14:20 UTC (rev 152)
+++ trunk/ocfs2/debugfs.ocfs2/dump.c	2004-07-09 23:17:05 UTC (rev 153)
@@ -41,29 +41,29 @@
 	int i;
 	char *str;
 
-	fprintf(out, "Revision: %u.%u\n", sb->s_major_rev_level, sb->s_minor_rev_level);
-	fprintf(out, "Mount Count: %u   Max Mount Count: %u\n", sb->s_mnt_count,
+	fprintf(out, "\tRevision: %u.%u\n", sb->s_major_rev_level, sb->s_minor_rev_level);
+	fprintf(out, "\tMount Count: %u   Max Mount Count: %u\n", sb->s_mnt_count,
 	       sb->s_max_mnt_count);
 
-	fprintf(out, "State: %u   Errors: %u\n", sb->s_state, sb->s_errors);
+	fprintf(out, "\tState: %u   Errors: %u\n", sb->s_state, sb->s_errors);
 
 	str = ctime((time_t*)&sb->s_lastcheck);
-	fprintf(out, "Check Interval: %u   Last Check: %s", sb->s_checkinterval, str);
+	fprintf(out, "\tCheck Interval: %u   Last Check: %s", sb->s_checkinterval, str);
 
-	fprintf(out, "Creator OS: %u\n", sb->s_creator_os);
-	fprintf(out, "Feature Compat: %u   Incompat: %u   RO Compat: %u\n",
+	fprintf(out, "\tCreator OS: %u\n", sb->s_creator_os);
+	fprintf(out, "\tFeature Compat: %u   Incompat: %u   RO Compat: %u\n",
 	       sb->s_feature_compat, sb->s_feature_incompat,
 	       sb->s_feature_ro_compat);
 
-	fprintf(out, "Root Blknum: %llu   System Dir Blknum: %llu\n",
+	fprintf(out, "\tRoot Blknum: %llu   System Dir Blknum: %llu\n",
 	       sb->s_root_blkno, sb->s_system_dir_blkno);
 
-	fprintf(out, "Block Size Bits: %u   Cluster Size Bits: %u\n",
+	fprintf(out, "\tBlock Size Bits: %u   Cluster Size Bits: %u\n",
 	       sb->s_blocksize_bits, sb->s_clustersize_bits);
 
-	fprintf(out, "Max Nodes: %u\n", sb->s_max_nodes);
-	fprintf(out, "Label: %s\n", sb->s_label);
-	fprintf(out, "UUID: ");
+	fprintf(out, "\tMax Nodes: %u\n", sb->s_max_nodes);
+	fprintf(out, "\tLabel: %s\n", sb->s_label);
+	fprintf(out, "\tUUID: ");
 	for (i = 0; i < 16; i++)
 		fprintf(out, "%02X", sb->s_uuid[i]);
 	fprintf(out, "\n");
@@ -77,7 +77,7 @@
  */
 void dump_local_alloc (FILE *out, ocfs2_local_alloc *loc)
 {
-	fprintf(out, "Local Bitmap Offset: %u   Size: %u\n",
+	fprintf(out, "\tLocal Bitmap Offset: %u   Size: %u\n",
 	       loc->la_bm_off, loc->la_size);
 
 	fprintf(out, "\tTotal: %u   Used: %u   Clear: %u\n",
@@ -140,37 +140,37 @@
 	if (in->i_flags & OCFS2_DLM_FL)
 		g_string_append (flags, "dlm ");
 
-	fprintf(out, "Inode: %llu   Mode: 0%0o   Generation: %u\n",
+	fprintf(out, "\tInode: %llu   Mode: 0%0o   Generation: %u\n",
 	       in->i_blkno, mode, in->i_generation);
 
-	fprintf(out, "Type: %s   Flags: %s\n", str, flags->str);
+	fprintf(out, "\tType: %s   Flags: %s\n", str, flags->str);
 
 	pw = getpwuid(in->i_uid);
 	gr = getgrgid(in->i_gid);
-	fprintf(out, "User: %d (%s)   Group: %d (%s)   Size: %llu\n",
+	fprintf(out, "\tUser: %d (%s)   Group: %d (%s)   Size: %llu\n",
 	       in->i_uid, (pw ? pw->pw_name : "unknown"),
 	       in->i_gid, (gr ? gr->gr_name : "unknown"),
 	       in->i_size);
 
-	fprintf(out, "Links: %u   Clusters: %u\n", in->i_links_count, in->i_clusters);
+	fprintf(out, "\tLinks: %u   Clusters: %u\n", in->i_links_count, in->i_clusters);
 
 	dump_disk_lock (out, &(in->i_disk_lock));
 
 	str = ctime((time_t*)&in->i_ctime);
-	fprintf(out, "ctime: 0x%llx -- %s", in->i_ctime, str);
+	fprintf(out, "\tctime: 0x%llx -- %s", in->i_ctime, str);
 	str = ctime((time_t*)&in->i_atime);
-	fprintf(out, "atime: 0x%llx -- %s", in->i_atime, str);
+	fprintf(out, "\tatime: 0x%llx -- %s", in->i_atime, str);
 	str = ctime((time_t*)&in->i_mtime);
-	fprintf(out, "mtime: 0x%llx -- %s", in->i_mtime, str);
+	fprintf(out, "\tmtime: 0x%llx -- %s", in->i_mtime, str);
 	str = ctime((time_t*)&in->i_dtime);
-	fprintf(out, "dtime: 0x%llx -- %s", in->i_dtime, str);
+	fprintf(out, "\tdtime: 0x%llx -- %s", in->i_dtime, str);
 
-	fprintf(out, "Last Extblk: %llu\n", in->i_last_eb_blk);
-	fprintf(out, "Sub Alloc Node: %u   Sub Alloc Blknum: %llu\n",
+	fprintf(out, "\tLast Extblk: %llu\n", in->i_last_eb_blk);
+	fprintf(out, "\tSub Alloc Node: %u   Sub Alloc Blknum: %llu\n",
 	       in->i_suballoc_node, in->i_suballoc_blkno);
 
 	if (in->i_flags & OCFS2_BITMAP_FL)
-		fprintf(out, "Bitmap Total: %u   Used: %u   Clear: %u\n",
+		fprintf(out, "\tBitmap Total: %u   Used: %u   Clear: %u\n",
 		       in->id1.bitmap1.i_total, in->id1.bitmap1.i_used,
 		       (in->id1.bitmap1.i_total - in->id1.bitmap1.i_used));
 
@@ -189,10 +189,10 @@
 	int i, j, k;
 	__u32 node_map;
 
-	fprintf(out, "Lock Master: %u   Level: 0x%0x   Seqnum: %llu\n",
+	fprintf(out, "\tLock Master: %u   Level: 0x%0x   Seqnum: %llu\n",
 	       dl->dl_master, dl->dl_level, dl->dl_seq_num);
 
-	fprintf(out, "Lock Node Map: ");
+	fprintf(out, "\tLock Node Map: ");
 	for (i = 0, j = 0; i < 8 && j < sb->s_max_nodes; ++i) {
 		if (i)
 			fprintf(out, "               ");
@@ -217,17 +217,17 @@
 	ocfs2_extent_rec *rec;
 	int i;
 
-	fprintf(out, "Tree Depth: %u   Count: %u   Next Free Rec: %u\n",
+	fprintf(out, "\tTree Depth: %u   Count: %u   Next Free Rec: %u\n",
 		ext->l_tree_depth, ext->l_count, ext->l_next_free_rec);
 
 	if (!ext->l_next_free_rec)
 		goto bail;
 
-	fprintf(out, "## File Offset   Num Clusters   Disk Offset\n");
+	fprintf(out, "\t## File Offset   Num Clusters   Disk Offset\n");
 
 	for (i = 0; i < ext->l_next_free_rec; ++i) {
 		rec = &(ext->l_recs[i]);
-		fprintf(out, "%-2d %-11u   %-12u   %llu\n", i, rec->e_cpos,
+		fprintf(out, "\t%-2d %-11u   %-12u   %llu\n", i, rec->e_cpos,
 			rec->e_clusters, rec->e_blkno);
 	}
 
@@ -241,10 +241,10 @@
  */
 void dump_extent_block (FILE *out, ocfs2_extent_block *blk)
 {
-	fprintf (out, "SubAlloc Blknum: %llu   SubAlloc Node: %u\n",
+	fprintf (out, "\tSubAlloc Blknum: %llu   SubAlloc Node: %u\n",
 		 blk->h_suballoc_blkno, blk->h_suballoc_node);
 
-	fprintf (out, "Blknum: %llu   Parent: %llu   Next Leaf: %llu\n",
+	fprintf (out, "\tBlknum: %llu   Parent: %llu   Next Leaf: %llu\n",
 		 blk->h_blkno, blk->h_parent_blk, blk->h_next_leaf_blk);
 
 	return ;
@@ -259,12 +259,12 @@
 	struct ocfs2_dir_entry *rec;
 	int i;
 
-	fprintf(out, "%-20s %-4s %-4s %-2s %-4s\n",
+	fprintf(out, "\t%-15s %-4s %-4s %-2s %-4s\n",
 		"Inode", "Rlen", "Nlen", "Ty", "Name");
 
 	for (i = 0; i < arr->len; ++i) {
 		rec = &(g_array_index(arr, struct ocfs2_dir_entry, i));
-		fprintf(out, "%-20llu %-4u %-4u %-2u %s\n", rec->inode,
+		fprintf(out, "\t%-15llu %-4u %-4u %-2u %s\n", rec->inode,
 			rec->rec_len, rec->name_len, rec->file_type, rec->name);
 	}
 
@@ -288,12 +288,12 @@
 
 	hdr = (ocfs_node_config_hdr *)buf;
 
-	fprintf(out, "Version: %u   Num Nodes: %u   Last Node: %u   SeqNum: %llu\n",
+	fprintf(out, "\tVersion: %u   Num Nodes: %u   Last Node: %u   SeqNum: %llu\n",
 		hdr->version, hdr->num_nodes, hdr->last_node, hdr->cfg_seq_num);
 
 	dump_disk_lock (out, &(hdr->disk_lock));
 
-	fprintf(out, "%-4s %-32s %-15s %-6s %s\n",
+	fprintf(out, "\t%-4s %-32s %-15s %-6s %s\n",
 		"Node", "Name", "IP Addr", "Port", "UUID");
 
 	p = buf + (2 << gbls.blksz_bits);
@@ -307,7 +307,7 @@
 		ina.s_addr = node->ipc_config.addr_u.ip_addr4;
 		strcpy (addr, inet_ntoa(ina));
 
-		fprintf(out, "%-4u %-32s %-15s %-6u ", i, node->node_name,
+		fprintf(out, "\t%-4u %-32s %-15s %-6u ", i, node->node_name,
 			addr, port);
 		for (j = 0; j < OCFS2_GUID_LEN; j++)
 			fprintf(out, "%c", node->guid.guid[j]);
@@ -330,7 +330,7 @@
 	ocfs2_super_block *sb = &((gbls.superblk)->id2.i_super);
 	__u32 i, j;
 
-	fprintf(out, "%-2s %-3s %-3s %-3s %-15s %-15s %-15s %-*s %-s\n",
+	fprintf(out, "\t%-2s %-3s %-3s %-3s %-15s %-15s %-15s %-*s %-s\n",
 		"No", "Mnt", "Vot", "Dty", "LockId", "Seq", "Time",
 		sb->s_max_nodes, "Map", "Type");
 
@@ -341,7 +341,7 @@
 		pub_flag = g_string_new (NULL);
 		get_publish_flag (pub->vote_type, pub_flag);
 
-		fprintf(out, "%-2d  %1u   %1u   %1u  %-15llu %-15llu %-15llu ",
+		fprintf(out, "\t%-2d  %1u   %1u   %1u  %-15llu %-15llu %-15llu ",
 			i, pub->mounted, pub->vote, pub->dirty, pub->lock_id,
 			pub->publ_seq_num, pub->time);
 
@@ -372,7 +372,7 @@
 	ocfs2_super_block *sb = &((gbls.superblk)->id2.i_super);
 	__u32 i;
 
-	fprintf(out, "%-2s %-2s %-1s %-15s %-15s %-s\n",
+	fprintf(out, "\t%-2s %-2s %-1s %-15s %-15s %-s\n",
 		"No", "NV", "O", "LockId", "Seq", "Type");
 
 	p = buf + ((2 + 4 + sb->s_max_nodes + sb->s_max_nodes) << gbls.blksz_bits);
@@ -382,7 +382,7 @@
 		vote_flag = g_string_new (NULL);
 		get_vote_flag (vote->type, vote_flag);
 
-		fprintf(out, "%-2u %-2u %-1u %-15llu %-15llu %-s\n", i,
+		fprintf(out, "\t%-2u %-2u %-1u %-15llu %-15llu %-s\n", i,
 			vote->node, vote->open_handle, vote->lock_id,
 			vote->vote_seq_num, vote_flag->str);
 

Modified: trunk/ocfs2/debugfs.ocfs2/include/journal.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/journal.h	2004-07-09 03:14:20 UTC (rev 152)
+++ trunk/ocfs2/debugfs.ocfs2/include/journal.h	2004-07-09 23:17:05 UTC (rev 153)
@@ -29,9 +29,11 @@
 #include <jbd.h>
 
 void read_journal (char *buf, __u64 buflen, FILE *out);
+void dump_metadata (int type, char *buf, __u64 buflen, FILE *out);
+int detect_block (char *buf);
+void dump_unknown (__u64 start, __u64 end, FILE *out);
 void print_header (journal_header_t *header, FILE *out);
 void print_super_block (journal_superblock_t *sb, FILE *out);
-void print_metadata_blocks (int start, int end, FILE *out);
 void print_tag_flag (__u32 flags, FILE *out);
 void print_jbd_block (journal_header_t *header, FILE *out);
 

Modified: trunk/ocfs2/debugfs.ocfs2/journal.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/journal.c	2004-07-09 03:14:20 UTC (rev 152)
+++ trunk/ocfs2/debugfs.ocfs2/journal.c	2004-07-09 23:17:05 UTC (rev 153)
@@ -39,49 +39,129 @@
 void read_journal (char *buf, __u64 buflen, FILE *out)
 {
 	char *block;
-	int blocknum;
+	__u64 blocknum;
 	journal_header_t *header;
-	int last_metadata = 0;
 	__u32 blksize = 1 << gbls.blksz_bits;
 	__u64 len;
 	char *p;
+	__u64 last_unknown = 0;
+	int type;
 
-	len = buflen;
-	p = buf;
-	blocknum = -1;
+	fprintf (out, "\tBlock 0: ");
+	print_super_block ((journal_superblock_t *) buf, out);
 
+	blocknum = 1;
+	p = buf + blksize;
+	len = buflen - blksize;
+
 	while (len) {
-		blocknum++;
 		block = p;
 		header = (journal_header_t *) block;
-		if (blocknum == 0) {
-			fprintf (out, "block %d: ", blocknum);
-			print_super_block ((journal_superblock_t *) block, out);
-		} else if (header->h_magic == ntohl(JFS_MAGIC_NUMBER)) {
-			if (last_metadata > 0) {
-				print_metadata_blocks(last_metadata, 
-						      blocknum - 1, out);
-				last_metadata = 0;
+		if (header->h_magic == ntohl(JFS_MAGIC_NUMBER)) {
+			if (last_unknown) {
+				dump_unknown (last_unknown, blocknum, out);
+				last_unknown = 0;
 			}
-			fprintf (out, "block %d: ", blocknum);
+			fprintf (out, "\tBlock %llu: ", blocknum);
 			print_jbd_block (header, out);
 		} else {
-			if (last_metadata == 0)
-				last_metadata = blocknum;
-//			continue;
+			type = detect_block (block);
+			if (type < 0) {
+				if (last_unknown == 0)
+					last_unknown = blocknum;
+			} else {
+				if (last_unknown) {
+					dump_unknown (last_unknown, blocknum, out);
+					last_unknown = 0;
+				}
+				fprintf (out, "\tBlock %llu: ", blocknum);
+				dump_metadata (type, block, blksize, out);
+			}
 		}
-		
+		blocknum++;
 		p += blksize;
 		len -= blksize;
 	}
 
-	if (last_metadata > 0)
-		print_metadata_blocks(last_metadata, blocknum, out);
+	if (last_unknown) {
+		dump_unknown (last_unknown, blocknum, out);
+		last_unknown = 0;
+	}
 
 	return ;
 }				/* read_journal */
 
 /*
+ * dump_metadata()
+ *
+ */
+void dump_metadata (int type, char *buf, __u64 buflen, FILE *out)
+{
+	switch (type) {
+	case 1:
+		fprintf(out, "Inode\n");
+		dump_inode (out, (ocfs2_dinode *)buf);
+		fprintf (out, "\n");
+		break;
+	case 2:
+		fprintf(out, "Extent\n");
+		dump_extent_block (out, (ocfs2_extent_block *)buf);
+		fprintf (out, "\n");
+		break;
+	default:
+		fprintf (out, "TODO\n\n");
+		break;
+	}
+
+	return ;
+}				/* dump_metadata */
+
+
+/*
+ * detect_block()
+ *
+ */
+int detect_block (char *buf)
+{
+	ocfs2_dinode *inode;
+	ocfs2_extent_block *extent;
+	int ret = -1;
+
+	inode = (ocfs2_dinode *)buf;
+	if (!memcmp(inode->i_signature, OCFS2_INODE_SIGNATURE,
+		    sizeof(OCFS2_INODE_SIGNATURE))) {
+		ret = 1;
+		goto bail;
+	}
+
+	extent = (ocfs2_extent_block *)buf;
+	if (!memcmp(extent->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE,
+		    sizeof(OCFS2_EXTENT_BLOCK_SIGNATURE))) {
+		ret = 2;
+		goto bail;
+	}
+
+bail:
+	return ret;
+}				/* detect_block */
+
+
+/*
+ * dump_unknown()
+ *
+ */
+void dump_unknown (__u64 start, __u64 end, FILE *out)
+{
+	if (start == end - 1)
+		fprintf (out, "\tBlock %llu: ", start);
+	else
+		fprintf (out, "\tBlock %llu to %llu: ", start, end - 1);
+	fprintf (out, "Unknown -- Probably Data\n\n");
+
+	return ;
+}				/* dump_unknown */
+
+/*
  * print_header()
  *
  */
@@ -117,7 +197,7 @@
 	fprintf (out, "\tFirst Commit ID: %u   Start Log Blknum: %u\n",
 		 jsb->s_sequence, jsb->s_start);
 
-	fprintf (out, "\tError: %u\n", jsb->s_errno);
+	fprintf (out, "\tError: %d\n", jsb->s_errno);
 
 	fprintf (out, "\tFeatures Compat: %u   Incompat: %u   RO Compat: %u\n",
 		 jsb->s_feature_compat, jsb->s_feature_incompat,
@@ -134,25 +214,12 @@
 	fprintf (out, "\tPer Txn Block Limit    Journal: %u    Data: %u\n",
 		 jsb->s_max_transaction, jsb->s_max_trans_data);
 
+	fprintf (out, "\n");
+
 	return;
 }				/* print_super_block */
 
-
 /*
- * print_metadata_blocks()
- *
- */
-void print_metadata_blocks (int start, int end, FILE *out)
-{
-	if (start == end)
-		fprintf(out, "block %d: ", start);
-	else
-		fprintf(out, "block %d --> block %d: ", start, end);
-	fprintf(out, "Filesystem Metadata\n\n");
-	return;
-}				/* print_metadata_blocks */
-
-/*
  * print_jbd_block()
  *
  */
@@ -225,6 +292,7 @@
 		fprintf(out, "Unknown Block Type\n");
 		break;
 	}
+	fprintf (out, "\n");
 
 	if (tagflg)
 		g_string_free (tagflg, 1);



More information about the Ocfs-tools-commits mailing list