gfs2-utils: RHEL7 - gfs2_edit: Print block types with log descriptors

Andrew Price andyp at fedoraproject.org
Mon Sep 8 17:34:07 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=34eddb6449ccd1896a5dbea27028c48a6dc2a11f
Commit:        34eddb6449ccd1896a5dbea27028c48a6dc2a11f
Parent:        674b743c39a6582b124634557f9c2850b9b19c63
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Wed Jun 11 12:07:46 2014 -0500
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Thu Jul 24 17:21:52 2014 +0100

gfs2_edit: Print block types with log descriptors

This patch makes gfs2_edit's journal print function print the metadata
block type along side the block number in its log descriptor output.
For example: In the past, when a log descriptor was printed, it looked
like this:
0x8200 (j+ 163): Log descriptor, type 300 (Metadata) len:504, data1: 503 (503)
                    0x70eb772          0x70df987          0x70dc7a1          0x70eb574
                    0x70dc5a3          0x70eb376          0x70dc3a5          0x70eb178
                    0x70dc1a7          0x70eaf7a          0x70dbfa9          0x70ead7c
With this patch, the output is more useful:
0x8200 (j+ 163): Log descriptor, type 300 (Metadata) len:504, data1: 503 (503)
                    0x70eb772 in       0x70df987 rb       0x70dc7a1 in       0x70eb574 in
                    0x70dc5a3 in       0x70eb376 in       0x70dc3a5 in       0x70eb178 in
                    0x70dc1a7 in       0x70eaf7a in       0x70dbfa9 in       0x70ead7c in
In this case, "in" indicates indirect blocks, and "rb" indicates a rgrp bitmap.
This is useful for getting a bigger picture of what that journal descriptor
contains and represents.
---
 gfs2/edit/hexedit.h |    1 +
 gfs2/edit/journal.c |   15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 541684a..f23c581 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -27,6 +27,7 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 };
 #define RGLIST_DUMMY_BLOCK -2
 #define JOURNALS_DUMMY_BLOCK -3
 
+extern const char *mtypes[];
 extern struct gfs2_sb sb;
 extern uint64_t block;
 extern int blockhist;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index bb56649..a72a044 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -202,6 +202,7 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
 {
 	int bcount = 0, found_tblk = 0, found_bblk = 0;
 	static char str[256];
+	struct gfs2_buffer_head *j_bmap_bh;
 
 	if (tblk_off)
 		*tblk_off = 0;
@@ -218,8 +219,17 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
 			}
 			bcount++;
 			if (prnt) {
-				sprintf(str, "0x%llx",
-					(unsigned long long)be64_to_cpu(*b));
+				if (is_meta_ld) {
+					j_bmap_bh = bread(&sbd, abs_block +
+							  bcount);
+					sprintf(str, "0x%llx %2s",
+						(unsigned long long)be64_to_cpu(*b),
+						mtypes[lgfs2_get_block_type(j_bmap_bh)]);
+					brelse(j_bmap_bh);
+				} else {
+					sprintf(str, "0x%llx",
+						(unsigned long long)be64_to_cpu(*b));
+				}
 				print_gfs2("%-18.18s ", str);
 			}
 			if (!found_tblk && tblk_off)
@@ -237,7 +247,6 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
 				int type, bmap = 0;
 				uint64_t o;
 				struct gfs2_buffer_head *save_bh;
-				struct gfs2_buffer_head *j_bmap_bh;
 
 				found_bblk = 1;
 				print_gfs2("<-------------------------");


More information about the cluster-commits mailing list