Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=4920c67a07c...
Commit: 4920c67a07c7c5c099a94ce49c807c9d23c97b00
Parent: d5dda8f8cda9fb1b32ec17dc1fcd3b196073e8aa
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Mon Jan 28 10:31:09 2013 -0700
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Wed Jul 24 10:40:31 2013 -0500
gfs2_edit: Add new option to print all bitmaps for an rgrp
This patch adds a new keyword 'rgbitmaps' that causes gfs2_edit to
print all bitmaps for the given resource group. This is handy for
analysis of file system fragmentation.
---
gfs2/edit/hexedit.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 9b9a599..c3a450b3 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -3253,7 +3253,7 @@ static void dump_journal(const char *journal)
/* ------------------------------------------------------------------------ */
static void usage(void)
{
- fprintf(stderr,"\nFormat is: gfs2_edit [-c 1] [-V] [-x] [-h] [identify] [-z
<0-9>] [-p structures|blocks][blocktype][blockalloc [val]][blockbits][blockrg][find
sb|rg|rb|di|in|lf|jd|lh|ld|ea|ed|lb|13|qc][field <f>[val]] /dev/device\n\n");
+ fprintf(stderr,"\nFormat is: gfs2_edit [-c 1] [-V] [-x] [-h] [identify] [-z
<0-9>] [-p structures|blocks][blocktype][blockalloc
[val]][blockbits][blockrg][rgcount][rgflags][rgbitmaps][find
sb|rg|rb|di|in|lf|jd|lh|ld|ea|ed|lb|13|qc][field <f>[val]] /dev/device\n\n");
fprintf(stderr,"If only the device is specified, it enters into hexedit
mode.\n");
fprintf(stderr,"identify - prints out only the block type, not the
details.\n");
fprintf(stderr,"printsavedmeta - prints out the saved metadata blocks from a
savemeta file.\n");
@@ -3264,6 +3264,8 @@ static void usage(void)
fprintf(stderr,"restoremeta - restore metadata for debugging
(DANGEROUS).\n");
fprintf(stderr,"rgcount - print how many RGs in the file system.\n");
fprintf(stderr,"rgflags rgnum [new flags] - print or modify flags for rg #rgnum (0
- X)\n");
+ fprintf(stderr,"rgbitmaps <rgnum> - print out the bitmaps for rgrp "
+ "rgnum.\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");
@@ -3540,6 +3542,29 @@ static void process_parameters(int argc, char *argv[], int pass)
gfs2_rgrp_free(&sbd.rgtree);
exit(EXIT_SUCCESS);
}
+ } else if (!strcmp(argv[i], "rgbitmaps")) {
+ int rg, bmap;
+ uint64_t rgblk;
+ struct rgrp_tree *rgd;
+
+ i++;
+ if (i >= argc - 1) {
+ printf("Error: rg # not specified.\n");
+ printf("Format is: %s rgbitmaps rgnum\n",
+ argv[0]);
+ gfs2_rgrp_free(&sbd.rgtree);
+ exit(EXIT_FAILURE);
+ }
+ rg = atoi(argv[i]);
+ rgblk = get_rg_addr(rg);
+ rgd = gfs2_blk2rgrpd(&sbd, rgblk);
+ if (rgd == NULL) {
+ printf("Error: rg # is invalid.\n");
+ gfs2_rgrp_free(&sbd.rgtree);
+ exit(EXIT_FAILURE);
+ }
+ for (bmap = 0; bmap < rgd->ri.ri_length; bmap++)
+ push_block(rgblk + bmap);
}
else if (!strcasecmp(argv[i], "savemeta")) {
getgziplevel(argv, &i);
@@ -3630,7 +3655,8 @@ int main(int argc, char *argv[])
if (termlines)
interactive_mode();
else { /* print all the structures requested */
- for (i = 0; i <= blockhist; i++) {
+ i = 0;
+ while (blockhist > 0) {
block = blockstack[i + 1].block;
if (!block)
break;
@@ -3642,6 +3668,7 @@ int main(int argc, char *argv[])
eol(0);
}
block = pop_block();
+ i++;
}
}
close(fd);