[Ocfs2-tools-commits] zab commits r1040 - in branches/endian-safe: debugfs.ocfs2 debugfs.ocfs2/include libocfs2 libocfs2/include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Aug 12 11:26:24 CDT 2005


Author: zab
Date: 2005-08-12 11:26:21 -0500 (Fri, 12 Aug 2005)
New Revision: 1040

Modified:
   branches/endian-safe/debugfs.ocfs2/Makefile
   branches/endian-safe/debugfs.ocfs2/commands.c
   branches/endian-safe/debugfs.ocfs2/dump.c
   branches/endian-safe/debugfs.ocfs2/include/dump.h
   branches/endian-safe/libocfs2/heartbeat.c
   branches/endian-safe/libocfs2/include/ocfs2.h
Log:
o teach debugfs to dump the node entries in the heartbeat file, barely


Modified: branches/endian-safe/debugfs.ocfs2/Makefile
===================================================================
--- branches/endian-safe/debugfs.ocfs2/Makefile	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/debugfs.ocfs2/Makefile	2005-08-12 16:26:21 UTC (rev 1040)
@@ -29,6 +29,7 @@
 OBJS = $(subst .c,.o,$(CFILES))
 
 LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
 
 MANS = debugfs.ocfs2.8
 
@@ -40,6 +41,6 @@
 	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
 
 debugfs.ocfs2: $(OBJS)
-	$(LINK) $(GLIB_LIBS) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) -lreadline -lncurses
+	$(LINK) $(GLIB_LIBS) $(LIBOCFS2_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) -lreadline -lncurses
 
 include $(TOPDIR)/Postamble.make

Modified: branches/endian-safe/debugfs.ocfs2/commands.c
===================================================================
--- branches/endian-safe/debugfs.ocfs2/commands.c	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/debugfs.ocfs2/commands.c	2005-08-12 16:26:21 UTC (rev 1040)
@@ -47,6 +47,7 @@
 static void do_ls (char **args);
 static void do_quit (char **args);
 static void do_help (char **args);
+static void do_hb (char **args);
 static void do_dump (char **args);
 static void do_rdump (char **args);
 static void do_cat (char **args);
@@ -72,6 +73,7 @@
 	{ "extent",	do_extent },
 	{ "group",	do_group },
 	{ "help",	do_help },
+	{ "hb",		do_hb },
 	{ "?",		do_help },
 	{ "lcd",	do_lcd },
 	{ "logdump",	do_logdump },
@@ -714,7 +716,6 @@
 
 	return ;
 }
-#if 0
 /*
  * do_hb()
  *
@@ -725,21 +726,18 @@
 	FILE *out;
 	int len;
 	errcode_t ret;
-	void (*dump_func) (FILE *out, char *buf);
 
 	if (check_device_open())
 		return ;
 
-	DBGFS_FATAL("internal");
-
 	ret = ocfs2_read_whole_file(gbls.fs, gbls.hb_blkno, &hbbuf, &len);
 	if (ret) {
 		com_err(args[0], ret, " ");
 		goto bail;
 	}
 
-	out = open_pager();
-	dump_func(out, hbbuf);
+	out = open_pager(gbls.interactive);
+	dump_hb(out, hbbuf, len);
 	close_pager(out);
 
 bail:
@@ -748,7 +746,6 @@
 
 	return ;
 }
-#endif
 
 /*
  * do_dump()

Modified: branches/endian-safe/debugfs.ocfs2/dump.c
===================================================================
--- branches/endian-safe/debugfs.ocfs2/dump.c	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/debugfs.ocfs2/dump.c	2005-08-12 16:26:21 UTC (rev 1040)
@@ -24,6 +24,7 @@
  */
 
 #include <main.h>
+#include <stdint.h>
 
 extern dbgfs_gbls gbls;
 
@@ -567,3 +568,23 @@
 
 	return ;
 }
+
+void dump_hb (FILE *out, char *buf, uint32_t len)
+{
+	uint32_t i;
+	struct o2hb_disk_heartbeat_block *hb;
+
+	fprintf (out, "\t%4s: %4s %16s %16s %8s\n",
+		 "node", "node", "seq", "generation", "checksum");
+	
+	for (i = 0; i < 255 && ((i + 1) * 512 < len); ++i) {
+		hb = (struct o2hb_disk_heartbeat_block *)(buf + (i * 512));
+		ocfs2_swap_disk_heartbeat_block(hb);
+		fprintf (out, "\t%4u: %4u %016"PRIx64" %016"PRIx64" "
+			 "%08"PRIx32"\n", i,
+			 hb->hb_node, hb->hb_seq, hb->hb_generation,
+			 hb->hb_cksum);
+	}
+
+	return ;
+}

Modified: branches/endian-safe/debugfs.ocfs2/include/dump.h
===================================================================
--- branches/endian-safe/debugfs.ocfs2/include/dump.h	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/debugfs.ocfs2/include/dump.h	2005-08-12 16:26:21 UTC (rev 1040)
@@ -50,5 +50,6 @@
 void dump_jbd_unknown (FILE *out, uint64_t start, uint64_t end);
 void dump_slots (FILE *out, char *buf, uint32_t len);
 void dump_fast_symlink (FILE *out, char *link);
+void dump_hb (FILE *out, char *buf, uint32_t len);
 
 #endif		/* __DUMP_H__ */

Modified: branches/endian-safe/libocfs2/heartbeat.c
===================================================================
--- branches/endian-safe/libocfs2/heartbeat.c	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/libocfs2/heartbeat.c	2005-08-12 16:26:21 UTC (rev 1040)
@@ -30,6 +30,16 @@
 
 #include "ocfs2.h"
 
+void ocfs2_swap_disk_heartbeat_block(struct o2hb_disk_heartbeat_block *hb)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	hb->hb_seq        = bswap_64(hb->hb_seq);
+	hb->hb_cksum      = bswap_32(hb->hb_cksum);
+	hb->hb_generation = bswap_64(hb->hb_generation);
+}
+
 errcode_t ocfs2_fill_heartbeat_desc(ocfs2_filesys *fs,
 				    struct o2cb_region_desc *desc)
 {

Modified: branches/endian-safe/libocfs2/include/ocfs2.h
===================================================================
--- branches/endian-safe/libocfs2/include/ocfs2.h	2005-08-12 16:18:31 UTC (rev 1039)
+++ branches/endian-safe/libocfs2/include/ocfs2.h	2005-08-12 16:26:21 UTC (rev 1040)
@@ -444,6 +444,7 @@
 errcode_t ocfs2_read_whole_file(ocfs2_filesys *fs, uint64_t blkno,
 				char **buf, int *len);
 
+void ocfs2_swap_disk_heartbeat_block(struct o2hb_disk_heartbeat_block *hb);
 errcode_t ocfs2_check_heartbeat(char *device, int *mount_flags,
 				struct list_head *nodes_list);
 



More information about the Ocfs2-tools-commits mailing list