Gitweb: http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff... Commit: aa6b5156a0d16ae78fcc49ba89e94094cf144a2f Parent: 89d49877de559e99505098a742b846e27184f04c Author: Bob Peterson rpeterso@redhat.com AuthorDate: Wed Jul 28 10:43:22 2010 -0500 Committer: Bob Peterson rpeterso@redhat.com CommitterDate: Wed Jul 28 10:43:22 2010 -0500
Make gfs2_edit show bit-to-block translation when viewing bitmaps
This patch makes the gfs2_edit utility show the blocks and block allocation values associated with the highlighted byte when walking through the rgrp bitmaps in hex mode. This means you can simply walk your cursor to any given byte of any given bitmap and see which four blocks are represented by that byte in the bitmap, and whether each of them is free, data, metadata, or unlinked. --- gfs2/edit/hexedit.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++-- gfs2/libgfs2/rgrp.c | 6 +++++ 2 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 8d2561f..5c207e2 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -499,7 +499,7 @@ int display_block_type(int from_restore) break; case GFS2_METATYPE_RB: /* 3 */ print_gfs2("(rsrc grp bitblk)"); - struct_len = 512; + struct_len = sizeof(struct gfs2_meta_header); break; case GFS2_METATYPE_DI: /* 4 */ print_gfs2("(disk inode)"); @@ -568,8 +568,11 @@ int display_block_type(int from_restore) rgd = gfs2_blk2rgrpd(&sbd, block); if (rgd) { gfs2_rgrp_read(&sbd, rgd); - type = gfs2_get_bitmap(&sbd, block, rgd); - gfs2_rgrp_relse(rgd); + if ((*(bh->b_data + 7) == GFS2_METATYPE_RG) || + (*(bh->b_data + 7) == GFS2_METATYPE_RB)) + type = 4; + else + type = gfs2_get_bitmap(&sbd, block, rgd); } else type = 4; screen_chunk_size = ((termlines - 4) * 16) >> 8 << 8; @@ -596,6 +599,60 @@ int display_block_type(int from_restore) print_gfs2(" pointer 0x%x", pnum); } } + else if ((*(bh->b_data + 7) == GFS2_METATYPE_RG)) { + int ptroffset = edit_row[dmode] * 16 + edit_col[dmode]; + + if (ptroffset >= struct_len || pgnum) { + int blknum, b, btype; + + blknum = pgnum * screen_chunk_size; + blknum += (ptroffset - struct_len); + blknum *= 4; + blknum += rgd->ri.ri_data0; + + print_gfs2(" blk "); + for (b = blknum; b < blknum + 4; b++) { + btype = gfs2_get_bitmap(&sbd, b, rgd); + print_gfs2("0x%x-%s ", b, + allocdesc[gfs1][btype]); + } + } + } + else if ((*(bh->b_data + 7) == GFS2_METATYPE_RB)) { + int ptroffset = edit_row[dmode] * 16 + edit_col[dmode]; + + if (ptroffset >= struct_len || pgnum) { + int blknum, b, btype, rb_number; + + rb_number = block - rgd->ri.ri_addr; + blknum = 0; + /* count the number of bytes representing + blocks prior to the displayed screen. */ + for (b = 0; b < rb_number; b++) { + struct_len = (b ? + sizeof(struct gfs2_meta_header) : + sizeof(struct gfs2_rgrp)); + blknum += (sbd.bsize - struct_len); + } + struct_len = sizeof(struct gfs2_meta_header); + /* add the number of bytes on this screen */ + blknum += (ptroffset - struct_len); + /* factor in the page number */ + blknum += pgnum * screen_chunk_size; + /* convert bytes to blocks */ + blknum *= GFS2_NBBY; + /* add the starting offset for this rgrp */ + blknum += rgd->ri.ri_data0; + print_gfs2(" blk "); + for (b = blknum; b < blknum + 4; b++) { + btype = gfs2_get_bitmap(&sbd, b, rgd); + print_gfs2("0x%x-%s ", b, + allocdesc[gfs1][btype]); + } + } + } + if (rgd) + gfs2_rgrp_relse(rgd); } if (block == sbd.sd_sb.sb_root_dir.no_addr) print_gfs2("--------------- Root directory ------------------"); diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c index e3e230e..84ea6d3 100644 --- a/gfs2/libgfs2/rgrp.c +++ b/gfs2/libgfs2/rgrp.c @@ -104,12 +104,18 @@ struct rgrp_list *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk) ri = &prev_rgd->ri; if (ri->ri_data0 <= blk && blk < ri->ri_data0 + ri->ri_data) return prev_rgd; + if (blk >= ri->ri_addr && blk < ri->ri_addr + ri->ri_length) + return prev_rgd; }
for (tmp = sdp->rglist.next; tmp != &sdp->rglist; tmp = tmp->next) { rgd = osi_list_entry(tmp, struct rgrp_list, list); ri = &rgd->ri;
+ if (blk >= ri->ri_addr && blk < ri->ri_addr + ri->ri_length) { + prev_rgd = rgd; + return rgd; + } if (ri->ri_data0 <= blk && blk < ri->ri_data0 + ri->ri_data) { prev_rgd = rgd; return rgd;
cluster-commits@lists.fedorahosted.org