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

Bob Peterson rpeterso at fedoraproject.org
Wed Feb 2 21:16:14 UTC 2011


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f09ef2ba0c4f4e6fb7a28138c36e2c4c38816bf5
Commit:        f09ef2ba0c4f4e6fb7a28138c36e2c4c38816bf5
Parent:        524dca1221b851159bf45a702f111bd8952036d7
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Wed Feb 2 14:39:10 2011 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Wed Feb 2 14:39:10 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#656371
---
 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 5432fa2..c4249e1 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -52,6 +52,7 @@ struct gfs2_leaf *lleaf;
 struct gfs2_log_header *llh;
 struct gfs2_log_descriptor *lld;
 int pgnum;
+int details = 0;
 
 const char *prog_name;
 
@@ -3152,13 +3153,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;
@@ -3274,6 +3285,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);
@@ -3299,6 +3315,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");
@@ -3384,6 +3401,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