From: rpeterso@sourceware.org <rpeterso@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/gfs2/edit hexedit.c hexedit.h
Date: 12 Oct 2007 15:37:20 -0000 [thread overview]
Message-ID: <20071012153720.18664.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-10-12 15:37:19
Modified files:
gfs2/edit : hexedit.c hexedit.h
Log message:
Add the ability for gfs2_edit to print gfs1 journals.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.h.diff?cvsroot=cluster&r1=1.10&r2=1.11
--- cluster/gfs2/edit/hexedit.c 2007/08/22 08:58:46 1.19
+++ cluster/gfs2/edit/hexedit.c 2007/10/12 15:37:19 1.20
@@ -423,8 +423,12 @@
struct_len = sizeof(struct gfs2_log_header);
break;
case GFS2_METATYPE_LD:
- print_gfs2("(log descriptor)");
- struct_len = sizeof(struct gfs2_log_descriptor);
+ print_gfs2("(log descriptor)");
+ if (gfs1)
+ struct_len = sizeof(struct gfs_log_descriptor);
+ else
+ struct_len =
+ sizeof(struct gfs2_log_descriptor);
break;
case GFS2_METATYPE_EA:
print_gfs2("(extended attr hdr)");
@@ -692,7 +696,7 @@
print_gfs2("Journal index entries found: %d.",
di->i_di.di_size / sizeof(struct gfs_jindex));
eol(0);
- lines_per_row[dmode] = 6;
+ lines_per_row[dmode] = 4;
for (print_entry_ndx=0; ; print_entry_ndx++) {
error = gfs2_readi(di, (void *)&buf,
print_entry_ndx*sizeof(struct gfs_jindex),
@@ -1876,12 +1880,12 @@
/* ------------------------------------------------------------------------ */
void dump_journal(const char *journal)
{
- struct gfs2_buffer_head *jindex_bh, *j_bh;
+ struct gfs2_buffer_head *jindex_bh, *j_bh = NULL;
uint64_t jindex_block, jblock, j_size, jb;
int error, start_line, journal_num;
struct gfs2_dinode jdi;
char jbuf[bufsize];
- struct gfs2_inode *j_inode;
+ struct gfs2_inode *j_inode = NULL;
start_line = line;
lines_per_row[dmode] = 1;
@@ -1890,31 +1894,66 @@
print_gfs2("Dumping journal #%d.", journal_num);
eol(0);
/* Figure out the block of the jindex file */
- jindex_block = masterblock("jindex");
+ if (gfs1)
+ jindex_block = sbd1->sb_jindex_di.no_addr;
+ else
+ jindex_block = masterblock("jindex");
/* read in the block */
jindex_bh = bread(&sbd, jindex_block);
/* get the dinode data from it. */
gfs2_dinode_in(&di, jindex_bh->b_data); /* parse disk inode into structure */
- do_dinode_extended(&di, jindex_bh->b_data); /* which parses the directory. */
+ if (!gfs1)
+ do_dinode_extended(&di, jindex_bh->b_data); /* parse dir. */
brelse(jindex_bh, not_updated);
- jblock = indirect->ii[0].dirent[journal_num + 2].block;
- j_bh = bread(&sbd, jblock);
- j_inode = inode_get(&sbd, j_bh);
- gfs2_dinode_in(&jdi, j_bh->b_data); /* parse disk inode into structure */
- j_size = jdi.di_size;
+ if (gfs1) {
+ struct gfs2_inode *jiinode;
+ struct gfs_jindex ji;
+
+ jiinode = inode_get(&sbd, jindex_bh);
+ error = gfs2_readi(jiinode, (void *)&jbuf,
+ journal_num * sizeof(struct gfs_jindex),
+ sizeof(struct gfs_jindex));
+ if (!error)
+ return;
+ gfs_jindex_in(&ji, jbuf);
+ jblock = ji.ji_addr;
+ j_size = ji.ji_nsegment * 0x10;
+ } else {
+ jblock = indirect->ii[0].dirent[journal_num + 2].block;
+ j_bh = bread(&sbd, jblock);
+ j_inode = inode_get(&sbd, j_bh);
+ gfs2_dinode_in(&jdi, j_bh->b_data);/* parse dinode to struct */
+ j_size = jdi.di_size;
+ }
- for (jb = 0; jb < j_size; jb += bufsize) {
- error = gfs2_readi(j_inode, (void *)&jbuf, jb, bufsize);
+ for (jb = 0; jb < j_size; jb += (gfs1 ? 1:bufsize)) {
+ if (gfs1) {
+ if (j_bh)
+ brelse(j_bh, not_updated);
+ j_bh = bread(&sbd, jblock + jb);
+ memcpy(jbuf, j_bh->b_data, bufsize);
+ }
+ else
+ error = gfs2_readi(j_inode, (void *)&jbuf, jb,
+ bufsize);
if (!error) /* end of file */
break;
if (get_block_type(jbuf) == GFS2_METATYPE_LD) {
uint64_t *b;
int i = 0;
- print_gfs2("Block #%4llx: ", jb / bufsize);
- b = (uint64_t *)(jbuf + sizeof(struct gfs2_log_descriptor));
+ print_gfs2("Block #%4llx: Log descriptor",
+ jb / (gfs1 ? 1 : bufsize));
+ eol(0);
+ print_gfs2(" ");
+ if (gfs1)
+ b = (uint64_t *)(jbuf +
+ sizeof(struct gfs_log_descriptor));
+ else
+ b = (uint64_t *)(jbuf +
+ sizeof(struct gfs2_log_descriptor));
while (*b && (char *)b < (jbuf + bufsize)) {
if (!termlines ||
(print_entry_ndx >= start_row[dmode] &&
@@ -1935,8 +1974,8 @@
gfs2_log_header_in(&lh, jbuf);
print_gfs2("Block #%4llx: Log header: Seq = 0x%x, tail = 0x%x, blk = 0x%x",
- jb / bufsize, lh.lh_sequence, lh.lh_tail,
- lh.lh_blkno);
+ jb / (gfs1 ? 1 : bufsize),
+ lh.lh_sequence, lh.lh_tail, lh.lh_blkno);
eol(0);
}
}
--- cluster/gfs2/edit/hexedit.h 2007/07/16 23:16:35 1.10
+++ cluster/gfs2/edit/hexedit.h 2007/10/12 15:37:19 1.11
@@ -171,6 +171,16 @@
char ji_reserved[64];
};
+struct gfs_log_descriptor {
+ struct gfs2_meta_header ld_header;
+
+ uint32_t ld_type; /* GFS_LOG_DESC_... Type of this log chunk */
+ uint32_t ld_length; /* Number of buffers in this chunk */
+ uint32_t ld_data1; /* descriptor-specific field */
+ uint32_t ld_data2; /* descriptor-specific field */
+ char ld_reserved[64];
+};
+
EXTERN struct blkstack_info blockstack[BLOCK_STACK_SIZE];
EXTERN struct iinfo *indirect; /* more than the most indirect
pointers possible for any given 4K block */
@@ -226,7 +236,6 @@
__LINE__, __FILE__); \
}
-#define pa(struct, member, count) print_array(#member, struct->member, count);
#define printk printw
/* Divide x by y. Round up if there is a remainder. */
reply other threads:[~2007-10-12 15:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071012153720.18664.qmail@sourceware.org \
--to=rpeterso@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.