Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=9d1c4678...
Commit: 9d1c4678ce559f774e7bb3eb349e9ddef0650289
Parent: 0d3b6ed1eb4bb102f5f763596d0cb14a434559ae
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Fri Feb 28 00:08:43 2014 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Fri Feb 28 00:08:43 2014 +0000
gfs2_edit: Report referencing block address in the new journal code
When a block is referenced in the journal, the address of the "real"
referencing block is now printed (as well as the address of the block in
the journal).
Also, when a dinode references a block as a extended attribute, it
wasn't properly flagging it as a reference. Now it does.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 19 ++++++++++---------
gfs2/edit/hexedit.h | 3 ++-
gfs2/edit/journal.c | 37 ++++++++++++++++++++++++-------------
gfs2/edit/savemeta.c | 2 +-
4 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index ac91c83..5c5ac89 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -833,7 +833,7 @@ static const struct lgfs2_metadata *find_mtype(uint32_t mtype, const
unsigned ve
/* hexdump - hex dump the filesystem block to the screen */
/* ------------------------------------------------------------------------ */
static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
- uint64_t flagref)
+ uint64_t flagref, uint64_t ref_blk)
{
const unsigned char *pointer, *ptr2;
int i;
@@ -983,12 +983,12 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
if (line - 3 > last_entry_onscreen[dmode])
last_entry_onscreen[dmode] = line - 3;
if (flagref && be64_to_cpu(*ref) == flagref)
- print_gfs2("<------------------------- ref to 0x%llx",
- flagref);
+ print_gfs2("<------------------------- ref in 0x%llx "
+ "to 0x%llx", ref_blk, flagref);
ref++;
if (flagref && be64_to_cpu(*ref) == flagref)
- print_gfs2("<------------------------- ref to 0x%llx",
- flagref);
+ print_gfs2("<------------------------- ref in 0x%llx "
+ "to 0x%llx", ref_blk, flagref);
ref++;
eol(0);
l += 16;
@@ -1347,7 +1347,8 @@ static void read_master_dir(void)
/* ------------------------------------------------------------------------ */
/* display */
/* ------------------------------------------------------------------------ */
-int display(int identify_only, int trunc_zeros, uint64_t flagref)
+int display(int identify_only, int trunc_zeros, uint64_t flagref,
+ uint64_t ref_blk)
{
uint64_t blk;
@@ -1443,7 +1444,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref)
if (dmode == HEX_MODE) /* if hex display mode */
hexdump(dev_offset, (gfs2_struct_type == GFS2_METATYPE_DI)?
struct_len + di.di_size:sbd.bsize, trunc_zeros,
- flagref);
+ flagref, ref_blk);
else if (dmode == GFS2_MODE) { /* if structure display */
if (block != JOURNALS_DUMMY_BLOCK)
display_gfs2(); /* display the gfs2 structure */
@@ -2248,7 +2249,7 @@ static void interactive_mode(void)
Quit = FALSE;
editing = FALSE;
while (!Quit) {
- display(FALSE, 0, 0);
+ display(FALSE, 0, 0, 0);
if (editing) {
if (edit_row[dmode] == -1)
block = goto_block();
@@ -2930,7 +2931,7 @@ int main(int argc, char *argv[])
block = blockstack[i + 1].block;
if (!block)
break;
- display(identify, 0, 0);
+ display(identify, 0, 0, 0);
if (!identify) {
display_extended();
printf("-------------------------------------" \
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 715e3f2..541684a 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -233,7 +233,8 @@ extern void gfs_dinode_in(struct gfs_dinode *di, struct
gfs2_buffer_head *bh);
extern void savemeta(char *out_fn, int saveoption, int gziplevel);
extern void restoremeta(const char *in_fn, const char *out_device,
uint64_t printblocksonly);
-extern int display(int identify_only, int trunc_zeros, uint64_t flagref);
+extern int display(int identify_only, int trunc_zeros, uint64_t flagref,
+ uint64_t ref_blk);
extern uint64_t check_keywords(const char *kword);
extern uint64_t masterblock(const char *fn);
extern void gfs_rgrp_print(struct gfs_rgrp *rg);
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index c69f349..3c2f5c7 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -204,7 +204,8 @@ static int ld_is_pertinent(const uint64_t *b, const char *end,
uint64_t tblk,
static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
uint64_t tblk, uint64_t *tblk_off, uint64_t bitblk,
struct rgrp_tree *rgd, uint64_t abs_block, int prnt,
- uint64_t *bblk_off, int is_meta_ld)
+ uint64_t *bblk_off, int is_meta_ld,
+ uint64_t ld_blk_refs[])
{
int bcount = 0, found_tblk = 0, found_bblk = 0;
static char str[256];
@@ -222,6 +223,8 @@ static int print_ld_blks(const uint64_t *b, const char *end, int
start_line,
eol(0);
print_gfs2(" ");
}
+ if (ld_blk_refs)
+ ld_blk_refs[bcount] = be64_to_cpu(*b);
bcount++;
if (prnt) {
sprintf(str, "0x%llx",
@@ -345,7 +348,8 @@ static uint64_t find_wrap_pt(struct gfs2_inode *j_inode, char *jbuf,
static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
uint64_t jb, struct gfs2_buffer_head *dummy_bh, int tblk,
uint64_t *tblk_off, uint64_t bitblk,
- struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off)
+ struct rgrp_tree *rgd, int *prnt, uint64_t *bblk_off,
+ uint64_t ld_blk_refs[])
{
uint64_t *b;
struct gfs2_log_descriptor ld;
@@ -393,7 +397,7 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t
j_size,
is_meta_ld = 1;
ld_blocks -= print_ld_blks(b, (dummy_bh->b_data + sbd.bsize), line,
tblk, tblk_off, bitblk, rgd, abs_block,
- *prnt, bblk_off, is_meta_ld);
+ *prnt, bblk_off, is_meta_ld, ld_blk_refs);
return ld_blocks;
}
@@ -406,15 +410,19 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
struct gfs2_buffer_head *mbh;
int structlen, ty, has_ref = 0;
uint64_t *b;
+ struct gfs2_dinode *dinode;
mbh = bread(&sbd, abs_block);
ty = get_block_type(mbh, &structlen);
+ if (ty == GFS2_METATYPE_DI) {
+ dinode = (struct gfs2_dinode *)mbh->b_data;
+ if (be64_to_cpu(dinode->di_eattr) == tblk)
+ has_ref = 1;
+ }
b = (uint64_t *)(mbh->b_data + structlen);
- while (ty && (char *)b < mbh->b_data + sbd.bsize) {
- if (be64_to_cpu(*b) == tblk) {
+ while (!has_ref && ty && (char *)b < mbh->b_data + sbd.bsize) {
+ if (be64_to_cpu(*b) == tblk)
has_ref = 1;
- break;
- }
b++;
}
brelse(mbh);
@@ -442,6 +450,7 @@ void dump_journal(const char *journal, int tblk)
uint64_t highest_seq = 0;
char *jbuf = NULL;
struct rgrp_tree *rgd = NULL;
+ uint64_t ld_blk_refs[503]; /* The most blks a LD can have */
start_line = line;
lines_per_row[dmode] = 1;
@@ -529,7 +538,7 @@ void dump_journal(const char *journal, int tblk)
ld_blocks = process_ld(abs_block, wrappt, j_size, jb,
&dummy_bh, tblk, &tblk_off,
bitblk, rgd, &is_pertinent,
- &bblk_off);
+ &bblk_off, ld_blk_refs);
offset_from_ld = 0;
} else if (!tblk &&
get_block_type(&dummy_bh, NULL) == GFS2_METATYPE_LH) {
@@ -567,20 +576,22 @@ void dump_journal(const char *journal, int tblk)
(dummy_bh.b_data +
sbd.bsize), start_line,
tblk, &tblk_off, 0, rgd,
- 0, 1, NULL, 1);
+ 0, 1, NULL, 1, NULL);
} else if (!is_meta(&dummy_bh)) {
continue;
}
/* Check if this metadata block references the block we're
trying to trace. */
- if (details ||
- (is_pertinent && tblk &&
+ if (details || (tblk && ((is_pertinent &&
((tblk_off && offset_from_ld == tblk_off) ||
(bblk_off && offset_from_ld == bblk_off))) ||
- meta_has_ref(abs_block, tblk)) {
+ meta_has_ref(abs_block, tblk)))) {
saveblk = block;
block = abs_block;
- display(0, tblk ? 1 : 0, tblk);
+ if (tblk)
+ display(0, 1, tblk, ld_blk_refs[offset_from_ld]);
+ else
+ display(0, 0, 0, 0);
block = saveblk;
}
}
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c5a33db..5bf7963 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -932,7 +932,7 @@ static int restore_data(int fd, gzFile gzin_fd, int printblocksonly,
block = savedata->blk;
if (printblocksonly > 1 && printblocksonly == block) {
block_in_mem = block;
- display(0, 0, 0);
+ display(0, 0, 0, 0);
return 0;
} else if (printblocksonly == 1) {
print_gfs2("%d (l=0x%x): ", blks_saved,