[Ocfs-tools-commits]
smushran commits r108 - in trunk/ocfs2/debugfs.ocfs2: . include
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Jun 25 20:41:32 CDT 2004
Author: smushran
Date: 2004-06-25 19:41:30 -0500 (Fri, 25 Jun 2004)
New Revision: 108
Modified:
trunk/ocfs2/debugfs.ocfs2/commands.c
trunk/ocfs2/debugfs.ocfs2/dump.c
trunk/ocfs2/debugfs.ocfs2/include/dump.h
trunk/ocfs2/debugfs.ocfs2/include/main.h
trunk/ocfs2/debugfs.ocfs2/include/readfs.h
trunk/ocfs2/debugfs.ocfs2/readfs.c
Log:
config nodes listed
Modified: trunk/ocfs2/debugfs.ocfs2/commands.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/commands.c 2004-06-26 00:41:30 UTC (rev 108)
@@ -62,7 +62,9 @@
static void do_curdev (char **args);
static void do_super (char **args);
static void do_inode (char **args);
-static void do_nodes (char **args);
+static void do_config (char **args);
+static void do_publish (char **args);
+static void do_vote (char **args);
extern gboolean allow_write;
@@ -72,11 +74,13 @@
__u32 clstrsz_bits = 0;
__u64 root_blkno = 0;
__u64 sysdir_blkno = 0;
+__u64 dlm_blkno = 0;
char *curdir = NULL;
char *superblk = NULL;
char *rootin = NULL;
char *sysdirin = NULL;
+
static Command commands[] =
{
{ "open", do_open },
@@ -111,7 +115,9 @@
{ "show_inode_info", do_inode },
{ "stat", do_inode },
- { "show_nodes", do_nodes }
+ { "nodes", do_config },
+ { "publish", do_publish },
+ { "vote", do_vote }
};
@@ -168,12 +174,16 @@
if (device)
do_close (NULL);
- if (dev == NULL)
+ if (dev == NULL) {
printf ("open requires a device argument\n");
+ goto bail;
+ }
dev_fd = open (dev, allow_write ? O_RDONLY : O_RDWR);
- if (dev_fd == -1)
+ if (dev_fd == -1) {
printf ("could not open device %s\n", dev);
+ goto bail;
+ }
device = g_strdup (dev);
@@ -202,6 +212,10 @@
if ((pread64(dev_fd, sysdirin, len, (sysdir_blkno << blksz_bits))) == -1)
DBGFS_FATAL("%s", strerror(errno));
+ /* load sysfiles blknums */
+ read_sysdir (dev_fd, sysdirin);
+
+bail:
return ;
} /* do_open */
@@ -361,6 +375,9 @@
// printf ("lcd\t\t\t\tChange current local working directory\n");
// printf ("read\t\t\t\tRead a low level structure\n");
// printf ("write\t\t\t\tWrite a low level structure\n");
+ printf ("nodes\t\t\t\tList of nodes\n");
+ printf ("publish\t\t\t\tPublish blocks\n");
+ printf ("vote\t\t\t\tVote blocks\n");
printf ("help, ?\t\t\t\tThis information\n");
printf ("quit, q\t\t\t\tExit the program\n");
} /* do_help */
@@ -470,20 +487,34 @@
} /* do_inode */
/*
- * do_nodes()
+ * do_config()
*
*/
-static void do_nodes (char **args)
+static void do_config (char **args)
{
- char *opts = args[1];
- __u32 nodenum;
+ process_dlm (dev_fd, CONFIG);
- if (opts)
- nodenum = atoi(opts);
- else
- nodenum = ULONG_MAX;
+ return ;
+} /* do_config */
- /* get the dlm file */
+/*
+ * do_publish()
+ *
+ */
+static void do_publish (char **args)
+{
+ process_dlm (dev_fd, PUBLISH);
return ;
-} /* do_nodes */
+} /* do_publish */
+
+/*
+ * do_vote()
+ *
+ */
+static void do_vote (char **args)
+{
+ process_dlm (dev_fd, VOTE);
+
+ return ;
+} /* do_vote */
Modified: trunk/ocfs2/debugfs.ocfs2/dump.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/dump.c 2004-06-26 00:41:30 UTC (rev 108)
@@ -30,6 +30,7 @@
#include <utils.h>
extern char *superblk;
+extern __u32 blksz_bits;
/*
* dump_super_block()
@@ -64,7 +65,7 @@
printf("Label: %s\n", sb->s_label);
printf("UUID: ");
for (i = 0; i < 16; i++)
- printf("%02X ", sb->s_uuid[i]);
+ printf("%02X", sb->s_uuid[i]);
printf("\n");
return ;
@@ -95,14 +96,8 @@
struct passwd *pw;
struct group *gr;
char *str;
- ocfs2_disk_lock *dl = &(in->i_disk_lock);
- ocfs2_super_block *sb = &(((ocfs2_dinode *)superblk)->id2.i_super);
- int i;
- int j;
- int k;
__u16 mode;
GString *flags = NULL;
- __u32 node_map;
if (S_ISREG(in->i_mode))
str = "regular";
@@ -159,20 +154,8 @@
printf("Links: %u Clusters: %u\n", in->i_links_count, in->i_clusters);
- printf("Lock Master: %u Level: 0x%0x Seqnum: %llu\n",
- dl->dl_master, dl->dl_level, dl->dl_seq_num);
+ dump_disk_lock (&(in->i_disk_lock));
- printf("Lock Node Map: ");
- for (i = 0, j = 0; i < 8 && j < sb->s_max_nodes; ++i) {
- if (i)
- printf(" ");
- node_map = dl->dl_node_map[i];
- for (k = 0; k < 32 && j < sb->s_max_nodes; k++, j++)
- printf ("%d%c", ((node_map & (1 << k)) ? 1 : 0),
- (((k + 1) % 8) ? '\0' : ' '));
- printf ("\n");
- }
-
str = ctime((time_t*)&in->i_ctime);
printf("ctime: 0x%llx -- %s", in->i_ctime, str);
str = ctime((time_t*)&in->i_atime);
@@ -197,6 +180,33 @@
} /* dump_inode */
/*
+ * dump_disk_lock()
+ *
+ */
+void dump_disk_lock (ocfs2_disk_lock *dl)
+{
+ ocfs2_super_block *sb = &(((ocfs2_dinode *)superblk)->id2.i_super);
+ int i, j, k;
+ __u32 node_map;
+
+ printf("Lock Master: %u Level: 0x%0x Seqnum: %llu\n",
+ dl->dl_master, dl->dl_level, dl->dl_seq_num);
+
+ printf("Lock Node Map: ");
+ for (i = 0, j = 0; i < 8 && j < sb->s_max_nodes; ++i) {
+ if (i)
+ printf(" ");
+ node_map = dl->dl_node_map[i];
+ for (k = 0; k < 32 && j < sb->s_max_nodes; k++, j++)
+ printf ("%d%c", ((node_map & (1 << k)) ? 1 : 0),
+ (((k + 1) % 8) ? '\0' : ' '));
+ printf ("\n");
+ }
+
+ return ;
+} /* dump_disk_lock */
+
+/*
* dump_extent_list()
*
*/
@@ -258,3 +268,63 @@
return ;
} /* dump_dir_entry */
+
+/*
+ * dump_config()
+ *
+ */
+void dump_config (char *buf)
+{
+ char *p;
+ ocfs_node_config_hdr *hdr;
+ ocfs_node_config_info *node;
+ ocfs2_super_block *sb = &(((ocfs2_dinode *)superblk)->id2.i_super);
+ __u16 port;
+ char *addr;
+ struct in_addr ina;
+ int i;
+
+ hdr = (ocfs_node_config_hdr *)buf;
+
+ printf("Version: %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 (&(hdr->disk_lock));
+
+ printf("%-4s %-32s %-15s %-6s %s\n",
+ "Node", "Name", "IP Addr", "Port", "UUID");
+
+ p = buf + (2 << blksz_bits);
+ for (i = 0; i < sb->s_max_nodes; ++i) {
+ node = (ocfs_node_config_info *)p;
+ port = htonl(node->ipc_config.ip_port);
+ ina.s_addr = node->ipc_config.addr_u.ip_addr4;
+ addr = inet_ntoa(ina);
+
+ printf("%-4u %-32s %-15s %-6u ", i, node->node_name, addr, port);
+ for (i = 0; i < 16; i++)
+ printf("%02X", sb->s_uuid[i]);
+ printf("\n");
+ p += (1 << blksz_bits);
+ }
+} /* dump_config */
+
+/*
+ * dump_publish()
+ *
+ */
+void dump_publish (char *buf)
+{
+
+
+} /* dump_publish */
+
+/*
+ * dump_vote()
+ *
+ */
+void dump_vote (char *buf)
+{
+
+
+} /* dump_vote */
Modified: trunk/ocfs2/debugfs.ocfs2/include/dump.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/dump.h 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/include/dump.h 2004-06-26 00:41:30 UTC (rev 108)
@@ -29,8 +29,12 @@
void dump_super_block (ocfs2_super_block *sb);
void dump_local_alloc (ocfs2_local_alloc *loc);
void dump_inode (ocfs2_dinode *in);
+void dump_disk_lock (ocfs2_disk_lock *dl);
void dump_extent_list (ocfs2_extent_list *ext);
void dump_extent_block (ocfs2_extent_block *blk);
void dump_dir_entry (GArray *arr);
+void dump_config (char *buf);
+void dump_publish (char *buf);
+void dump_vote (char *buf);
#endif /* __DUMP_H__ */
Modified: trunk/ocfs2/debugfs.ocfs2/include/main.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/main.h 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/include/main.h 2004-06-26 00:41:30 UTC (rev 108)
@@ -39,6 +39,10 @@
#include <pwd.h>
#include <grp.h>
#include <time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
#include <glib.h>
@@ -50,6 +54,12 @@
#include <ocfs2_fs.h>
#include <ocfs1_fs_compat.h>
+enum {
+ CONFIG,
+ PUBLISH,
+ VOTE
+};
+
#define safefree(_p) do {if (_p) { free(_p); (_p) = NULL; } } while (0)
#define DBGFS_FATAL(fmt, arg...) ({ fprintf(stderr, "ERROR at %s, %d: " fmt ". EXITING!!!\n", \
Modified: trunk/ocfs2/debugfs.ocfs2/include/readfs.h
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/include/readfs.h 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/include/readfs.h 2004-06-26 00:41:30 UTC (rev 108)
@@ -31,5 +31,8 @@
int traverse_extents (int fd, ocfs2_extent_list *ext, GArray *arr, int dump);
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);
+void read_sysdir (int fd, char *sysdir);
+void read_file (int fd, ocfs2_extent_list *ext, __u64 size, char *buf);
+void process_dlm (int fd, int type);
#endif /* __READFS_H__ */
Modified: trunk/ocfs2/debugfs.ocfs2/readfs.c
===================================================================
--- trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-25 23:49:25 UTC (rev 107)
+++ trunk/ocfs2/debugfs.ocfs2/readfs.c 2004-06-26 00:41:30 UTC (rev 108)
@@ -31,6 +31,8 @@
extern __u32 blksz_bits;
extern __u32 clstrsz_bits;
+extern __u64 dlm_blkno;
+extern char *superblk;
/*
* read_super_block()
@@ -224,3 +226,132 @@
return ;
} /* read_dir */
+
+/*
+ * read_sysdir()
+ *
+ */
+void read_sysdir (int fd, char *sysdir)
+{
+ ocfs2_dinode *inode;
+ struct ocfs2_dir_entry *rec;
+ GArray *dirarr = NULL;
+ char *dlm = ocfs2_system_inode_names[DLM_SYSTEM_INODE];
+ int i;
+
+ inode = (ocfs2_dinode *)sysdir;
+
+ if (!S_ISDIR(inode->i_mode)) {
+ printf("No system directory on thei volume\n");
+ goto bail;
+ }
+
+ dirarr = g_array_new(0, 1, sizeof(struct ocfs2_dir_entry));
+
+ read_dir (fd, &(inode->id2.i_list), inode->i_size, dirarr);
+
+ for (i = 0; i < dirarr->len; ++i) {
+ rec = &(g_array_index(dirarr, struct ocfs2_dir_entry, i));
+ if (!strncmp (rec->name, dlm, strlen(dlm)))
+ dlm_blkno = rec->inode;
+ }
+
+bail:
+ if (dirarr)
+ g_array_free (dirarr, 1);
+
+
+ return ;
+} /* read_sysdir */
+
+/*
+ * read_file()
+ *
+ */
+void read_file (int fd, ocfs2_extent_list *ext, __u64 size, char *buf)
+{
+ GArray *arr = NULL;
+ ocfs2_extent_rec *rec;
+ char *p;
+ __u64 off, foff, len;
+ int i;
+
+ arr = g_array_new(0, 1, sizeof(ocfs2_extent_rec));
+
+ traverse_extents (fd, ext, arr, 0);
+
+ p = buf;
+
+ for (i = 0; i < arr->len; ++i) {
+ rec = &(g_array_index(arr, ocfs2_extent_rec, i));
+ off = rec->e_blkno << blksz_bits;
+ foff = rec->e_cpos << clstrsz_bits;
+ len = rec->e_clusters << clstrsz_bits;
+ if ((foff + len) > size)
+ len = size - foff;
+
+ if ((pread64(fd, p, len, off)) == -1)
+ DBGFS_FATAL("%s", strerror(errno));
+
+ p += len;
+ }
+
+ if (arr)
+ g_array_free (arr, 1);
+
+ return ;
+} /* read_file */
+
+/*
+ * process_dlm()
+ *
+ */
+void process_dlm (int fd, int type)
+{
+ char *buf = NULL;
+ __u32 buflen;
+ char *dlmbuf = NULL;
+ ocfs2_dinode *inode;
+ ocfs2_super_block *sb = &(((ocfs2_dinode *)superblk)->id2.i_super);
+
+ /* get the dlm inode */
+ buflen = 1 << blksz_bits;
+ if (!(buf = malloc(buflen)))
+ DBGFS_FATAL("%s", strerror(errno));
+
+ if ((read_inode (fd, dlm_blkno, buf, buflen)) == -1) {
+ printf("Invalid dlm system file\n");
+ goto bail;
+ }
+ inode = (ocfs2_dinode *)buf;
+
+ /* length of file to read */
+ buflen = 2 + 4 + (3 * sb->s_max_nodes);
+ buflen <<= blksz_bits;
+
+ /* alloc the buffer */
+ if (!(dlmbuf = malloc (buflen)))
+ DBGFS_FATAL("%s", strerror(errno));
+
+ read_file (fd, &(inode->id2.i_list), buflen, dlmbuf);
+
+ switch (type) {
+ case CONFIG:
+ dump_config (dlmbuf);
+ break;
+ case PUBLISH:
+ dump_publish (dlmbuf);
+ break;
+ case VOTE:
+ dump_vote (dlmbuf);
+ break;
+ default:
+ break;
+ }
+
+bail:
+ safefree (buf);
+ safefree (dlmbuf);
+
+ return ;
+} /* process_dlm */
More information about the Ocfs-tools-commits
mailing list