[Cluster-devel] [gfs2-utils patch] gfs2_edit: Print block types with log descriptors

2014-06-11 Thread Bob Peterson
Hi,

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.

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson rpete...@redhat.com 
---
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(-);



[Cluster-devel] [gfs2-utils patch] gfs2_edit: print LB (log descriptor continuation blocks) for GFS2

2014-06-11 Thread Bob Peterson
Hi,

This patch allows gfs2_edit to print metadata blocks of type LB
(log descriptor continuation blocks) for GFS2. Prior to this, only
GFS1's continuation blocks would print.

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson rpete...@redhat.com 
---
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index e012bc3..bb56649 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -582,12 +582,15 @@ void dump_journal(const char *journal, int tblk)
[UNMOUNTED] : );
}
eol(0);
-   } else if (sbd.gfs1  ld_blocks  0) {
-   print_gfs2(0x%llx (j+%4llx): GFS log descriptor
+   } else if ((ld_blocks  0) 
+  (sbd.gfs1 || block_type == GFS2_METATYPE_LB)) {
+   print_gfs2(0x%llx (j+%4llx): Log descriptor
continuation block, abs_block, jb);
eol(0);
print_gfs2();
-   ld_blocks -= print_ld_blks((uint64_t *)dummy_bh.b_data,
+   ld_blocks -= print_ld_blks((uint64_t *)dummy_bh.b_data +
+  (sbd.gfs1 ? 0 :
+   sizeof(struct 
gfs2_meta_header)),
   (dummy_bh.b_data +
sbd.bsize), start_line,
   tblk, tblk_off, 0, rgd,