cluster: RHEL6 - gfs2_edit: add -d option for printing journal details

Bob Peterson rpeterso at fedoraproject.org
Thu Feb 3 18:35:41 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=0bfad0d0504aa0c2a2cfa973d79367f3208f8c04
Commit:        0bfad0d0504aa0c2a2cfa973d79367f3208f8c04
Parent:        d7f914ed829bdcddbc69fcc0c152142d12f3cd1b
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Thu Feb 3 08:18:32 2011 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Thu Feb 3 11:27:27 2011 -0600

    gfs2_edit: add -d option for printing journal details

    This patch adds a new parameter "-d" to gfs2_edit.  If -d is specified,
    printing a journal will dump the details of the metadata blocks contained
    in the journal, as well as the usual log descriptors and log headers.
    This makes it easier to find dinode revisions in the journal.

    rhbz#674843
---
 gfs2/edit/hexedit.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index fd12c0d..bb59758 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -38,6 +38,7 @@ struct gfs2_leaf *lleaf;
 struct gfs2_log_header *llh;
 struct gfs2_log_descriptor *lld;
 int pgnum;
+int details = 0;
 
 int display(int identify_only);
 
@@ -3137,13 +3138,23 @@ static void check_journal_wrap(uint64_t seq, uint64_t *highest_seq)
 	*highest_seq = seq;
 }
 
+int is_meta(struct gfs2_buffer_head *bh)
+{
+	uint32_t check_magic = ((struct gfs2_meta_header *)(bh->b_data))->mh_magic;
+
+	check_magic = be32_to_cpu(check_magic);
+	if (check_magic == GFS2_MAGIC)
+		return 1;
+	return 0;
+}
+
 /* ------------------------------------------------------------------------ */
 /* dump_journal - dump a journal file's contents.                           */
 /* ------------------------------------------------------------------------ */
 static void dump_journal(const char *journal)
 {
 	struct gfs2_buffer_head *j_bh = NULL, dummy_bh;
-	uint64_t jblock, j_size, jb, abs_block;
+	uint64_t jblock, j_size, jb, abs_block, saveblk;
 	int error, start_line, journal_num;
 	struct gfs2_inode *j_inode = NULL;
 	int ld_blocks = 0;
@@ -3259,6 +3270,11 @@ static void dump_journal(const char *journal)
 			ld_blocks -= print_ld_blocks((uint64_t *)dummy_bh.b_data,
 						     (dummy_bh.b_data +
 						      sbd.bsize), start_line);
+		} else if (details && is_meta(&dummy_bh)) {
+			saveblk = block;
+			block = abs_block;
+			display(0);
+			block = saveblk;
 		}
 	}
 	brelse(j_bh);
@@ -3284,6 +3300,7 @@ static void usage(void)
 	fprintf(stderr,"rgflags rgnum [new flags] - print or modify flags for rg #rgnum (0 - X)\n");
 	fprintf(stderr,"-V   prints version number.\n");
 	fprintf(stderr,"-c 1 selects alternate color scheme 1\n");
+	fprintf(stderr,"-d   prints details (for printing journals)\n");
 	fprintf(stderr,"-p   prints GFS2 structures or blocks to stdout.\n");
 	fprintf(stderr,"     sb - prints the superblock.\n");
 	fprintf(stderr,"     size - prints the filesystem size.\n");
@@ -3368,6 +3385,9 @@ static void parameterpass1(int argc, char *argv[], int i)
 				  it out later */
 		dmode = GFS2_MODE;
 	}
+	else if (!strcasecmp(argv[i], "-d") ||
+		 !strcasecmp(argv[i], "-details"))
+		details = 1;
 	else if (!strcasecmp(argv[i], "savemeta"))
 		termlines = 0;
 	else if (!strcasecmp(argv[i], "savemetaslow"))


More information about the cluster-commits mailing list